CURRENT_LOAD_SOURCE

When called within the scope of a COPY statement, returns the file name used for the load.

When called within the scope of a COPY statement, returns the file name used for the load. The following exceptions apply:

  • 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>.

This function is not supported for COPY LOCAL.

Behavior type

Stable

Syntax

CURRENT_LOAD_SOURCE()

Examples

Create a table and populate one of its columns with the names of two separate files as they are 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        | /home/load_file_1
1   |  cats        | /home/load_file_1
4   |  superheroes | /home/load_file_2
3   |  birds       | /home/load_file_1
5   |  whales      | /home/load_file_2
(5 rows)