1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-30 06:01:21 +03:00

Back out ALTER DOMAIN patch until missing file appears.

This commit is contained in:
Bruce Momjian
2002-12-06 03:43:35 +00:00
parent 853153ca6d
commit 5b4c16e099
22 changed files with 263 additions and 1527 deletions

View File

@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.15 2002/12/06 03:28:27 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.16 2002/12/06 03:42:54 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -36,7 +36,6 @@
#include "commands/proclang.h"
#include "commands/schemacmds.h"
#include "commands/trigger.h"
#include "commands/typecmds.h"
#include "lib/stringinfo.h"
#include "miscadmin.h"
#include "optimizer/clauses.h"

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_constraint.c,v 1.9 2002/12/06 03:28:27 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_constraint.c,v 1.10 2002/12/06 03:42:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -199,7 +199,6 @@ CreateConstraintEntry(const char *constraintName,
domobject.classId = RelOid_pg_type;
domobject.objectId = domainId;
domobject.objectSubId = 0;
recordDependencyOn(&conobject, &domobject, DEPENDENCY_AUTO);
}
@@ -497,16 +496,15 @@ RemoveConstraintById(Oid conId)
HeapTuple typTup;
ScanKeyData typKey[1];
SysScanDesc typScan;
int nkeys = 0;
typRel = heap_openr(TypeRelationName, RowExclusiveLock);
ScanKeyEntryInitialize(&typKey[nkeys++], 0x0,
ObjectIdAttributeNumber, F_OIDEQ,
ScanKeyEntryInitialize(&typKey[0], 0x0,
Anum_pg_constraint_contypid, F_OIDEQ,
ObjectIdGetDatum(con->contypid));
typScan = systable_beginscan(typRel, TypeOidIndex, true,
SnapshotNow, nkeys, typKey);
SnapshotNow, 1, typKey);
typTup = systable_getnext(typScan);
@@ -519,11 +517,6 @@ RemoveConstraintById(Oid conId)
/* Keep lock on domain type until end of xact */
heap_close(typRel, NoLock);
}
else
{
elog(ERROR, "RemoveConstraintById: Constraint %u is not a known type",
conId);
}
/* Fry the constraint itself */
simple_heap_delete(conDesc, &tup->t_self);

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.83 2002/12/06 03:28:27 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.84 2002/12/06 03:42:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -139,7 +139,7 @@ TypeCreate(const char *typeName,
Oid elementType,
Oid baseType,
const char *defaultTypeValue, /* human readable rep */
char *defaultTypeBin, /* cooked rep */
const char *defaultTypeBin, /* cooked rep */
bool passedByValue,
char alignment,
char storage,
@@ -291,16 +291,79 @@ TypeCreate(const char *typeName,
*/
if (!IsBootstrapProcessingMode())
{
GenerateTypeDependencies(typeNamespace,
typeObjectId,
relationOid,
relationKind,
inputProcedure,
outputProcedure,
elementType,
baseType,
defaultTypeBin,
false);
ObjectAddress myself,
referenced;
myself.classId = RelOid_pg_type;
myself.objectId = typeObjectId;
myself.objectSubId = 0;
/* dependency on namespace */
/* skip for relation rowtype, since we have indirect dependency */
if (!OidIsValid(relationOid))
{
referenced.classId = get_system_catalog_relid(NamespaceRelationName);
referenced.objectId = typeNamespace;
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
}
/* Normal dependencies on the I/O functions */
referenced.classId = RelOid_pg_proc;
referenced.objectId = inputProcedure;
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
referenced.classId = RelOid_pg_proc;
referenced.objectId = outputProcedure;
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
/*
* If the type is a rowtype for a relation, mark it as internally
* dependent on the relation, *unless* it is a stand-alone
* composite type relation. For the latter case, we have to
* reverse the dependency.
*
* In the former case, this allows the type to be auto-dropped when
* the relation is, and not otherwise. And in the latter, of
* course we get the opposite effect.
*/
if (OidIsValid(relationOid))
{
referenced.classId = RelOid_pg_class;
referenced.objectId = relationOid;
referenced.objectSubId = 0;
if (relationKind != RELKIND_COMPOSITE_TYPE)
recordDependencyOn(&myself, &referenced, DEPENDENCY_INTERNAL);
else
recordDependencyOn(&referenced, &myself, DEPENDENCY_INTERNAL);
}
/*
* If the type is an array type, mark it auto-dependent on the
* base type. (This is a compromise between the typical case
* where the array type is automatically generated and the case
* where it is manually created: we'd prefer INTERNAL for the
* former case and NORMAL for the latter.)
*/
if (OidIsValid(elementType))
{
referenced.classId = RelOid_pg_type;
referenced.objectId = elementType;
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO);
}
/* Normal dependency from a domain to its base type. */
if (OidIsValid(baseType))
{
referenced.classId = RelOid_pg_type;
referenced.objectId = baseType;
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
}
}
/*
@@ -311,107 +374,6 @@ TypeCreate(const char *typeName,
return typeObjectId;
}
void
GenerateTypeDependencies(Oid typeNamespace,
Oid typeObjectId,
Oid relationOid, /* only for 'c'atalog typeType */
char relationKind,
Oid inputProcedure,
Oid outputProcedure,
Oid elementType,
Oid baseType,
char *defaultTypeBin, /* cooked rep */
bool rebuild)
{
ObjectAddress myself,
referenced;
/*
* If true, we need to remove all current dependencies that the type
* holds, and rebuild them from scratch. This allows us to easily
* implement alter type, and alter domain statements.
*/
if (rebuild)
deleteDependencyRecordsFor(RelOid_pg_type,
typeObjectId);
myself.classId = RelOid_pg_type;
myself.objectId = typeObjectId;
myself.objectSubId = 0;
/* dependency on namespace */
/* skip for relation rowtype, since we have indirect dependency */
if (!OidIsValid(relationOid))
{
referenced.classId = get_system_catalog_relid(NamespaceRelationName);
referenced.objectId = typeNamespace;
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
}
/* Normal dependencies on the I/O functions */
referenced.classId = RelOid_pg_proc;
referenced.objectId = inputProcedure;
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
referenced.classId = RelOid_pg_proc;
referenced.objectId = outputProcedure;
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
/*
* If the type is a rowtype for a relation, mark it as internally
* dependent on the relation, *unless* it is a stand-alone
* composite type relation. For the latter case, we have to
* reverse the dependency.
*
* In the former case, this allows the type to be auto-dropped when
* the relation is, and not otherwise. And in the latter, of
* course we get the opposite effect.
*/
if (OidIsValid(relationOid))
{
referenced.classId = RelOid_pg_class;
referenced.objectId = relationOid;
referenced.objectSubId = 0;
if (relationKind != RELKIND_COMPOSITE_TYPE)
recordDependencyOn(&myself, &referenced, DEPENDENCY_INTERNAL);
else
recordDependencyOn(&referenced, &myself, DEPENDENCY_INTERNAL);
}
/*
* If the type is an array type, mark it auto-dependent on the
* base type. (This is a compromise between the typical case
* where the array type is automatically generated and the case
* where it is manually created: we'd prefer INTERNAL for the
* former case and NORMAL for the latter.)
*/
if (OidIsValid(elementType))
{
referenced.classId = RelOid_pg_type;
referenced.objectId = elementType;
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_AUTO);
}
/* Normal dependency from a domain to its base type. */
if (OidIsValid(baseType))
{
referenced.classId = RelOid_pg_type;
referenced.objectId = baseType;
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
}
/* Dependency on the default expression */
if (defaultTypeBin)
recordDependencyOnExpr(&myself, stringToNode(defaultTypeBin),
NIL, DEPENDENCY_NORMAL);
}
/*
* TypeRename
* This renames a type

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.100 2002/12/06 03:28:27 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.101 2002/12/06 03:42:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -667,7 +667,7 @@ cluster(ClusterStmt *stmt)
tableOid = RangeVarGetRelid(stmt->relation, false);
if (!check_cluster_ownership(tableOid))
elog(ERROR, "CLUSTER: You do not own relation %s",
stmt->relation->relname);
stmt->relation->relname);
tuple = SearchSysCache(RELOID,
ObjectIdGetDatum(tableOid),
@@ -706,7 +706,7 @@ cluster(ClusterStmt *stmt)
}
if (indexOid == InvalidOid)
elog(ERROR, "CLUSTER: No previously clustered index found on table %s",
stmt->relation->relname);
stmt->relation->relname);
RelationClose(rel);
ReleaseSysCache(ituple);
ReleaseSysCache(idxtuple);
@@ -721,7 +721,7 @@ cluster(ClusterStmt *stmt)
/* XXX Maybe the namespace should be reported as well */
if (!OidIsValid(indexOid))
elog(ERROR, "CLUSTER: cannot find index \"%s\" for table \"%s\"",
stmt->indexname, stmt->relation->relname);
stmt->indexname, stmt->relation->relname);
rvtc.tableOid = tableOid;
rvtc.indexOid = indexOid;
rvtc.isPrevious = false;
@@ -819,7 +819,7 @@ get_tables_to_cluster(AclId owner)
List *rvs = NIL;
/*
* Get all indexes that have indisclustered set. System
* Get all indexes that have indisclustered set. System
* relations or nailed-in relations cannot ever have
* indisclustered set, because CLUSTER will refuse to
* set it when called with one of them as argument.

File diff suppressed because it is too large Load Diff

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.114 2002/12/06 03:28:27 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.115 2002/12/06 03:42:57 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1610,8 +1610,8 @@ ExecEvalConstraintTest(ConstraintTest *constraint, ExprContext *econtext,
conResult = ExecEvalExpr(constraint->check_expr, econtext, isNull, isDone);
if (!DatumGetBool(conResult))
elog(ERROR, "ExecEvalConstraintTest: Domain %s constraint %s failed",
constraint->domname, constraint->name);
elog(ERROR, "Domain %s constraint %s failed",
constraint->name, constraint->domname);
}
break;
default:

View File

@@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.227 2002/12/06 03:28:28 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.228 2002/12/06 03:42:59 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1479,20 +1479,6 @@ _copyAlterTableStmt(AlterTableStmt *from)
return newnode;
}
static AlterDomainStmt *
_copyAlterDomainStmt(AlterDomainStmt *from)
{
AlterDomainStmt *newnode = makeNode(AlterDomainStmt);
COPY_SCALAR_FIELD(subtype);
COPY_NODE_FIELD(typename);
COPY_STRING_FIELD(name);
COPY_NODE_FIELD(def);
COPY_SCALAR_FIELD(behavior);
return newnode;
}
static GrantStmt *
_copyGrantStmt(GrantStmt *from)
{
@@ -2478,9 +2464,6 @@ copyObject(void *from)
case T_AlterTableStmt:
retval = _copyAlterTableStmt(from);
break;
case T_AlterDomainStmt:
retval = _copyAlterDomainStmt(from);
break;
case T_GrantStmt:
retval = _copyGrantStmt(from);
break;

View File

@@ -18,7 +18,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.172 2002/12/06 03:28:32 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.173 2002/12/06 03:43:08 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -525,18 +525,6 @@ _equalAlterTableStmt(AlterTableStmt *a, AlterTableStmt *b)
return true;
}
static bool
_equalAlterDomainStmt(AlterDomainStmt *a, AlterDomainStmt *b)
{
COMPARE_SCALAR_FIELD(subtype);
COMPARE_NODE_FIELD(typename);
COMPARE_STRING_FIELD(name);
COMPARE_NODE_FIELD(def);
COMPARE_SCALAR_FIELD(behavior);
return true;
}
static bool
_equalGrantStmt(GrantStmt *a, GrantStmt *b)
{
@@ -1633,9 +1621,6 @@ equal(void *a, void *b)
case T_AlterTableStmt:
retval = _equalAlterTableStmt(a, b);
break;
case T_AlterDomainStmt:
retval = _equalAlterDomainStmt(a, b);
break;
case T_GrantStmt:
retval = _equalGrantStmt(a, b);
break;

View File

@@ -11,7 +11,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.384 2002/12/06 03:28:33 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.385 2002/12/06 03:43:08 momjian Exp $
*
* HISTORY
* AUTHOR DATE MAJOR EVENT
@@ -128,7 +128,7 @@ static void doNegateFloat(Value *v);
}
%type <node> stmt schema_stmt
AlterDatabaseSetStmt AlterDomainStmt AlterGroupStmt
AlterDatabaseSetStmt AlterGroupStmt
AlterTableStmt AlterUserStmt AlterUserSetStmt
AnalyzeStmt ClosePortalStmt ClusterStmt CommentStmt
ConstraintsSetStmt CopyStmt CreateAsStmt CreateCastStmt
@@ -479,7 +479,6 @@ stmtmulti: stmtmulti ';' stmt
stmt :
AlterDatabaseSetStmt
| AlterDomainStmt
| AlterGroupStmt
| AlterTableStmt
| AlterUserStmt
@@ -3730,53 +3729,6 @@ CreateDomainStmt:
}
;
AlterDomainStmt:
/* ALTER DOMAIN <domain> {SET DEFAULT <expr>|DROP DEFAULT} */
ALTER DOMAIN_P any_name alter_column_default
{
AlterDomainStmt *n = makeNode(AlterDomainStmt);
n->subtype = 'T';
n->typename = $3;
n->def = $4;
$$ = (Node *)n;
}
/* ALTER DOMAIN <domain> DROP NOT NULL */
| ALTER DOMAIN_P any_name DROP NOT NULL_P
{
AlterDomainStmt *n = makeNode(AlterDomainStmt);
n->subtype = 'N';
n->typename = $3;
$$ = (Node *)n;
}
/* ALTER DOMAIN <domain> SET NOT NULL */
| ALTER DOMAIN_P any_name SET NOT NULL_P
{
AlterDomainStmt *n = makeNode(AlterDomainStmt);
n->subtype = 'O';
n->typename = $3;
$$ = (Node *)n;
}
/* ALTER DOMAIN <domain> ADD CONSTRAINT ... */
| ALTER DOMAIN_P any_name ADD TableConstraint
{
AlterDomainStmt *n = makeNode(AlterDomainStmt);
n->subtype = 'C';
n->typename = $3;
n->def = $5;
$$ = (Node *)n;
}
/* ALTER DOMAIN <domain> DROP CONSTRAINT <name> [RESTRICT|CASCADE] */
| ALTER DOMAIN_P any_name DROP CONSTRAINT name opt_drop_behavior
{
AlterDomainStmt *n = makeNode(AlterDomainStmt);
n->subtype = 'X';
n->typename = $3;
n->name = $6;
n->behavior = $7;
$$ = (Node *)n;
}
;
opt_as: AS {}
| /* EMPTY */ {}
;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.133 2002/12/06 03:28:33 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.134 2002/12/06 03:43:12 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -629,14 +629,6 @@ transformExpr(ParseState *pstate, Node *expr, ConstraintTestValue *domVal)
case T_DomainConstraintValue:
{
/*
* If domVal is NULL, we are not translating an expression that
* can use it
*/
if (domVal == NULL)
elog(ERROR, "VALUE is not allowed in expression for node %d",
nodeTag(expr));
result = (Node *) copyObject(domVal);
break;

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.311 2002/12/06 03:28:33 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.312 2002/12/06 03:43:13 momjian Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
@@ -1781,7 +1781,7 @@ PostgresMain(int argc, char *argv[], const char *username)
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
puts("$Revision: 1.311 $ $Date: 2002/12/06 03:28:33 $\n");
puts("$Revision: 1.312 $ $Date: 2002/12/06 03:43:13 $\n");
}
/*
@@ -2319,10 +2319,6 @@ CreateCommandTag(Node *parsetree)
tag = "ALTER TABLE";
break;
case T_AlterDomainStmt:
tag = "ALTER DOMAIN";
break;
case T_GrantStmt:
{
GrantStmt *stmt = (GrantStmt *) parsetree;

View File

@@ -10,7 +10,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.183 2002/12/06 03:28:33 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.184 2002/12/06 03:43:16 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -36,7 +36,6 @@
#include "commands/sequence.h"
#include "commands/tablecmds.h"
#include "commands/trigger.h"
#include "commands/typecmds.h"
#include "commands/user.h"
#include "commands/vacuum.h"
#include "commands/view.h"
@@ -561,49 +560,6 @@ ProcessUtility(Node *parsetree,
}
break;
case T_AlterDomainStmt:
{
AlterDomainStmt *stmt = (AlterDomainStmt *) parsetree;
/*
* Some or all of these functions are recursive to cover
* inherited things, so permission checks are done there.
*/
switch (stmt->subtype)
{
case 'T': /* ALTER COLUMN DEFAULT */
/*
* Recursively alter column default for table and,
* if requested, for descendants
*/
AlterDomainDefault(stmt->typename,
stmt->def);
break;
case 'N': /* ALTER COLUMN DROP NOT NULL */
AlterDomainNotNull(stmt->typename,
false);
break;
case 'O': /* ALTER COLUMN SET NOT NULL */
AlterDomainNotNull(stmt->typename,
true);
break;
case 'C': /* ADD CONSTRAINT */
AlterDomainAddConstraint(stmt->typename,
stmt->def);
break;
case 'X': /* DROP CONSTRAINT */
AlterDomainDropConstraint(stmt->typename,
stmt->name,
stmt->behavior);
break;
default: /* oops */
elog(ERROR, "T_AlterDomainStmt: unknown subtype");
break;
}
}
break;
case T_GrantStmt:
ExecuteGrantStmt((GrantStmt *) parsetree);