You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Used postgres where possible to generate the error codes. A few
questionable codes have been marked with TODOs to be addressed in future
work.
Epic: none
Informs: cockroachdb#107369
Release note: none
Copy file name to clipboardExpand all lines: pkg/sql/logictest/testdata/logic_test/udf_insert
+10-8Lines changed: 10 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
statement ok
2
2
CREATE TABLE t (a INT PRIMARY KEY, b INT DEFAULT 0);
3
3
4
-
statement error pq: return type mismatch in function declared to return record\nDETAIL: Function's final statement must be SELECT or INSERT/UPDATE/DELETE RETURNING.
4
+
statement error pgcode 42P13 pq: return type mismatch in function declared to return record\nDETAIL: Function's final statement must be SELECT or INSERT/UPDATE/DELETE RETURNING.
5
5
CREATE FUNCTION f_err() RETURNS RECORD AS
6
6
$$
7
7
INSERT INTO t VALUES (1,2);
@@ -18,20 +18,22 @@ SELECT f_void();
18
18
----
19
19
NULL
20
20
21
-
statement error missing "a" primary key column
21
+
# TODO(107369): This doesn't error in postgres, and this is the error code for
22
+
# invalid foreign key, which may not make sense.
23
+
statement error pgcode 42830 missing "a" primary key column
22
24
CREATE FUNCTION f_err(b INT) RETURNS RECORD AS
23
25
$$
24
26
INSERT INTO t (b) VALUES (b);
25
27
SELECT * FROM t WHERE t.a=a AND t.b=b;
26
28
$$ LANGUAGE SQL;
27
29
28
-
statement error pq: volatile statement not allowed in stable function
30
+
statement error pgcode 22023 pq: volatile statement not allowed in stable function
29
31
CREATE FUNCTION f_err(i INT, j INT) RETURNS RECORD STABLE AS
30
32
$$
31
33
INSERT INTO t VALUES (i,j) RETURNING *;
32
34
$$ LANGUAGE SQL;
33
35
34
-
statement error pq: volatile statement not allowed in immutable function
36
+
statement error pgcode 22023 pq: volatile statement not allowed in immutable function
35
37
CREATE FUNCTION f_err(i INT, j INT) RETURNS RECORD IMMUTABLE AS
36
38
$$
37
39
INSERT INTO t VALUES (i,j) RETURNING *;
@@ -54,7 +56,7 @@ SELECT f_insert(3,4);
54
56
----
55
57
(3,4)
56
58
57
-
statement error duplicate key
59
+
statement error pgcode 23505 duplicate key
58
60
SELECT f_insert(3,4);
59
61
60
62
query II rowsort
@@ -138,7 +140,7 @@ SELECT f_2values(7,8,9,10);
138
140
(7,8)
139
141
(9,10)
140
142
141
-
statement error pq: duplicate key value violates unique constraint "t_multi_pkey"
0 commit comments