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: max_row_size guardrails miss indexed virtual computed columns #69540

Open
michae2 opened this issue Aug 29, 2021 · 2 comments
Open

sql: max_row_size guardrails miss indexed virtual computed columns #69540

michae2 opened this issue Aug 29, 2021 · 2 comments
Labels
A-sql-execution Relating to SQL execution. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. docs-done docs-known-limitation T-sql-queries SQL Queries Team X-nostale Marks an issue/pr that should be ignored by the stale bot

Comments

@michae2
Copy link
Collaborator

michae2 commented Aug 29, 2021

The new max_row_size guardrails added in #67953 and #69457 miss large rows caused by indexed virtual computed columns. This is because they only check the size of primary key rows, not secondary index rows.

Here's one way to reproduce it:

SET CLUSTER SETTING sql.guardrails.max_row_size_err = '1KiB';
CREATE TABLE t (c CHAR, d STRING DEFAULT repeat('x', 2000), INDEX (d));
CREATE TABLE t2 (c CHAR, d STRING AS (repeat(c, 2000)) VIRTUAL, INDEX (d));
INSERT INTO t (c) VALUES ('x');
INSERT INTO t2 (c) VALUES ('x');

The first insert fails but the second does not. Both should fail.

demo@127.0.0.1:26257/defaultdb> INSERT INTO t (c) VALUES ('x');
ERROR: row larger than max row size: table 53 family 0 primary key /Table/53/1/688592352786874369/0 size 2023
SQLSTATE: 54000

demo@127.0.0.1:26257/defaultdb> INSERT INTO t2 (c) VALUES ('x');
INSERT 1


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

demo@127.0.0.1:26257/defaultdb> SELECT c, pg_column_size(d) FROM t2;
  c | pg_column_size
----+-----------------
  x |           2003
(1 row)


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

demo@127.0.0.1:26257/defaultdb> SELECT version();
                                                          version
----------------------------------------------------------------------------------------------------------------------------
  CockroachDB CCL v21.2.0-alpha.00000000-3740-g6700cf65e8 (x86_64-apple-darwin20.6.0, built 2021/08/29 04:36:22, go1.16.6)
(1 row)


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

Jira issue: CRDB-9646

@michae2 michae2 added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-sql-execution Relating to SQL execution. labels Aug 29, 2021
@blathers-crl blathers-crl bot added the T-sql-queries SQL Queries Team label Aug 29, 2021
@rytaft
Copy link
Collaborator

rytaft commented May 18, 2022

Should this be a known limitation? Adding the label, but feel free to remove it if not.

Copy link

github-actions bot commented Jan 1, 2024

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!

@michae2 michae2 added X-nostale Marks an issue/pr that should be ignored by the stale bot and removed no-issue-activity labels Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-execution Relating to SQL execution. C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. docs-done docs-known-limitation T-sql-queries SQL Queries Team X-nostale Marks an issue/pr that should be ignored by the stale bot
Projects
Status: Backlog
Development

No branches or pull requests

3 participants