summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2023-05-10 18:26:10 +0200
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2023-05-10 18:26:10 +0200
commit8e1d68c8f8eae96334db2f6633d2a61bcfb22f9a (patch)
tree0b535de9b0b0939dcb39f118922fa789ced31600
parentccd21e1cfa11fa4f39d01d95cf119beae9cf4d20 (diff)
downloadpostgresql-8e1d68c8f8eae96334db2f6633d2a61bcfb22f9a.tar.gz
Fix publication syntax error message
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 <alvherre@alvh.no-ip.org>
-rw-r--r--src/backend/parser/gram.y4
-rw-r--r--src/test/regress/expected/publication.out9
-rw-r--r--src/test/regress/sql/publication.sql4
3 files changed, 15 insertions, 2 deletions
diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y
index 0b9cd62bf0..2ece5d71d1 100644
--- a/src/backend/parser/gram.y
+++ b/src/backend/parser/gram.y
@@ -18447,7 +18447,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)
@@ -18489,7 +18489,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));
}
diff --git a/src/test/regress/expected/publication.out b/src/test/regress/expected/publication.out
index 427f87ea07..69dc6cfd85 100644
--- a/src/test/regress/expected/publication.out
+++ b/src/test/regress/expected/publication.out
@@ -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
diff --git a/src/test/regress/sql/publication.sql b/src/test/regress/sql/publication.sql
index a47c5939d5..d5051a5e74 100644
--- a/src/test/regress/sql/publication.sql
+++ b/src/test/regress/sql/publication.sql
@@ -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