mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-03-01 19:45:33 +08:00
Back out ALTER DOMAIN patch until missing file appears.
This commit is contained in:
parent
853153ca6d
commit
5b4c16e099
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.50 2002/12/06 03:28:27 momjian Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.51 2002/12/06 03:42:52 momjian Exp $
|
||||||
PostgreSQL documentation
|
PostgreSQL documentation
|
||||||
Complete list of usable sgml source files in this directory.
|
Complete list of usable sgml source files in this directory.
|
||||||
-->
|
-->
|
||||||
@ -38,7 +38,6 @@ Complete list of usable sgml source files in this directory.
|
|||||||
<!-- SQL commands -->
|
<!-- SQL commands -->
|
||||||
<!entity abort system "abort.sgml">
|
<!entity abort system "abort.sgml">
|
||||||
<!entity alterDatabase system "alter_database.sgml">
|
<!entity alterDatabase system "alter_database.sgml">
|
||||||
<!entity alterDomain system "alter_domain.sgml">
|
|
||||||
<!entity alterGroup system "alter_group.sgml">
|
<!entity alterGroup system "alter_group.sgml">
|
||||||
<!entity alterTable system "alter_table.sgml">
|
<!entity alterTable system "alter_table.sgml">
|
||||||
<!entity alterTrigger system "alter_trigger.sgml">
|
<!entity alterTrigger system "alter_trigger.sgml">
|
||||||
|
@ -1,237 +0,0 @@
|
|||||||
<!--
|
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/alter_domain.sgml,v 1.1 2002/12/06 03:28:27 momjian Exp $
|
|
||||||
PostgreSQL documentation
|
|
||||||
-->
|
|
||||||
|
|
||||||
<refentry id="SQL-ALTERDOMAIN">
|
|
||||||
<refmeta>
|
|
||||||
<refentrytitle id="sql-alterdomain-title">ALTER DOMAIN</refentrytitle>
|
|
||||||
<refmiscinfo>SQL - Language Statements</refmiscinfo>
|
|
||||||
</refmeta>
|
|
||||||
<refnamediv>
|
|
||||||
<refname>
|
|
||||||
ALTER DOMAIN
|
|
||||||
</refname>
|
|
||||||
<refpurpose>
|
|
||||||
change the definition of a table
|
|
||||||
</refpurpose>
|
|
||||||
</refnamediv>
|
|
||||||
<refsynopsisdiv>
|
|
||||||
<refsynopsisdivinfo>
|
|
||||||
<date>2002-11-27</date>
|
|
||||||
</refsynopsisdivinfo>
|
|
||||||
<synopsis>
|
|
||||||
ALTER DOMAIN <replaceable class="PARAMETER">domain</replaceable>
|
|
||||||
{ SET DEFAULT <replaceable class="PARAMETER">value</replaceable> | DROP DEFAULT }
|
|
||||||
ALTER DOMAIN <replaceable class="PARAMETER">domain</replaceable>
|
|
||||||
{ SET | DROP } NOT NULL
|
|
||||||
ALTER DOMAIN <replaceable class="PARAMETER">domain</replaceable>
|
|
||||||
ADD <replaceable class="PARAMETER">domain_constraint</replaceable>
|
|
||||||
ALTER DOMAIN <replaceable class="PARAMETER">domain</replaceable>
|
|
||||||
DROP CONSTRAINT <replaceable class="PARAMETER">constraint_name</replaceable> [ RESTRICT | CASCADE ]
|
|
||||||
</synopsis>
|
|
||||||
|
|
||||||
<refsect2 id="R2-SQL-ALTERDOMAIN-1">
|
|
||||||
<refsect2info>
|
|
||||||
<date>2002-11-27</date>
|
|
||||||
</refsect2info>
|
|
||||||
<title>
|
|
||||||
Inputs
|
|
||||||
</title>
|
|
||||||
<para>
|
|
||||||
<variablelist>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><replaceable class="PARAMETER"> domain </replaceable></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
The name (possibly schema-qualified) of an existing domain to
|
|
||||||
alter.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><replaceable class="PARAMETER"> domain_constraint </replaceable></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
New domain constraint for the domain.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><replaceable class="PARAMETER"> constraint_name </replaceable></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Name of an existing constraint to drop.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term>CASCADE</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Automatically drop objects that depend constraint.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term>RESTRICT</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Refuse to drop the constraint if there are any dependent
|
|
||||||
objects. This is the default behavior.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
</variablelist>
|
|
||||||
</para>
|
|
||||||
</refsect2>
|
|
||||||
|
|
||||||
<refsect2 id="R2-SQL-ALTERDOMAIN-2">
|
|
||||||
<refsect2info>
|
|
||||||
<date>1998-04-15</date>
|
|
||||||
</refsect2info>
|
|
||||||
<title>
|
|
||||||
Outputs
|
|
||||||
</title>
|
|
||||||
<para>
|
|
||||||
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
|
||||||
<term><computeroutput>ALTER DOMAIN</computeroutput></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Message returned from domain alteration.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term><computeroutput>ERROR</computeroutput></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
Message returned if domain is not available.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
</variablelist>
|
|
||||||
</para>
|
|
||||||
</refsect2>
|
|
||||||
</refsynopsisdiv>
|
|
||||||
|
|
||||||
<refsect1 id="R1-SQL-ALTERDOMAIN-1">
|
|
||||||
<refsect1info>
|
|
||||||
<date>2002-11-27</date>
|
|
||||||
</refsect1info>
|
|
||||||
<title>
|
|
||||||
Description
|
|
||||||
</title>
|
|
||||||
<para>
|
|
||||||
<command>ALTER DOMAIN</command> changes the definition of an existing domain.
|
|
||||||
There are several sub-forms:
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
|
||||||
<term>SET/DROP DEFAULT</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
These forms set or remove the default value for a column. Note
|
|
||||||
that defaults only apply to subsequent <command>INSERT</command>
|
|
||||||
commands; they do not cause rows already in a table using the domain.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term>SET/DROP NOT NULL</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
These forms change whether a domain is marked to allow NULL
|
|
||||||
values or to reject NULL values. You may only <literal>SET NOT NULL</>
|
|
||||||
when the tables using the domain contain no null values in the domain
|
|
||||||
based column.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term>ADD <replaceable class="PARAMETER">domain_constraint</replaceable></term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
This form adds a new constraint to a table using the same syntax as
|
|
||||||
<xref linkend="SQL-CREATEDOMAIN" endterm="SQL-CREATEDOMAIN-TITLE">.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
<varlistentry>
|
|
||||||
<term>DROP CONSTRAINT</term>
|
|
||||||
<listitem>
|
|
||||||
<para>
|
|
||||||
This form drops constraints on a domain.
|
|
||||||
</para>
|
|
||||||
</listitem>
|
|
||||||
</varlistentry>
|
|
||||||
|
|
||||||
</variablelist>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
You must own the domain to use <command>ALTER DOMAIN</>; except for
|
|
||||||
<command>ALTER TABLE OWNER</>, which may only be executed by a superuser.
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
<refsect1 id="R1-SQL-ALTERDOMAIN-2">
|
|
||||||
<title>
|
|
||||||
Usage
|
|
||||||
</title>
|
|
||||||
<para>
|
|
||||||
To add a NOT NULL constraint to a column:
|
|
||||||
<programlisting>
|
|
||||||
ALTER DOMAIN zipcode SET NOT NULL;
|
|
||||||
</programlisting>
|
|
||||||
To remove a NOT NULL constraint from a column:
|
|
||||||
<programlisting>
|
|
||||||
ALTER DOMAIN zipcode DROP NOT NULL;
|
|
||||||
</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
To add a check constraint to a table:
|
|
||||||
<programlisting>
|
|
||||||
ALTER DOMAIN zipcode ADD CONSTRAINT zipchk CHECK (char_length(VALUE) = 5);
|
|
||||||
</programlisting>
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<para>
|
|
||||||
To remove a check constraint from a table and all its children:
|
|
||||||
<programlisting>
|
|
||||||
ALTER DOMAIN zipcode DROP CONSTRAINT zipchk;
|
|
||||||
</programlisting>
|
|
||||||
</para>
|
|
||||||
</refsect1>
|
|
||||||
|
|
||||||
</refentry>
|
|
||||||
|
|
||||||
<!-- Keep this comment at the end of the file
|
|
||||||
Local variables:
|
|
||||||
mode: sgml
|
|
||||||
sgml-omittag:nil
|
|
||||||
sgml-shorttag:t
|
|
||||||
sgml-minimize-attributes:nil
|
|
||||||
sgml-always-quote-attributes:t
|
|
||||||
sgml-indent-step:1
|
|
||||||
sgml-indent-data:t
|
|
||||||
sgml-parent-document:nil
|
|
||||||
sgml-default-dtd-file:"../reference.ced"
|
|
||||||
sgml-exposed-tags:nil
|
|
||||||
sgml-local-catalogs:"/usr/lib/sgml/catalog"
|
|
||||||
sgml-local-ecat-files:nil
|
|
||||||
End:
|
|
||||||
-->
|
|
@ -1,5 +1,5 @@
|
|||||||
<!-- reference.sgml
|
<!-- reference.sgml
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/reference.sgml,v 1.39 2002/12/06 03:28:27 momjian Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/reference.sgml,v 1.40 2002/12/06 03:42:48 momjian Exp $
|
||||||
|
|
||||||
PostgreSQL Reference Manual
|
PostgreSQL Reference Manual
|
||||||
-->
|
-->
|
||||||
@ -47,7 +47,6 @@ PostgreSQL Reference Manual
|
|||||||
|
|
||||||
&abort;
|
&abort;
|
||||||
&alterDatabase;
|
&alterDatabase;
|
||||||
&alterDomain;
|
|
||||||
&alterGroup;
|
&alterGroup;
|
||||||
&alterTable;
|
&alterTable;
|
||||||
&alterTrigger;
|
&alterTrigger;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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/proclang.h"
|
||||||
#include "commands/schemacmds.h"
|
#include "commands/schemacmds.h"
|
||||||
#include "commands/trigger.h"
|
#include "commands/trigger.h"
|
||||||
#include "commands/typecmds.h"
|
|
||||||
#include "lib/stringinfo.h"
|
#include "lib/stringinfo.h"
|
||||||
#include "miscadmin.h"
|
#include "miscadmin.h"
|
||||||
#include "optimizer/clauses.h"
|
#include "optimizer/clauses.h"
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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.classId = RelOid_pg_type;
|
||||||
domobject.objectId = domainId;
|
domobject.objectId = domainId;
|
||||||
domobject.objectSubId = 0;
|
|
||||||
|
|
||||||
recordDependencyOn(&conobject, &domobject, DEPENDENCY_AUTO);
|
recordDependencyOn(&conobject, &domobject, DEPENDENCY_AUTO);
|
||||||
}
|
}
|
||||||
@ -497,16 +496,15 @@ RemoveConstraintById(Oid conId)
|
|||||||
HeapTuple typTup;
|
HeapTuple typTup;
|
||||||
ScanKeyData typKey[1];
|
ScanKeyData typKey[1];
|
||||||
SysScanDesc typScan;
|
SysScanDesc typScan;
|
||||||
int nkeys = 0;
|
|
||||||
|
|
||||||
typRel = heap_openr(TypeRelationName, RowExclusiveLock);
|
typRel = heap_openr(TypeRelationName, RowExclusiveLock);
|
||||||
|
|
||||||
ScanKeyEntryInitialize(&typKey[nkeys++], 0x0,
|
ScanKeyEntryInitialize(&typKey[0], 0x0,
|
||||||
ObjectIdAttributeNumber, F_OIDEQ,
|
Anum_pg_constraint_contypid, F_OIDEQ,
|
||||||
ObjectIdGetDatum(con->contypid));
|
ObjectIdGetDatum(con->contypid));
|
||||||
|
|
||||||
typScan = systable_beginscan(typRel, TypeOidIndex, true,
|
typScan = systable_beginscan(typRel, TypeOidIndex, true,
|
||||||
SnapshotNow, nkeys, typKey);
|
SnapshotNow, 1, typKey);
|
||||||
|
|
||||||
typTup = systable_getnext(typScan);
|
typTup = systable_getnext(typScan);
|
||||||
|
|
||||||
@ -519,11 +517,6 @@ RemoveConstraintById(Oid conId)
|
|||||||
/* Keep lock on domain type until end of xact */
|
/* Keep lock on domain type until end of xact */
|
||||||
heap_close(typRel, NoLock);
|
heap_close(typRel, NoLock);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
elog(ERROR, "RemoveConstraintById: Constraint %u is not a known type",
|
|
||||||
conId);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fry the constraint itself */
|
/* Fry the constraint itself */
|
||||||
simple_heap_delete(conDesc, &tup->t_self);
|
simple_heap_delete(conDesc, &tup->t_self);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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 elementType,
|
||||||
Oid baseType,
|
Oid baseType,
|
||||||
const char *defaultTypeValue, /* human readable rep */
|
const char *defaultTypeValue, /* human readable rep */
|
||||||
char *defaultTypeBin, /* cooked rep */
|
const char *defaultTypeBin, /* cooked rep */
|
||||||
bool passedByValue,
|
bool passedByValue,
|
||||||
char alignment,
|
char alignment,
|
||||||
char storage,
|
char storage,
|
||||||
@ -291,16 +291,79 @@ TypeCreate(const char *typeName,
|
|||||||
*/
|
*/
|
||||||
if (!IsBootstrapProcessingMode())
|
if (!IsBootstrapProcessingMode())
|
||||||
{
|
{
|
||||||
GenerateTypeDependencies(typeNamespace,
|
ObjectAddress myself,
|
||||||
typeObjectId,
|
referenced;
|
||||||
relationOid,
|
|
||||||
relationKind,
|
myself.classId = RelOid_pg_type;
|
||||||
inputProcedure,
|
myself.objectId = typeObjectId;
|
||||||
outputProcedure,
|
myself.objectSubId = 0;
|
||||||
elementType,
|
|
||||||
baseType,
|
/* dependency on namespace */
|
||||||
defaultTypeBin,
|
/* skip for relation rowtype, since we have indirect dependency */
|
||||||
false);
|
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;
|
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
|
* TypeRename
|
||||||
* This renames a type
|
* This renames a type
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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);
|
tableOid = RangeVarGetRelid(stmt->relation, false);
|
||||||
if (!check_cluster_ownership(tableOid))
|
if (!check_cluster_ownership(tableOid))
|
||||||
elog(ERROR, "CLUSTER: You do not own relation %s",
|
elog(ERROR, "CLUSTER: You do not own relation %s",
|
||||||
stmt->relation->relname);
|
stmt->relation->relname);
|
||||||
|
|
||||||
tuple = SearchSysCache(RELOID,
|
tuple = SearchSysCache(RELOID,
|
||||||
ObjectIdGetDatum(tableOid),
|
ObjectIdGetDatum(tableOid),
|
||||||
@ -706,7 +706,7 @@ cluster(ClusterStmt *stmt)
|
|||||||
}
|
}
|
||||||
if (indexOid == InvalidOid)
|
if (indexOid == InvalidOid)
|
||||||
elog(ERROR, "CLUSTER: No previously clustered index found on table %s",
|
elog(ERROR, "CLUSTER: No previously clustered index found on table %s",
|
||||||
stmt->relation->relname);
|
stmt->relation->relname);
|
||||||
RelationClose(rel);
|
RelationClose(rel);
|
||||||
ReleaseSysCache(ituple);
|
ReleaseSysCache(ituple);
|
||||||
ReleaseSysCache(idxtuple);
|
ReleaseSysCache(idxtuple);
|
||||||
@ -721,7 +721,7 @@ cluster(ClusterStmt *stmt)
|
|||||||
/* XXX Maybe the namespace should be reported as well */
|
/* XXX Maybe the namespace should be reported as well */
|
||||||
if (!OidIsValid(indexOid))
|
if (!OidIsValid(indexOid))
|
||||||
elog(ERROR, "CLUSTER: cannot find index \"%s\" for table \"%s\"",
|
elog(ERROR, "CLUSTER: cannot find index \"%s\" for table \"%s\"",
|
||||||
stmt->indexname, stmt->relation->relname);
|
stmt->indexname, stmt->relation->relname);
|
||||||
rvtc.tableOid = tableOid;
|
rvtc.tableOid = tableOid;
|
||||||
rvtc.indexOid = indexOid;
|
rvtc.indexOid = indexOid;
|
||||||
rvtc.isPrevious = false;
|
rvtc.isPrevious = false;
|
||||||
@ -819,7 +819,7 @@ get_tables_to_cluster(AclId owner)
|
|||||||
List *rvs = NIL;
|
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
|
* relations or nailed-in relations cannot ever have
|
||||||
* indisclustered set, because CLUSTER will refuse to
|
* indisclustered set, because CLUSTER will refuse to
|
||||||
* set it when called with one of them as argument.
|
* set it when called with one of them as argument.
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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);
|
conResult = ExecEvalExpr(constraint->check_expr, econtext, isNull, isDone);
|
||||||
|
|
||||||
if (!DatumGetBool(conResult))
|
if (!DatumGetBool(conResult))
|
||||||
elog(ERROR, "ExecEvalConstraintTest: Domain %s constraint %s failed",
|
elog(ERROR, "Domain %s constraint %s failed",
|
||||||
constraint->domname, constraint->name);
|
constraint->name, constraint->domname);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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;
|
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 *
|
static GrantStmt *
|
||||||
_copyGrantStmt(GrantStmt *from)
|
_copyGrantStmt(GrantStmt *from)
|
||||||
{
|
{
|
||||||
@ -2478,9 +2464,6 @@ copyObject(void *from)
|
|||||||
case T_AlterTableStmt:
|
case T_AlterTableStmt:
|
||||||
retval = _copyAlterTableStmt(from);
|
retval = _copyAlterTableStmt(from);
|
||||||
break;
|
break;
|
||||||
case T_AlterDomainStmt:
|
|
||||||
retval = _copyAlterDomainStmt(from);
|
|
||||||
break;
|
|
||||||
case T_GrantStmt:
|
case T_GrantStmt:
|
||||||
retval = _copyGrantStmt(from);
|
retval = _copyGrantStmt(from);
|
||||||
break;
|
break;
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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;
|
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
|
static bool
|
||||||
_equalGrantStmt(GrantStmt *a, GrantStmt *b)
|
_equalGrantStmt(GrantStmt *a, GrantStmt *b)
|
||||||
{
|
{
|
||||||
@ -1633,9 +1621,6 @@ equal(void *a, void *b)
|
|||||||
case T_AlterTableStmt:
|
case T_AlterTableStmt:
|
||||||
retval = _equalAlterTableStmt(a, b);
|
retval = _equalAlterTableStmt(a, b);
|
||||||
break;
|
break;
|
||||||
case T_AlterDomainStmt:
|
|
||||||
retval = _equalAlterDomainStmt(a, b);
|
|
||||||
break;
|
|
||||||
case T_GrantStmt:
|
case T_GrantStmt:
|
||||||
retval = _equalGrantStmt(a, b);
|
retval = _equalGrantStmt(a, b);
|
||||||
break;
|
break;
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -128,7 +128,7 @@ static void doNegateFloat(Value *v);
|
|||||||
}
|
}
|
||||||
|
|
||||||
%type <node> stmt schema_stmt
|
%type <node> stmt schema_stmt
|
||||||
AlterDatabaseSetStmt AlterDomainStmt AlterGroupStmt
|
AlterDatabaseSetStmt AlterGroupStmt
|
||||||
AlterTableStmt AlterUserStmt AlterUserSetStmt
|
AlterTableStmt AlterUserStmt AlterUserSetStmt
|
||||||
AnalyzeStmt ClosePortalStmt ClusterStmt CommentStmt
|
AnalyzeStmt ClosePortalStmt ClusterStmt CommentStmt
|
||||||
ConstraintsSetStmt CopyStmt CreateAsStmt CreateCastStmt
|
ConstraintsSetStmt CopyStmt CreateAsStmt CreateCastStmt
|
||||||
@ -479,7 +479,6 @@ stmtmulti: stmtmulti ';' stmt
|
|||||||
|
|
||||||
stmt :
|
stmt :
|
||||||
AlterDatabaseSetStmt
|
AlterDatabaseSetStmt
|
||||||
| AlterDomainStmt
|
|
||||||
| AlterGroupStmt
|
| AlterGroupStmt
|
||||||
| AlterTableStmt
|
| AlterTableStmt
|
||||||
| AlterUserStmt
|
| 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 {}
|
opt_as: AS {}
|
||||||
| /* EMPTY */ {}
|
| /* EMPTY */ {}
|
||||||
;
|
;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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:
|
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);
|
result = (Node *) copyObject(domVal);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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
|
* NOTES
|
||||||
* this is the "main" module of the postgres backend and
|
* this is the "main" module of the postgres backend and
|
||||||
@ -1781,7 +1781,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
|||||||
if (!IsUnderPostmaster)
|
if (!IsUnderPostmaster)
|
||||||
{
|
{
|
||||||
puts("\nPOSTGRES backend interactive interface ");
|
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";
|
tag = "ALTER TABLE";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case T_AlterDomainStmt:
|
|
||||||
tag = "ALTER DOMAIN";
|
|
||||||
break;
|
|
||||||
|
|
||||||
case T_GrantStmt:
|
case T_GrantStmt:
|
||||||
{
|
{
|
||||||
GrantStmt *stmt = (GrantStmt *) parsetree;
|
GrantStmt *stmt = (GrantStmt *) parsetree;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* 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/sequence.h"
|
||||||
#include "commands/tablecmds.h"
|
#include "commands/tablecmds.h"
|
||||||
#include "commands/trigger.h"
|
#include "commands/trigger.h"
|
||||||
#include "commands/typecmds.h"
|
|
||||||
#include "commands/user.h"
|
#include "commands/user.h"
|
||||||
#include "commands/vacuum.h"
|
#include "commands/vacuum.h"
|
||||||
#include "commands/view.h"
|
#include "commands/view.h"
|
||||||
@ -561,49 +560,6 @@ ProcessUtility(Node *parsetree,
|
|||||||
}
|
}
|
||||||
break;
|
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:
|
case T_GrantStmt:
|
||||||
ExecuteGrantStmt((GrantStmt *) parsetree);
|
ExecuteGrantStmt((GrantStmt *) parsetree);
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: pg_type.h,v 1.135 2002/12/06 03:28:33 momjian Exp $
|
* $Id: pg_type.h,v 1.136 2002/12/06 03:43:18 momjian Exp $
|
||||||
*
|
*
|
||||||
* NOTES
|
* NOTES
|
||||||
* the genbki.sh script reads this file and generates .bki
|
* the genbki.sh script reads this file and generates .bki
|
||||||
@ -550,7 +550,7 @@ extern Oid TypeCreate(const char *typeName,
|
|||||||
Oid elementType,
|
Oid elementType,
|
||||||
Oid baseType,
|
Oid baseType,
|
||||||
const char *defaultTypeValue,
|
const char *defaultTypeValue,
|
||||||
char *defaultTypeBin,
|
const char *defaultTypeBin,
|
||||||
bool passedByValue,
|
bool passedByValue,
|
||||||
char alignment,
|
char alignment,
|
||||||
char storage,
|
char storage,
|
||||||
@ -558,18 +558,6 @@ extern Oid TypeCreate(const char *typeName,
|
|||||||
int32 typNDims,
|
int32 typNDims,
|
||||||
bool typeNotNull);
|
bool typeNotNull);
|
||||||
|
|
||||||
extern 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);
|
|
||||||
|
|
||||||
|
|
||||||
extern void TypeRename(const char *oldTypeName, Oid typeNamespace,
|
extern void TypeRename(const char *oldTypeName, Oid typeNamespace,
|
||||||
const char *newTypeName);
|
const char *newTypeName);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: defrem.h,v 1.47 2002/12/06 03:28:33 momjian Exp $
|
* $Id: defrem.h,v 1.48 2002/12/06 03:43:28 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -52,6 +52,14 @@ extern void RemoveOperatorById(Oid operOid);
|
|||||||
extern void DefineAggregate(List *names, List *parameters);
|
extern void DefineAggregate(List *names, List *parameters);
|
||||||
extern void RemoveAggregate(RemoveAggrStmt *stmt);
|
extern void RemoveAggregate(RemoveAggrStmt *stmt);
|
||||||
|
|
||||||
|
/* commands/typecmds.c */
|
||||||
|
extern void DefineType(List *names, List *parameters);
|
||||||
|
extern void RemoveType(List *names, DropBehavior behavior);
|
||||||
|
extern void RemoveTypeById(Oid typeOid);
|
||||||
|
extern void DefineDomain(CreateDomainStmt *stmt);
|
||||||
|
extern void RemoveDomain(List *names, DropBehavior behavior);
|
||||||
|
extern Oid DefineCompositeType(const RangeVar *typevar, List *coldeflist);
|
||||||
|
|
||||||
/* commands/opclasscmds.c */
|
/* commands/opclasscmds.c */
|
||||||
extern void DefineOpClass(CreateOpClassStmt *stmt);
|
extern void DefineOpClass(CreateOpClassStmt *stmt);
|
||||||
extern void RemoveOpClass(RemoveOpClassStmt *stmt);
|
extern void RemoveOpClass(RemoveOpClassStmt *stmt);
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: nodes.h,v 1.127 2002/12/06 03:28:33 momjian Exp $
|
* $Id: nodes.h,v 1.128 2002/12/06 03:43:28 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -157,7 +157,6 @@ typedef enum NodeTag
|
|||||||
T_UpdateStmt,
|
T_UpdateStmt,
|
||||||
T_SelectStmt,
|
T_SelectStmt,
|
||||||
T_AlterTableStmt,
|
T_AlterTableStmt,
|
||||||
T_AlterDomainStmt,
|
|
||||||
T_SetOperationStmt,
|
T_SetOperationStmt,
|
||||||
T_GrantStmt,
|
T_GrantStmt,
|
||||||
T_ClosePortalStmt,
|
T_ClosePortalStmt,
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $Id: parsenodes.h,v 1.219 2002/12/06 03:28:33 momjian Exp $
|
* $Id: parsenodes.h,v 1.220 2002/12/06 03:43:28 momjian Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -827,33 +827,6 @@ typedef struct AlterTableStmt
|
|||||||
DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
|
DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
|
||||||
} AlterTableStmt;
|
} AlterTableStmt;
|
||||||
|
|
||||||
/* ----------------------
|
|
||||||
* Alter Domain
|
|
||||||
*
|
|
||||||
* The fields are used in different ways by the different variants of
|
|
||||||
* this command. Subtypes should match AlterTable subtypes
|
|
||||||
* ----------------------
|
|
||||||
*/
|
|
||||||
typedef struct AlterDomainStmt
|
|
||||||
{
|
|
||||||
NodeTag type;
|
|
||||||
char subtype; /*------------
|
|
||||||
* T = alter column default
|
|
||||||
* N = alter column drop not null
|
|
||||||
* O = alter column set not null
|
|
||||||
* C = add constraint
|
|
||||||
* X = drop constraint
|
|
||||||
* U = change owner
|
|
||||||
*------------
|
|
||||||
*/
|
|
||||||
List *typename; /* table to work on */
|
|
||||||
char *name; /* column or constraint name to act on, or
|
|
||||||
* new owner */
|
|
||||||
Node *def; /* definition of default or constraint */
|
|
||||||
DropBehavior behavior; /* RESTRICT or CASCADE for DROP cases */
|
|
||||||
} AlterDomainStmt;
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------
|
/* ----------------------
|
||||||
* Grant|Revoke Statement
|
* Grant|Revoke Statement
|
||||||
* ----------------------
|
* ----------------------
|
||||||
|
@ -115,7 +115,7 @@ INSERT INTO nulltest DEFAULT VALUES;
|
|||||||
ERROR: Domain dnotnull does not allow NULL values
|
ERROR: Domain dnotnull does not allow NULL values
|
||||||
INSERT INTO nulltest values ('a', 'b', 'c', 'd', 'c'); -- Good
|
INSERT INTO nulltest values ('a', 'b', 'c', 'd', 'c'); -- Good
|
||||||
insert into nulltest values ('a', 'b', 'c', 'd', NULL);
|
insert into nulltest values ('a', 'b', 'c', 'd', NULL);
|
||||||
ERROR: ExecEvalConstraintTest: Domain dcheck constraint $1 failed
|
ERROR: Domain $1 constraint dcheck failed
|
||||||
insert into nulltest values ('a', 'b', 'c', 'd', 'a');
|
insert into nulltest values ('a', 'b', 'c', 'd', 'a');
|
||||||
ERROR: ExecInsert: rejected due to CHECK constraint "nulltest_col5" on "nulltest"
|
ERROR: ExecInsert: rejected due to CHECK constraint "nulltest_col5" on "nulltest"
|
||||||
INSERT INTO nulltest values (NULL, 'b', 'c', 'd', 'd');
|
INSERT INTO nulltest values (NULL, 'b', 'c', 'd', 'd');
|
||||||
@ -127,7 +127,7 @@ ERROR: ExecInsert: Fail to add null value in not null attribute col3
|
|||||||
INSERT INTO nulltest values ('a', 'b', 'c', NULL, 'd'); -- Good
|
INSERT INTO nulltest values ('a', 'b', 'c', NULL, 'd'); -- Good
|
||||||
-- Test copy
|
-- Test copy
|
||||||
COPY nulltest FROM stdin; --fail
|
COPY nulltest FROM stdin; --fail
|
||||||
ERROR: copy: line 1, ExecEvalConstraintTest: Domain dcheck constraint $1 failed
|
ERROR: copy: line 1, Domain $1 constraint dcheck failed
|
||||||
lost synchronization with server, resetting connection
|
lost synchronization with server, resetting connection
|
||||||
SET autocommit TO 'on';
|
SET autocommit TO 'on';
|
||||||
-- Last row is bad
|
-- Last row is bad
|
||||||
@ -158,7 +158,6 @@ ERROR: Domain dnotnull does not allow NULL values
|
|||||||
drop table nulltest;
|
drop table nulltest;
|
||||||
drop domain dnotnull restrict;
|
drop domain dnotnull restrict;
|
||||||
drop domain dnull restrict;
|
drop domain dnull restrict;
|
||||||
drop domain dcheck restrict;
|
|
||||||
create domain ddef1 int4 DEFAULT 3;
|
create domain ddef1 int4 DEFAULT 3;
|
||||||
create domain ddef2 oid DEFAULT '12';
|
create domain ddef2 oid DEFAULT '12';
|
||||||
-- Type mixing, function returns int8
|
-- Type mixing, function returns int8
|
||||||
@ -192,80 +191,7 @@ select * from defaulttest;
|
|||||||
(4 rows)
|
(4 rows)
|
||||||
|
|
||||||
drop sequence ddef4_seq;
|
drop sequence ddef4_seq;
|
||||||
drop table defaulttest cascade;
|
drop table defaulttest;
|
||||||
-- Test ALTER DOMAIN .. NOT NULL
|
|
||||||
create domain dnotnulltest integer;
|
|
||||||
create table domnotnull
|
|
||||||
( col1 dnotnulltest
|
|
||||||
, col2 dnotnulltest
|
|
||||||
);
|
|
||||||
insert into domnotnull default values;
|
|
||||||
alter domain dnotnulltest set not null; -- fails
|
|
||||||
ERROR: ALTER DOMAIN: Relation "domnotnull" Attribute "col1" contains NULL values
|
|
||||||
update domnotnull set col1 = 5;
|
|
||||||
alter domain dnotnulltest set not null; -- fails
|
|
||||||
ERROR: ALTER DOMAIN: Relation "domnotnull" Attribute "col2" contains NULL values
|
|
||||||
update domnotnull set col2 = 6;
|
|
||||||
alter domain dnotnulltest set not null;
|
|
||||||
alter domain dnotnulltest set not null; -- fails
|
|
||||||
ERROR: AlterDomain: dnotnulltest is already set to NOT NULL
|
|
||||||
update domnotnull set col1 = null; -- fails
|
|
||||||
ERROR: Domain dnotnulltest does not allow NULL values
|
|
||||||
alter domain dnotnulltest drop not null;
|
|
||||||
alter domain dnotnulltest drop not null; -- fails
|
|
||||||
ERROR: AlterDomain: dnotnulltest is already set to NULL
|
|
||||||
update domnotnull set col1 = null;
|
|
||||||
drop domain dnotnulltest cascade;
|
|
||||||
NOTICE: Drop cascades to table domnotnull column col2
|
|
||||||
NOTICE: Drop cascades to table domnotnull column col1
|
|
||||||
-- Test ALTER DOMAIN .. DEFAULT ..
|
|
||||||
create table domdeftest (col1 ddef1);
|
|
||||||
insert into domdeftest default values;
|
|
||||||
select * from domdeftest;
|
|
||||||
col1
|
|
||||||
------
|
|
||||||
3
|
|
||||||
(1 row)
|
|
||||||
|
|
||||||
alter domain ddef1 set default '42';
|
|
||||||
insert into domdeftest default values;
|
|
||||||
select * from domdeftest;
|
|
||||||
col1
|
|
||||||
------
|
|
||||||
3
|
|
||||||
42
|
|
||||||
(2 rows)
|
|
||||||
|
|
||||||
alter domain ddef1 drop default;
|
|
||||||
insert into domdeftest default values;
|
|
||||||
select * from domdeftest;
|
|
||||||
col1
|
|
||||||
------
|
|
||||||
3
|
|
||||||
42
|
|
||||||
|
|
||||||
(3 rows)
|
|
||||||
|
|
||||||
drop table domdeftest;
|
|
||||||
-- Test ALTER DOMAIN .. CONSTRAINT ..
|
|
||||||
create domain con as integer;
|
|
||||||
create table domcontest (col1 con);
|
|
||||||
insert into domcontest values (1);
|
|
||||||
insert into domcontest values (2);
|
|
||||||
alter domain con add constraint t check (VALUE < 1); -- fails
|
|
||||||
ERROR: AlterDomainAddConstraint: Domain con constraint t failed
|
|
||||||
alter domain con add constraint t check (VALUE < 34);
|
|
||||||
alter domain con add check (VALUE > 0);
|
|
||||||
insert into domcontest values (-5); -- fails
|
|
||||||
ERROR: ExecEvalConstraintTest: Domain con constraint $1 failed
|
|
||||||
insert into domcontest values (42); -- fails
|
|
||||||
ERROR: ExecEvalConstraintTest: Domain con constraint t failed
|
|
||||||
insert into domcontest values (5);
|
|
||||||
alter domain con drop constraint t;
|
|
||||||
insert into domcontest values (-5); --fails
|
|
||||||
ERROR: ExecEvalConstraintTest: Domain con constraint $1 failed
|
|
||||||
insert into domcontest values (42);
|
|
||||||
-- cleanup
|
|
||||||
drop domain ddef1 restrict;
|
drop domain ddef1 restrict;
|
||||||
drop domain ddef2 restrict;
|
drop domain ddef2 restrict;
|
||||||
drop domain ddef3 restrict;
|
drop domain ddef3 restrict;
|
||||||
|
@ -14,8 +14,8 @@ float8/.*-qnx=float8-exp-three-digits
|
|||||||
float8/alpha.*-dec-osf.*:cc=float8-fp-exception
|
float8/alpha.*-dec-osf.*:cc=float8-fp-exception
|
||||||
float8/i.86-pc-cygwin=float8-small-is-zero
|
float8/i.86-pc-cygwin=float8-small-is-zero
|
||||||
geometry/.*-darwin=geometry-positive-zeros
|
geometry/.*-darwin=geometry-positive-zeros
|
||||||
geometry/i.86-.*-freebsd4.[0-7]=geometry-positive-zeros
|
geometry/i.86-.*-freebsd4.[0-5]=geometry-positive-zeros
|
||||||
geometry/alpha.*-freebsd4.[0-7]=geometry-positive-zeros
|
geometry/alpha.*-freebsd4.[0-5]=geometry-positive-zeros
|
||||||
geometry/i.86-.*-openbsd=geometry-positive-zeros
|
geometry/i.86-.*-openbsd=geometry-positive-zeros
|
||||||
geometry/sparc-.*-openbsd=geometry-positive-zeros
|
geometry/sparc-.*-openbsd=geometry-positive-zeros
|
||||||
geometry/.*-netbsd1.[0-5]=geometry-positive-zeros
|
geometry/.*-netbsd1.[0-5]=geometry-positive-zeros
|
||||||
|
@ -127,7 +127,6 @@ SELECT cast(col4 as dnotnull) from nulltest; -- fail
|
|||||||
drop table nulltest;
|
drop table nulltest;
|
||||||
drop domain dnotnull restrict;
|
drop domain dnotnull restrict;
|
||||||
drop domain dnull restrict;
|
drop domain dnull restrict;
|
||||||
drop domain dcheck restrict;
|
|
||||||
|
|
||||||
|
|
||||||
create domain ddef1 int4 DEFAULT 3;
|
create domain ddef1 int4 DEFAULT 3;
|
||||||
@ -160,71 +159,7 @@ COPY defaulttest(col5) FROM stdin;
|
|||||||
select * from defaulttest;
|
select * from defaulttest;
|
||||||
|
|
||||||
drop sequence ddef4_seq;
|
drop sequence ddef4_seq;
|
||||||
drop table defaulttest cascade;
|
drop table defaulttest;
|
||||||
|
|
||||||
-- Test ALTER DOMAIN .. NOT NULL
|
|
||||||
create domain dnotnulltest integer;
|
|
||||||
create table domnotnull
|
|
||||||
( col1 dnotnulltest
|
|
||||||
, col2 dnotnulltest
|
|
||||||
);
|
|
||||||
|
|
||||||
insert into domnotnull default values;
|
|
||||||
alter domain dnotnulltest set not null; -- fails
|
|
||||||
|
|
||||||
update domnotnull set col1 = 5;
|
|
||||||
alter domain dnotnulltest set not null; -- fails
|
|
||||||
|
|
||||||
update domnotnull set col2 = 6;
|
|
||||||
|
|
||||||
alter domain dnotnulltest set not null;
|
|
||||||
alter domain dnotnulltest set not null; -- fails
|
|
||||||
|
|
||||||
update domnotnull set col1 = null; -- fails
|
|
||||||
|
|
||||||
alter domain dnotnulltest drop not null;
|
|
||||||
alter domain dnotnulltest drop not null; -- fails
|
|
||||||
|
|
||||||
update domnotnull set col1 = null;
|
|
||||||
|
|
||||||
drop domain dnotnulltest cascade;
|
|
||||||
|
|
||||||
-- Test ALTER DOMAIN .. DEFAULT ..
|
|
||||||
create table domdeftest (col1 ddef1);
|
|
||||||
|
|
||||||
insert into domdeftest default values;
|
|
||||||
select * from domdeftest;
|
|
||||||
|
|
||||||
alter domain ddef1 set default '42';
|
|
||||||
insert into domdeftest default values;
|
|
||||||
select * from domdeftest;
|
|
||||||
|
|
||||||
alter domain ddef1 drop default;
|
|
||||||
insert into domdeftest default values;
|
|
||||||
select * from domdeftest;
|
|
||||||
|
|
||||||
drop table domdeftest;
|
|
||||||
|
|
||||||
-- Test ALTER DOMAIN .. CONSTRAINT ..
|
|
||||||
create domain con as integer;
|
|
||||||
create table domcontest (col1 con);
|
|
||||||
|
|
||||||
insert into domcontest values (1);
|
|
||||||
insert into domcontest values (2);
|
|
||||||
alter domain con add constraint t check (VALUE < 1); -- fails
|
|
||||||
|
|
||||||
alter domain con add constraint t check (VALUE < 34);
|
|
||||||
alter domain con add check (VALUE > 0);
|
|
||||||
|
|
||||||
insert into domcontest values (-5); -- fails
|
|
||||||
insert into domcontest values (42); -- fails
|
|
||||||
insert into domcontest values (5);
|
|
||||||
|
|
||||||
alter domain con drop constraint t;
|
|
||||||
insert into domcontest values (-5); --fails
|
|
||||||
insert into domcontest values (42);
|
|
||||||
|
|
||||||
-- cleanup
|
|
||||||
drop domain ddef1 restrict;
|
drop domain ddef1 restrict;
|
||||||
drop domain ddef2 restrict;
|
drop domain ddef2 restrict;
|
||||||
drop domain ddef3 restrict;
|
drop domain ddef3 restrict;
|
||||||
|
Loading…
Reference in New Issue
Block a user