Skip to content

Commit

Permalink
sql: add regression tests for memory accounting bug
Browse files Browse the repository at this point in the history
Add regression tests for a bug where backfilling a computed column or a column
with a default value using a builtin function would cause a `memory budget
exceeded` error (cockroachdb#34901). This was fixed by cockroachdb#34935.

Release note: None
  • Loading branch information
lucy-zhang committed Mar 12, 2019
1 parent 57c5b2b commit bc482ad
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/computed
Original file line number Diff line number Diff line change
Expand Up @@ -746,3 +746,19 @@ CREATE TABLE x (

query error value type decimal doesn't match type INT8 of column "a"
INSERT INTO x VALUES(1.4)

# Regression test for #34901: verify that builtins can be used in computed
# column expressions without a "memory budget exceeded" error while backfilling
statement ok
CREATE TABLE builtin_table (x STRING)

statement ok
INSERT INTO builtin_table VALUES ('a')

statement ok
ALTER TABLE builtin_table ADD COLUMN y STRING AS (concat(x, 'b')) STORED

query TT
SELECT * FROM builtin_table
----
a ab
16 changes: 16 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/default
Original file line number Diff line number Diff line change
Expand Up @@ -117,3 +117,19 @@ column_name data_type is_nullable column_default generation_expression indi
a INT8 false NULL · {primary} false
b TIMESTAMP true NULL · {} false
c INT8 true NULL · {} false

# Regression test for #34901: verify that builtins can be used in default value
# expressions without a "memory budget exceeded" error while backfilling
statement ok
CREATE TABLE builtin_table (x STRING)

statement ok
INSERT INTO builtin_table VALUES ('a')

statement ok
ALTER TABLE builtin_table ADD COLUMN y STRING DEFAULT (concat('b', 'c'))

query TT
SELECT * FROM builtin_table
----
a bc

0 comments on commit bc482ad

Please sign in to comment.