Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit59d1b3d

Browse files
committed
Track dependencies on shared objects (which is to say, roles; we already
have adequate mechanisms for tracking the contents of databases andtablespaces). This solves the longstanding problem that you can drop auser who still owns objects and/or has access permissions.Alvaro Herrera, with some kibitzing from Tom Lane.
1 parent442b59d commit59d1b3d

38 files changed

+1842
-85
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 157 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!--
22
Documentation of the system catalogs, directed toward PostgreSQL developers
3-
$PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.106 2005/06/28 05:08:50 tgl Exp $
3+
$PostgreSQL: pgsql/doc/src/sgml/catalogs.sgml,v 2.107 2005/07/07 20:39:56 tgl Exp $
44
-->
55

66
<chapter id="catalogs">
@@ -173,6 +173,11 @@
173173
<entry>query rewrite rules</entry>
174174
</row>
175175

176+
<row>
177+
<entry><link linkend="catalog-pg-shdepend"><structname>pg_shdepend</structname></link></entry>
178+
<entry>dependencies on shared objects</entry>
179+
</row>
180+
176181
<row>
177182
<entry><link linkend="catalog-pg-statistic"><structname>pg_statistic</structname></link></entry>
178183
<entry>planner statistics</entry>
@@ -1890,6 +1895,12 @@
18901895
RESTRICT</> case.
18911896
</para>
18921897

1898+
<para>
1899+
See also <link linkend="catalog-pg-shdepend"><structname>pg_shdepend</structname></link>,
1900+
which performs a similar function for dependencies involving objects
1901+
that are shared across a database cluster.
1902+
</para>
1903+
18931904
<table>
18941905
<title><structname>pg_depend</> Columns</title>
18951906

@@ -3024,7 +3035,7 @@
30243035

30253036
<row>
30263037
<entry><structfield>proargmodes</structfield></entry>
3027-
<entry><type>"char"[]</type></entry>
3038+
<entry><type>char[]</type></entry>
30283039
<entry></entry>
30293040
<entry>
30303041
An array with the modes of the function arguments, encoded as
@@ -3198,6 +3209,149 @@
31983209
</sect1>
31993210

32003211

3212+
<sect1 id="catalog-pg-shdepend">
3213+
<title><structname>pg_shdepend</structname></title>
3214+
3215+
<indexterm zone="catalog-pg-shdepend">
3216+
<primary>pg_shdepend</primary>
3217+
</indexterm>
3218+
3219+
<para>
3220+
The catalog <structname>pg_shdepend</structname> records the
3221+
dependency relationships between database objects and shared objects,
3222+
such as roles. This information allows
3223+
<productname>PostgreSQL</productname> to ensure that those objects are
3224+
unreferenced before attempting to delete them.
3225+
</para>
3226+
3227+
<para>
3228+
See also <link linkend="catalog-pg-depend"><structname>pg_depend</structname></link>,
3229+
which performs a similar function for dependencies involving objects
3230+
within a single database.
3231+
</para>
3232+
3233+
<para>
3234+
Unlike most system catalogs, <structname>pg_shdepend</structname>
3235+
is shared across all databases of a cluster: there is only one
3236+
copy of <structname>pg_shdepend</structname> per cluster, not
3237+
one per database.
3238+
</para>
3239+
3240+
<table>
3241+
<title><structname>pg_shdepend</> Columns</title>
3242+
3243+
<tgroup cols=4>
3244+
<thead>
3245+
<row>
3246+
<entry>Name</entry>
3247+
<entry>Type</entry>
3248+
<entry>References</entry>
3249+
<entry>Description</entry>
3250+
</row>
3251+
</thead>
3252+
3253+
<tbody>
3254+
<row>
3255+
<entry><structfield>dbid</structfield></entry>
3256+
<entry><type>oid</type></entry>
3257+
<entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.oid</literal></entry>
3258+
<entry>The OID of the database the dependent object is in,
3259+
or zero for a shared object</entry>
3260+
</row>
3261+
3262+
<row>
3263+
<entry><structfield>classid</structfield></entry>
3264+
<entry><type>oid</type></entry>
3265+
<entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
3266+
<entry>The OID of the system catalog the dependent object is in</entry>
3267+
</row>
3268+
3269+
<row>
3270+
<entry><structfield>objid</structfield></entry>
3271+
<entry><type>oid</type></entry>
3272+
<entry>any OID column</entry>
3273+
<entry>The OID of the specific dependent object</entry>
3274+
</row>
3275+
3276+
<row>
3277+
<entry><structfield>refclassid</structfield></entry>
3278+
<entry><type>oid</type></entry>
3279+
<entry><literal><link linkend="catalog-pg-class"><structname>pg_class</structname></link>.oid</literal></entry>
3280+
<entry>The OID of the system catalog the referenced object is in
3281+
(must be a shared catalog)</entry>
3282+
</row>
3283+
3284+
<row>
3285+
<entry><structfield>refobjid</structfield></entry>
3286+
<entry><type>oid</type></entry>
3287+
<entry>any OID column</entry>
3288+
<entry>The OID of the specific referenced object</entry>
3289+
</row>
3290+
3291+
<row>
3292+
<entry><structfield>deptype</structfield></entry>
3293+
<entry><type>char</type></entry>
3294+
<entry></entry>
3295+
<entry>
3296+
A code defining the specific semantics of this dependency relationship; see text.
3297+
</entry>
3298+
</row>
3299+
3300+
</tbody>
3301+
</tgroup>
3302+
</table>
3303+
3304+
<para>
3305+
In all cases, a <structname>pg_shdepend</structname> entry indicates that
3306+
the referenced object may not be dropped without also dropping the dependent
3307+
object. However, there are several subflavors identified by
3308+
<structfield>deptype</>:
3309+
3310+
<variablelist>
3311+
<varlistentry>
3312+
<term><symbol>SHARED_DEPENDENCY_OWNER</> (<literal>o</>)</term>
3313+
<listitem>
3314+
<para>
3315+
The referenced object (which must be a role) is the owner of the
3316+
dependent object.
3317+
</para>
3318+
</listitem>
3319+
</varlistentry>
3320+
3321+
<varlistentry>
3322+
<term><symbol>SHARED_DEPENDENCY_ACL</> (<literal>a</>)</term>
3323+
<listitem>
3324+
<para>
3325+
The referenced object (which must be a role) is mentioned in the
3326+
ACL (access control list, i.e., privileges list) of the
3327+
dependent object. (A <symbol>SHARED_DEPENDENCY_ACL</> entry is
3328+
not made for the owner of the object, since the owner will have
3329+
a <symbol>SHARED_DEPENDENCY_OWNER</> entry anyway.)
3330+
</para>
3331+
</listitem>
3332+
</varlistentry>
3333+
3334+
<varlistentry>
3335+
<term><symbol>SHARED_DEPENDENCY_PIN</> (<literal>p</>)</term>
3336+
<listitem>
3337+
<para>
3338+
There is no dependent object; this type of entry is a signal
3339+
that the system itself depends on the referenced object, and so
3340+
that object must never be deleted. Entries of this type are
3341+
created only by <command>initdb</command>. The columns for the
3342+
dependent object contain zeroes.
3343+
</para>
3344+
</listitem>
3345+
</varlistentry>
3346+
</variablelist>
3347+
3348+
Other dependency flavors may be needed in future. Note in particular
3349+
that the current definition only supports roles as referenced objects.
3350+
</para>
3351+
3352+
</sect1>
3353+
3354+
32013355
<sect1 id="catalog-pg-statistic">
32023356
<title><structname>pg_statistic</structname></title>
32033357

@@ -4196,7 +4350,7 @@
41964350
<entry><literal><link linkend="catalog-pg-database"><structname>pg_database</structname></link>.oid</literal></entry>
41974351
<entry>
41984352
OID of the database in which the object exists, or
4199-
zero if the object is aglobally-shared object, or
4353+
zero if the object is a shared object, or
42004354
NULL if the object is a transaction ID
42014355
</entry>
42024356
</row>

‎src/backend/catalog/Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# Makefile for backend/catalog
44
#
5-
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.54 2005/06/28 05:08:52 tgl Exp $
5+
# $PostgreSQL: pgsql/src/backend/catalog/Makefile,v 1.55 2005/07/07 20:39:57 tgl Exp $
66
#
77
#-------------------------------------------------------------------------
88

@@ -12,7 +12,8 @@ include $(top_builddir)/src/Makefile.global
1212

1313
OBJS = catalog.o dependency.o heap.o index.o indexing.o namespace.o aclchk.o\
1414
pg_aggregate.o pg_constraint.o pg_conversion.o pg_depend.o\
15-
pg_largeobject.o pg_namespace.o pg_operator.o pg_proc.o pg_type.o
15+
pg_largeobject.o pg_namespace.o pg_operator.o pg_proc.o pg_shdepend.o\
16+
pg_type.o
1617

1718
BKIFILES = postgres.bki postgres.description
1819

@@ -31,7 +32,7 @@ POSTGRES_BKI_SRCS := $(addprefix $(top_srcdir)/src/include/catalog/,\
3132
pg_operator.h pg_opclass.h pg_am.h pg_amop.h pg_amproc.h \
3233
pg_language.h pg_largeobject.h pg_aggregate.h pg_statistic.h \
3334
pg_rewrite.h pg_trigger.h pg_listener.h pg_description.h pg_cast.h \
34-
pg_namespace.h pg_conversion.h pg_database.h \
35+
pg_namespace.h pg_conversion.h pg_database.hpg_shdepend.h\
3536
pg_authid.h pg_auth_members.h pg_tablespace.h pg_depend.h \
3637
indexing.h \
3738
)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp