Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 8fbe5a3

Browse files
committed
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.
1 parent b536458 commit 8fbe5a3

File tree

4 files changed

+8
-1
lines changed

4 files changed

+8
-1
lines changed

contrib/sepgsql/expected/label.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ SECURITY LABEL ON TABLE t2
9191
ERROR: SELinux: invalid security label: "invalid security context"
9292
SECURITY LABEL ON COLUMN t2
9393
IS 'system_u:object_r:sepgsql_ro_table_t:s0'; -- be failed
94-
ERROR: improper relation name (too many dotted names):
94+
ERROR: column name must be qualified
9595
SECURITY LABEL ON COLUMN t2.b
9696
IS 'system_u:object_r:sepgsql_ro_table_t:s0'; -- ok
9797
--

src/backend/catalog/objectaddress.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,10 @@ get_object_address_attribute(ObjectType objtype, List *objname,
794794
AttrNumber attnum;
795795

796796
/* Extract relation name and open relation. */
797+
if (list_length(objname) < 2)
798+
ereport(ERROR,
799+
(errcode(ERRCODE_SYNTAX_ERROR),
800+
errmsg("column name must be qualified")));
797801
attname = strVal(lfirst(list_tail(objname)));
798802
relname = list_truncate(list_copy(objname), list_length(objname) - 1);
799803
relation = relation_openrv(makeRangeVarFromNameList(relname), lockmode);

src/test/regress/input/security_label.source

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ SET SESSION AUTHORIZATION seclabel_user1;
4949

5050
SECURITY LABEL ON TABLE seclabel_tbl1 IS 'classified'; -- OK
5151
SECURITY LABEL ON COLUMN seclabel_tbl1.a IS 'unclassified'; -- OK
52+
SECURITY LABEL ON COLUMN seclabel_tbl1 IS 'unclassified'; -- fail
5253
SECURITY LABEL ON TABLE seclabel_tbl1 IS '...invalid label...'; -- fail
5354
SECURITY LABEL FOR 'dummy' ON TABLE seclabel_tbl1 IS 'unclassified'; -- OK
5455
SECURITY LABEL FOR 'unknown_seclabel' ON TABLE seclabel_tbl1 IS 'classified'; -- fail

src/test/regress/output/security_label.source

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ LOAD '@abs_builddir@/dummy_seclabel@DLSUFFIX@';
4545
SET SESSION AUTHORIZATION seclabel_user1;
4646
SECURITY LABEL ON TABLE seclabel_tbl1 IS 'classified'; -- OK
4747
SECURITY LABEL ON COLUMN seclabel_tbl1.a IS 'unclassified'; -- OK
48+
SECURITY LABEL ON COLUMN seclabel_tbl1 IS 'unclassified'; -- fail
49+
ERROR: column name must be qualified
4850
SECURITY LABEL ON TABLE seclabel_tbl1 IS '...invalid label...'; -- fail
4951
ERROR: '...invalid label...' is not a valid security label
5052
SECURITY LABEL FOR 'dummy' ON TABLE seclabel_tbl1 IS 'unclassified'; -- OK

0 commit comments

Comments
 (0)