2002-07-12 20:43:19 +02:00
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
*
|
|
|
|
* dependency.h
|
|
|
|
* Routines to support inter-object dependencies.
|
|
|
|
*
|
|
|
|
*
|
2019-01-02 18:44:25 +01:00
|
|
|
* Portions Copyright (c) 1996-2019, PostgreSQL Global Development Group
|
2002-07-12 20:43:19 +02:00
|
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
|
|
*
|
2010-09-20 22:08:53 +02:00
|
|
|
* src/include/catalog/dependency.h
|
2002-07-12 20:43:19 +02:00
|
|
|
*
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
#ifndef DEPENDENCY_H
|
|
|
|
#define DEPENDENCY_H
|
|
|
|
|
2010-08-27 13:47:41 +02:00
|
|
|
#include "catalog/objectaddress.h"
|
2002-07-12 20:43:19 +02:00
|
|
|
|
|
|
|
|
2008-06-09 00:41:04 +02:00
|
|
|
/*
|
2002-07-12 20:43:19 +02:00
|
|
|
* Precise semantics of a dependency relationship are specified by the
|
|
|
|
* DependencyType code (which is stored in a "char" field in pg_depend,
|
|
|
|
* so we assign ASCII-code values to the enumeration members).
|
|
|
|
*
|
|
|
|
* In all cases, a dependency relationship indicates that the referenced
|
|
|
|
* object may not be dropped without also dropping the dependent object.
|
Redesign the partition dependency mechanism.
The original setup for dependencies of partitioned objects had
serious problems:
1. It did not verify that a drop cascading to a partition-child object
also cascaded to at least one of the object's partition parents. Now,
normally a child object would share all its dependencies with one or
another parent (e.g. a child index's opclass dependencies would be shared
with the parent index), so that this oversight is usually harmless.
But if some dependency failed to fit this pattern, the child could be
dropped while all its parents remain, creating a logically broken
situation. (It's easy to construct artificial cases that break it,
such as attaching an unrelated extension dependency to the child object
and then dropping the extension. I'm not sure if any less-artificial
cases exist.)
2. Management of partition dependencies during ATTACH/DETACH PARTITION
was complicated and buggy; for example, after detaching a partition
table it was possible to create cases where a formerly-child index
should be dropped and was not, because the correct set of dependencies
had not been reconstructed.
Less seriously, because multiple partition relationships were
represented identically in pg_depend, there was an order-of-traversal
dependency on which partition parent was cited in error messages.
We also had some pre-existing order-of-traversal hazards for error
messages related to internal and extension dependencies. This is
cosmetic to users but causes testing problems.
To fix #1, add a check at the end of the partition tree traversal
to ensure that at least one partition parent got deleted. To fix #2,
establish a new policy that partition dependencies are in addition to,
not instead of, a child object's usual dependencies; in this way
ATTACH/DETACH PARTITION need not cope with adding or removing the
usual dependencies.
To fix the cosmetic problem, distinguish between primary and secondary
partition dependency entries in pg_depend, by giving them different
deptypes. (They behave identically except for having different
priorities for being cited in error messages.) This means that the
former 'I' dependency type is replaced with new 'P' and 'S' types.
This also fixes a longstanding bug that after handling an internal
dependency by recursing to the owning object, findDependentObjects
did not verify that the current target was now scheduled for deletion,
and did not apply the current recursion level's objflags to it.
Perhaps that should be back-patched; but in the back branches it
would only matter if some concurrent transaction had removed the
internal-linkage pg_depend entry before the recursive call found it,
or the recursive call somehow failed to find it, both of which seem
unlikely.
Catversion bump because the contents of pg_depend change for
partitioning relationships.
Patch HEAD only. It's annoying that we're not fixing #2 in v11,
but there seems no practical way to do so given that the problem
is exactly a poor choice of what entries to put in pg_depend.
We can't really fix that while staying compatible with what's
in pg_depend in existing v11 installations.
Discussion: https://postgr.es/m/CAH2-Wzkypv1R+teZrr71U23J578NnTBt2X8+Y=Odr4pOdW1rXg@mail.gmail.com
2019-02-11 20:41:13 +01:00
|
|
|
* However, there are several subflavors; see the description of pg_depend
|
|
|
|
* in catalogs.sgml for details.
|
2002-07-12 20:43:19 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef enum DependencyType
|
|
|
|
{
|
2002-09-04 22:31:48 +02:00
|
|
|
DEPENDENCY_NORMAL = 'n',
|
|
|
|
DEPENDENCY_AUTO = 'a',
|
|
|
|
DEPENDENCY_INTERNAL = 'i',
|
Redesign the partition dependency mechanism.
The original setup for dependencies of partitioned objects had
serious problems:
1. It did not verify that a drop cascading to a partition-child object
also cascaded to at least one of the object's partition parents. Now,
normally a child object would share all its dependencies with one or
another parent (e.g. a child index's opclass dependencies would be shared
with the parent index), so that this oversight is usually harmless.
But if some dependency failed to fit this pattern, the child could be
dropped while all its parents remain, creating a logically broken
situation. (It's easy to construct artificial cases that break it,
such as attaching an unrelated extension dependency to the child object
and then dropping the extension. I'm not sure if any less-artificial
cases exist.)
2. Management of partition dependencies during ATTACH/DETACH PARTITION
was complicated and buggy; for example, after detaching a partition
table it was possible to create cases where a formerly-child index
should be dropped and was not, because the correct set of dependencies
had not been reconstructed.
Less seriously, because multiple partition relationships were
represented identically in pg_depend, there was an order-of-traversal
dependency on which partition parent was cited in error messages.
We also had some pre-existing order-of-traversal hazards for error
messages related to internal and extension dependencies. This is
cosmetic to users but causes testing problems.
To fix #1, add a check at the end of the partition tree traversal
to ensure that at least one partition parent got deleted. To fix #2,
establish a new policy that partition dependencies are in addition to,
not instead of, a child object's usual dependencies; in this way
ATTACH/DETACH PARTITION need not cope with adding or removing the
usual dependencies.
To fix the cosmetic problem, distinguish between primary and secondary
partition dependency entries in pg_depend, by giving them different
deptypes. (They behave identically except for having different
priorities for being cited in error messages.) This means that the
former 'I' dependency type is replaced with new 'P' and 'S' types.
This also fixes a longstanding bug that after handling an internal
dependency by recursing to the owning object, findDependentObjects
did not verify that the current target was now scheduled for deletion,
and did not apply the current recursion level's objflags to it.
Perhaps that should be back-patched; but in the back branches it
would only matter if some concurrent transaction had removed the
internal-linkage pg_depend entry before the recursive call found it,
or the recursive call somehow failed to find it, both of which seem
unlikely.
Catversion bump because the contents of pg_depend change for
partitioning relationships.
Patch HEAD only. It's annoying that we're not fixing #2 in v11,
but there seems no practical way to do so given that the problem
is exactly a poor choice of what entries to put in pg_depend.
We can't really fix that while staying compatible with what's
in pg_depend in existing v11 installations.
Discussion: https://postgr.es/m/CAH2-Wzkypv1R+teZrr71U23J578NnTBt2X8+Y=Odr4pOdW1rXg@mail.gmail.com
2019-02-11 20:41:13 +01:00
|
|
|
DEPENDENCY_PARTITION_PRI = 'P',
|
|
|
|
DEPENDENCY_PARTITION_SEC = 'S',
|
2011-02-08 22:08:41 +01:00
|
|
|
DEPENDENCY_EXTENSION = 'e',
|
2016-04-05 23:38:54 +02:00
|
|
|
DEPENDENCY_AUTO_EXTENSION = 'x',
|
2002-09-04 22:31:48 +02:00
|
|
|
DEPENDENCY_PIN = 'p'
|
2002-07-12 20:43:19 +02:00
|
|
|
} DependencyType;
|
|
|
|
|
2005-07-07 22:40:02 +02:00
|
|
|
/*
|
|
|
|
* There is also a SharedDependencyType enum type that determines the exact
|
|
|
|
* semantics of an entry in pg_shdepend. Just like regular dependency entries,
|
|
|
|
* any pg_shdepend entry means that the referenced object cannot be dropped
|
|
|
|
* unless the dependent object is dropped at the same time. There are some
|
|
|
|
* additional rules however:
|
|
|
|
*
|
|
|
|
* (a) For a SHARED_DEPENDENCY_PIN entry, there is no dependent object --
|
|
|
|
* rather, the referenced object is an essential part of the system. This
|
|
|
|
* applies to the initdb-created superuser. Entries of this type are only
|
|
|
|
* created by initdb; objects in this category don't need further pg_shdepend
|
|
|
|
* entries if more objects come to depend on them.
|
|
|
|
*
|
|
|
|
* (b) a SHARED_DEPENDENCY_OWNER entry means that the referenced object is
|
|
|
|
* the role owning the dependent object. The referenced object must be
|
|
|
|
* a pg_authid entry.
|
|
|
|
*
|
|
|
|
* (c) a SHARED_DEPENDENCY_ACL entry means that the referenced object is
|
|
|
|
* a role mentioned in the ACL field of the dependent object. The referenced
|
|
|
|
* object must be a pg_authid entry. (SHARED_DEPENDENCY_ACL entries are not
|
|
|
|
* created for the owner of an object; hence two objects may be linked by
|
|
|
|
* one or the other, but not both, of these dependency types.)
|
|
|
|
*
|
2015-07-29 01:01:53 +02:00
|
|
|
* (d) a SHARED_DEPENDENCY_POLICY entry means that the referenced object is
|
|
|
|
* a role mentioned in a policy object. The referenced object must be a
|
|
|
|
* pg_authid entry.
|
|
|
|
*
|
2005-07-07 22:40:02 +02:00
|
|
|
* SHARED_DEPENDENCY_INVALID is a value used as a parameter in internal
|
|
|
|
* routines, and is not valid in the catalog itself.
|
|
|
|
*/
|
|
|
|
typedef enum SharedDependencyType
|
|
|
|
{
|
|
|
|
SHARED_DEPENDENCY_PIN = 'p',
|
|
|
|
SHARED_DEPENDENCY_OWNER = 'o',
|
|
|
|
SHARED_DEPENDENCY_ACL = 'a',
|
2015-07-29 01:01:53 +02:00
|
|
|
SHARED_DEPENDENCY_POLICY = 'r',
|
2005-07-07 22:40:02 +02:00
|
|
|
SHARED_DEPENDENCY_INVALID = 0
|
|
|
|
} SharedDependencyType;
|
|
|
|
|
2006-08-21 02:57:26 +02:00
|
|
|
/* expansible list of ObjectAddresses (private in dependency.c) */
|
2006-08-20 23:56:16 +02:00
|
|
|
typedef struct ObjectAddresses ObjectAddresses;
|
2002-07-12 20:43:19 +02:00
|
|
|
|
2004-05-05 06:48:48 +02:00
|
|
|
/*
|
2005-10-15 04:49:52 +02:00
|
|
|
* This enum covers all system catalogs whose OIDs can appear in
|
2015-07-21 13:20:53 +02:00
|
|
|
* pg_depend.classId or pg_shdepend.classId. Keep object_classes[] in sync.
|
2004-05-05 06:48:48 +02:00
|
|
|
*/
|
|
|
|
typedef enum ObjectClass
|
|
|
|
{
|
|
|
|
OCLASS_CLASS, /* pg_class */
|
|
|
|
OCLASS_PROC, /* pg_proc */
|
|
|
|
OCLASS_TYPE, /* pg_type */
|
|
|
|
OCLASS_CAST, /* pg_cast */
|
2011-02-12 14:54:13 +01:00
|
|
|
OCLASS_COLLATION, /* pg_collation */
|
2004-05-05 06:48:48 +02:00
|
|
|
OCLASS_CONSTRAINT, /* pg_constraint */
|
|
|
|
OCLASS_CONVERSION, /* pg_conversion */
|
|
|
|
OCLASS_DEFAULT, /* pg_attrdef */
|
|
|
|
OCLASS_LANGUAGE, /* pg_language */
|
2009-12-11 04:34:57 +01:00
|
|
|
OCLASS_LARGEOBJECT, /* pg_largeobject */
|
2004-05-05 06:48:48 +02:00
|
|
|
OCLASS_OPERATOR, /* pg_operator */
|
|
|
|
OCLASS_OPCLASS, /* pg_opclass */
|
2006-12-23 01:43:13 +01:00
|
|
|
OCLASS_OPFAMILY, /* pg_opfamily */
|
2016-03-24 03:01:35 +01:00
|
|
|
OCLASS_AM, /* pg_am */
|
2006-12-23 01:43:13 +01:00
|
|
|
OCLASS_AMOP, /* pg_amop */
|
|
|
|
OCLASS_AMPROC, /* pg_amproc */
|
2004-05-05 06:48:48 +02:00
|
|
|
OCLASS_REWRITE, /* pg_rewrite */
|
|
|
|
OCLASS_TRIGGER, /* pg_trigger */
|
|
|
|
OCLASS_SCHEMA, /* pg_namespace */
|
Implement multivariate n-distinct coefficients
Add support for explicitly declared statistic objects (CREATE
STATISTICS), allowing collection of statistics on more complex
combinations that individual table columns. Companion commands DROP
STATISTICS and ALTER STATISTICS ... OWNER TO / SET SCHEMA / RENAME are
added too. All this DDL has been designed so that more statistic types
can be added later on, such as multivariate most-common-values and
multivariate histograms between columns of a single table, leaving room
for permitting columns on multiple tables, too, as well as expressions.
This commit only adds support for collection of n-distinct coefficient
on user-specified sets of columns in a single table. This is useful to
estimate number of distinct groups in GROUP BY and DISTINCT clauses;
estimation errors there can cause over-allocation of memory in hashed
aggregates, for instance, so it's a worthwhile problem to solve. A new
special pseudo-type pg_ndistinct is used.
(num-distinct estimation was deemed sufficiently useful by itself that
this is worthwhile even if no further statistic types are added
immediately; so much so that another version of essentially the same
functionality was submitted by Kyotaro Horiguchi:
https://postgr.es/m/20150828.173334.114731693.horiguchi.kyotaro@lab.ntt.co.jp
though this commit does not use that code.)
Author: Tomas Vondra. Some code rework by Álvaro.
Reviewed-by: Dean Rasheed, David Rowley, Kyotaro Horiguchi, Jeff Janes,
Ideriha Takeshi
Discussion: https://postgr.es/m/543AFA15.4080608@fuzzy.cz
https://postgr.es/m/20170320190220.ixlaueanxegqd5gr@alvherre.pgsql
2017-03-24 18:06:10 +01:00
|
|
|
OCLASS_STATISTIC_EXT, /* pg_statistic_ext */
|
2007-08-21 03:11:32 +02:00
|
|
|
OCLASS_TSPARSER, /* pg_ts_parser */
|
|
|
|
OCLASS_TSDICT, /* pg_ts_dict */
|
|
|
|
OCLASS_TSTEMPLATE, /* pg_ts_template */
|
|
|
|
OCLASS_TSCONFIG, /* pg_ts_config */
|
2005-07-07 22:40:02 +02:00
|
|
|
OCLASS_ROLE, /* pg_authid */
|
|
|
|
OCLASS_DATABASE, /* pg_database */
|
|
|
|
OCLASS_TBLSPACE, /* pg_tablespace */
|
2008-12-19 17:25:19 +01:00
|
|
|
OCLASS_FDW, /* pg_foreign_data_wrapper */
|
|
|
|
OCLASS_FOREIGN_SERVER, /* pg_foreign_server */
|
|
|
|
OCLASS_USER_MAPPING, /* pg_user_mapping */
|
2009-10-05 21:24:49 +02:00
|
|
|
OCLASS_DEFACL, /* pg_default_acl */
|
2011-04-10 17:42:00 +02:00
|
|
|
OCLASS_EXTENSION, /* pg_extension */
|
2012-07-18 16:16:16 +02:00
|
|
|
OCLASS_EVENT_TRIGGER, /* pg_event_trigger */
|
Rename pg_rowsecurity -> pg_policy and other fixes
As pointed out by Robert, we should really have named pg_rowsecurity
pg_policy, as the objects stored in that catalog are policies. This
patch fixes that and updates the column names to start with 'pol' to
match the new catalog name.
The security consideration for COPY with row level security, also
pointed out by Robert, has also been addressed by remembering and
re-checking the OID of the relation initially referenced during COPY
processing, to make sure it hasn't changed under us by the time we
finish planning out the query which has been built.
Robert and Alvaro also commented on missing OCLASS and OBJECT entries
for POLICY (formerly ROWSECURITY or POLICY, depending) in various
places. This patch fixes that too, which also happens to add the
ability to COMMENT on policies.
In passing, attempt to improve the consistency of messages, comments,
and documentation as well. This removes various incarnations of
'row-security', 'row-level security', 'Row-security', etc, in favor
of 'policy', 'row level security' or 'row_security' as appropriate.
Happy Thanksgiving!
2014-11-27 07:06:36 +01:00
|
|
|
OCLASS_POLICY, /* pg_policy */
|
2017-01-19 18:00:00 +01:00
|
|
|
OCLASS_PUBLICATION, /* pg_publication */
|
|
|
|
OCLASS_PUBLICATION_REL, /* pg_publication_rel */
|
|
|
|
OCLASS_SUBSCRIPTION, /* pg_subscription */
|
2015-07-21 13:20:53 +02:00
|
|
|
OCLASS_TRANSFORM /* pg_transform */
|
2004-05-05 06:48:48 +02:00
|
|
|
} ObjectClass;
|
|
|
|
|
2015-07-21 13:20:53 +02:00
|
|
|
#define LAST_OCLASS OCLASS_TRANSFORM
|
|
|
|
|
Delete deleteWhatDependsOn() in favor of more performDeletion() flag bits.
deleteWhatDependsOn() had grown an uncomfortably large number of
assumptions about what it's used for. There are actually only two minor
differences between what it does and what a regular performDeletion() call
can do, so let's invent additional bits in performDeletion's existing flags
argument that specify those behaviors, and get rid of deleteWhatDependsOn()
as such. (We'd probably have done it this way from the start, except that
performDeletion didn't originally have a flags argument, IIRC.)
Also, add a SKIP_EXTENSIONS flag bit that prevents ever recursing to an
extension, and use that when dropping temporary objects at session end.
This provides a more general solution to the problem addressed in a hacky
way in commit 08dd23cec: if an extension script creates temp objects and
forgets to remove them again, the whole extension went away when its
contained temp objects were deleted. The previous solution only covered
temp relations, but this solves it for all object types.
These changes require minor additions in dependency.c to pass the flags
to subroutines that previously didn't get them, but it's still a net
savings of code, and it seems cleaner than before.
Having done this, revert the special-case code added in 08dd23cec that
prevented addition of pg_depend records for temp table extension
membership, because that caused its own oddities: dropping an extension
that had created such a table didn't automatically remove the table,
leading to a failure if the table had another dependency on the extension
(such as use of an extension data type), or to a duplicate-name failure if
you then tried to recreate the extension. But we keep the part that
prevents the pg_temp_nnn schema from becoming an extension member; we never
want that to happen. Add a regression test case covering these behaviors.
Although this fixes some arguable bugs, we've heard few field complaints,
and any such problems are easily worked around by explicitly dropping temp
objects at the end of extension scripts (which seems like good practice
anyway). So I won't risk a back-patch.
Discussion: https://postgr.es/m/e51f4311-f483-4dd0-1ccc-abec3c405110@BlueTreble.com
2016-12-02 20:57:35 +01:00
|
|
|
/* flag bits for performDeletion/performMultipleDeletions: */
|
Phase 2 of pgindent updates.
Change pg_bsd_indent to follow upstream rules for placement of comments
to the right of code, and remove pgindent hack that caused comments
following #endif to not obey the general rule.
Commit e3860ffa4dd0dad0dd9eea4be9cc1412373a8c89 wasn't actually using
the published version of pg_bsd_indent, but a hacked-up version that
tried to minimize the amount of movement of comments to the right of
code. The situation of interest is where such a comment has to be
moved to the right of its default placement at column 33 because there's
code there. BSD indent has always moved right in units of tab stops
in such cases --- but in the previous incarnation, indent was working
in 8-space tab stops, while now it knows we use 4-space tabs. So the
net result is that in about half the cases, such comments are placed
one tab stop left of before. This is better all around: it leaves
more room on the line for comment text, and it means that in such
cases the comment uniformly starts at the next 4-space tab stop after
the code, rather than sometimes one and sometimes two tabs after.
Also, ensure that comments following #endif are indented the same
as comments following other preprocessor commands such as #else.
That inconsistency turns out to have been self-inflicted damage
from a poorly-thought-through post-indent "fixup" in pgindent.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
2017-06-21 21:18:54 +02:00
|
|
|
#define PERFORM_DELETION_INTERNAL 0x0001 /* internal action */
|
|
|
|
#define PERFORM_DELETION_CONCURRENTLY 0x0002 /* concurrent drop */
|
|
|
|
#define PERFORM_DELETION_QUIETLY 0x0004 /* suppress notices */
|
|
|
|
#define PERFORM_DELETION_SKIP_ORIGINAL 0x0008 /* keep original obj */
|
|
|
|
#define PERFORM_DELETION_SKIP_EXTENSIONS 0x0010 /* keep extensions */
|
2019-05-22 18:55:34 +02:00
|
|
|
#define PERFORM_DELETION_CONCURRENT_LOCK 0x0020 /* normal drop with
|
|
|
|
* concurrent lock mode */
|
2004-05-05 06:48:48 +02:00
|
|
|
|
2002-07-12 20:43:19 +02:00
|
|
|
|
Delete deleteWhatDependsOn() in favor of more performDeletion() flag bits.
deleteWhatDependsOn() had grown an uncomfortably large number of
assumptions about what it's used for. There are actually only two minor
differences between what it does and what a regular performDeletion() call
can do, so let's invent additional bits in performDeletion's existing flags
argument that specify those behaviors, and get rid of deleteWhatDependsOn()
as such. (We'd probably have done it this way from the start, except that
performDeletion didn't originally have a flags argument, IIRC.)
Also, add a SKIP_EXTENSIONS flag bit that prevents ever recursing to an
extension, and use that when dropping temporary objects at session end.
This provides a more general solution to the problem addressed in a hacky
way in commit 08dd23cec: if an extension script creates temp objects and
forgets to remove them again, the whole extension went away when its
contained temp objects were deleted. The previous solution only covered
temp relations, but this solves it for all object types.
These changes require minor additions in dependency.c to pass the flags
to subroutines that previously didn't get them, but it's still a net
savings of code, and it seems cleaner than before.
Having done this, revert the special-case code added in 08dd23cec that
prevented addition of pg_depend records for temp table extension
membership, because that caused its own oddities: dropping an extension
that had created such a table didn't automatically remove the table,
leading to a failure if the table had another dependency on the extension
(such as use of an extension data type), or to a duplicate-name failure if
you then tried to recreate the extension. But we keep the part that
prevents the pg_temp_nnn schema from becoming an extension member; we never
want that to happen. Add a regression test case covering these behaviors.
Although this fixes some arguable bugs, we've heard few field complaints,
and any such problems are easily worked around by explicitly dropping temp
objects at the end of extension scripts (which seems like good practice
anyway). So I won't risk a back-patch.
Discussion: https://postgr.es/m/e51f4311-f483-4dd0-1ccc-abec3c405110@BlueTreble.com
2016-12-02 20:57:35 +01:00
|
|
|
/* in dependency.c */
|
2012-01-26 15:24:54 +01:00
|
|
|
|
2002-07-12 20:43:19 +02:00
|
|
|
extern void performDeletion(const ObjectAddress *object,
|
2019-05-22 19:04:48 +02:00
|
|
|
DropBehavior behavior, int flags);
|
2002-07-12 20:43:19 +02:00
|
|
|
|
2006-08-20 23:56:16 +02:00
|
|
|
extern void performMultipleDeletions(const ObjectAddresses *objects,
|
2019-05-22 19:04:48 +02:00
|
|
|
DropBehavior behavior, int flags);
|
2006-08-20 23:56:16 +02:00
|
|
|
|
2002-07-16 07:53:34 +02:00
|
|
|
extern void recordDependencyOnExpr(const ObjectAddress *depender,
|
2019-05-22 19:04:48 +02:00
|
|
|
Node *expr, List *rtable,
|
|
|
|
DependencyType behavior);
|
2002-07-16 07:53:34 +02:00
|
|
|
|
2003-05-28 18:04:02 +02:00
|
|
|
extern void recordDependencyOnSingleRelExpr(const ObjectAddress *depender,
|
2019-05-22 19:04:48 +02:00
|
|
|
Node *expr, Oid relId,
|
|
|
|
DependencyType behavior,
|
|
|
|
DependencyType self_behavior,
|
|
|
|
bool ignore_self);
|
2003-05-28 18:04:02 +02:00
|
|
|
|
2004-05-05 06:48:48 +02:00
|
|
|
extern ObjectClass getObjectClass(const ObjectAddress *object);
|
|
|
|
|
2006-08-20 23:56:16 +02:00
|
|
|
extern ObjectAddresses *new_object_addresses(void);
|
|
|
|
|
|
|
|
extern void add_exact_object_address(const ObjectAddress *object,
|
2019-05-22 19:04:48 +02:00
|
|
|
ObjectAddresses *addrs);
|
2006-08-20 23:56:16 +02:00
|
|
|
|
|
|
|
extern bool object_address_present(const ObjectAddress *object,
|
2019-05-22 19:04:48 +02:00
|
|
|
const ObjectAddresses *addrs);
|
2006-08-20 23:56:16 +02:00
|
|
|
|
2007-08-21 03:11:32 +02:00
|
|
|
extern void record_object_address_dependencies(const ObjectAddress *depender,
|
2019-05-22 19:04:48 +02:00
|
|
|
ObjectAddresses *referenced,
|
|
|
|
DependencyType behavior);
|
2007-08-21 03:11:32 +02:00
|
|
|
|
2019-03-20 23:06:29 +01:00
|
|
|
extern void sort_object_addresses(ObjectAddresses *addrs);
|
|
|
|
|
2006-08-20 23:56:16 +02:00
|
|
|
extern void free_object_addresses(ObjectAddresses *addrs);
|
|
|
|
|
2002-07-12 20:43:19 +02:00
|
|
|
/* in pg_depend.c */
|
|
|
|
|
|
|
|
extern void recordDependencyOn(const ObjectAddress *depender,
|
2019-05-22 19:04:48 +02:00
|
|
|
const ObjectAddress *referenced,
|
|
|
|
DependencyType behavior);
|
2002-07-12 20:43:19 +02:00
|
|
|
|
2002-07-16 07:53:34 +02:00
|
|
|
extern void recordMultipleDependencies(const ObjectAddress *depender,
|
2019-05-22 19:04:48 +02:00
|
|
|
const ObjectAddress *referenced,
|
|
|
|
int nreferenced,
|
|
|
|
DependencyType behavior);
|
2002-07-16 07:53:34 +02:00
|
|
|
|
2011-07-23 22:59:39 +02:00
|
|
|
extern void recordDependencyOnCurrentExtension(const ObjectAddress *object,
|
2019-05-22 19:04:48 +02:00
|
|
|
bool isReplace);
|
2011-02-08 22:08:41 +01:00
|
|
|
|
|
|
|
extern long deleteDependencyRecordsFor(Oid classId, Oid objectId,
|
2019-05-22 19:04:48 +02:00
|
|
|
bool skipExtensionDeps);
|
2002-07-17 00:12:20 +02:00
|
|
|
|
2011-02-10 23:36:44 +01:00
|
|
|
extern long deleteDependencyRecordsForClass(Oid classId, Oid objectId,
|
2019-05-22 19:04:48 +02:00
|
|
|
Oid refclassId, char deptype);
|
2011-02-10 23:36:44 +01:00
|
|
|
|
2005-08-01 06:03:59 +02:00
|
|
|
extern long changeDependencyFor(Oid classId, Oid objectId,
|
2019-05-22 19:04:48 +02:00
|
|
|
Oid refClassId, Oid oldRefObjectId,
|
|
|
|
Oid newRefObjectId);
|
2005-08-01 06:03:59 +02:00
|
|
|
|
2019-04-12 08:36:05 +02:00
|
|
|
extern long changeDependenciesOf(Oid classId, Oid oldObjectId,
|
2019-05-22 19:04:48 +02:00
|
|
|
Oid newObjectId);
|
2019-04-12 08:36:05 +02:00
|
|
|
|
2019-03-29 08:25:20 +01:00
|
|
|
extern long changeDependenciesOn(Oid refClassId, Oid oldRefObjectId,
|
2019-05-22 19:04:48 +02:00
|
|
|
Oid newRefObjectId);
|
2019-03-29 08:25:20 +01:00
|
|
|
|
2011-02-08 22:08:41 +01:00
|
|
|
extern Oid getExtensionOfObject(Oid classId, Oid objectId);
|
|
|
|
|
2017-04-06 14:33:16 +02:00
|
|
|
extern bool sequenceIsOwned(Oid seqId, char deptype, Oid *tableId, int32 *colId);
|
|
|
|
extern List *getOwnedSequences(Oid relid, AttrNumber attnum);
|
2017-05-17 22:31:56 +02:00
|
|
|
extern Oid getOwnedSequence(Oid relid, AttrNumber attnum);
|
2008-05-17 01:36:05 +02:00
|
|
|
|
2007-12-02 00:44:44 +01:00
|
|
|
extern Oid get_constraint_index(Oid constraintId);
|
|
|
|
|
|
|
|
extern Oid get_index_constraint(Oid indexId);
|
|
|
|
|
2019-03-29 08:25:20 +01:00
|
|
|
extern List *get_index_ref_constraints(Oid indexId);
|
|
|
|
|
2005-07-07 22:40:02 +02:00
|
|
|
/* in pg_shdepend.c */
|
|
|
|
|
|
|
|
extern void recordSharedDependencyOn(ObjectAddress *depender,
|
2019-05-22 19:04:48 +02:00
|
|
|
ObjectAddress *referenced,
|
|
|
|
SharedDependencyType deptype);
|
2005-07-07 22:40:02 +02:00
|
|
|
|
2009-01-22 21:16:10 +01:00
|
|
|
extern void deleteSharedDependencyRecordsFor(Oid classId, Oid objectId,
|
2019-05-22 19:04:48 +02:00
|
|
|
int32 objectSubId);
|
2005-07-07 22:40:02 +02:00
|
|
|
|
|
|
|
extern void recordDependencyOnOwner(Oid classId, Oid objectId, Oid owner);
|
|
|
|
|
|
|
|
extern void changeDependencyOnOwner(Oid classId, Oid objectId,
|
2019-05-22 19:04:48 +02:00
|
|
|
Oid newOwnerId);
|
2005-07-07 22:40:02 +02:00
|
|
|
|
2009-01-22 21:16:10 +01:00
|
|
|
extern void updateAclDependencies(Oid classId, Oid objectId, int32 objectSubId,
|
2019-05-22 19:04:48 +02:00
|
|
|
Oid ownerId,
|
|
|
|
int noldmembers, Oid *oldmembers,
|
|
|
|
int nnewmembers, Oid *newmembers);
|
2005-07-07 22:40:02 +02:00
|
|
|
|
2008-03-24 20:47:35 +01:00
|
|
|
extern bool checkSharedDependencies(Oid classId, Oid objectId,
|
2019-05-22 19:04:48 +02:00
|
|
|
char **detail_msg, char **detail_log_msg);
|
2005-07-07 22:40:02 +02:00
|
|
|
|
2009-10-08 00:14:26 +02:00
|
|
|
extern void shdepLockAndCheckObject(Oid classId, Oid objectId);
|
|
|
|
|
2005-07-07 22:40:02 +02:00
|
|
|
extern void copyTemplateDependencies(Oid templateDbId, Oid newDbId);
|
|
|
|
|
|
|
|
extern void dropDatabaseDependencies(Oid databaseId);
|
|
|
|
|
2005-11-21 13:49:33 +01:00
|
|
|
extern void shdepDropOwned(List *relids, DropBehavior behavior);
|
|
|
|
|
|
|
|
extern void shdepReassignOwned(List *relids, Oid newrole);
|
|
|
|
|
Phase 2 of pgindent updates.
Change pg_bsd_indent to follow upstream rules for placement of comments
to the right of code, and remove pgindent hack that caused comments
following #endif to not obey the general rule.
Commit e3860ffa4dd0dad0dd9eea4be9cc1412373a8c89 wasn't actually using
the published version of pg_bsd_indent, but a hacked-up version that
tried to minimize the amount of movement of comments to the right of
code. The situation of interest is where such a comment has to be
moved to the right of its default placement at column 33 because there's
code there. BSD indent has always moved right in units of tab stops
in such cases --- but in the previous incarnation, indent was working
in 8-space tab stops, while now it knows we use 4-space tabs. So the
net result is that in about half the cases, such comments are placed
one tab stop left of before. This is better all around: it leaves
more room on the line for comment text, and it means that in such
cases the comment uniformly starts at the next 4-space tab stop after
the code, rather than sometimes one and sometimes two tabs after.
Also, ensure that comments following #endif are indented the same
as comments following other preprocessor commands such as #else.
That inconsistency turns out to have been self-inflicted damage
from a poorly-thought-through post-indent "fixup" in pgindent.
This patch is much less interesting than the first round of indent
changes, but also bulkier, so I thought it best to separate the effects.
Discussion: https://postgr.es/m/E1dAmxK-0006EE-1r@gemulon.postgresql.org
Discussion: https://postgr.es/m/30527.1495162840@sss.pgh.pa.us
2017-06-21 21:18:54 +02:00
|
|
|
#endif /* DEPENDENCY_H */
|