CURRENT_LOAD_SOURCE
Returns the file name used during the COPY statement.
Behavior Type
Syntax
CURRENT_LOAD_SOURCE()
Behavior
- If the function is called outside of the context of a
COPY
statement, it returns NULL. - If the function is called by a UDL that does not set the source, it returns the string <unknown>.
Examples
This example creates a table and populates column c3 with the names of the two separate files being loaded.
=> CREATE TABLE t (c1 integer, c2 varchar(50), c3 varchar(200)); CREATE TABLE
=> COPY t (c1, c2, c3 AS CURRENT_LOAD_SOURCE()) FROM '/home/load_file_1' ON exampledb_node02, '/home/load_file_2' ON exampledb_node03 DELIMITER ',';
Rows Loaded ------------- 5 (1 row)
=> SELECT * FROM t; c1 | c2 | c3 ----+--------------+----------------------- 2 | dogs | load_file_1 1 | cats | load_file_1 4 | superheroes | load_file_2 3 | birds | load_file_1 5 | whales | load_file_2 (5 rows)