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] ON CONFLICT DO UPDATE with arrays on temp table #1999

Closed
jaki opened this issue Aug 7, 2019 · 0 comments
Closed

[YSQL] ON CONFLICT DO UPDATE with arrays on temp table #1999

jaki opened this issue Aug 7, 2019 · 0 comments
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue

Comments

@jaki
Copy link
Contributor

jaki commented Aug 7, 2019

Jira Link: DB-1858
The non-temporary table examples below are taken from the Postgres regress test arrays.

create table arr_pk_tbl (pk int4 primary key, f1 int[]);
insert into arr_pk_tbl values (1, '{1,2,3}');
insert into arr_pk_tbl values (1, '{3,4,5}') on conflict (pk)
  do update set f1[1] = excluded.f1[1], f1[3] = excluded.f1[3]
  returning pk, f1;

outputs

 pk |   f1
----+---------
  1 | {3,2,5}
(1 row)

as expected. However, when changing it to a temporary table,

create temp table arr_pk_tbl (pk int4 primary key, f1 int[]);
insert into arr_pk_tbl values (1, '{1,2,3}');
insert into arr_pk_tbl values (1, '{3,4,5}') on conflict (pk)
  do update set f1[1] = excluded.f1[1], f1[3] = excluded.f1[3]
  returning pk, f1;

outputs

 pk |   f1
----+---------
  1 | {3,4,5}
(1 row)

which is incorrect.

Similarly, we have

insert into arr_pk_tbl(pk, f1[1:2]) values (1, '{6,7,8}') on conflict (pk)
  do update set f1[1] = excluded.f1[1],
    f1[2] = excluded.f1[2],
    f1[3] = excluded.f1[3]
  returning pk, f1;

outputting

 pk |     f1
----+------------
  1 | {6,7,NULL}
(1 row)

on non-temporary table but outputting

 pk |  f1
----+-------
  1 | {6,7}
(1 row)

on temporary table, again incorrect.

@jaki jaki added the area/ysql Yugabyte SQL (YSQL) label Aug 7, 2019
jaki pushed a commit to jaki/yugabyte-db that referenced this issue Aug 22, 2019
There are some TODO commented out lines in the `yb_arrays` Postgres
regress test.  The first few are related to temporary tables not being
supported.  Since they are by now supported, resolve these TODOs.
Discover a new issue and open as issue yugabyte#1999, referencing the workaround
and future fix within the test.
@m-iancu m-iancu added this to YQL-beta Dec 6, 2021
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels Jun 9, 2022
@jasonyb jasonyb closed this as completed in f69b08f Aug 9, 2024
@github-project-automation github-project-automation bot moved this to Done in YQL-beta Aug 9, 2024
jasonyb pushed a commit that referenced this issue Aug 9, 2024
Summary:
 43d4b49 [PLAT-14771]: Restrict user actions on releases page based on appropriate RBAC permissions
 1473a23 [PLAT-14792]: Master and TServer nodes displays empty tool tip if nodes are unreachable
 Excluded: 78a2bc7 [#23114] YSQL: Refactoring the yb_pg_pgaudit.sql/.out test.
 da9b281 [doc][ybm] Prometheus integration (#23292)
 bd4874b [#13358] YSQL: Fix DDL atomicity stress test failure in tsan build
 edd8e3f [PLAT-14524] Undo all @JsonProperty annotations added earlier to fix APIs
 Excluded: 4a2657e [PLAT-14787] Implement a master tablet lb api for YW
 b9d2e9d [#23445]yugabyted: Node not starting with DNS name and `--secure` option
 f171e13 [#23447]yugabyted: Node doesn't restart with `--secure` enabled
 d4f036d [PLAT-14790] Region metadata is not populated when provisioned nodes are added via Node Agent when using assisted Manual Provisioning (provision_instance.py script)
 71ab66f [doc][ybm] Backup and restore clarifications (#23400)
 4768023 [doc] ysql_yb_bnl_batch_size flag (#23397)
 3d4bc2a [#23117] YSQL: Enable ALTER VIEW in parser
 Excluded: 03bbbed Bumping version to 2.23.1.0 on branch master
 622046d [#23335] DocDB: Set field close timestamp for the log segment being copied
 Excluded: f69b08f [#1999] YSQL: fix temp table INSERT ON CONFLICT
 Excluded: efd4cb7 [#23429] YSQL: fix INSERT ON CONFLICT TupleDesc ref leak
 Excluded: 9e7181f [PLAT-14785] Add REST APIs for job scheduler (auto-master failover)
 d56903c [PLAT-14850]API Token authentication loops through the users and checks token against each of these.

Test Plan: Jenkins: rebase: pg15-cherrypicks

Reviewers: jason, tfoucher

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D37201
jasonyb pushed a commit that referenced this issue Aug 12, 2024
…FLICT

Summary:
Merge:
f69b08f

- nodeModifyTable.c:
  - ExecOnConflictUpdate
    - goto yb_skip_transaction_control_check: false conflict between YB
      pg15 a87fee2 and YB master
      f69b08f.  Keep pg15 version.
    - yb_skip_transaction_control_check: conflict between same commits.
      Keep pg15 version.
    - ExecQual: conflict between same commits plus upstream PG
      277cb789836b5ddf81aabb80c2058268c70e2f36.  Keep pg15 version.
    - (end of function): same.

INSERT ON CONFLICT for temp tables is buggy, as shown by the issue #1999
example (same as arr_pk_tbl example here).  The cause appears to be
several uses of IsYugaByteEnabled where IsYBRelation should be used.
Make those changes and find the repro is resolved.  Also change one
instance of IsYBBackedRelation to IsYBRelation.  See related pg15 commit
a87fee2.

For tests, move the yb_pg_arrays test case to yb_dml_insert_conflict,
and add the previously buggy test case to yb_pg_arrays.  Also, though
this didn't fail before, add issue #2061 test case to
yb_dml_insert_conflict.
Jira: DB-1858

Test Plan:
On Almalinux 8:

    ./yb_build.sh fastdebug --gcc11 --java-test TestPgRegressDml
    ./yb_build.sh fastdebug --gcc11 --java-test TestPgRegressArrays

Jenkins: rebase: pg15-cherrypicks

Reviewers: aagrawal

Reviewed By: aagrawal

Subscribers: yql

Tags: #jenkins-ready

Differential Revision: https://phorge.dev.yugabyte.com/D37220
@github-project-automation github-project-automation bot moved this to Done in YSQL Aug 28, 2024
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
Status: Done
Development

No branches or pull requests

3 participants