aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2012-05-22 11:19:33 -0400
committerRobert Haas <rhaas@postgresql.org>2012-05-22 11:23:36 -0400
commit8fbe5a317de6c91826ae2c91f73f780bb0d6489e (patch)
treefd48724df7f192a058d86dc00a23cf92cf33c05f /src
parentb536458e73a8d9294817228f06961913f6faa551 (diff)
downloadpostgresql-8fbe5a317de6c91826ae2c91f73f780bb0d6489e.tar.gz
postgresql-8fbe5a317de6c91826ae2c91f73f780bb0d6489e.zip
Fix error message for COMMENT/SECURITY LABEL ON COLUMN xxx IS 'yyy'
When the column name is an unqualified name, rather than table.column, the error message complains about too many dotted names, which is wrong. Report by Peter Eisentraut based on examination of the sepgsql regression test output, but the problem also affects COMMENT. New wording as suggested by Tom Lane.
Diffstat (limited to 'src')
-rw-r--r--src/backend/catalog/objectaddress.c4
-rw-r--r--src/test/regress/input/security_label.source1
-rw-r--r--src/test/regress/output/security_label.source2
3 files changed, 7 insertions, 0 deletions
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 250069f4107..d133f64776e 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -794,6 +794,10 @@ get_object_address_attribute(ObjectType objtype, List *objname,
AttrNumber attnum;
/* Extract relation name and open relation. */
+ if (list_length(objname) < 2)
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("column name must be qualified")));
attname = strVal(lfirst(list_tail(objname)));
relname = list_truncate(list_copy(objname), list_length(objname) - 1);
relation = relation_openrv(makeRangeVarFromNameList(relname), lockmode);
diff --git a/src/test/regress/input/security_label.source b/src/test/regress/input/security_label.source
index 70771d75967..287dd76ead1 100644
--- a/src/test/regress/input/security_label.source
+++ b/src/test/regress/input/security_label.source
@@ -49,6 +49,7 @@ SET SESSION AUTHORIZATION seclabel_user1;
SECURITY LABEL ON TABLE seclabel_tbl1 IS 'classified'; -- OK
SECURITY LABEL ON COLUMN seclabel_tbl1.a IS 'unclassified'; -- OK
+SECURITY LABEL ON COLUMN seclabel_tbl1 IS 'unclassified'; -- fail
SECURITY LABEL ON TABLE seclabel_tbl1 IS '...invalid label...'; -- fail
SECURITY LABEL FOR 'dummy' ON TABLE seclabel_tbl1 IS 'unclassified'; -- OK
SECURITY LABEL FOR 'unknown_seclabel' ON TABLE seclabel_tbl1 IS 'classified'; -- fail
diff --git a/src/test/regress/output/security_label.source b/src/test/regress/output/security_label.source
index 6994d19c2e8..9be8bbd15c4 100644
--- a/src/test/regress/output/security_label.source
+++ b/src/test/regress/output/security_label.source
@@ -45,6 +45,8 @@ LOAD '@abs_builddir@/dummy_seclabel@DLSUFFIX@';
SET SESSION AUTHORIZATION seclabel_user1;
SECURITY LABEL ON TABLE seclabel_tbl1 IS 'classified'; -- OK
SECURITY LABEL ON COLUMN seclabel_tbl1.a IS 'unclassified'; -- OK
+SECURITY LABEL ON COLUMN seclabel_tbl1 IS 'unclassified'; -- fail
+ERROR: column name must be qualified
SECURITY LABEL ON TABLE seclabel_tbl1 IS '...invalid label...'; -- fail
ERROR: '...invalid label...' is not a valid security label
SECURITY LABEL FOR 'dummy' ON TABLE seclabel_tbl1 IS 'unclassified'; -- OK