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: support writes to columns added in a transaction #43057

Open
ajwerner opened this issue Dec 9, 2019 · 2 comments
Open

sql: support writes to columns added in a transaction #43057

ajwerner opened this issue Dec 9, 2019 · 2 comments
Labels
A-schema-descriptors Relating to SQL table/db descriptor handling. A-schema-transactional A-sql-pgcompat Semantic compatibility with PostgreSQL C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@ajwerner
Copy link
Contributor

ajwerner commented Dec 9, 2019

This issue is being peeled out as a sub-issue of #42061, specifically around the problem and proposal put forth in this comment: #42061 (comment).

Please refer to the above comment for a bunch of commentary. The short summary is that columns added to tables using ALTER TABLE ... ADD COLUMN statements in a transaction are not available for use after that statement in the same transaction. Postgres permits immediate use of the new column.

Relates to #40862


I'll move content from the referenced thread into this issue as it settles.

Jira issue: CRDB-5300

@ajwerner ajwerner added A-sql-pgcompat Semantic compatibility with PostgreSQL A-schema-descriptors Relating to SQL table/db descriptor handling. labels Dec 9, 2019
@jordanlewis jordanlewis added this to Triage in SQL Foundations via automation Mar 18, 2020
@thoszhang thoszhang moved this from Needs Triage (4/28/2020) to Backlog in SQL Foundations May 4, 2020
@thoszhang thoszhang added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label May 5, 2020
@thoszhang thoszhang moved this from Backlog to Backlog: transactional schema changes in SQL Foundations Aug 27, 2020
@jlinder jlinder added the T-sql-schema-deprecated Use T-sql-foundations instead label Jun 16, 2021
@devadvocado
Copy link
Contributor

Ran into this issue when testing UDFs in 22.2

demo@127.0.0.1:26257/movr> BEGIN;
BEGIN


Time: 0ms total (execution 0ms / network 0ms)

demo@127.0.0.1:26257/movr  OPEN> ALTER TABLE users ADD COLUMN is_awesome BOOL DEFAULT true;
ALTER TABLE
Time: 7ms total (execution 7ms / network 0ms)

demo@127.0.0.1:26257/movr  OPEN> CREATE FUNCTION areyouawesome(boolean) RETURNS int AS $$                                                                                                                                     SELECT COUNT(is_awesome) FROM users WHERE is_awesome = $1;                                                    $$ LANGUAGE SQL;
ERROR: column "is_awesome" does not exist
SQLSTATE: 42703
demo@127.0.0.1:26257/? ERROR>

@ajwerner
Copy link
Contributor Author

This is a major motivation for https://github.com/cockroachdb/cockroach/blob/master/docs/RFCS/20200909_transactional_schema_changes.md. It's a hard problem.

@exalate-issue-sync exalate-issue-sync bot added T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) and removed T-sql-schema-deprecated Use T-sql-foundations instead labels May 10, 2023
@blathers-crl blathers-crl bot added this to Triage in SQL Foundations May 10, 2023
@rafiss rafiss moved this from Triage [old] to Triage in SQL Foundations May 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-schema-descriptors Relating to SQL table/db descriptor handling. A-schema-transactional A-sql-pgcompat Semantic compatibility with PostgreSQL C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
SQL Foundations
  
Triage
Development

No branches or pull requests

5 participants