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

sql: UPDATE should support RETURNING non-updated columns #4368

Closed
maddyblue opened this issue Feb 13, 2016 · 2 comments · Fixed by #5044
Closed

sql: UPDATE should support RETURNING non-updated columns #4368

maddyblue opened this issue Feb 13, 2016 · 2 comments · Fixed by #5044
Assignees
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Milestone

Comments

@maddyblue
Copy link
Contributor

test=# update table1 set column_b = '' returning column_a;
 column_a
----------
        1
(1 row)

UPDATE 1
@maddyblue maddyblue self-assigned this Feb 13, 2016
@petermattis petermattis added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Feb 14, 2016
@petermattis petermattis modified the milestone: Beta Feb 14, 2016
RaduBerinde added a commit to RaduBerinde/cockroach that referenced this issue Feb 25, 2016
This change adds support for `RETURNING *` in inserts and deletes. For updates
we currently only expand the updated columns; this is related to an existing
problem (we can't return other columns even explicitly, cockroachdb#4368).

Fixes cockroachdb#4593.
@RaduBerinde
Copy link
Member

Related:

INSERT INTO t (a) VALUES (1) RETURNING *;

This returns only column a. I think it should return all columns from the table. PG does:

INSERT INTO t (a) VALUES (1) RETURNING *;
 a | b 
---+---
 1 |  
(1 row)

RaduBerinde added a commit to RaduBerinde/cockroach that referenced this issue Feb 25, 2016
This change adds support for `RETURNING *` in inserts and deletes. For updates
we currently only expand the updated columns; this is related to an existing
problem (we can't return other columns even explicitly, cockroachdb#4368).

Fixes cockroachdb#4593.
@RaduBerinde
Copy link
Member

I wonder if we should just use all visible table columns in returningHelper instead of passing the columns from insert/update.

Edit: never mind, it's not that simple, the rowVals have to match the columns we pass to rh.

RaduBerinde added a commit to RaduBerinde/cockroach that referenced this issue Feb 25, 2016
This change adds support for `RETURNING *` in inserts and deletes. For updates
we currently only expand the updated columns; this is related to an existing
problem (we can't return other columns even explicitly, cockroachdb#4368).

Fixes cockroachdb#4593.
@petermattis petermattis assigned RaduBerinde and unassigned maddyblue Mar 8, 2016
RaduBerinde added a commit to RaduBerinde/cockroach that referenced this issue Mar 10, 2016
The RETURNING clause can only access columns that are being updated or inserted.
This is fixed by always providing all columns to ReturningHelper. For update we
already have values for all columns in rowVals; for insert we fill in the
provided values and let the other values be NULL.

Fixes cockroachdb#4368.
RaduBerinde added a commit to RaduBerinde/cockroach that referenced this issue Mar 10, 2016
The RETURNING clause can only access columns that are being updated or inserted.
This is fixed by always providing all columns to ReturningHelper. For update we
already have values for all columns in rowVals; for insert we fill in the
provided values and let the other values be NULL.

Fixes cockroachdb#4368.
RaduBerinde added a commit to RaduBerinde/cockroach that referenced this issue Mar 10, 2016
The RETURNING clause can only access columns that are being updated or inserted.
This is fixed by always providing all columns to ReturningHelper. For update we
already have values for all columns in rowVals; for insert we fill in the
provided values and let the other values be NULL.

Fixes cockroachdb#4368.
RaduBerinde added a commit to RaduBerinde/cockroach that referenced this issue Mar 10, 2016
The RETURNING clause can only access columns that are being updated or inserted.
This is fixed by always providing all columns to ReturningHelper. For update we
already have values for all columns in rowVals; for insert we fill in the
provided values and let the other values be NULL.

Fixes cockroachdb#4368.
RaduBerinde added a commit to RaduBerinde/cockroach that referenced this issue Mar 10, 2016
The RETURNING clause can only access columns that are being updated or inserted.
This is fixed by always providing all columns to ReturningHelper. For update we
already have values for all columns in rowVals; for insert we fill in the
provided values and let the other values be NULL.

Fixes cockroachdb#4368.
RaduBerinde added a commit to RaduBerinde/cockroach that referenced this issue Mar 10, 2016
The RETURNING clause can only access columns that are being updated or inserted.
This is fixed by always providing all columns to ReturningHelper. For update we
already have values for all columns in rowVals; for insert we fill in the
provided values and let the other values be NULL.

Fixes cockroachdb#4368.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants