Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Fix error message for COMMENT/SECURITY LABEL ON COLUMN xxx IS 'yyy'
authorRobert Haas <rhaas@postgresql.org>
Tue, 22 May 2012 15:19:33 +0000 (11:19 -0400)
committerRobert Haas <rhaas@postgresql.org>
Tue, 22 May 2012 15:23:36 +0000 (11:23 -0400)
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.

contrib/sepgsql/expected/label.out
src/backend/catalog/objectaddress.c
src/test/regress/input/security_label.source
src/test/regress/output/security_label.source

index f9587dee57a26611a79b200655e1f89061b7aa79..d4a6f8ae9620fa5cda86fa22da057268e8429524 100644 (file)
@@ -91,7 +91,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
 --
index 250069f41078978e36df39e50bdb4646f9a77634..d133f64776ee59a9611d3cf094a4a3832314781d 100644 (file)
@@ -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);
index 70771d75967e7a95ced5309c4766fe1c0b9cc92d..287dd76ead1a4c08356fff9df47e37b90d482a92 100644 (file)
@@ -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
index 6994d19c2e8788a59324d5a9b32d0a703903b6ac..9be8bbd15c4e7308000d598a17234eb9ff4989ef 100644 (file)
@@ -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