summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2005-08-01 04:03:59 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2005-08-01 04:03:59 +0000
commit35508d1cca1630e40b157d67b427174c3e1999aa (patch)
tree5779ce1a2a645766399fddf8761ef70e388bbc93 /src/include
parenta85e5d1b1b346e039aef61d23775dd1f2ff547ae (diff)
downloadpostgresql-35508d1cca1630e40b157d67b427174c3e1999aa.tar.gz
Add ALTER object SET SCHEMA capability for a limited but useful set of
object kinds (tables, functions, types). Documentation is not here yet. Original code by Bernd Helmle, extensive rework by Bruce Momjian and Tom Lane.
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/dependency.h6
-rw-r--r--src/include/catalog/namespace.h4
-rw-r--r--src/include/catalog/pg_constraint.h5
-rw-r--r--src/include/commands/alter.h4
-rw-r--r--src/include/commands/defrem.h4
-rw-r--r--src/include/commands/tablecmds.h9
-rw-r--r--src/include/commands/typecmds.h5
-rw-r--r--src/include/nodes/nodes.h3
-rw-r--r--src/include/nodes/parsenodes.h21
9 files changed, 49 insertions, 12 deletions
diff --git a/src/include/catalog/dependency.h b/src/include/catalog/dependency.h
index 06fdf02a10..ab50817cb7 100644
--- a/src/include/catalog/dependency.h
+++ b/src/include/catalog/dependency.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/dependency.h,v 1.15 2005/07/07 20:39:59 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/dependency.h,v 1.16 2005/08/01 04:03:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -174,6 +174,10 @@ extern void recordMultipleDependencies(const ObjectAddress *depender,
extern long deleteDependencyRecordsFor(Oid classId, Oid objectId);
+extern long changeDependencyFor(Oid classId, Oid objectId,
+ Oid refClassId, Oid oldRefObjectId,
+ Oid newRefObjectId);
+
/* in pg_shdepend.c */
extern void recordSharedDependencyOn(ObjectAddress *depender,
diff --git a/src/include/catalog/namespace.h b/src/include/catalog/namespace.h
index 4176f2c218..060849e8ba 100644
--- a/src/include/catalog/namespace.h
+++ b/src/include/catalog/namespace.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.35 2004/12/31 22:03:24 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/namespace.h,v 1.36 2005/08/01 04:03:57 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -74,12 +74,14 @@ extern void DeconstructQualifiedName(List *names,
char **objname_p);
extern Oid LookupExplicitNamespace(const char *nspname);
+extern Oid LookupCreationNamespace(const char *nspname);
extern Oid QualifiedNameGetCreationNamespace(List *names, char **objname_p);
extern RangeVar *makeRangeVarFromNameList(List *names);
extern char *NameListToString(List *names);
extern char *NameListToQuotedString(List *names);
extern bool isTempNamespace(Oid namespaceId);
+extern bool isAnyTempNamespace(Oid namespaceId);
extern bool isOtherTempNamespace(Oid namespaceId);
extern void PushSpecialNamespace(Oid namespaceId);
diff --git a/src/include/catalog/pg_constraint.h b/src/include/catalog/pg_constraint.h
index 288a6adfa5..d0495ca0e5 100644
--- a/src/include/catalog/pg_constraint.h
+++ b/src/include/catalog/pg_constraint.h
@@ -8,7 +8,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/catalog/pg_constraint.h,v 1.16 2005/04/14 01:38:20 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/pg_constraint.h,v 1.17 2005/08/01 04:03:57 tgl Exp $
*
* NOTES
* the genbki.sh script reads this file and generates .bki
@@ -185,4 +185,7 @@ extern char *ChooseConstraintName(const char *name1, const char *name2,
extern char *GetConstraintNameForTrigger(Oid triggerId);
+extern void AlterConstraintNamespaces(Oid ownerId, Oid oldNspId,
+ Oid newNspId, bool isType);
+
#endif /* PG_CONSTRAINT_H */
diff --git a/src/include/commands/alter.h b/src/include/commands/alter.h
index 1a34030bff..33588bad32 100644
--- a/src/include/commands/alter.h
+++ b/src/include/commands/alter.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/alter.h,v 1.6 2004/12/31 22:03:28 pgsql Exp $
+ * $PostgreSQL: pgsql/src/include/commands/alter.h,v 1.7 2005/08/01 04:03:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,7 +17,7 @@
#include "nodes/parsenodes.h"
extern void ExecRenameStmt(RenameStmt *stmt);
-
+extern void ExecAlterObjectSchemaStmt(AlterObjectSchemaStmt *stmt);
extern void ExecAlterOwnerStmt(AlterOwnerStmt *stmt);
#endif /* ALTER_H */
diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h
index 10c3438065..a0f3dc67d6 100644
--- a/src/include/commands/defrem.h
+++ b/src/include/commands/defrem.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.66 2005/06/28 05:09:12 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/commands/defrem.h,v 1.67 2005/08/01 04:03:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -55,6 +55,8 @@ extern void AlterFunction(AlterFunctionStmt *stmt);
extern void CreateCast(CreateCastStmt *stmt);
extern void DropCast(DropCastStmt *stmt);
extern void DropCastById(Oid castOid);
+extern void AlterFunctionNamespace(List *name, List *argtypes,
+ const char *newschema);
/* commands/operatorcmds.c */
extern void DefineOperator(List *names, List *parameters);
diff --git a/src/include/commands/tablecmds.h b/src/include/commands/tablecmds.h
index 5ec8c9a57d..582720df3b 100644
--- a/src/include/commands/tablecmds.h
+++ b/src/include/commands/tablecmds.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/tablecmds.h,v 1.22 2005/01/27 03:18:24 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/commands/tablecmds.h,v 1.23 2005/08/01 04:03:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -15,6 +15,7 @@
#define TABLECMDS_H
#include "nodes/parsenodes.h"
+#include "utils/rel.h"
extern Oid DefineRelation(CreateStmt *stmt, char relkind);
@@ -27,6 +28,12 @@ extern void AlterTableInternal(Oid relid, List *cmds, bool recurse);
extern void AlterTableCreateToastTable(Oid relOid, bool silent);
+extern void AlterTableNamespace(RangeVar *relation, const char *newschema);
+
+extern void AlterRelationNamespaceInternal(Relation classRel, Oid relOid,
+ Oid oldNspOid, Oid newNspOid,
+ bool hasDependEntry);
+
extern void ExecuteTruncate(List *relations);
extern void renameatt(Oid myrelid,
diff --git a/src/include/commands/typecmds.h b/src/include/commands/typecmds.h
index a940a78f48..a070a27a29 100644
--- a/src/include/commands/typecmds.h
+++ b/src/include/commands/typecmds.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/commands/typecmds.h,v 1.11 2005/06/28 05:09:12 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/commands/typecmds.h,v 1.12 2005/08/01 04:03:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -35,5 +35,8 @@ extern void AlterDomainDropConstraint(List *names, const char *constrName,
extern List *GetDomainConstraints(Oid typeOid);
extern void AlterTypeOwner(List *names, Oid newOwnerId);
+extern void AlterTypeNamespace(List *names, const char *newschema);
+extern void AlterTypeNamespaceInternal(Oid typeOid, Oid nspOid,
+ bool errorOnTableType);
#endif /* TYPECMDS_H */
diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h
index a488d8dce7..24480f1281 100644
--- a/src/include/nodes/nodes.h
+++ b/src/include/nodes/nodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.173 2005/07/31 17:19:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/nodes.h,v 1.174 2005/08/01 04:03:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -284,6 +284,7 @@ typedef enum NodeTag
T_DeclareCursorStmt,
T_CreateTableSpaceStmt,
T_DropTableSpaceStmt,
+ T_AlterObjectSchemaStmt,
T_AlterOwnerStmt,
T_A_Expr = 800,
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 68262d28f7..fc88dec535 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.287 2005/07/31 17:19:21 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/nodes/parsenodes.h,v 1.288 2005/08/01 04:03:58 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1477,28 +1477,43 @@ typedef struct RemoveOpClassStmt
typedef struct RenameStmt
{
NodeTag type;
+ ObjectType renameType; /* OBJECT_TABLE, OBJECT_COLUMN, etc */
RangeVar *relation; /* in case it's a table */
List *object; /* in case it's some other object */
List *objarg; /* argument types, if applicable */
char *subname; /* name of contained object (column, rule,
* trigger, etc) */
char *newname; /* the new name */
- ObjectType renameType; /* OBJECT_TABLE, OBJECT_COLUMN, etc */
} RenameStmt;
/* ----------------------
+ * ALTER object SET SCHEMA Statement
+ * ----------------------
+ */
+typedef struct AlterObjectSchemaStmt
+{
+ NodeTag type;
+ ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
+ RangeVar *relation; /* in case it's a table */
+ List *object; /* in case it's some other object */
+ List *objarg; /* argument types, if applicable */
+ char *addname; /* additional name if needed */
+ char *newschema; /* the new schema */
+} AlterObjectSchemaStmt;
+
+/* ----------------------
* Alter Object Owner Statement
* ----------------------
*/
typedef struct AlterOwnerStmt
{
NodeTag type;
+ ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
RangeVar *relation; /* in case it's a table */
List *object; /* in case it's some other object */
List *objarg; /* argument types, if applicable */
char *addname; /* additional name if needed */
char *newowner; /* the new owner */
- ObjectType objectType; /* OBJECT_TABLE, OBJECT_TYPE, etc */
} AlterOwnerStmt;