Skip to content

Commit e4a6cdd

Browse files
zhangwenchao-123my-ship-it
authored andcommitted
Fix copy to directory table always return 1.
Fix when there is no file in directory table for copy to, the return number is always 1 which should be zero. Authored-by: Zhang Wenchao zwcpostgres@gmail.com
1 parent f9b8d27 commit e4a6cdd

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

src/backend/commands/copyto.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1878,7 +1878,10 @@ CopyToDispatchDirectoryTable(CopyToState cstate)
18781878

18791879
pfree(cdbCopy);
18801880

1881-
return 1;
1881+
if (processed)
1882+
return 1;
1883+
else
1884+
return 0;
18821885
}
18831886

18841887
/*

src/test/regress/input/directory_table.source

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,8 @@ COPY BINARY dir_table2 TO '@abs_srcdir@/data/dir_table2'; -- fail
388388
COPY BINARY dir_table1 TO '@abs_srcdir@/data/dir_table1'; -- fail
389389
\COPY BINARY DIRECTORY TABLE dir_table1 'nation1' TO '@abs_srcdir@/data/nation1'; -- OK
390390
COPY BINARY DIRECTORY TABLE dir_table1 'nation1' TO '@abs_srcdir@/data/nation1'; -- OK
391+
\COPY BINARY DIRECTORY TABLE dir_table1 'unknown' TO '@abs_srcdir@/data/unknown'; -- OK
392+
COPY BINARY DIRECTORY TABLE dir_table1 'unknown' TO '@abs_srcdir@/data/unknown'; -- OK
391393
\COPY BINARY DIRECTORY TABLE dir_table1 'nation2' TO stdin; -- OK
392394
COPY BINARY DIRECTORY TABLE dir_table1 'nation2' TO stdin; -- OK
393395
\COPY BINARY DIRECTORY TABLE dir_table1 'nation2' TO stdout; -- OK

src/test/regress/output/directory_table.source

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,8 @@ COPY BINARY dir_table1 TO '@abs_srcdir@/data/dir_table1'; -- fail
10441044
ERROR: COPY to directory table must specify the relative_path name.
10451045
\COPY BINARY DIRECTORY TABLE dir_table1 'nation1' TO '@abs_srcdir@/data/nation1'; -- OK
10461046
COPY BINARY DIRECTORY TABLE dir_table1 'nation1' TO '@abs_srcdir@/data/nation1'; -- OK
1047+
\COPY BINARY DIRECTORY TABLE dir_table1 'unknown' TO '@abs_srcdir@/data/unknown'; -- OK
1048+
COPY BINARY DIRECTORY TABLE dir_table1 'unknown' TO '@abs_srcdir@/data/unknown'; -- OK
10471049
\COPY BINARY DIRECTORY TABLE dir_table1 'nation2' TO stdin; -- OK
10481050
0|ALGERIA|0| haggle. carefully final deposits detect slyly agai
10491051
1|ARGENTINA|1|al foxes promise slyly according to the regular accounts. bold requests alon

src/test/regress/output/directory_table_optimizer.source

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,6 +1044,8 @@ COPY BINARY dir_table1 TO '@abs_srcdir@/data/dir_table1'; -- fail
10441044
ERROR: COPY to directory table must specify the relative_path name.
10451045
\COPY BINARY DIRECTORY TABLE dir_table1 'nation1' TO '@abs_srcdir@/data/nation1'; -- OK
10461046
COPY BINARY DIRECTORY TABLE dir_table1 'nation1' TO '@abs_srcdir@/data/nation1'; -- OK
1047+
\COPY BINARY DIRECTORY TABLE dir_table1 'unknown' TO '@abs_srcdir@/data/unknown'; -- OK
1048+
COPY BINARY DIRECTORY TABLE dir_table1 'unknown' TO '@abs_srcdir@/data/unknown'; -- OK
10471049
\COPY BINARY DIRECTORY TABLE dir_table1 'nation2' TO stdin; -- OK
10481050
0|ALGERIA|0| haggle. carefully final deposits detect slyly agai
10491051
1|ARGENTINA|1|al foxes promise slyly according to the regular accounts. bold requests alon

0 commit comments

Comments
 (0)