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: gate functions in views and descriptor expressions in mixed-version state #70442

Open
ajwerner opened this issue Sep 20, 2021 · 2 comments
Labels
A-schema-descriptors Relating to SQL table/db descriptor handling. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)

Comments

@ajwerner
Copy link
Contributor

ajwerner commented Sep 20, 2021

Describe the problem

Cockroach stores sql expressions in a number of places: views, default expressions, computed expressions, index predicates, on update expressions etc. These expressions may invoke functions. Functions (and probably other syntactic elements) can be introduced in new versions. Unfortunately, there's no code which exists today to validate that an expression uses only functions or syntax that is available at the current version. This is a problem in a mixed-version state where the gateway processing the SQL is using code newer than the current active cluster version.

To Reproduce

Let's consider the following in the v20.2 <-> v21.1 mixed state. Node 1 is running 21.1, other are running 20.2. soundex is a new function in 21.1.

root@localhost:26257/defaultdb> CREATE TABLE foo (i INT PRIMARY KEY, j STRING DEFAULT (soundex('a')));
CREATE TABLE

Other node:

root@localhost:26259/defaultdb> INSERT INTO foo(i) VALUES (1);
ERROR: unknown function: soundex()
SQLSTATE: 42883

Expected behavior

We should probably prevent the creation of this table.

Additional context

This seems to not be so bad. The entity is unusable for writes, but things aren't really worse than that.

This was noted by @nvanbenschoten in #70204 (comment).

Jira issue: CRDB-10077

@ajwerner ajwerner added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Sep 20, 2021
@RichardJCai
Copy link
Contributor

@otan also mentioned that this is also applicable to if we change the implementation of a builtin.

@github-actions
Copy link

We have marked this issue as stale because it has been inactive for
18 months. If this issue is still relevant, removing the stale label
or adding a comment will keep it active. Otherwise, we'll close it in
10 days to keep the issue queue tidy. Thank you for your contribution
to CockroachDB!

@rafiss rafiss added T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) and removed no-issue-activity labels Aug 24, 2023
@rafiss rafiss added the A-schema-descriptors Relating to SQL table/db descriptor handling. label Aug 29, 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. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions)
Projects
No open projects
Status: Triage
Development

No branches or pull requests

3 participants