Fix publication syntax error message
authorAlvaro Herrera <[email protected]>
Wed, 10 May 2023 16:26:10 +0000 (18:26 +0200)
committerAlvaro Herrera <[email protected]>
Wed, 10 May 2023 16:26:10 +0000 (18:26 +0200)
There was some odd wording in corner-case gram.y error messages "some
error ... at or near", which appears to have been modeled after "syntax
error" messages.  However, they don't work that way, and they're just
wrong.  They're also uncovered by tests.  Remove the trailing words,
and also add tests.

They were introduced with 5a2832465fd8; backpatch to 15.

Author: Álvaro Herrera <[email protected]>

src/backend/parser/gram.y
src/test/regress/expected/publication.out
src/test/regress/sql/publication.sql

index a723d9db78f0dc1cdb1382673d4b4b1407435c4b..d6426f3b8e0eabbea4fd5fc3e11d69ffdec34a67 100644 (file)
@@ -18832,7 +18832,7 @@ preprocess_pubobj_list(List *pubobjspec_list, core_yyscan_t yyscanner)
                        if (!pubobj->name && !pubobj->pubtable)
                                ereport(ERROR,
                                                errcode(ERRCODE_SYNTAX_ERROR),
-                                               errmsg("invalid table name at or near"),
+                                               errmsg("invalid table name"),
                                                parser_errposition(pubobj->location));
 
                        if (pubobj->name)
@@ -18874,7 +18874,7 @@ preprocess_pubobj_list(List *pubobjspec_list, core_yyscan_t yyscanner)
                        else
                                ereport(ERROR,
                                                errcode(ERRCODE_SYNTAX_ERROR),
-                                               errmsg("invalid schema name at or near"),
+                                               errmsg("invalid schema name"),
                                                parser_errposition(pubobj->location));
                }
 
index 427f87ea0771c8cd4e1ec797cd438766d9d08884..69dc6cfd8593dc67ceb6c75b5ea2648f1c5c8b4e 100644 (file)
@@ -132,6 +132,15 @@ Tables:
 Tables from schemas:
     "pub_test"
 
+-- weird parser corner case
+CREATE PUBLICATION testpub_parsertst FOR TABLE pub_test.testpub_nopk, CURRENT_SCHEMA;
+ERROR:  invalid table name
+LINE 1: ...estpub_parsertst FOR TABLE pub_test.testpub_nopk, CURRENT_SC...
+                                                             ^
+CREATE PUBLICATION testpub_parsertst FOR TABLES IN SCHEMA foo, test.foo;
+ERROR:  invalid schema name
+LINE 1: ...CATION testpub_parsertst FOR TABLES IN SCHEMA foo, test.foo;
+                                                              ^
 -- should be able to add a table of the same schema to the schema publication
 ALTER PUBLICATION testpub_forschema ADD TABLE pub_test.testpub_nopk;
 \dRp+ testpub_forschema
index a47c5939d58e384dadff0242d50a564e0a963748..d5051a5e74604cdac39b25fc2cfae6effa3d4802 100644 (file)
@@ -79,6 +79,10 @@ CREATE PUBLICATION testpub_for_tbl_schema FOR TABLES IN SCHEMA pub_test, TABLE p
 RESET client_min_messages;
 \dRp+ testpub_for_tbl_schema
 
+-- weird parser corner case
+CREATE PUBLICATION testpub_parsertst FOR TABLE pub_test.testpub_nopk, CURRENT_SCHEMA;
+CREATE PUBLICATION testpub_parsertst FOR TABLES IN SCHEMA foo, test.foo;
+
 -- should be able to add a table of the same schema to the schema publication
 ALTER PUBLICATION testpub_forschema ADD TABLE pub_test.testpub_nopk;
 \dRp+ testpub_forschema