2 .\" Title: SECURITY LABEL
3 .\" Author: The PostgreSQL Global Development Group
4 .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
6 .\" Manual: PostgreSQL 18.0 Documentation
7 .\" Source: PostgreSQL 18.0
10 .TH "SECURITY LABEL" "7" "2025" "PostgreSQL 18.0" "PostgreSQL 18.0 Documentation"
11 .\" -----------------------------------------------------------------
12 .\" * Define some portability stuff
13 .\" -----------------------------------------------------------------
14 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 .\" http://bugs.debian.org/507673
16 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
17 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
20 .\" -----------------------------------------------------------------
21 .\" * set default formatting
22 .\" -----------------------------------------------------------------
23 .\" disable hyphenation
25 .\" disable justification (adjust text to left margin only)
27 .\" -----------------------------------------------------------------
28 .\" * MAIN CONTENT STARTS HERE *
29 .\" -----------------------------------------------------------------
31 SECURITY_LABEL \- define or change a security label applied to an object
35 SECURITY LABEL [ FOR \fIprovider\fR ] ON
37 TABLE \fIobject_name\fR |
38 COLUMN \fItable_name\fR\&.\fIcolumn_name\fR |
39 AGGREGATE \fIaggregate_name\fR ( \fIaggregate_signature\fR ) |
40 DATABASE \fIobject_name\fR |
41 DOMAIN \fIobject_name\fR |
42 EVENT TRIGGER \fIobject_name\fR |
43 FOREIGN TABLE \fIobject_name\fR |
44 FUNCTION \fIfunction_name\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ] |
45 LARGE OBJECT \fIlarge_object_oid\fR |
46 MATERIALIZED VIEW \fIobject_name\fR |
47 [ PROCEDURAL ] LANGUAGE \fIobject_name\fR |
48 PROCEDURE \fIprocedure_name\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ] |
49 PUBLICATION \fIobject_name\fR |
50 ROLE \fIobject_name\fR |
51 ROUTINE \fIroutine_name\fR [ ( [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [, \&.\&.\&.] ] ) ] |
52 SCHEMA \fIobject_name\fR |
53 SEQUENCE \fIobject_name\fR |
54 SUBSCRIPTION \fIobject_name\fR |
55 TABLESPACE \fIobject_name\fR |
56 TYPE \fIobject_name\fR |
57 VIEW \fIobject_name\fR
58 } IS { \fIstring_literal\fR | NULL }
60 where \fIaggregate_signature\fR is:
63 [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ] |
64 [ [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ] ] ORDER BY [ \fIargmode\fR ] [ \fIargname\fR ] \fIargtype\fR [ , \&.\&.\&. ]
69 applies a security label to a database object\&. An arbitrary number of security labels, one per label provider, can be associated with a given database object\&. Label providers are loadable modules which register themselves by using the function
70 \fBregister_label_provider\fR\&.
76 .nr an-no-space-flag 1
84 \fBregister_label_provider\fR
85 is not an SQL function; it can only be called from C code loaded into the backend\&.
89 The label provider determines whether a given label is valid and whether it is permissible to assign that label to a given object\&. The meaning of a given label is likewise at the discretion of the label provider\&.
91 places no restrictions on whether or how a label provider must interpret security labels; it merely provides a mechanism for storing them\&. In practice, this facility is intended to allow integration with label\-based mandatory access control (MAC) systems such as
92 SELinux\&. Such systems make all access control decisions based on object labels, rather than traditional discretionary access control (DAC) concepts such as users and groups\&.
94 You must own the database object to use
95 \fBSECURITY LABEL\fR\&.
100 \fItable_name\&.column_name\fR
110 The name of the object to be labeled\&. Names of objects that reside in schemas (tables, functions, etc\&.) can be schema\-qualified\&.
115 The name of the provider with which this label is to be associated\&. The named provider must be loaded and must consent to the proposed labeling operation\&. If exactly one provider is loaded, the provider name may be omitted for brevity\&.
120 The mode of a function, procedure, or aggregate argument:
124 VARIADIC\&. If omitted, the default is
127 does not actually pay any attention to
129 arguments, since only the input arguments are needed to determine the function\*(Aqs identity\&. So it is sufficient to list the
138 The name of a function, procedure, or aggregate argument\&. Note that
140 does not actually pay any attention to argument names, since only the argument data types are needed to determine the function\*(Aqs identity\&.
145 The data type of a function, procedure, or aggregate argument\&.
148 \fIlarge_object_oid\fR
150 The OID of the large object\&.
155 This is a noise word\&.
160 The new setting of the security label, written as a string literal\&.
167 to drop the security label\&.
171 The following example shows how the security label of a table could be set or changed:
177 SECURITY LABEL FOR selinux ON TABLE mytable IS \*(Aqsystem_u:object_r:sepgsql_table_t:s0\*(Aq;
189 SECURITY LABEL FOR selinux ON TABLE mytable IS NULL;
199 command in the SQL standard\&.
201 sepgsql, src/test/modules/dummy_seclabel