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

Commit fab220b

Browse files
committed
Doc: improve documentation about inheritance.
Clarify documentation about inheritance of check constraints, in particular mentioning the NO INHERIT option, which didn't exist when this text was written. Document that in an inherited query, the applicable row security policies are those of the explicitly-named table, not its children. This is the intended behavior (per off-list discussion with Stephen Frost), and there are regression tests for it, but it wasn't documented anywhere user-facing as far as I could find. Do a bit of wordsmithing on the description of inherited access-privilege checks. Back-patch to 9.5 where RLS was added.
1 parent e9c0335 commit fab220b

File tree

1 file changed

+21
-11
lines changed

1 file changed

+21
-11
lines changed

doc/src/sgml/ddl.sgml

+21-11
Original file line numberDiff line numberDiff line change
@@ -2559,7 +2559,8 @@ VALUES ('Albany', NULL, NULL, 'NY');
25592559

25602560
<para>
25612561
All check constraints and not-null constraints on a parent table are
2562-
automatically inherited by its children. Other types of constraints
2562+
automatically inherited by its children, unless explicitly specified
2563+
otherwise with <literal>NO INHERIT</> clauses. Other types of constraints
25632564
(unique, primary key, and foreign key constraints) are not inherited.
25642565
</para>
25652566

@@ -2570,10 +2571,12 @@ VALUES ('Albany', NULL, NULL, 'NY');
25702571
same column name appears in multiple parent tables, or in both a parent
25712572
table and the child's definition, then these columns are <quote>merged</>
25722573
so that there is only one such column in the child table. To be merged,
2573-
columns must have the same data types, else an error is raised. The
2574-
merged column will have copies of all the check constraints coming from
2575-
any one of the column definitions it came from, and will be marked not-null
2576-
if any of them are.
2574+
columns must have the same data types, else an error is raised.
2575+
Inheritable check constraints and not-null constraints are merged in a
2576+
similar fashion. Thus, for example, a merged column will be marked
2577+
not-null if any one of the column definitions it came from is marked
2578+
not-null. Check constraints are merged if they have the same name,
2579+
and the merge will fail if their conditions are different.
25772580
</para>
25782581

25792582
<para>
@@ -2625,12 +2628,19 @@ VALUES ('Albany', NULL, NULL, 'NY');
26252628
</para>
26262629

26272630
<para>
2628-
Note how table access permissions are handled. Querying a parent
2629-
table can automatically access data in child tables without further
2630-
access privilege checking. This preserves the appearance that the
2631-
data is (also) in the parent table. Accessing the child tables
2632-
directly is, however, not automatically allowed and would require
2633-
further privileges to be granted.
2631+
Inherited queries perform access permission checks on the parent table
2632+
only. Thus, for example, granting <literal>UPDATE</> permission on
2633+
the <structname>cities</> table implies permission to update rows in
2634+
the <structname>capitals</structname> table as well, when they are
2635+
accessed through <structname>cities</>. This preserves the appearance
2636+
that the data is (also) in the parent table. But
2637+
the <structname>capitals</structname> table could not be updated directly
2638+
without an additional grant. In a similar way, the parent table's row
2639+
security policies (see <xref linkend="ddl-rowsecurity">) are applied to
2640+
rows coming from child tables during an inherited query. A child table's
2641+
policies, if any, are applied only when it is the table explicitly named
2642+
in the query; and in that case, any policies attached to its parent(s) are
2643+
ignored.
26342644
</para>
26352645

26362646
<para>

0 commit comments

Comments
 (0)