disable excluded and add testcase

This commit is contained in:
gentle_hu
2020-08-25 21:23:29 +08:00
committed by gentle_hu
parent 69e83a8d8d
commit b062f44ad9
7 changed files with 45 additions and 2 deletions

View File

@ -17418,6 +17418,10 @@ columnref: ColId
{
$$ = makeColumnRef($1, $2, @1, yyscanner);
}
| EXCLUDED indirection
{
$$ = makeColumnRef("excluded", $2, @2, yyscanner);
}
;
indirection_el:
@ -17810,7 +17814,6 @@ SignedIconst: Iconst { $$ = $1; }
ColId: IDENT { $$ = $1; }
| unreserved_keyword { $$ = pstrdup($1); }
| col_name_keyword { $$ = pstrdup($1); }
| EXCLUDED { $$ = pstrdup($1); }
;
/* Type/function identifier --- names that can be type or function names.

View File

@ -191,6 +191,7 @@ PG_KEYWORD("every", EVERY, UNRESERVED_KEYWORD)
PG_KEYWORD("except", EXCEPT, RESERVED_KEYWORD)
PG_KEYWORD("exchange", EXCHANGE, UNRESERVED_KEYWORD)
PG_KEYWORD("exclude", EXCLUDE, UNRESERVED_KEYWORD)
PG_KEYWORD("excluded", EXCLUDED, RESERVED_KEYWORD)
PG_KEYWORD("excluding", EXCLUDING, UNRESERVED_KEYWORD)
PG_KEYWORD("exclusive", EXCLUSIVE, UNRESERVED_KEYWORD)
PG_KEYWORD("execute", EXECUTE, UNRESERVED_KEYWORD)

View File

@ -1,12 +1,13 @@
\c upsert
DROP SCHEMA upsert_test CASCADE;
NOTICE: drop cascades to 8 other objects
NOTICE: drop cascades to 9 other objects
DETAIL: drop cascades to type upsert_test.atype
drop cascades to type upsert_test.btype
drop cascades to table upsert_test.t_grammer
drop cascades to table upsert_test.t_default
drop cascades to table upsert_test.t_data
drop cascades to table upsert_test.t_trigger
drop cascades to table upsert_test."excluded"
drop cascades to function upsert_test.upsert_before_func()
drop cascades to function upsert_test.upsert_after_func()
DROP SCHEMA upsert_test_unlog CASCADE;

View File

@ -186,3 +186,25 @@ SELECT * FROM t_default ORDER BY 1;
--? 92 | .840485369320959 | Sun May 17 00:00:00 2020
(3 rows)
-- for table named excluded
INSERT INTO excluded values(1,1),(2,2) ON DUPLICATE KEY UPDATE b = excluded.b + 1;
ERROR: syntax error at or near "excluded"
LINE 1: INSERT INTO excluded values(1,1),(2,2) ON DUPLICATE KEY UPDA...
^
INSERT INTO "excluded" values(1,1),(2,2) ON DUPLICATE KEY UPDATE b = excluded.b + 1;
ERROR: table reference "excluded" is ambiguous
LINE 1: ...alues(1,1),(2,2) ON DUPLICATE KEY UPDATE b = excluded.b + 1;
^
CONTEXT: referenced column: b
INSERT INTO "excluded" values(5,5),(6,6) ON DUPLICATE KEY UPDATE b = 1;
SELECT * FROM excluded;
ERROR: syntax error at or near "excluded"
LINE 1: SELECT * FROM excluded;
^
SELECT * FROM "excluded";
a | b
---+---
5 | 5
6 | 6
(2 rows)

View File

@ -22,6 +22,12 @@ CREATE TABLE t_data (c_int INT PRIMARY KEY, c_tiny TINYINT, c_smallint SMALLINT,
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t_data_pkey" for table "t_data"
CREATE TABLE t_trigger (key INT PRIMARY KEY, color TEXT);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "t_trigger_pkey" for table "t_trigger"
CREATE TABLE excluded (a int primary key, b int);
ERROR: syntax error at or near "excluded"
LINE 1: CREATE TABLE excluded (a int primary key, b int);
^
CREATE TABLE "excluded" (a int primary key, b int);
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "excluded_pkey" for table "excluded"
-- unlogged table
CREATE SCHEMA upsert_test_unlog;
SET CURRENT_SCHEMA TO upsert_test_unlog;

View File

@ -111,3 +111,10 @@ INSERT INTO t_grammer VALUES(0, 0) ON DUPLICATE KEY UPDATE c2 = c4.a;
SELECT * FROM t_data ORDER BY 1;
SELECT * FROM t_grammer ORDER BY 1;
SELECT * FROM t_default ORDER BY 1;
-- for table named excluded
INSERT INTO excluded values(1,1),(2,2) ON DUPLICATE KEY UPDATE b = excluded.b + 1;
INSERT INTO "excluded" values(1,1),(2,2) ON DUPLICATE KEY UPDATE b = excluded.b + 1;
INSERT INTO "excluded" values(5,5),(6,6) ON DUPLICATE KEY UPDATE b = 1;
SELECT * FROM excluded;
SELECT * FROM "excluded";

View File

@ -20,6 +20,9 @@ CREATE TABLE t_data (c_int INT PRIMARY KEY, c_tiny TINYINT, c_smallint SMALLINT,
c_var VARCHAR, c_text TEXT, c_bytea BYTEA, c_date DATE, c_timestamp TIMESTAMP, c_time TIME,
c_intarray INT[3], c_com atype);
CREATE TABLE t_trigger (key INT PRIMARY KEY, color TEXT);
CREATE TABLE excluded (a int primary key, b int);
CREATE TABLE "excluded" (a int primary key, b int);
-- unlogged table
CREATE SCHEMA upsert_test_unlog;