Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YSQL] Rows Not Getting Persisted inside Partitioned Tables Using Copy From #6021

Closed
emhna opened this issue Oct 12, 2020 · 1 comment
Closed
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue

Comments

@emhna
Copy link
Contributor

emhna commented Oct 12, 2020

Jira Link: DB-2495
After creating a partitioned table, rows do not get persisted inside the table using the copy from command.
Eg.

// set up partition table
create table test1 (a int, b int) partition by list (a);
create table test2 (b int, a int);
alter table test1 attach partition test2 for values in (1);

// copy from
copy test1 from stdout;
>> 1	2
>> 1	3
>> 1	4
>> \.
COPY 3

// verified nothing persisted in parent nor child tables
select * from test1;
 a | b 
---+---
(0 rows)
select * from test2;
 a | b 
---+---
(0 rows)

It is confirmed this only occurs with COPY FROM command, including when input is sourced from regular file not stdin.
Explicit insertion (ie. INSERT INTO) works.

Note, this issue occurred prior to COPY FROM OOM fix (eg. #5453, #2855).

The reason why this issue has not been detected before is because there doesn't seem to be "yb" test file that explicitly verifies this use case.
Eg. yb_pg_insert.sql's donothingbrtrig_test is a partitioned table that copies from stdout.
However, it attaches row level trigger to return null and expects nothing to be persisted into the table.

As a workaround, users should try to copy directly into child/partitioned tables rather than the parent/partitioning table.

@emhna emhna added the area/ysql Yugabyte SQL (YSQL) label Oct 12, 2020
@m-iancu m-iancu added this to YQL-beta Dec 7, 2021
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels Jun 9, 2022
@sushantrmishra
Copy link

Retried the test case, not reproducible in 2.15 .

yugabyte=# copy test1 from stdin with (format csv);
Enter data to be copied followed by a newline.
End with a backslash and a period on a line by itself, or an EOF signal.
>> 1,2
>> 1, 3
>> 1, 4
>> \.
COPY 3
yugabyte=#
yugabyte=#
yugabyte=# select * from test1;
 a | b
---+---
 1 | 4
 1 | 3
 1 | 2
(3 rows)

yugabyte=# select * from test2;
 b | a
---+---
 4 | 1
 3 | 1
 2 | 1
(3 rows)

yugabyte=#
yugabyte=# select version();

        version

--------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
------------------------
 PostgreSQL 11.2-YB-2.15.3.0-b0 on x86_64-pc-linux-gnu, compiled by clang version 13.0.1 (/opt/yb-build/llvm/y
b-llvm-v13.0.1-yb-2-1659058819-0131d8e1-centos7-x86_64-build/src/llvm-project/clang 0131d8e1a20f72a0f374979985
db4c2871be71bc), 64-bit
(1 row)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue
Projects
Status: Done
Development

No branches or pull requests

4 participants