Skip to content

Commit ae7c8b2

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 9255d21 commit ae7c8b2

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
@@ -65,7 +65,7 @@ SECURITY LABEL ON TABLE t2
6565
ERROR: SELinux: invalid security label: "invalid security context"
6666
SECURITY LABEL ON COLUMN t2
6767
IS 'system_u:object_r:sepgsql_ro_table_t:s0'; -- be failed
68-
ERROR: improper relation name (too many dotted names):
68+
ERROR: column name must be qualified
6969
SECURITY LABEL ON COLUMN t2.b
7070
IS 'system_u:object_r:sepgsql_ro_table_t:s0'; -- ok
7171
--

src/backend/catalog/objectaddress.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -526,6 +526,10 @@ get_object_address_attribute(ObjectType objtype, List *objname,
526526
const char *attname;
527527

528528
/* Extract relation name and open relation. */
529+
if (list_length(objname) < 2)
530+
ereport(ERROR,
531+
(errcode(ERRCODE_SYNTAX_ERROR),
532+
errmsg("column name must be qualified")));
529533
attname = strVal(lfirst(list_tail(objname)));
530534
relname = list_truncate(list_copy(objname), list_length(objname) - 1);
531535
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
@@ -44,6 +44,7 @@ SET SESSION AUTHORIZATION seclabel_user1;
4444

4545
SECURITY LABEL ON TABLE seclabel_tbl1 IS 'classified'; -- OK
4646
SECURITY LABEL ON COLUMN seclabel_tbl1.a IS 'unclassified'; -- OK
47+
SECURITY LABEL ON COLUMN seclabel_tbl1 IS 'unclassified'; -- fail
4748
SECURITY LABEL ON TABLE seclabel_tbl1 IS '...invalid label...'; -- fail
4849
SECURITY LABEL FOR 'dummy' ON TABLE seclabel_tbl1 IS 'unclassified'; -- OK
4950
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
@@ -37,6 +37,8 @@ LOAD '@abs_builddir@/dummy_seclabel@DLSUFFIX@';
3737
SET SESSION AUTHORIZATION seclabel_user1;
3838
SECURITY LABEL ON TABLE seclabel_tbl1 IS 'classified'; -- OK
3939
SECURITY LABEL ON COLUMN seclabel_tbl1.a IS 'unclassified'; -- OK
40+
SECURITY LABEL ON COLUMN seclabel_tbl1 IS 'unclassified'; -- fail
41+
ERROR: column name must be qualified
4042
SECURITY LABEL ON TABLE seclabel_tbl1 IS '...invalid label...'; -- fail
4143
ERROR: '...invalid label...' is not a valid security label
4244
SECURITY LABEL FOR 'dummy' ON TABLE seclabel_tbl1 IS 'unclassified'; -- OK

0 commit comments

Comments
 (0)