From f72267134456d1a2da045c9f99925c98bb162762 Mon Sep 17 00:00:00 2001 From: zhangwenchao <656540940@qq.com> Date: Tue, 6 Aug 2024 18:37:00 +0800 Subject: [PATCH] Fix psql of copy binary directory table to. Fix copy binary directory table to, such as: \copy binary directory table public.test 'aa.bb' to 'bb.aa'; Authored-by: Zhang Wenchao zwcpostgres@gmail.com --- src/bin/psql/copy.c | 2 +- src/test/regress/input/directory_table.source | 15 ++- .../regress/output/directory_table.source | 91 ++++++++------ .../output/directory_table_optimizer.source | 113 +++++++++++------- 4 files changed, 136 insertions(+), 85 deletions(-) diff --git a/src/bin/psql/copy.c b/src/bin/psql/copy.c index 1abad9c59fd..1e83ad06ee2 100644 --- a/src/bin/psql/copy.c +++ b/src/bin/psql/copy.c @@ -152,7 +152,7 @@ parse_slash_copy(const char *args) xstrcat(&result->before_tofrom, " "); xstrcat(&result->before_tofrom, token); - token = strtokx(NULL, whitespace, ".,()", "\"", + token = strtokx(NULL, whitespace, NULL, "\"", 0, false, false, pset.encoding); if (!token) diff --git a/src/test/regress/input/directory_table.source b/src/test/regress/input/directory_table.source index 72f5abd3aa6..1dea2045080 100644 --- a/src/test/regress/input/directory_table.source +++ b/src/test/regress/input/directory_table.source @@ -206,6 +206,7 @@ CREATE DIRECTORY TABLE IF NOT EXISTS dir_table4 TABLESPACE directory_tblspc; CREATE DIRECTORY TABLE IF NOT EXISTS dir_table2 TABLESPACE directory_tblspc; -- fail CREATE DIRECTORY TABLE dir_table5 TABLESPACE directory_tblspc; CREATE DIRECTORY TABLE dir_table6 TABLESPACE pg_default; +CREATE DIRECTORY TABLE "abs.dir_table"; SELECT count(*) FROM pg_directory_table; SELECT relname, relisshared, relpersistence, relkind FROM pg_class WHERE relname like '%dir_table%' ORDER BY 1; @@ -322,6 +323,11 @@ COPY BINARY dir_table2 FROM PROGRAM 'cat @abs_srcdir@/data/nation.csv' 'nation5' SELECT relative_path, size, tag FROM dir_table2 ORDER BY 1; SELECT relative_path, content FROM directory_table('dir_table2') ORDER BY 1; +\COPY BINARY dir_table1 FROM '@abs_srcdir@/data/nation.csv' 'nation.txt'; -- OK +COPY BINARY dir_table1 FROM '@abs_srcdir@/data/nation.csv' 'nation2.txt'; -- OK +\COPY BINARY "abs.dir_table" FROM '@abs_srcdir@/data/nation.csv' 'aa.bb'; -- OK +COPY BINARY "abs.dir_table" FROM '@abs_srcdir@/data/nation.csv' 'cc.dd'; -- OK + -- Test copy binary from directory table \COPY BINARY dir_table1 FROM '@abs_srcdir@/data/nation.csv' 'nation_failed' (format CSV); \COPY BINARY dir_table1 FROM '@abs_srcdir@/data/nation.csv' 'nation_failed' (freeze off); @@ -397,9 +403,13 @@ COPY BINARY DIRECTORY TABLE dir_table1 'nation2' TO stdout; -- OK \COPY BINARY DIRECTORY TABLE dir_table1 'nation2' TO PROGRAM 'gzip -c -1 > @abs_srcdir@/data/nation2.gz'; -- OK COPY BINARY DIRECTORY TABLE dir_table1 'nation2' TO PROGRAM 'gzip -c -1 > @abs_srcdir@/data/nation2.gz'; -- OK -\COPY BINARY dir_table1 FROM '@abs_srcdir@/data/nation.csv' 'nation.txt'; -- OK +\COPY BINARY DIRECTORY TABLE "abs.dir_table" 'aa.bb' TO '@abs_srcdir@/data/aa.bb'; -- OK +COPY BINARY DIRECTORY TABLE "abs.dir_table" 'cc.dd' TO '@abs_srcdir@/data/cc.dd'; -- OK \COPY BINARY DIRECTORY TABLE dir_table1 'nation.txt' TO '@abs_srcdir@/data/nation.txt'; -- OK -COPY BINARY DIRECTORY TABLE dir_table1 'nation.txt' TO '@abs_srcdir@/data/nation2.txt'; -- OK +COPY BINARY DIRECTORY TABLE dir_table1 'nation2.txt' TO '@abs_srcdir@/data/nation2.txt'; -- OK +\COPY BINARY DIRECTORY TABLE public.dir_table1 'nation.txt' TO '@abs_srcdir@/data/nation3.txt'; -- OK +COPY BINARY DIRECTORY TABLE public.dir_table1 'nation2.txt' TO '@abs_srcdir@/data/nation4.txt'; -- OK + SELECT relative_path, size, tag FROM dir_table1 ORDER BY 1; SELECT relative_path, size, tag FROM dir_table2 ORDER BY 1; @@ -621,6 +631,7 @@ DROP DIRECTORY TABLE IF EXISTS dir_table3; DROP DIRECTORY TABLE IF EXISTS dir_table4; DROP DIRECTORY TABLE IF EXISTS dir_table5; DROP DIRECTORY TABLE IF EXISTS dir_table6; +DROP DIRECTORY TABLE IF EXISTS "abs.dir_table"; DROP FUNCTION IF EXISTS triggertest; diff --git a/src/test/regress/output/directory_table.source b/src/test/regress/output/directory_table.source index 7e52197d6f6..ad7b0af90e9 100644 --- a/src/test/regress/output/directory_table.source +++ b/src/test/regress/output/directory_table.source @@ -528,28 +528,31 @@ CREATE DIRECTORY TABLE IF NOT EXISTS dir_table2 TABLESPACE directory_tblspc; NOTICE: relation "dir_table2" already exists, skipping CREATE DIRECTORY TABLE dir_table5 TABLESPACE directory_tblspc; CREATE DIRECTORY TABLE dir_table6 TABLESPACE pg_default; +CREATE DIRECTORY TABLE "abs.dir_table"; SELECT count(*) FROM pg_directory_table; count ------- - 6 + 7 (1 row) SELECT relname, relisshared, relpersistence, relkind FROM pg_class WHERE relname like '%dir_table%' ORDER BY 1; - relname | relisshared | relpersistence | relkind ------------------+-------------+----------------+--------- - dir_table1 | f | p | d - dir_table1_pkey | f | p | i - dir_table2 | f | p | d - dir_table2_pkey | f | p | i - dir_table3 | f | p | d - dir_table3_pkey | f | p | i - dir_table4 | f | p | d - dir_table4_pkey | f | p | i - dir_table5 | f | p | d - dir_table5_pkey | f | p | i - dir_table6 | f | p | d - dir_table6_pkey | f | p | i -(12 rows) + relname | relisshared | relpersistence | relkind +--------------------+-------------+----------------+--------- + abs.dir_table | f | p | d + abs.dir_table_pkey | f | p | i + dir_table1 | f | p | d + dir_table1_pkey | f | p | i + dir_table2 | f | p | d + dir_table2_pkey | f | p | i + dir_table3 | f | p | d + dir_table3_pkey | f | p | i + dir_table4 | f | p | d + dir_table4_pkey | f | p | i + dir_table5 | f | p | d + dir_table5_pkey | f | p | i + dir_table6 | f | p | d + dir_table6_pkey | f | p | i +(14 rows) \d+ dir_table1; Directory table "public.dir_table1" @@ -628,21 +631,23 @@ NOTICE: directory table "dir_table5" does not exist, skipping SELECT count(*) FROM pg_directory_table; count ------- - 4 + 5 (1 row) SELECT relname, relisshared, relpersistence, relkind FROM pg_class WHERE relname like '%dir_table%' ORDER BY 1; - relname | relisshared | relpersistence | relkind ------------------+-------------+----------------+--------- - dir_table1 | f | p | d - dir_table1_pkey | f | p | i - dir_table2 | f | p | d - dir_table2_pkey | f | p | i - dir_table3 | f | p | d - dir_table3_pkey | f | p | i - dir_table6 | f | p | d - dir_table6_pkey | f | p | i -(8 rows) + relname | relisshared | relpersistence | relkind +--------------------+-------------+----------------+--------- + abs.dir_table | f | p | d + abs.dir_table_pkey | f | p | i + dir_table1 | f | p | d + dir_table1_pkey | f | p | i + dir_table2 | f | p | d + dir_table2_pkey | f | p | i + dir_table3 | f | p | d + dir_table3_pkey | f | p | i + dir_table6 | f | p | d + dir_table6_pkey | f | p | i +(10 rows) \c dirtable_db SELECT count(*) FROM pg_directory_table; @@ -845,6 +850,12 @@ SELECT relative_path, content FROM directory_table('dir_table2') ORDER BY 1; nation4 | \x307c414c47455249417c307c20686167676c652e206361726566756c6c792066696e616c206465706f736974732064657465637420736c796c7920616761690a317c415247454e54494e417c317c616c20666f7865732070726f6d69736520736c796c79206163636f7264696e6720746f2074686520726567756c6172206163636f756e74732e20626f6c6420726571756573747320616c6f6e0a327c4252415a494c7c317c7920616c6f6e6773696465206f66207468652070656e64696e67206465706f736974732e206361726566756c6c79207370656369616c207061636b61676573206172652061626f7574207468652069726f6e696320666f726765732e20736c796c79207370656369616c200a337c43414e4144417c317c6561732068616e672069726f6e69632c2073696c656e74207061636b616765732e20736c796c7920726567756c6172207061636b616765732061726520667572696f75736c79206f76657220746865207469746865732e20666c756666696c7920626f6c640a347c45475950547c347c792061626f766520746865206361726566756c6c7920756e757375616c207468656f646f6c697465732e2066696e616c206475676f7574732061726520717569636b6c79206163726f73732074686520667572696f75736c7920726567756c617220640a357c455448494f5049417c307c76656e207061636b616765732077616b6520717569636b6c792e20726567750a367c4652414e43457c337c726566756c6c792066696e616c2072657175657374732e20726567756c61722c2069726f6e690a377c4745524d414e597c337c6c20706c6174656c6574732e20726567756c6172206163636f756e747320782d7261793a20756e757375616c2c20726567756c6172206163636f0a387c494e4449417c327c737320657863757365732063616a6f6c6520736c796c79206163726f737320746865207061636b616765732e206465706f73697473207072696e742061726f756e0a397c494e444f4e455349417c327c20736c796c792065787072657373206173796d70746f7465732e20726567756c6172206465706f7369747320686167676c6520736c796c792e206361726566756c6c792069726f6e696320686f636b657920706c617965727320736c65657020626c697468656c792e206361726566756c6c0a31307c4952414e7c347c6566756c6c7920616c6f6e6773696465206f662074686520736c796c792066696e616c20646570656e64656e636965732e200a31317c495241517c347c6e6963206465706f7369747320626f6f73742061746f702074686520717569636b6c792066696e616c2072657175657374733f20717569636b6c7920726567756c610a31327c4a4150414e7c327c6f75736c792e2066696e616c2c20657870726573732067696674732063616a6f6c6520610a31337c4a4f5244414e7c347c6963206465706f736974732061726520626c697468656c792061626f757420746865206361726566756c6c7920726567756c61722070610a31347c4b454e59417c307c2070656e64696e67206578637573657320686167676c6520667572696f75736c79206465706f736974732e2070656e64696e672c20657870726573732070696e746f206265616e732077616b6520666c756666696c79207061737420740a31357c4d4f524f43434f7c307c726e732e20626c697468656c7920626f6c6420636f7572747320616d6f6e672074686520636c6f73656c7920726567756c6172207061636b616765732075736520667572696f75736c7920626f6c6420706c6174656c6574733f0a31367c4d4f5a414d42495155457c307c732e2069726f6e69632c20756e757375616c206173796d70746f7465732077616b6520626c697468656c7920720a31377c504552557c317c706c6174656c6574732e20626c697468656c792070656e64696e6720646570656e64656e636965732075736520666c756666696c79206163726f737320746865206576656e2070696e746f206265616e732e206361726566756c6c792073696c656e74206163636f756e0a31387c4348494e417c327c6320646570656e64656e636965732e20667572696f75736c792065787072657373206e6f746f726e697320736c65657020736c796c7920726567756c6172206163636f756e74732e20696465617320736c6565702e206465706f730a31397c524f4d414e49417c337c756c6172206173796d70746f746573206172652061626f75742074686520667572696f7573206d756c7469706c696572732e206578707265737320646570656e64656e63696573206e61672061626f7665207468652069726f6e6963616c6c792069726f6e6963206163636f756e740a32307c5341554449204152414249417c347c74732e2073696c656e7420726571756573747320686167676c652e20636c6f73656c792065787072657373207061636b6167657320736c656570206163726f73732074686520626c697468656c790a32317c564945544e414d7c327c68656c7920656e746963696e676c792065787072657373206163636f756e74732e206576656e2c2066696e616c200a32327c5255535349417c337c20726571756573747320616761696e73742074686520706c6174656c65747320757365206e65766572206163636f7264696e6720746f2074686520717569636b6c7920726567756c61722070696e740a32337c554e49544544204b494e47444f4d7c337c65616e7320626f6f7374206361726566756c6c79207370656369616c2072657175657374732e206163636f756e7473206172652e206361726566756c6c0a32347c554e49544544205354415445537c317c792066696e616c207061636b616765732e20736c6f7720666f7865732063616a6f6c6520717569636b6c792e20717569636b6c792073696c656e7420706c6174656c657473206272656163682069726f6e6963206163636f756e74732e20756e757375616c2070696e746f2062650a (4 rows) +\COPY BINARY dir_table1 FROM '@abs_srcdir@/data/nation.csv' 'nation.txt'; -- OK +NOTICE: dir_table1 INSERT AFTER ROW +COPY BINARY dir_table1 FROM '@abs_srcdir@/data/nation.csv' 'nation2.txt'; -- OK +NOTICE: dir_table1 INSERT AFTER ROW +\COPY BINARY "abs.dir_table" FROM '@abs_srcdir@/data/nation.csv' 'aa.bb'; -- OK +COPY BINARY "abs.dir_table" FROM '@abs_srcdir@/data/nation.csv' 'cc.dd'; -- OK -- Test copy binary from directory table \COPY BINARY dir_table1 FROM '@abs_srcdir@/data/nation.csv' 'nation_failed' (format CSV); ERROR: conflicting or redundant options @@ -1152,19 +1163,22 @@ COPY BINARY DIRECTORY TABLE dir_table1 'nation2' TO stdout; -- OK 24|UNITED STATES|1|y final packages. slow foxes cajole quickly. quickly silent platelets breach ironic accounts. unusual pinto be \COPY BINARY DIRECTORY TABLE dir_table1 'nation2' TO PROGRAM 'gzip -c -1 > @abs_srcdir@/data/nation2.gz'; -- OK COPY BINARY DIRECTORY TABLE dir_table1 'nation2' TO PROGRAM 'gzip -c -1 > @abs_srcdir@/data/nation2.gz'; -- OK -\COPY BINARY dir_table1 FROM '@abs_srcdir@/data/nation.csv' 'nation.txt'; -- OK -NOTICE: dir_table1 INSERT AFTER ROW +\COPY BINARY DIRECTORY TABLE "abs.dir_table" 'aa.bb' TO '@abs_srcdir@/data/aa.bb'; -- OK +COPY BINARY DIRECTORY TABLE "abs.dir_table" 'cc.dd' TO '@abs_srcdir@/data/cc.dd'; -- OK \COPY BINARY DIRECTORY TABLE dir_table1 'nation.txt' TO '@abs_srcdir@/data/nation.txt'; -- OK -COPY BINARY DIRECTORY TABLE dir_table1 'nation.txt' TO '@abs_srcdir@/data/nation2.txt'; -- OK +COPY BINARY DIRECTORY TABLE dir_table1 'nation2.txt' TO '@abs_srcdir@/data/nation2.txt'; -- OK +\COPY BINARY DIRECTORY TABLE public.dir_table1 'nation.txt' TO '@abs_srcdir@/data/nation3.txt'; -- OK +COPY BINARY DIRECTORY TABLE public.dir_table1 'nation2.txt' TO '@abs_srcdir@/data/nation4.txt'; -- OK SELECT relative_path, size, tag FROM dir_table1 ORDER BY 1; relative_path | size | tag ---------------+------+-------- nation1 | 2199 | nation2 | 2199 | + nation2.txt | 2199 | nation3 | 2199 | nation nation4 | 2199 | nation nation.txt | 2199 | -(5 rows) +(6 rows) SELECT relative_path, size, tag FROM dir_table2 ORDER BY 1; relative_path | size | tag @@ -1302,10 +1316,11 @@ SELECT relative_path, size, tag FROM dir_table1 ORDER BY 1; ---------------+------+-------- nation1 | 2199 | nation2 | 2199 | + nation2.txt | 2199 | nation3 | 2199 | nation nation4 | 2199 | nation nation.txt | 2199 | -(5 rows) +(6 rows) SELECT relative_path, size, tag FROM dir_table2 ORDER BY 1; relative_path | size | tag @@ -1325,10 +1340,11 @@ SELECT relative_path, size, tag FROM dir_table1 ORDER BY 1; ---------------+------+-------- nation1 | 2199 | nation2 | 2199 | + nation2.txt | 2199 | nation3 | 2199 | nation nation4 | 2199 | nation nation.txt | 2199 | -(5 rows) +(6 rows) SELECT relative_path, size, tag FROM dir_table2 ORDER BY 1; relative_path | size | tag @@ -1375,10 +1391,11 @@ SELECT relative_path, size, tag FROM dir_table1 ORDER BY 1; ---------------+------+----------------- nation1 | 2199 | nation_new_tag nation2 | 2199 | nation2_new_tag + nation2.txt | 2199 | nation_new_tag nation3 | 2199 | nation_new_tag nation4 | 2199 | nation_new_tag nation.txt | 2199 | nation_new_tag -(5 rows) +(6 rows) SELECT relative_path, size, tag FROM dir_table2 ORDER BY 1; relative_path | size | tag @@ -1467,10 +1484,11 @@ SELECT remove_file('dir_table1', 'nation1'); -- fail SELECT relative_path, size, tag FROM dir_table1 ORDER BY 1; relative_path | size | tag ---------------+------+---------------- + nation2.txt | 2199 | nation_new_tag nation3 | 2199 | nation_new_tag nation4 | 2199 | nation_new_tag nation.txt | 2199 | nation_new_tag -(3 rows) +(4 rows) SELECT relative_path, size, tag FROM dir_table2 ORDER BY 1; relative_path | size | tag @@ -1900,6 +1918,7 @@ DROP DIRECTORY TABLE IF EXISTS dir_table4; DROP DIRECTORY TABLE IF EXISTS dir_table5; NOTICE: directory table "dir_table5" does not exist, skipping DROP DIRECTORY TABLE IF EXISTS dir_table6; +DROP DIRECTORY TABLE IF EXISTS "abs.dir_table"; DROP FUNCTION IF EXISTS triggertest; DROP STORAGE USER MAPPING IF EXISTS FOR CURRENT_USER STORAGE SERVER oss_server1; DROP STORAGE USER MAPPING IF EXISTS FOR CURRENT_USER STORAGE SERVER oss_server2; diff --git a/src/test/regress/output/directory_table_optimizer.source b/src/test/regress/output/directory_table_optimizer.source index 3aa1fcac4c6..8c53a34e67d 100644 --- a/src/test/regress/output/directory_table_optimizer.source +++ b/src/test/regress/output/directory_table_optimizer.source @@ -528,28 +528,31 @@ CREATE DIRECTORY TABLE IF NOT EXISTS dir_table2 TABLESPACE directory_tblspc; NOTICE: relation "dir_table2" already exists, skipping CREATE DIRECTORY TABLE dir_table5 TABLESPACE directory_tblspc; CREATE DIRECTORY TABLE dir_table6 TABLESPACE pg_default; +CREATE DIRECTORY TABLE "abs.dir_table"; SELECT count(*) FROM pg_directory_table; count ------- - 6 + 7 (1 row) SELECT relname, relisshared, relpersistence, relkind FROM pg_class WHERE relname like '%dir_table%' ORDER BY 1; - relname | relisshared | relpersistence | relkind ------------------+-------------+----------------+--------- - dir_table1 | f | p | d - dir_table1_pkey | f | p | i - dir_table2 | f | p | d - dir_table2_pkey | f | p | i - dir_table3 | f | p | d - dir_table3_pkey | f | p | i - dir_table4 | f | p | d - dir_table4_pkey | f | p | i - dir_table5 | f | p | d - dir_table5_pkey | f | p | i - dir_table6 | f | p | d - dir_table6_pkey | f | p | i -(12 rows) + relname | relisshared | relpersistence | relkind +--------------------+-------------+----------------+--------- + abs.dir_table | f | p | d + abs.dir_table_pkey | f | p | i + dir_table1 | f | p | d + dir_table1_pkey | f | p | i + dir_table2 | f | p | d + dir_table2_pkey | f | p | i + dir_table3 | f | p | d + dir_table3_pkey | f | p | i + dir_table4 | f | p | d + dir_table4_pkey | f | p | i + dir_table5 | f | p | d + dir_table5_pkey | f | p | i + dir_table6 | f | p | d + dir_table6_pkey | f | p | i +(14 rows) \d+ dir_table1; Directory table "public.dir_table1" @@ -628,21 +631,23 @@ NOTICE: directory table "dir_table5" does not exist, skipping SELECT count(*) FROM pg_directory_table; count ------- - 4 + 5 (1 row) SELECT relname, relisshared, relpersistence, relkind FROM pg_class WHERE relname like '%dir_table%' ORDER BY 1; - relname | relisshared | relpersistence | relkind ------------------+-------------+----------------+--------- - dir_table1 | f | p | d - dir_table1_pkey | f | p | i - dir_table2 | f | p | d - dir_table2_pkey | f | p | i - dir_table3 | f | p | d - dir_table3_pkey | f | p | i - dir_table6 | f | p | d - dir_table6_pkey | f | p | i -(8 rows) + relname | relisshared | relpersistence | relkind +--------------------+-------------+----------------+--------- + abs.dir_table | f | p | d + abs.dir_table_pkey | f | p | i + dir_table1 | f | p | d + dir_table1_pkey | f | p | i + dir_table2 | f | p | d + dir_table2_pkey | f | p | i + dir_table3 | f | p | d + dir_table3_pkey | f | p | i + dir_table6 | f | p | d + dir_table6_pkey | f | p | i +(10 rows) \c dirtable_db SELECT count(*) FROM pg_directory_table; @@ -845,6 +850,12 @@ SELECT relative_path, content FROM directory_table('dir_table2') ORDER BY 1; nation4 | \x307c414c47455249417c307c20686167676c652e206361726566756c6c792066696e616c206465706f736974732064657465637420736c796c7920616761690a317c415247454e54494e417c317c616c20666f7865732070726f6d69736520736c796c79206163636f7264696e6720746f2074686520726567756c6172206163636f756e74732e20626f6c6420726571756573747320616c6f6e0a327c4252415a494c7c317c7920616c6f6e6773696465206f66207468652070656e64696e67206465706f736974732e206361726566756c6c79207370656369616c207061636b61676573206172652061626f7574207468652069726f6e696320666f726765732e20736c796c79207370656369616c200a337c43414e4144417c317c6561732068616e672069726f6e69632c2073696c656e74207061636b616765732e20736c796c7920726567756c6172207061636b616765732061726520667572696f75736c79206f76657220746865207469746865732e20666c756666696c7920626f6c640a347c45475950547c347c792061626f766520746865206361726566756c6c7920756e757375616c207468656f646f6c697465732e2066696e616c206475676f7574732061726520717569636b6c79206163726f73732074686520667572696f75736c7920726567756c617220640a357c455448494f5049417c307c76656e207061636b616765732077616b6520717569636b6c792e20726567750a367c4652414e43457c337c726566756c6c792066696e616c2072657175657374732e20726567756c61722c2069726f6e690a377c4745524d414e597c337c6c20706c6174656c6574732e20726567756c6172206163636f756e747320782d7261793a20756e757375616c2c20726567756c6172206163636f0a387c494e4449417c327c737320657863757365732063616a6f6c6520736c796c79206163726f737320746865207061636b616765732e206465706f73697473207072696e742061726f756e0a397c494e444f4e455349417c327c20736c796c792065787072657373206173796d70746f7465732e20726567756c6172206465706f7369747320686167676c6520736c796c792e206361726566756c6c792069726f6e696320686f636b657920706c617965727320736c65657020626c697468656c792e206361726566756c6c0a31307c4952414e7c347c6566756c6c7920616c6f6e6773696465206f662074686520736c796c792066696e616c20646570656e64656e636965732e200a31317c495241517c347c6e6963206465706f7369747320626f6f73742061746f702074686520717569636b6c792066696e616c2072657175657374733f20717569636b6c7920726567756c610a31327c4a4150414e7c327c6f75736c792e2066696e616c2c20657870726573732067696674732063616a6f6c6520610a31337c4a4f5244414e7c347c6963206465706f736974732061726520626c697468656c792061626f757420746865206361726566756c6c7920726567756c61722070610a31347c4b454e59417c307c2070656e64696e67206578637573657320686167676c6520667572696f75736c79206465706f736974732e2070656e64696e672c20657870726573732070696e746f206265616e732077616b6520666c756666696c79207061737420740a31357c4d4f524f43434f7c307c726e732e20626c697468656c7920626f6c6420636f7572747320616d6f6e672074686520636c6f73656c7920726567756c6172207061636b616765732075736520667572696f75736c7920626f6c6420706c6174656c6574733f0a31367c4d4f5a414d42495155457c307c732e2069726f6e69632c20756e757375616c206173796d70746f7465732077616b6520626c697468656c7920720a31377c504552557c317c706c6174656c6574732e20626c697468656c792070656e64696e6720646570656e64656e636965732075736520666c756666696c79206163726f737320746865206576656e2070696e746f206265616e732e206361726566756c6c792073696c656e74206163636f756e0a31387c4348494e417c327c6320646570656e64656e636965732e20667572696f75736c792065787072657373206e6f746f726e697320736c65657020736c796c7920726567756c6172206163636f756e74732e20696465617320736c6565702e206465706f730a31397c524f4d414e49417c337c756c6172206173796d70746f746573206172652061626f75742074686520667572696f7573206d756c7469706c696572732e206578707265737320646570656e64656e63696573206e61672061626f7665207468652069726f6e6963616c6c792069726f6e6963206163636f756e740a32307c5341554449204152414249417c347c74732e2073696c656e7420726571756573747320686167676c652e20636c6f73656c792065787072657373207061636b6167657320736c656570206163726f73732074686520626c697468656c790a32317c564945544e414d7c327c68656c7920656e746963696e676c792065787072657373206163636f756e74732e206576656e2c2066696e616c200a32327c5255535349417c337c20726571756573747320616761696e73742074686520706c6174656c65747320757365206e65766572206163636f7264696e6720746f2074686520717569636b6c7920726567756c61722070696e740a32337c554e49544544204b494e47444f4d7c337c65616e7320626f6f7374206361726566756c6c79207370656369616c2072657175657374732e206163636f756e7473206172652e206361726566756c6c0a32347c554e49544544205354415445537c317c792066696e616c207061636b616765732e20736c6f7720666f7865732063616a6f6c6520717569636b6c792e20717569636b6c792073696c656e7420706c6174656c657473206272656163682069726f6e6963206163636f756e74732e20756e757375616c2070696e746f2062650a (4 rows) +\COPY BINARY dir_table1 FROM '/code/profile/src/test/regress/data/nation.csv' 'nation.txt'; -- OK +NOTICE: dir_table1 INSERT AFTER ROW +COPY BINARY dir_table1 FROM '/code/profile/src/test/regress/data/nation.csv' 'nation2.txt'; -- OK +NOTICE: dir_table1 INSERT AFTER ROW +\COPY BINARY "abs.dir_table" FROM '/code/profile/src/test/regress/data/nation.csv' 'aa.bb'; -- OK +COPY BINARY "abs.dir_table" FROM '/code/profile/src/test/regress/data/nation.csv' 'cc.dd'; -- OK -- Test copy binary from directory table \COPY BINARY dir_table1 FROM '@abs_srcdir@/data/nation.csv' 'nation_failed' (format CSV); ERROR: conflicting or redundant options @@ -1152,19 +1163,22 @@ COPY BINARY DIRECTORY TABLE dir_table1 'nation2' TO stdout; -- OK 24|UNITED STATES|1|y final packages. slow foxes cajole quickly. quickly silent platelets breach ironic accounts. unusual pinto be \COPY BINARY DIRECTORY TABLE dir_table1 'nation2' TO PROGRAM 'gzip -c -1 > @abs_srcdir@/data/nation2.gz'; -- OK COPY BINARY DIRECTORY TABLE dir_table1 'nation2' TO PROGRAM 'gzip -c -1 > @abs_srcdir@/data/nation2.gz'; -- OK -\COPY BINARY dir_table1 FROM '@abs_srcdir@/data/nation.csv' 'nation.txt'; -- OK -NOTICE: dir_table1 INSERT AFTER ROW +\COPY BINARY DIRECTORY TABLE "abs.dir_table" 'aa.bb' TO '@abs_srcdir@/data/aa.bb'; -- OK +COPY BINARY DIRECTORY TABLE "abs.dir_table" 'cc.dd' TO '@abs_srcdir@/data/cc.dd'; -- OK \COPY BINARY DIRECTORY TABLE dir_table1 'nation.txt' TO '@abs_srcdir@/data/nation.txt'; -- OK -COPY BINARY DIRECTORY TABLE dir_table1 'nation.txt' TO '@abs_srcdir@/data/nation2.txt'; -- OK +COPY BINARY DIRECTORY TABLE dir_table1 'nation2.txt' TO '@abs_srcdir@/data/nation2.txt'; -- OK +\COPY BINARY DIRECTORY TABLE public.dir_table1 'nation.txt' TO '@abs_srcdir@/data/nation3.txt'; -- OK +COPY BINARY DIRECTORY TABLE public.dir_table1 'nation2.txt' TO '@abs_srcdir@/data/nation4.txt'; -- OK SELECT relative_path, size, tag FROM dir_table1 ORDER BY 1; relative_path | size | tag ---------------+------+-------- nation1 | 2199 | nation2 | 2199 | + nation2.txt | 2199 | nation3 | 2199 | nation nation4 | 2199 | nation nation.txt | 2199 | -(5 rows) +(6 rows) SELECT relative_path, size, tag FROM dir_table2 ORDER BY 1; relative_path | size | tag @@ -1239,17 +1253,19 @@ WHERE dir_table1.md5 = dir_table2.md5 ORDER BY 1 LIMIT 1; QUERY PLAN ------------------------------------------------------------------ Limit - -> Sort - Sort Key: dir_table1.relative_path - -> Hash Join - Hash Cond: (dir_table1.md5 = dir_table2.md5) - -> Gather Motion 3:1 (slice1; segments: 3) - -> Seq Scan on dir_table1 - -> Hash - -> Gather Motion 3:1 (slice2; segments: 3) - -> Seq Scan on dir_table2 + -> Gather Motion 3:1 (slice1; segments: 3) + Merge Key: dir_table1.relative_path + -> Limit + -> Sort + Sort Key: dir_table1.relative_path + -> Hash Join + Hash Cond: (dir_table1.md5 = dir_table2.md5) + -> Seq Scan on dir_table1 + -> Hash + -> Broadcast Motion 3:3 (slice2; segments: 3) + -> Seq Scan on dir_table2 Optimizer: Pivotal Optimizer (GPORCA) -(11 rows) +(13 rows) SELECT dir_table1.relative_path FROM dir_table1, dir_table2 WHERE dir_table1.md5 = dir_table2.md5 ORDER BY 1 LIMIT 1; @@ -1300,10 +1316,11 @@ SELECT relative_path, size, tag FROM dir_table1 ORDER BY 1; ---------------+------+-------- nation1 | 2199 | nation2 | 2199 | + nation2.txt | 2199 | nation3 | 2199 | nation nation4 | 2199 | nation nation.txt | 2199 | -(5 rows) +(6 rows) SELECT relative_path, size, tag FROM dir_table2 ORDER BY 1; relative_path | size | tag @@ -1323,10 +1340,11 @@ SELECT relative_path, size, tag FROM dir_table1 ORDER BY 1; ---------------+------+-------- nation1 | 2199 | nation2 | 2199 | + nation2.txt | 2199 | nation3 | 2199 | nation nation4 | 2199 | nation nation.txt | 2199 | -(5 rows) +(6 rows) SELECT relative_path, size, tag FROM dir_table2 ORDER BY 1; relative_path | size | tag @@ -1373,10 +1391,11 @@ SELECT relative_path, size, tag FROM dir_table1 ORDER BY 1; ---------------+------+----------------- nation1 | 2199 | nation_new_tag nation2 | 2199 | nation2_new_tag + nation2.txt | 2199 | nation_new_tag nation3 | 2199 | nation_new_tag nation4 | 2199 | nation_new_tag nation.txt | 2199 | nation_new_tag -(5 rows) +(6 rows) SELECT relative_path, size, tag FROM dir_table2 ORDER BY 1; relative_path | size | tag @@ -1465,10 +1484,11 @@ SELECT remove_file('dir_table1', 'nation1'); -- fail SELECT relative_path, size, tag FROM dir_table1 ORDER BY 1; relative_path | size | tag ---------------+------+---------------- + nation2.txt | 2199 | nation_new_tag nation3 | 2199 | nation_new_tag nation4 | 2199 | nation_new_tag nation.txt | 2199 | nation_new_tag -(3 rows) +(4 rows) SELECT relative_path, size, tag FROM dir_table2 ORDER BY 1; relative_path | size | tag @@ -1898,6 +1918,7 @@ DROP DIRECTORY TABLE IF EXISTS dir_table4; DROP DIRECTORY TABLE IF EXISTS dir_table5; NOTICE: directory table "dir_table5" does not exist, skipping DROP DIRECTORY TABLE IF EXISTS dir_table6; +DROP DIRECTORY TABLE IF EXISTS "abs.dir_table"; DROP FUNCTION IF EXISTS triggertest; DROP STORAGE USER MAPPING IF EXISTS FOR CURRENT_USER STORAGE SERVER oss_server1; DROP STORAGE USER MAPPING IF EXISTS FOR CURRENT_USER STORAGE SERVER oss_server2;