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 with RETURNING should be able to return other columns #4645

Closed
RaduBerinde opened this issue Feb 25, 2016 · 1 comment
Closed
Labels
C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.

Comments

@RaduBerinde
Copy link
Member

When doing an UPDATE, we should be able to use RETURNING on other columns:

DROP TABLE IF EXISTS t;
CREATE TABLE t (a INT, b INT);

INSERT INTO t VALUES (1);
UPDATE t SET b = 2 RETURNING a;

We get an error: pq: qualified name "a" not found.
Related to this, RETURNING * should return all columns in the table, not just the updated ones.

This works in pg;

UPDATE t SET b = 2 RETURNING a;
 a 

---
 1
(1 row)

UPDATE 1
UPDATE t SET b = 2 RETURNING *;
 a | b 
---+---
 1 | 2
(1 row)

Also related, there is this testcase for INSERT:

statement error pq: qualified name "b" not found
INSERT INTO return (a) VALUES (default) RETURNING b

I am not sure if this should work or not (I haven't checked what pg does).

@mjibson

@RaduBerinde RaduBerinde added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Feb 25, 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; filed cockroachdb#4645).

Fixes cockroachdb#4593.
@RaduBerinde
Copy link
Member Author

Oops, this is a duplicate of #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

No branches or pull requests

1 participant