sql: adding a computed column doesn't validate against existing values #88234
Labels
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
Describe the problem
Right now it's possible to add computed columns where the generated values for a subset of columns
can never be properly computed. For example a computed column could be the division between two
columns, in a given table:
ALTER TABLE ADD COLUMN c INT AS c1/c2 VIRTUAL
. If there is any c2 that iszero then this computed column would have a division by zero. When the computed column is STORED this
statement will rollback. But, when its virtual this column will be added and any SELECT involving the problematic
column will fail.
The ideal solution here is to have validation for VIRTUAL computed columns, where when a column is
added the existing values in the table are validated for the generated expression. If any of the expressions
can't be generated then the error is surfaced similar to a STORED computed column.
Jira issue: CRDB-19740
The text was updated successfully, but these errors were encountered: