aboutsummaryrefslogtreecommitdiff
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:24:16 -0400
commitae7c8b290f525504978c01d77366a753505d10d5 (patch)
treec24801da29a8f40210bfcd3aff388dcd4abae725
parent9255d21d2fe5209c96b712f96c799fe594f00f4b (diff)
downloadpostgresql-ae7c8b290f525504978c01d77366a753505d10d5.tar.gz
postgresql-ae7c8b290f525504978c01d77366a753505d10d5.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.
-rw-r--r--contrib/sepgsql/expected/label.out2
-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
4 files changed, 8 insertions, 1 deletions
diff --git a/contrib/sepgsql/expected/label.out b/contrib/sepgsql/expected/label.out
index bac169f37bf..279cfab0914 100644
--- a/contrib/sepgsql/expected/label.out
+++ b/contrib/sepgsql/expected/label.out
@@ -65,7 +65,7 @@ SECURITY LABEL ON TABLE t2
ERROR: SELinux: invalid security label: "invalid security context"
SECURITY LABEL ON COLUMN t2
IS 'system_u:object_r:sepgsql_ro_table_t:s0'; -- be failed
-ERROR: improper relation name (too many dotted names):
+ERROR: column name must be qualified
SECURITY LABEL ON COLUMN t2.b
IS 'system_u:object_r:sepgsql_ro_table_t:s0'; -- ok
--
diff --git a/src/backend/catalog/objectaddress.c b/src/backend/catalog/objectaddress.c
index 3925b8ec95c..403bd9e283c 100644
--- a/src/backend/catalog/objectaddress.c
+++ b/src/backend/catalog/objectaddress.c
@@ -526,6 +526,10 @@ get_object_address_attribute(ObjectType objtype, List *objname,
const char *attname;
/* 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 810a721ca8f..9b430b09a57 100644
--- a/src/test/regress/input/security_label.source
+++ b/src/test/regress/input/security_label.source
@@ -44,6 +44,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 4bc803d694f..4b53bd54c90 100644
--- a/src/test/regress/output/security_label.source
+++ b/src/test/regress/output/security_label.source
@@ -37,6 +37,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