mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Allow schema-qualified operator names to be used in the optional
arguments of CREATE OPERATOR.
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_operator.sgml,v 1.29 2002/05/18 15:44:47 petere Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/ref/create_operator.sgml,v 1.30 2002/08/10 19:01:53 tgl Exp $
|
||||||
PostgreSQL documentation
|
PostgreSQL documentation
|
||||||
-->
|
-->
|
||||||
|
|
||||||
@ -437,6 +437,15 @@ MYBOXES.description === box '((0,0), (1,1))'
|
|||||||
Refer to <command>DROP OPERATOR</command> to delete
|
Refer to <command>DROP OPERATOR</command> to delete
|
||||||
user-defined operators from a database.
|
user-defined operators from a database.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
To give a schema-qualified operator name in <replaceable
|
||||||
|
class="parameter">com_op</replaceable> or the other optional
|
||||||
|
arguments, use the <literal>OPERATOR()</> syntax, for example
|
||||||
|
<programlisting>
|
||||||
|
COMMUTATOR = OPERATOR(myschema.===) ,
|
||||||
|
</programlisting>
|
||||||
|
</para>
|
||||||
</refsect2>
|
</refsect2>
|
||||||
</refsect1>
|
</refsect1>
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!--
|
<!--
|
||||||
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.64 2002/08/05 19:43:31 petere Exp $
|
$Header: /cvsroot/pgsql/doc/src/sgml/syntax.sgml,v 1.65 2002/08/10 19:01:53 tgl Exp $
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<chapter id="sql-syntax">
|
<chapter id="sql-syntax">
|
||||||
@ -755,7 +755,7 @@ SELECT (5 !) - 6;
|
|||||||
</row>
|
</row>
|
||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry><token>LIKE</token> <token>ILIKE</token></entry>
|
<entry><token>LIKE</token> <token>ILIKE</token> <token>SIMILAR</token></entry>
|
||||||
<entry></entry>
|
<entry></entry>
|
||||||
<entry>string pattern matching</entry>
|
<entry>string pattern matching</entry>
|
||||||
</row>
|
</row>
|
||||||
@ -801,6 +801,17 @@ SELECT (5 !) - 6;
|
|||||||
the same precedence as the built-in <quote>+</quote> operator, no
|
the same precedence as the built-in <quote>+</quote> operator, no
|
||||||
matter what yours does.
|
matter what yours does.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
When a schema-qualified operator name is used in the
|
||||||
|
<literal>OPERATOR</> syntax, as for example in
|
||||||
|
<programlisting>
|
||||||
|
SELECT 3 OPERATOR(pg_catalog.+) 4;
|
||||||
|
</programlisting>
|
||||||
|
the <literal>OPERATOR</> construct is taken to have the default precedence
|
||||||
|
shown above for <quote>any other</> operator. This is true no matter
|
||||||
|
which specific operator name appears inside <literal>OPERATOR()</>.
|
||||||
|
</para>
|
||||||
</sect2>
|
</sect2>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.78 2002/06/20 20:29:27 momjian Exp $
|
* $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.79 2002/08/10 19:01:53 tgl Exp $
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* The "DefineFoo" routines take the parse tree and pick out the
|
* The "DefineFoo" routines take the parse tree and pick out the
|
||||||
@ -35,6 +35,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
#include "catalog/namespace.h"
|
||||||
#include "commands/defrem.h"
|
#include "commands/defrem.h"
|
||||||
#include "parser/parse_type.h"
|
#include "parser/parse_type.h"
|
||||||
#include "utils/int8.h"
|
#include "utils/int8.h"
|
||||||
@ -86,6 +87,8 @@ defGetString(DefElem *def)
|
|||||||
return strVal(def->arg);
|
return strVal(def->arg);
|
||||||
case T_TypeName:
|
case T_TypeName:
|
||||||
return TypeNameToString((TypeName *) def->arg);
|
return TypeNameToString((TypeName *) def->arg);
|
||||||
|
case T_List:
|
||||||
|
return NameListToString((List *) def->arg);
|
||||||
default:
|
default:
|
||||||
elog(ERROR, "Define: cannot interpret argument of \"%s\"",
|
elog(ERROR, "Define: cannot interpret argument of \"%s\"",
|
||||||
def->defname);
|
def->defname);
|
||||||
@ -156,6 +159,8 @@ defGetQualifiedName(DefElem *def)
|
|||||||
{
|
{
|
||||||
case T_TypeName:
|
case T_TypeName:
|
||||||
return ((TypeName *) def->arg)->names;
|
return ((TypeName *) def->arg)->names;
|
||||||
|
case T_List:
|
||||||
|
return (List *) def->arg;
|
||||||
case T_String:
|
case T_String:
|
||||||
/* Allow quoted name for backwards compatibility */
|
/* Allow quoted name for backwards compatibility */
|
||||||
return makeList1(def->arg);
|
return makeList1(def->arg);
|
||||||
@ -168,6 +173,9 @@ defGetQualifiedName(DefElem *def)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Extract a TypeName from a DefElem.
|
* Extract a TypeName from a DefElem.
|
||||||
|
*
|
||||||
|
* Note: we do not accept a List arg here, because the parser will only
|
||||||
|
* return a bare List when the name looks like an operator name.
|
||||||
*/
|
*/
|
||||||
TypeName *
|
TypeName *
|
||||||
defGetTypeName(DefElem *def)
|
defGetTypeName(DefElem *def)
|
||||||
@ -223,11 +231,14 @@ defGetTypeLength(DefElem *def)
|
|||||||
"variable") == 0)
|
"variable") == 0)
|
||||||
return -1; /* variable length */
|
return -1; /* variable length */
|
||||||
break;
|
break;
|
||||||
|
case T_List:
|
||||||
|
/* must be an operator name */
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
elog(ERROR, "Define: cannot interpret argument of \"%s\"",
|
elog(ERROR, "Define: cannot interpret argument of \"%s\"",
|
||||||
def->defname);
|
def->defname);
|
||||||
}
|
}
|
||||||
elog(ERROR, "Define: invalid argument for \"%s\"",
|
elog(ERROR, "Define: invalid argument for \"%s\": \"%s\"",
|
||||||
def->defname);
|
def->defname, defGetString(def));
|
||||||
return 0; /* keep compiler quiet */
|
return 0; /* keep compiler quiet */
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.357 2002/08/06 05:40:45 ishii Exp $
|
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.358 2002/08/10 19:01:53 tgl Exp $
|
||||||
*
|
*
|
||||||
* HISTORY
|
* HISTORY
|
||||||
* AUTHOR DATE MAJOR EVENT
|
* AUTHOR DATE MAJOR EVENT
|
||||||
@ -1307,27 +1307,19 @@ copy_opt_list:
|
|||||||
copy_opt_item:
|
copy_opt_item:
|
||||||
BINARY
|
BINARY
|
||||||
{
|
{
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("binary", (Node *)makeInteger(TRUE));
|
||||||
$$->defname = "binary";
|
|
||||||
$$->arg = (Node *)makeInteger(TRUE);
|
|
||||||
}
|
}
|
||||||
| OIDS
|
| OIDS
|
||||||
{
|
{
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("oids", (Node *)makeInteger(TRUE));
|
||||||
$$->defname = "oids";
|
|
||||||
$$->arg = (Node *)makeInteger(TRUE);
|
|
||||||
}
|
}
|
||||||
| DELIMITER opt_as Sconst
|
| DELIMITER opt_as Sconst
|
||||||
{
|
{
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("delimiter", (Node *)makeString($3));
|
||||||
$$->defname = "delimiter";
|
|
||||||
$$->arg = (Node *)makeString($3);
|
|
||||||
}
|
}
|
||||||
| NULL_P opt_as Sconst
|
| NULL_P opt_as Sconst
|
||||||
{
|
{
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("null", (Node *)makeString($3));
|
||||||
$$->defname = "null";
|
|
||||||
$$->arg = (Node *)makeString($3);
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -1336,9 +1328,7 @@ copy_opt_item:
|
|||||||
opt_binary:
|
opt_binary:
|
||||||
BINARY
|
BINARY
|
||||||
{
|
{
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("binary", (Node *)makeInteger(TRUE));
|
||||||
$$->defname = "binary";
|
|
||||||
$$->arg = (Node *)makeInteger(TRUE);
|
|
||||||
}
|
}
|
||||||
| /*EMPTY*/ { $$ = NULL; }
|
| /*EMPTY*/ { $$ = NULL; }
|
||||||
;
|
;
|
||||||
@ -1346,9 +1336,7 @@ opt_binary:
|
|||||||
opt_oids:
|
opt_oids:
|
||||||
WITH OIDS
|
WITH OIDS
|
||||||
{
|
{
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("oids", (Node *)makeInteger(TRUE));
|
||||||
$$->defname = "oids";
|
|
||||||
$$->arg = (Node *)makeInteger(TRUE);
|
|
||||||
}
|
}
|
||||||
| /*EMPTY*/ { $$ = NULL; }
|
| /*EMPTY*/ { $$ = NULL; }
|
||||||
;
|
;
|
||||||
@ -1357,9 +1345,7 @@ copy_delimiter:
|
|||||||
/* USING DELIMITERS kept for backward compatibility. 2002-06-15 */
|
/* USING DELIMITERS kept for backward compatibility. 2002-06-15 */
|
||||||
opt_using DELIMITERS Sconst
|
opt_using DELIMITERS Sconst
|
||||||
{
|
{
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("delimiter", (Node *)makeString($3));
|
||||||
$$->defname = "delimiter";
|
|
||||||
$$->arg = (Node *)makeString($3);
|
|
||||||
}
|
}
|
||||||
| /*EMPTY*/ { $$ = NULL; }
|
| /*EMPTY*/ { $$ = NULL; }
|
||||||
;
|
;
|
||||||
@ -2276,7 +2262,7 @@ def_elem: ColLabel '=' def_arg
|
|||||||
|
|
||||||
/* Note: any simple identifier will be returned as a type name! */
|
/* Note: any simple identifier will be returned as a type name! */
|
||||||
def_arg: func_return { $$ = (Node *)$1; }
|
def_arg: func_return { $$ = (Node *)$1; }
|
||||||
| all_Op { $$ = (Node *)makeString($1); }
|
| qual_all_Op { $$ = (Node *)$1; }
|
||||||
| NumericOnly { $$ = (Node *)$1; }
|
| NumericOnly { $$ = (Node *)$1; }
|
||||||
| Sconst { $$ = (Node *)makeString($1); }
|
| Sconst { $$ = (Node *)makeString($1); }
|
||||||
;
|
;
|
||||||
@ -3568,27 +3554,19 @@ createdb_opt_list:
|
|||||||
createdb_opt_item:
|
createdb_opt_item:
|
||||||
LOCATION opt_equal Sconst
|
LOCATION opt_equal Sconst
|
||||||
{
|
{
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("location", (Node *)makeString($3));
|
||||||
$$->defname = "location";
|
|
||||||
$$->arg = (Node *)makeString($3);
|
|
||||||
}
|
}
|
||||||
| LOCATION opt_equal DEFAULT
|
| LOCATION opt_equal DEFAULT
|
||||||
{
|
{
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("location", NULL);
|
||||||
$$->defname = "location";
|
|
||||||
$$->arg = NULL;
|
|
||||||
}
|
}
|
||||||
| TEMPLATE opt_equal name
|
| TEMPLATE opt_equal name
|
||||||
{
|
{
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("template", (Node *)makeString($3));
|
||||||
$$->defname = "template";
|
|
||||||
$$->arg = (Node *)makeString($3);
|
|
||||||
}
|
}
|
||||||
| TEMPLATE opt_equal DEFAULT
|
| TEMPLATE opt_equal DEFAULT
|
||||||
{
|
{
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("template", NULL);
|
||||||
$$->defname = "template";
|
|
||||||
$$->arg = NULL;
|
|
||||||
}
|
}
|
||||||
| ENCODING opt_equal Sconst
|
| ENCODING opt_equal Sconst
|
||||||
{
|
{
|
||||||
@ -3598,9 +3576,7 @@ createdb_opt_item:
|
|||||||
elog(ERROR, "%s is not a valid encoding name", $3);
|
elog(ERROR, "%s is not a valid encoding name", $3);
|
||||||
encoding = pg_char_to_encoding($3);
|
encoding = pg_char_to_encoding($3);
|
||||||
|
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("encoding", (Node *)makeInteger(encoding));
|
||||||
$$->defname = "encoding";
|
|
||||||
$$->arg = (Node *)makeInteger(encoding);
|
|
||||||
}
|
}
|
||||||
| ENCODING opt_equal Iconst
|
| ENCODING opt_equal Iconst
|
||||||
{
|
{
|
||||||
@ -3610,27 +3586,19 @@ createdb_opt_item:
|
|||||||
if (!strcmp(encoding_name,"") ||
|
if (!strcmp(encoding_name,"") ||
|
||||||
pg_valid_server_encoding(encoding_name) < 0)
|
pg_valid_server_encoding(encoding_name) < 0)
|
||||||
elog(ERROR, "%d is not a valid encoding code", $3);
|
elog(ERROR, "%d is not a valid encoding code", $3);
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("encoding", (Node *)makeInteger($3));
|
||||||
$$->defname = "encoding";
|
|
||||||
$$->arg = (Node *)makeInteger($3);
|
|
||||||
}
|
}
|
||||||
| ENCODING opt_equal DEFAULT
|
| ENCODING opt_equal DEFAULT
|
||||||
{
|
{
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("encoding", (Node *)makeInteger(-1));
|
||||||
$$->defname = "encoding";
|
|
||||||
$$->arg = (Node *)makeInteger(-1);
|
|
||||||
}
|
}
|
||||||
| OWNER opt_equal name
|
| OWNER opt_equal name
|
||||||
{
|
{
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("owner", (Node *)makeString($3));
|
||||||
$$->defname = "owner";
|
|
||||||
$$->arg = (Node *)makeString($3);
|
|
||||||
}
|
}
|
||||||
| OWNER opt_equal DEFAULT
|
| OWNER opt_equal DEFAULT
|
||||||
{
|
{
|
||||||
$$ = makeNode(DefElem);
|
$$ = makeDefElem("owner", NULL);
|
||||||
$$->defname = "owner";
|
|
||||||
$$->arg = NULL;
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user