Commit ea4686e3 authored by Tom Lane's avatar Tom Lane

Implement CREATE/DROP OPERATOR CLASS. Work still remains: need more

documentation (xindex.sgml should be rewritten), need to teach pg_dump
about it, need to update contrib modules that currently build pg_opclass
entries by hand.  Original patch by Bill Studenmund, grammar adjustments
and general update for 7.3 by Tom Lane.
parent b9459c6a
This diff is collapsed.
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.42 2002/07/22 08:57:15 ishii Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/allfiles.sgml,v 1.43 2002/07/29 22:14:10 tgl 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.
--> -->
...@@ -61,6 +61,7 @@ Complete list of usable sgml source files in this directory. ...@@ -61,6 +61,7 @@ Complete list of usable sgml source files in this directory.
<!entity createIndex system "create_index.sgml"> <!entity createIndex system "create_index.sgml">
<!entity createLanguage system "create_language.sgml"> <!entity createLanguage system "create_language.sgml">
<!entity createOperator system "create_operator.sgml"> <!entity createOperator system "create_operator.sgml">
<!entity createOperatorClass system "create_opclass.sgml">
<!entity createRule system "create_rule.sgml"> <!entity createRule system "create_rule.sgml">
<!entity createSchema system "create_schema.sgml"> <!entity createSchema system "create_schema.sgml">
<!entity createSequence system "create_sequence.sgml"> <!entity createSequence system "create_sequence.sgml">
...@@ -82,6 +83,7 @@ Complete list of usable sgml source files in this directory. ...@@ -82,6 +83,7 @@ Complete list of usable sgml source files in this directory.
<!entity dropIndex system "drop_index.sgml"> <!entity dropIndex system "drop_index.sgml">
<!entity dropLanguage system "drop_language.sgml"> <!entity dropLanguage system "drop_language.sgml">
<!entity dropOperator system "drop_operator.sgml"> <!entity dropOperator system "drop_operator.sgml">
<!entity dropOperatorClass system "drop_opclass.sgml">
<!entity dropRule system "drop_rule.sgml"> <!entity dropRule system "drop_rule.sgml">
<!entity dropSchema system "drop_schema.sgml"> <!entity dropSchema system "drop_schema.sgml">
<!entity dropSequence system "drop_sequence.sgml"> <!entity dropSequence system "drop_sequence.sgml">
......
This diff is collapsed.
<!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_opclass.sgml,v 1.1 2002/07/29 22:14:10 tgl Exp $
PostgreSQL documentation
-->
<refentry id="SQL-DROPOPCLASS">
<refmeta>
<refentrytitle id="SQL-DROPOPCLASS-TITLE">DROP OPERATOR CLASS</refentrytitle>
<refmiscinfo>SQL - Language Statements</refmiscinfo>
</refmeta>
<refnamediv>
<refname>
DROP OPERATOR CLASS
</refname>
<refpurpose>
remove a user-defined operator class
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<refsynopsisdivinfo>
<date>2002-07-28</date>
</refsynopsisdivinfo>
<synopsis>
DROP OPERATOR CLASS <replaceable class="PARAMETER">name</replaceable> USING <replaceable class="PARAMETER">access_method</replaceable> [ CASCADE | RESTRICT ]
</synopsis>
<refsect2 id="R2-SQL-DROPOPCLASS-1">
<refsect2info>
<date>2002-07-28</date>
</refsect2info>
<title>
Inputs
</title>
<para>
<variablelist>
<varlistentry>
<term><replaceable class="parameter">name</replaceable></term>
<listitem>
<para>
The name (optionally schema-qualified) of an existing operator class.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><replaceable class="parameter">access_method</replaceable></term>
<listitem>
<para>
The name of the index access method the operator class is for.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>CASCADE</term>
<listitem>
<para>
Automatically drop objects that depend on the operator class.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>RESTRICT</term>
<listitem>
<para>
Refuse to drop the operator class if there are any dependent objects.
This is the default.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
<refsect2 id="R2-SQL-DROPOPCLASS-2">
<refsect2info>
<date>2002-07-28</date>
</refsect2info>
<title>
Outputs
</title>
<para>
<variablelist>
<varlistentry>
<term><computeroutput>
DROP OPERATOR CLASS
</computeroutput></term>
<listitem>
<para>
The message returned if the command is successful.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect2>
</refsynopsisdiv>
<refsect1 id="R1-SQL-DROPOPCLASS-1">
<refsect1info>
<date>2002-07-28</date>
</refsect1info>
<title>
Description
</title>
<para>
<command>DROP OPERATOR CLASS</command> drops an existing operator class
from the database.
To execute this command you must be the owner of the operator class.
</para>
<refsect2 id="R2-SQL-DROPOPCLASS-3">
<refsect2info>
<date>2002-07-28</date>
</refsect2info>
<title>
Notes
</title>
<para>
The <command>DROP OPERATOR CLASS</command> statement is a
<productname>PostgreSQL</productname>
language extension.
</para>
<para>
Refer to
<xref linkend="sql-createopclass" endterm="sql-createopclass-title">
for information on how to create operator classes.
</para>
</refsect2>
</refsect1>
<refsect1 id="R1-SQL-DROPOPCLASS-2">
<title>
Usage
</title>
<para>
Remove btree operator class <literal>widget_ops</literal>:
<programlisting>
DROP OPERATOR CLASS widget_ops USING btree;
</programlisting>
This command will not execute if there are any existing indexes
that use the operator class. Add <literal>CASCADE</> to drop
such indexes along with the operator class.
</para>
</refsect1>
<refsect1 id="R1-SQL-DROPOPCLASS-3">
<title>
Compatibility
</title>
<refsect2 id="R2-SQL-DROPOPCLASS-4">
<refsect2info>
<date>2002-07-28</date>
</refsect2info>
<title>
SQL92
</title>
<para>
There is no <command>DROP OPERATOR CLASS</command> in
<acronym>SQL92</acronym>.
</para>
</refsect2>
</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:
-->
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_operator.sgml,v 1.17 2002/07/12 18:43:13 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/ref/drop_operator.sgml,v 1.18 2002/07/29 22:14:10 tgl Exp $
PostgreSQL documentation PostgreSQL documentation
--> -->
...@@ -172,10 +172,6 @@ ERROR: RemoveOperator: right unary operator '<replaceable class="PARAMETER">oper ...@@ -172,10 +172,6 @@ ERROR: RemoveOperator: right unary operator '<replaceable class="PARAMETER">oper
<xref linkend="sql-createoperator" endterm="sql-createoperator-title"> <xref linkend="sql-createoperator" endterm="sql-createoperator-title">
for information on how to create operators. for information on how to create operators.
</para> </para>
<para>
It is the user's responsibility to remove any access method
operator classes that rely on the deleted operator.
</para>
</refsect2> </refsect2>
</refsect1> </refsect1>
......
<!-- reference.sgml <!-- reference.sgml
$Header: /cvsroot/pgsql/doc/src/sgml/reference.sgml,v 1.31 2002/07/22 08:57:15 ishii Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/reference.sgml,v 1.32 2002/07/29 22:14:10 tgl Exp $
PostgreSQL Reference Manual PostgreSQL Reference Manual
--> -->
...@@ -70,6 +70,7 @@ PostgreSQL Reference Manual ...@@ -70,6 +70,7 @@ PostgreSQL Reference Manual
&createIndex; &createIndex;
&createLanguage; &createLanguage;
&createOperator; &createOperator;
&createOperatorClass;
&createRule; &createRule;
&createSchema; &createSchema;
&createSequence; &createSequence;
...@@ -91,6 +92,7 @@ PostgreSQL Reference Manual ...@@ -91,6 +92,7 @@ PostgreSQL Reference Manual
&dropIndex; &dropIndex;
&dropLanguage; &dropLanguage;
&dropOperator; &dropOperator;
&dropOperatorClass;
&dropRule; &dropRule;
&dropSchema; &dropSchema;
&dropSequence; &dropSequence;
......
<!-- <!--
$Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.143 2002/07/20 15:12:55 tgl Exp $ $Header: /cvsroot/pgsql/doc/src/sgml/release.sgml,v 1.144 2002/07/29 22:14:10 tgl Exp $
--> -->
<appendix id="release"> <appendix id="release">
...@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without ...@@ -24,6 +24,7 @@ CDATA means the content is "SGML-free", so you can write without
worries about funny characters. worries about funny characters.
--> -->
<literallayout><![CDATA[ <literallayout><![CDATA[
CREATE OPERATOR CLASS/DROP OPERATOR CLASS
CREATE CAST/DROP CAST CREATE CAST/DROP CAST
Sequences created by SERIAL column definitions now auto-drop with the column Sequences created by SERIAL column definitions now auto-drop with the column
Most forms of DROP now support RESTRICT and CASCADE options Most forms of DROP now support RESTRICT and CASCADE options
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.71 2002/07/20 05:16:56 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.72 2002/07/29 22:14:10 tgl Exp $
* *
* NOTES * NOTES
* See acl.h. * See acl.h.
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "catalog/pg_group.h" #include "catalog/pg_group.h"
#include "catalog/pg_language.h" #include "catalog/pg_language.h"
#include "catalog/pg_namespace.h" #include "catalog/pg_namespace.h"
#include "catalog/pg_opclass.h"
#include "catalog/pg_operator.h" #include "catalog/pg_operator.h"
#include "catalog/pg_proc.h" #include "catalog/pg_proc.h"
#include "catalog/pg_shadow.h" #include "catalog/pg_shadow.h"
...@@ -1369,3 +1370,30 @@ pg_namespace_ownercheck(Oid nsp_oid, Oid userid) ...@@ -1369,3 +1370,30 @@ pg_namespace_ownercheck(Oid nsp_oid, Oid userid)
return userid == owner_id; return userid == owner_id;
} }
/*
* Ownership check for an operator class (specified by OID).
*/
bool
pg_opclass_ownercheck(Oid opc_oid, Oid userid)
{
HeapTuple tuple;
AclId owner_id;
/* Superusers bypass all permission checking. */
if (superuser_arg(userid))
return true;
tuple = SearchSysCache(CLAOID,
ObjectIdGetDatum(opc_oid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "pg_opclass_ownercheck: operator class %u not found",
opc_oid);
owner_id = ((Form_pg_opclass) GETSTRUCT(tuple))->opcowner;
ReleaseSysCache(tuple);
return userid == owner_id;
}
This diff is collapsed.
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.186 2002/07/20 05:16:56 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.187 2002/07/29 22:14:10 tgl Exp $
* *
* *
* INTERFACE ROUTINES * INTERFACE ROUTINES
...@@ -712,7 +712,7 @@ index_create(Oid heapRelationId, ...@@ -712,7 +712,7 @@ index_create(Oid heapRelationId,
false, /* isDeferred */ false, /* isDeferred */
heapRelationId, heapRelationId,
indexInfo->ii_KeyAttrNumbers, indexInfo->ii_KeyAttrNumbers,
indexInfo->ii_NumIndexAttrs, indexInfo->ii_NumKeyAttrs,
InvalidOid, /* no domain */ InvalidOid, /* no domain */
InvalidOid, /* no foreign key */ InvalidOid, /* no foreign key */
NULL, NULL,
...@@ -732,7 +732,7 @@ index_create(Oid heapRelationId, ...@@ -732,7 +732,7 @@ index_create(Oid heapRelationId,
} }
else else
{ {
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++) for (i = 0; i < indexInfo->ii_NumKeyAttrs; i++)
{ {
referenced.classId = RelOid_pg_class; referenced.classId = RelOid_pg_class;
referenced.objectId = heapRelationId; referenced.objectId = heapRelationId;
...@@ -742,6 +742,16 @@ index_create(Oid heapRelationId, ...@@ -742,6 +742,16 @@ index_create(Oid heapRelationId,
} }
} }
/* Store dependency on operator classes */
referenced.classId = get_system_catalog_relid(OperatorClassRelationName);
for (i = 0; i < indexInfo->ii_NumIndexAttrs; i++)
{
referenced.objectId = classObjectId[i];
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);
}
/* Store the dependency on the function (if appropriate) */ /* Store the dependency on the function (if appropriate) */
if (OidIsValid(indexInfo->ii_FuncOid)) if (OidIsValid(indexInfo->ii_FuncOid))
{ {
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Makefile for backend/commands # Makefile for backend/commands
# #
# IDENTIFICATION # IDENTIFICATION
# $Header: /cvsroot/pgsql/src/backend/commands/Makefile,v 1.29 2002/07/11 07:39:27 ishii Exp $ # $Header: /cvsroot/pgsql/src/backend/commands/Makefile,v 1.30 2002/07/29 22:14:10 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -15,7 +15,8 @@ include $(top_builddir)/src/Makefile.global ...@@ -15,7 +15,8 @@ include $(top_builddir)/src/Makefile.global
OBJS = aggregatecmds.o analyze.o async.o cluster.o comment.o \ OBJS = aggregatecmds.o analyze.o async.o cluster.o comment.o \
conversioncmds.o copy.o \ conversioncmds.o copy.o \
dbcommands.o define.o explain.o functioncmds.o \ dbcommands.o define.o explain.o functioncmds.o \
indexcmds.o lockcmds.o operatorcmds.o portalcmds.o proclang.o \ indexcmds.o lockcmds.o operatorcmds.o opclasscmds.o \
portalcmds.o proclang.o \
schemacmds.o sequence.o tablecmds.o trigger.o typecmds.o user.o \ schemacmds.o sequence.o tablecmds.o trigger.o typecmds.o user.o \
vacuum.o vacuumlazy.o variable.o view.o vacuum.o vacuumlazy.o variable.o view.o
......
This diff is collapsed.
...@@ -15,7 +15,7 @@ ...@@ -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.197 2002/07/24 19:11:10 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.198 2002/07/29 22:14:10 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -2147,6 +2147,19 @@ _copyRemoveOperStmt(RemoveOperStmt *from) ...@@ -2147,6 +2147,19 @@ _copyRemoveOperStmt(RemoveOperStmt *from)
return newnode; return newnode;
} }
static RemoveOpClassStmt *
_copyRemoveOpClassStmt(RemoveOpClassStmt *from)
{
RemoveOpClassStmt *newnode = makeNode(RemoveOpClassStmt);
Node_Copy(from, newnode, opclassname);
if (from->amname)
newnode->amname = pstrdup(from->amname);
newnode->behavior = from->behavior;
return newnode;
}
static RenameStmt * static RenameStmt *
_copyRenameStmt(RenameStmt *from) _copyRenameStmt(RenameStmt *from)
{ {
...@@ -2252,6 +2265,36 @@ _copyCreateDomainStmt(CreateDomainStmt *from) ...@@ -2252,6 +2265,36 @@ _copyCreateDomainStmt(CreateDomainStmt *from)
return newnode; return newnode;
} }
static CreateOpClassStmt *
_copyCreateOpClassStmt(CreateOpClassStmt *from)
{
CreateOpClassStmt *newnode = makeNode(CreateOpClassStmt);
Node_Copy(from, newnode, opclassname);
if (from->amname)
newnode->amname = pstrdup(from->amname);
Node_Copy(from, newnode, datatype);
Node_Copy(from, newnode, items);
newnode->isDefault = from->isDefault;
return newnode;
}
static CreateOpClassItem *
_copyCreateOpClassItem(CreateOpClassItem *from)
{
CreateOpClassItem *newnode = makeNode(CreateOpClassItem);
newnode->itemtype = from->itemtype;
Node_Copy(from, newnode, name);
Node_Copy(from, newnode, args);
newnode->number = from->number;
newnode->recheck = from->recheck;
Node_Copy(from, newnode, storedtype);
return newnode;
}
static CreatedbStmt * static CreatedbStmt *
_copyCreatedbStmt(CreatedbStmt *from) _copyCreatedbStmt(CreatedbStmt *from)
{ {
...@@ -2872,6 +2915,9 @@ copyObject(void *from) ...@@ -2872,6 +2915,9 @@ copyObject(void *from)
case T_RemoveOperStmt: case T_RemoveOperStmt:
retval = _copyRemoveOperStmt(from); retval = _copyRemoveOperStmt(from);
break; break;
case T_RemoveOpClassStmt:
retval = _copyRemoveOpClassStmt(from);
break;
case T_RenameStmt: case T_RenameStmt:
retval = _copyRenameStmt(from); retval = _copyRenameStmt(from);
break; break;
...@@ -2899,6 +2945,12 @@ copyObject(void *from) ...@@ -2899,6 +2945,12 @@ copyObject(void *from)
case T_CreateDomainStmt: case T_CreateDomainStmt:
retval = _copyCreateDomainStmt(from); retval = _copyCreateDomainStmt(from);
break; break;
case T_CreateOpClassStmt:
retval = _copyCreateOpClassStmt(from);
break;
case T_CreateOpClassItem:
retval = _copyCreateOpClassItem(from);
break;
case T_CreatedbStmt: case T_CreatedbStmt:
retval = _copyCreatedbStmt(from); retval = _copyCreatedbStmt(from);
break; break;
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,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.144 2002/07/24 19:11:10 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.145 2002/07/29 22:14:10 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -976,6 +976,18 @@ _equalRemoveOperStmt(RemoveOperStmt *a, RemoveOperStmt *b) ...@@ -976,6 +976,18 @@ _equalRemoveOperStmt(RemoveOperStmt *a, RemoveOperStmt *b)
return true; return true;
} }
static bool
_equalRemoveOpClassStmt(RemoveOpClassStmt *a, RemoveOpClassStmt *b)
{
if (!equal(a->opclassname, b->opclassname))
return false;
if (!equalstr(a->amname, b->amname))
return false;
if (a->behavior != b->behavior)
return false;
return true;
}
static bool static bool
_equalRenameStmt(RenameStmt *a, RenameStmt *b) _equalRenameStmt(RenameStmt *a, RenameStmt *b)
...@@ -1082,6 +1094,42 @@ _equalCreateDomainStmt(CreateDomainStmt *a, CreateDomainStmt *b) ...@@ -1082,6 +1094,42 @@ _equalCreateDomainStmt(CreateDomainStmt *a, CreateDomainStmt *b)
return true; return true;
} }
static bool
_equalCreateOpClassStmt(CreateOpClassStmt *a, CreateOpClassStmt *b)
{
if (!equal(a->opclassname, b->opclassname))
return false;
if (!equalstr(a->amname, b->amname))
return false;
if (!equal(a->datatype, b->datatype))
return false;
if (!equal(a->items, b->items))
return false;
if (a->isDefault != b->isDefault)
return false;
return true;
}
static bool
_equalCreateOpClassItem(CreateOpClassItem *a, CreateOpClassItem *b)
{
if (a->itemtype != b->itemtype)
return false;
if (!equal(a->name, b->name))
return false;
if (!equal(a->args, b->args))
return false;
if (a->number != b->number)
return false;
if (a->recheck != b->recheck)
return false;
if (!equal(a->storedtype, b->storedtype))
return false;
return true;
}
static bool static bool
_equalCreatedbStmt(CreatedbStmt *a, CreatedbStmt *b) _equalCreatedbStmt(CreatedbStmt *a, CreatedbStmt *b)
{ {
...@@ -2036,6 +2084,9 @@ equal(void *a, void *b) ...@@ -2036,6 +2084,9 @@ equal(void *a, void *b)
case T_RemoveOperStmt: case T_RemoveOperStmt:
retval = _equalRemoveOperStmt(a, b); retval = _equalRemoveOperStmt(a, b);
break; break;
case T_RemoveOpClassStmt:
retval = _equalRemoveOpClassStmt(a, b);
break;
case T_RenameStmt: case T_RenameStmt:
retval = _equalRenameStmt(a, b); retval = _equalRenameStmt(a, b);
break; break;
...@@ -2063,6 +2114,12 @@ equal(void *a, void *b) ...@@ -2063,6 +2114,12 @@ equal(void *a, void *b)
case T_CreateDomainStmt: case T_CreateDomainStmt:
retval = _equalCreateDomainStmt(a, b); retval = _equalCreateDomainStmt(a, b);
break; break;
case T_CreateOpClassStmt:
retval = _equalCreateOpClassStmt(a, b);
break;
case T_CreateOpClassItem:
retval = _equalCreateOpClassItem(a, b);
break;
case T_CreatedbStmt: case T_CreatedbStmt:
retval = _equalCreatedbStmt(a, b); retval = _equalCreatedbStmt(a, b);
break; break;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.349 2002/07/24 19:11:10 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.350 2002/07/29 22:14:10 tgl Exp $
* *
* HISTORY * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -136,11 +136,11 @@ static void doNegateFloat(Value *v); ...@@ -136,11 +136,11 @@ static void doNegateFloat(Value *v);
AlterTableStmt, AlterUserStmt, AlterUserSetStmt, AlterTableStmt, AlterUserStmt, AlterUserSetStmt,
AnalyzeStmt, ClosePortalStmt, ClusterStmt, CommentStmt, AnalyzeStmt, ClosePortalStmt, ClusterStmt, CommentStmt,
ConstraintsSetStmt, CopyStmt, CreateAsStmt, CreateCastStmt, ConstraintsSetStmt, CopyStmt, CreateAsStmt, CreateCastStmt,
CreateDomainStmt, CreateGroupStmt, CreatePLangStmt, CreateDomainStmt, CreateGroupStmt, CreateOpClassStmt, CreatePLangStmt,
CreateSchemaStmt, CreateSeqStmt, CreateStmt, CreateSchemaStmt, CreateSeqStmt, CreateStmt,
CreateAssertStmt, CreateTrigStmt, CreateUserStmt, CreateAssertStmt, CreateTrigStmt, CreateUserStmt,
CreatedbStmt, CursorStmt, DefineStmt, DeleteStmt, CreatedbStmt, CursorStmt, DefineStmt, DeleteStmt,
DropGroupStmt, DropPLangStmt, DropStmt, DropGroupStmt, DropOpClassStmt, DropPLangStmt, DropStmt,
DropAssertStmt, DropTrigStmt, DropRuleStmt, DropCastStmt, DropAssertStmt, DropTrigStmt, DropRuleStmt, DropCastStmt,
DropUserStmt, DropdbStmt, ExplainStmt, FetchStmt, DropUserStmt, DropdbStmt, ExplainStmt, FetchStmt,
GrantStmt, IndexStmt, InsertStmt, ListenStmt, LoadStmt, GrantStmt, IndexStmt, InsertStmt, ListenStmt, LoadStmt,
...@@ -156,7 +156,7 @@ static void doNegateFloat(Value *v); ...@@ -156,7 +156,7 @@ static void doNegateFloat(Value *v);
%type <node> select_no_parens, select_with_parens, select_clause, %type <node> select_no_parens, select_with_parens, select_clause,
simple_select simple_select
%type <node> alter_column_default %type <node> alter_column_default, opclass_item
%type <ival> add_drop %type <ival> add_drop
%type <dbehavior> opt_drop_behavior %type <dbehavior> opt_drop_behavior
...@@ -218,7 +218,7 @@ static void doNegateFloat(Value *v); ...@@ -218,7 +218,7 @@ static void doNegateFloat(Value *v);
target_list, update_target_list, insert_column_list, target_list, update_target_list, insert_column_list,
insert_target_list, def_list, opt_indirection, insert_target_list, def_list, opt_indirection,
group_clause, TriggerFuncArgs, select_limit, group_clause, TriggerFuncArgs, select_limit,
opt_select_limit opt_select_limit, opclass_item_list
%type <range> into_clause, OptTempTableName %type <range> into_clause, OptTempTableName
...@@ -240,7 +240,7 @@ static void doNegateFloat(Value *v); ...@@ -240,7 +240,7 @@ static void doNegateFloat(Value *v);
%type <boolean> opt_instead, opt_cursor %type <boolean> opt_instead, opt_cursor
%type <boolean> index_opt_unique, opt_verbose, opt_full %type <boolean> index_opt_unique, opt_verbose, opt_full
%type <boolean> opt_freeze, opt_default %type <boolean> opt_freeze, opt_default, opt_recheck
%type <defelt> opt_binary, opt_oids, copy_delimiter %type <defelt> opt_binary, opt_oids, copy_delimiter
%type <boolean> copy_from %type <boolean> copy_from
...@@ -326,7 +326,7 @@ static void doNegateFloat(Value *v); ...@@ -326,7 +326,7 @@ static void doNegateFloat(Value *v);
BOOLEAN, BY, BOOLEAN, BY,
CACHE, CALLED, CASCADE, CASE, CAST, CHAIN, CHAR_P, CACHE, CALLED, CASCADE, CASE, CAST, CHAIN, CHAR_P,
CHARACTER, CHARACTERISTICS, CHECK, CHECKPOINT, CLOSE, CHARACTER, CHARACTERISTICS, CHECK, CHECKPOINT, CLASS, CLOSE,
CLUSTER, COALESCE, COLLATE, COLUMN, COMMENT, COMMIT, CLUSTER, COALESCE, COLLATE, COLUMN, COMMENT, COMMIT,
COMMITTED, CONSTRAINT, CONSTRAINTS, CONVERSION_P, COPY, CREATE, CREATEDB, COMMITTED, CONSTRAINT, CONSTRAINTS, CONVERSION_P, COPY, CREATE, CREATEDB,
CREATEUSER, CROSS, CURRENT_DATE, CURRENT_TIME, CREATEUSER, CROSS, CURRENT_DATE, CURRENT_TIME,
...@@ -371,7 +371,7 @@ static void doNegateFloat(Value *v); ...@@ -371,7 +371,7 @@ static void doNegateFloat(Value *v);
PRECISION, PRIMARY, PRIOR, PRIVILEGES, PROCEDURE, PRECISION, PRIMARY, PRIOR, PRIVILEGES, PROCEDURE,
PROCEDURAL, PROCEDURAL,
READ, REAL, REFERENCES, REINDEX, RELATIVE, RENAME, REPLACE, READ, REAL, RECHECK, REFERENCES, REINDEX, RELATIVE, RENAME, REPLACE,
RESET, RESTRICT, RETURNS, REVOKE, RIGHT, ROLLBACK, ROW, RESET, RESTRICT, RETURNS, REVOKE, RIGHT, ROLLBACK, ROW,
RULE, RULE,
...@@ -481,6 +481,7 @@ stmt : ...@@ -481,6 +481,7 @@ stmt :
| CreateSchemaStmt | CreateSchemaStmt
| CreateGroupStmt | CreateGroupStmt
| CreateSeqStmt | CreateSeqStmt
| CreateOpClassStmt
| CreatePLangStmt | CreatePLangStmt
| CreateAssertStmt | CreateAssertStmt
| CreateTrigStmt | CreateTrigStmt
...@@ -492,6 +493,7 @@ stmt : ...@@ -492,6 +493,7 @@ stmt :
| CommentStmt | CommentStmt
| DropCastStmt | DropCastStmt
| DropGroupStmt | DropGroupStmt
| DropOpClassStmt
| DropPLangStmt | DropPLangStmt
| DropAssertStmt | DropAssertStmt
| DropTrigStmt | DropTrigStmt
...@@ -2265,6 +2267,93 @@ def_arg: func_return { $$ = (Node *)$1; } ...@@ -2265,6 +2267,93 @@ def_arg: func_return { $$ = (Node *)$1; }
; ;
/*****************************************************************************
*
* QUERIES :
* CREATE OPERATOR CLASS ...
* DROP OPERATOR CLASS ...
*
*****************************************************************************/
CreateOpClassStmt:
CREATE OPERATOR CLASS any_name opt_default FOR TYPE_P Typename
USING access_method AS opclass_item_list
{
CreateOpClassStmt *n = makeNode(CreateOpClassStmt);
n->opclassname = $4;
n->isDefault = $5;
n->datatype = $8;
n->amname = $10;
n->items = $12;
$$ = (Node *) n;
}
;
opclass_item_list:
opclass_item { $$ = makeList1($1); }
| opclass_item_list ',' opclass_item { $$ = lappend($1, $3); }
;
opclass_item:
OPERATOR Iconst any_operator opt_recheck
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_OPERATOR;
n->name = $3;
n->args = NIL;
n->number = $2;
n->recheck = $4;
$$ = (Node *) n;
}
| OPERATOR Iconst any_operator '(' oper_argtypes ')' opt_recheck
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_OPERATOR;
n->name = $3;
n->args = $5;
n->number = $2;
n->recheck = $7;
$$ = (Node *) n;
}
| FUNCTION Iconst func_name func_args
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_FUNCTION;
n->name = $3;
n->args = $4;
n->number = $2;
$$ = (Node *) n;
}
| STORAGE Typename
{
CreateOpClassItem *n = makeNode(CreateOpClassItem);
n->itemtype = OPCLASS_ITEM_STORAGETYPE;
n->storedtype = $2;
$$ = (Node *) n;
}
;
opt_default: DEFAULT { $$ = TRUE; }
| /*EMPTY*/ { $$ = FALSE; }
;
opt_recheck: RECHECK { $$ = TRUE; }
| /*EMPTY*/ { $$ = FALSE; }
;
DropOpClassStmt:
DROP OPERATOR CLASS any_name USING access_method opt_drop_behavior
{
RemoveOpClassStmt *n = makeNode(RemoveOpClassStmt);
n->opclassname = $4;
n->amname = $6;
n->behavior = $7;
$$ = (Node *) n;
}
;
/***************************************************************************** /*****************************************************************************
* *
* QUERY: * QUERY:
...@@ -3655,10 +3744,6 @@ CreateConversionStmt: ...@@ -3655,10 +3744,6 @@ CreateConversionStmt:
} }
; ;
opt_default: DEFAULT { $$ = TRUE; }
| /*EMPTY*/ { $$ = FALSE; }
;
/***************************************************************************** /*****************************************************************************
* *
* QUERY: * QUERY:
...@@ -6624,6 +6709,7 @@ unreserved_keyword: ...@@ -6624,6 +6709,7 @@ unreserved_keyword:
| CHAIN | CHAIN
| CHARACTERISTICS | CHARACTERISTICS
| CHECKPOINT | CHECKPOINT
| CLASS
| CLOSE | CLOSE
| CLUSTER | CLUSTER
| COMMENT | COMMENT
...@@ -6715,6 +6801,7 @@ unreserved_keyword: ...@@ -6715,6 +6801,7 @@ unreserved_keyword:
| PROCEDURAL | PROCEDURAL
| PROCEDURE | PROCEDURE
| READ | READ
| RECHECK
| REINDEX | REINDEX
| RELATIVE | RELATIVE
| RENAME | RENAME
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.122 2002/07/18 23:11:28 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.123 2002/07/29 22:14:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -68,6 +68,7 @@ static const ScanKeyword ScanKeywords[] = { ...@@ -68,6 +68,7 @@ static const ScanKeyword ScanKeywords[] = {
{"characteristics", CHARACTERISTICS}, {"characteristics", CHARACTERISTICS},
{"check", CHECK}, {"check", CHECK},
{"checkpoint", CHECKPOINT}, {"checkpoint", CHECKPOINT},
{"class", CLASS},
{"close", CLOSE}, {"close", CLOSE},
{"cluster", CLUSTER}, {"cluster", CLUSTER},
{"coalesce", COALESCE}, {"coalesce", COALESCE},
...@@ -232,6 +233,7 @@ static const ScanKeyword ScanKeywords[] = { ...@@ -232,6 +233,7 @@ static const ScanKeyword ScanKeywords[] = {
{"procedure", PROCEDURE}, {"procedure", PROCEDURE},
{"read", READ}, {"read", READ},
{"real", REAL}, {"real", REAL},
{"recheck", RECHECK},
{"references", REFERENCES}, {"references", REFERENCES},
{"reindex", REINDEX}, {"reindex", REINDEX},
{"relative", RELATIVE}, {"relative", RELATIVE},
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.272 2002/07/18 23:11:28 petere Exp $ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.273 2002/07/29 22:14:11 tgl Exp $
* *
* NOTES * NOTES
* this is the "main" module of the postgres backend and * this is the "main" module of the postgres backend and
...@@ -1693,7 +1693,7 @@ PostgresMain(int argc, char *argv[], const char *username) ...@@ -1693,7 +1693,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.272 $ $Date: 2002/07/18 23:11:28 $\n"); puts("$Revision: 1.273 $ $Date: 2002/07/29 22:14:11 $\n");
} }
/* /*
...@@ -2452,6 +2452,14 @@ CreateCommandTag(Node *parsetree) ...@@ -2452,6 +2452,14 @@ CreateCommandTag(Node *parsetree)
tag = "DROP CAST"; tag = "DROP CAST";
break; break;
case T_CreateOpClassStmt:
tag = "CREATE OPERATOR CLASS";
break;
case T_RemoveOpClassStmt:
tag = "DROP OPERATOR CLASS";
break;
default: default:
elog(LOG, "CreateCommandTag: unknown parse node type %d", elog(LOG, "CreateCommandTag: unknown parse node type %d",
nodeTag(parsetree)); nodeTag(parsetree));
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.165 2002/07/25 10:07:11 ishii Exp $ * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.166 2002/07/29 22:14:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -836,6 +836,14 @@ ProcessUtility(Node *parsetree, ...@@ -836,6 +836,14 @@ ProcessUtility(Node *parsetree,
DropCast((DropCastStmt *) parsetree); DropCast((DropCastStmt *) parsetree);
break; break;
case T_CreateOpClassStmt:
DefineOpClass((CreateOpClassStmt *) parsetree);
break;
case T_RemoveOpClassStmt:
RemoveOpClass((RemoveOpClassStmt *) parsetree);
break;
default: default:
elog(ERROR, "ProcessUtility: command #%d unsupported", elog(ERROR, "ProcessUtility: command #%d unsupported",
nodeTag(parsetree)); nodeTag(parsetree));
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.71 2002/07/20 05:16:58 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.72 2002/07/29 22:14:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -280,23 +280,19 @@ regprocedurein(PG_FUNCTION_ARGS) ...@@ -280,23 +280,19 @@ regprocedurein(PG_FUNCTION_ARGS)
} }
/* /*
* regprocedureout - converts proc OID to "pro_name(args)" * format_procedure - converts proc OID to "pro_name(args)"
*
* This exports the useful functionality of regprocedureout for use
* in other backend modules. The result is a palloc'd string.
*/ */
Datum char *
regprocedureout(PG_FUNCTION_ARGS) format_procedure(Oid procedure_oid)
{ {
RegProcedure proid = PG_GETARG_OID(0);
char *result; char *result;
HeapTuple proctup; HeapTuple proctup;
if (proid == InvalidOid)
{
result = pstrdup("-");
PG_RETURN_CSTRING(result);
}
proctup = SearchSysCache(PROCOID, proctup = SearchSysCache(PROCOID,
ObjectIdGetDatum(proid), ObjectIdGetDatum(procedure_oid),
0, 0, 0); 0, 0, 0);
if (HeapTupleIsValid(proctup)) if (HeapTupleIsValid(proctup))
...@@ -316,7 +312,7 @@ regprocedureout(PG_FUNCTION_ARGS) ...@@ -316,7 +312,7 @@ regprocedureout(PG_FUNCTION_ARGS)
* Would this proc be found (given the right args) by regprocedurein? * Would this proc be found (given the right args) by regprocedurein?
* If not, we need to qualify it. * If not, we need to qualify it.
*/ */
if (FunctionIsVisible(proid)) if (FunctionIsVisible(procedure_oid))
nspname = NULL; nspname = NULL;
else else
nspname = get_namespace_name(procform->pronamespace); nspname = get_namespace_name(procform->pronamespace);
...@@ -344,9 +340,26 @@ regprocedureout(PG_FUNCTION_ARGS) ...@@ -344,9 +340,26 @@ regprocedureout(PG_FUNCTION_ARGS)
{ {
/* If OID doesn't match any pg_proc entry, return it numerically */ /* If OID doesn't match any pg_proc entry, return it numerically */
result = (char *) palloc(NAMEDATALEN); result = (char *) palloc(NAMEDATALEN);
snprintf(result, NAMEDATALEN, "%u", proid); snprintf(result, NAMEDATALEN, "%u", procedure_oid);
} }
return result;
}
/*
* regprocedureout - converts proc OID to "pro_name(args)"
*/
Datum
regprocedureout(PG_FUNCTION_ARGS)
{
RegProcedure proid = PG_GETARG_OID(0);
char *result;
if (proid == InvalidOid)
result = pstrdup("-");
else
result = format_procedure(proid);
PG_RETURN_CSTRING(result); PG_RETURN_CSTRING(result);
} }
...@@ -602,23 +615,19 @@ regoperatorin(PG_FUNCTION_ARGS) ...@@ -602,23 +615,19 @@ regoperatorin(PG_FUNCTION_ARGS)
} }
/* /*
* regoperatorout - converts operator OID to "opr_name(args)" * format_operator - converts operator OID to "opr_name(args)"
*
* This exports the useful functionality of regoperatorout for use
* in other backend modules. The result is a palloc'd string.
*/ */
Datum char *
regoperatorout(PG_FUNCTION_ARGS) format_operator(Oid operator_oid)
{ {
Oid oprid = PG_GETARG_OID(0);
char *result; char *result;
HeapTuple opertup; HeapTuple opertup;
if (oprid == InvalidOid)
{
result = pstrdup("0");
PG_RETURN_CSTRING(result);
}
opertup = SearchSysCache(OPEROID, opertup = SearchSysCache(OPEROID,
ObjectIdGetDatum(oprid), ObjectIdGetDatum(operator_oid),
0, 0, 0); 0, 0, 0);
if (HeapTupleIsValid(opertup)) if (HeapTupleIsValid(opertup))
...@@ -636,7 +645,7 @@ regoperatorout(PG_FUNCTION_ARGS) ...@@ -636,7 +645,7 @@ regoperatorout(PG_FUNCTION_ARGS)
* Would this oper be found (given the right args) by regoperatorin? * Would this oper be found (given the right args) by regoperatorin?
* If not, we need to qualify it. * If not, we need to qualify it.
*/ */
if (!OperatorIsVisible(oprid)) if (!OperatorIsVisible(operator_oid))
{ {
nspname = get_namespace_name(operform->oprnamespace); nspname = get_namespace_name(operform->oprnamespace);
appendStringInfo(&buf, "%s.", appendStringInfo(&buf, "%s.",
...@@ -665,9 +674,26 @@ regoperatorout(PG_FUNCTION_ARGS) ...@@ -665,9 +674,26 @@ regoperatorout(PG_FUNCTION_ARGS)
{ {
/* If OID doesn't match any pg_operator entry, return it numerically */ /* If OID doesn't match any pg_operator entry, return it numerically */
result = (char *) palloc(NAMEDATALEN); result = (char *) palloc(NAMEDATALEN);
snprintf(result, NAMEDATALEN, "%u", oprid); snprintf(result, NAMEDATALEN, "%u", operator_oid);
} }
return result;
}
/*
* regoperatorout - converts operator OID to "opr_name(args)"
*/
Datum
regoperatorout(PG_FUNCTION_ARGS)
{
Oid oprid = PG_GETARG_OID(0);
char *result;
if (oprid == InvalidOid)
result = pstrdup("0");
else
result = format_operator(oprid);
PG_RETURN_CSTRING(result); PG_RETURN_CSTRING(result);
} }
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,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
# #
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.162 2002/07/24 19:11:11 petere Exp $ # $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.163 2002/07/29 22:14:11 tgl Exp $
# #
#------------------------------------------------------------------------- #-------------------------------------------------------------------------
...@@ -708,14 +708,15 @@ $ECHO_N "initializing pg_depend... "$ECHO_C ...@@ -708,14 +708,15 @@ $ECHO_N "initializing pg_depend... "$ECHO_C
-- First delete any already-made entries; PINs override all else, and must -- First delete any already-made entries; PINs override all else, and must
-- be the only entries for their objects. -- be the only entries for their objects.
DELETE FROM pg_depend; DELETE FROM pg_depend;
INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_cast;
INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_class; INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_class;
INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_proc; INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_proc;
INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_type; INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_type;
INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_cast;
INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_constraint; INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_constraint;
INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_attrdef; INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_attrdef;
INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_language; INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_language;
INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_operator; INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_operator;
INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_opclass;
INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_rewrite; INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_rewrite;
INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_trigger; INSERT INTO pg_depend SELECT 0,0,0, tableoid,oid,0, 'p' FROM pg_trigger;
-- restriction here to avoid pinning the public namespace -- restriction here to avoid pinning the public namespace
......
...@@ -8,7 +8,7 @@ ...@@ -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_am.h,v 1.22 2002/06/20 20:29:43 momjian Exp $ * $Id: pg_am.h,v 1.23 2002/07/29 22:14:11 tgl Exp $
* *
* NOTES * NOTES
* the genbki.sh script reads this file and generates .bki * the genbki.sh script reads this file and generates .bki
...@@ -107,5 +107,6 @@ DATA(insert OID = 405 ( hash PGUID 1 1 0 f f f t hashgettuple hashinsert hashbe ...@@ -107,5 +107,6 @@ DATA(insert OID = 405 ( hash PGUID 1 1 0 f f f t hashgettuple hashinsert hashbe
DESCR("hash index access method"); DESCR("hash index access method");
DATA(insert OID = 783 ( gist PGUID 100 7 0 f t f f gistgettuple gistinsert gistbeginscan gistrescan gistendscan gistmarkpos gistrestrpos gistbuild gistbulkdelete gistcostestimate )); DATA(insert OID = 783 ( gist PGUID 100 7 0 f t f f gistgettuple gistinsert gistbeginscan gistrescan gistendscan gistmarkpos gistrestrpos gistbuild gistbulkdelete gistcostestimate ));
DESCR("GiST index access method"); DESCR("GiST index access method");
#define GIST_AM_OID 783
#endif /* PG_AM_H */ #endif /* PG_AM_H */
...@@ -7,7 +7,7 @@ ...@@ -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.42 2002/07/18 23:11:32 petere Exp $ * $Id: defrem.h,v 1.43 2002/07/29 22:14:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -59,6 +59,10 @@ extern void RemoveTypeById(Oid typeOid); ...@@ -59,6 +59,10 @@ extern void RemoveTypeById(Oid typeOid);
extern void DefineDomain(CreateDomainStmt *stmt); extern void DefineDomain(CreateDomainStmt *stmt);
extern void RemoveDomain(List *names, DropBehavior behavior); extern void RemoveDomain(List *names, DropBehavior behavior);
extern void DefineOpClass(CreateOpClassStmt *stmt);
extern void RemoveOpClass(RemoveOpClassStmt *stmt);
extern void RemoveOpClassById(Oid opclassOid);
/* support routines in commands/define.c */ /* support routines in commands/define.c */
......
...@@ -7,7 +7,7 @@ ...@@ -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.113 2002/07/18 23:11:32 petere Exp $ * $Id: nodes.h,v 1.114 2002/07/29 22:14:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -201,6 +201,8 @@ typedef enum NodeTag ...@@ -201,6 +201,8 @@ typedef enum NodeTag
T_CreateConversionStmt, T_CreateConversionStmt,
T_CreateCastStmt, T_CreateCastStmt,
T_DropCastStmt, T_DropCastStmt,
T_CreateOpClassStmt,
T_RemoveOpClassStmt,
T_A_Expr = 700, T_A_Expr = 700,
T_ColumnRef, T_ColumnRef,
...@@ -235,6 +237,7 @@ typedef enum NodeTag ...@@ -235,6 +237,7 @@ typedef enum NodeTag
T_FuncWithArgs, T_FuncWithArgs,
T_PrivTarget, T_PrivTarget,
T_InsertDefault, T_InsertDefault,
T_CreateOpClassItem,
/* /*
* TAGS FOR FUNCTION-CALL CONTEXT AND RESULTINFO NODES (see fmgr.h) * TAGS FOR FUNCTION-CALL CONTEXT AND RESULTINFO NODES (see fmgr.h)
......
...@@ -7,7 +7,7 @@ ...@@ -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.194 2002/07/24 19:11:14 petere Exp $ * $Id: parsenodes.h,v 1.195 2002/07/29 22:14:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -1115,6 +1115,37 @@ typedef struct CreateDomainStmt ...@@ -1115,6 +1115,37 @@ typedef struct CreateDomainStmt
List *constraints; /* constraints (list of Constraint nodes) */ List *constraints; /* constraints (list of Constraint nodes) */
} CreateDomainStmt; } CreateDomainStmt;
/* ----------------------
* Create Operator Class Statement
* ----------------------
*/
typedef struct CreateOpClassStmt
{
NodeTag type;
List *opclassname; /* qualified name (list of Value strings) */
char *amname; /* name of index AM opclass is for */
TypeName *datatype; /* datatype of indexed column */
List *items; /* List of CreateOpClassItem nodes */
bool isDefault; /* Should be marked as default for type? */
} CreateOpClassStmt;
#define OPCLASS_ITEM_OPERATOR 1
#define OPCLASS_ITEM_FUNCTION 2
#define OPCLASS_ITEM_STORAGETYPE 3
typedef struct CreateOpClassItem
{
NodeTag type;
int itemtype; /* see codes above */
/* fields used for an operator or function item: */
List *name; /* operator or function name */
List *args; /* argument types */
int number; /* strategy num or support proc num */
bool recheck; /* only used for operators */
/* fields used for a storagetype item: */
TypeName *storedtype; /* datatype stored in index */
} CreateOpClassItem;
/* ---------------------- /* ----------------------
* Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement * Drop Table|Sequence|View|Index|Type|Domain|Conversion|Schema Statement
* ---------------------- * ----------------------
...@@ -1288,6 +1319,18 @@ typedef struct RemoveOperStmt ...@@ -1288,6 +1319,18 @@ typedef struct RemoveOperStmt
DropBehavior behavior; /* RESTRICT or CASCADE behavior */ DropBehavior behavior; /* RESTRICT or CASCADE behavior */
} RemoveOperStmt; } RemoveOperStmt;
/* ----------------------
* Drop Operator Class Statement
* ----------------------
*/
typedef struct RemoveOpClassStmt
{
NodeTag type;
List *opclassname; /* qualified name (list of Value strings) */
char *amname; /* name of index AM opclass is for */
DropBehavior behavior; /* RESTRICT or CASCADE behavior */
} RemoveOpClassStmt;
/* ---------------------- /* ----------------------
* Alter Object Rename Statement * Alter Object Rename Statement
* ---------------------- * ----------------------
......
...@@ -7,7 +7,7 @@ ...@@ -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: acl.h,v 1.45 2002/06/20 20:29:52 momjian Exp $ * $Id: acl.h,v 1.46 2002/07/29 22:14:11 tgl Exp $
* *
* NOTES * NOTES
* For backward-compatibility purposes we have to allow there * For backward-compatibility purposes we have to allow there
...@@ -209,5 +209,6 @@ extern bool pg_type_ownercheck(Oid type_oid, Oid userid); ...@@ -209,5 +209,6 @@ extern bool pg_type_ownercheck(Oid type_oid, Oid userid);
extern bool pg_oper_ownercheck(Oid oper_oid, Oid userid); extern bool pg_oper_ownercheck(Oid oper_oid, Oid userid);
extern bool pg_proc_ownercheck(Oid proc_oid, Oid userid); extern bool pg_proc_ownercheck(Oid proc_oid, Oid userid);
extern bool pg_namespace_ownercheck(Oid nsp_oid, Oid userid); extern bool pg_namespace_ownercheck(Oid nsp_oid, Oid userid);
extern bool pg_opclass_ownercheck(Oid opc_oid, Oid userid);
#endif /* ACL_H */ #endif /* ACL_H */
...@@ -7,7 +7,7 @@ ...@@ -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: builtins.h,v 1.187 2002/07/20 05:49:28 momjian Exp $ * $Id: builtins.h,v 1.188 2002/07/29 22:14:11 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -343,6 +343,8 @@ extern Datum regclassout(PG_FUNCTION_ARGS); ...@@ -343,6 +343,8 @@ extern Datum regclassout(PG_FUNCTION_ARGS);
extern Datum regtypein(PG_FUNCTION_ARGS); extern Datum regtypein(PG_FUNCTION_ARGS);
extern Datum regtypeout(PG_FUNCTION_ARGS); extern Datum regtypeout(PG_FUNCTION_ARGS);
extern List *stringToQualifiedNameList(const char *string, const char *caller); extern List *stringToQualifiedNameList(const char *string, const char *caller);
extern char *format_procedure(Oid procedure_oid);
extern char *format_operator(Oid operator_oid);
/* ruleutils.c */ /* ruleutils.c */
extern Datum pg_get_ruledef(PG_FUNCTION_ARGS); extern Datum pg_get_ruledef(PG_FUNCTION_ARGS);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment