Skip to content

Commit 0094d6a

Browse files
committed
sql: standardize error message for ON UPDATE expressions
This makes the legacy schema changer return the same error text that the declarative one has. Release note: None
1 parent fc190f4 commit 0094d6a

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

pkg/sql/alter_table.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,10 +1000,9 @@ func applyColumnMutation(
10001000
fk.OnUpdate != semenumpb.ForeignKeyAction_RESTRICT {
10011001
return pgerror.Newf(
10021002
pgcode.InvalidColumnDefinition,
1003-
"column %s(%d) cannot have both an ON UPDATE expression and a foreign"+
1004-
" key ON UPDATE action",
1003+
"column cannot specify both ON UPDATE expression and a foreign"+
1004+
" key ON UPDATE action for column %q",
10051005
col.GetName(),
1006-
col.GetID(),
10071006
)
10081007
}
10091008
}

pkg/sql/logictest/testdata/logic_test/on_update

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ CREATE TABLE test_fk_invalid (p STRING PRIMARY KEY, j STRING ON UPDATE 'test', C
167167
statement ok
168168
CREATE TABLE alter_fk (p STRING PRIMARY KEY, j STRING REFERENCES test_fk_base (j) ON UPDATE CASCADE)
169169

170-
statement error pq: column j\(2\) cannot have both an ON UPDATE expression and a foreign key ON UPDATE action
170+
statement error cannot specify both ON UPDATE expression and a foreign key ON UPDATE action for column "j"
171171
ALTER TABLE alter_fk ALTER COLUMN j SET ON UPDATE 'failure'
172172

173173
statement ok

0 commit comments

Comments
 (0)