2004-06-25 23:55:59 +02:00
|
|
|
<!--
|
2010-09-20 22:08:53 +02:00
|
|
|
doc/src/sgml/ref/alter_operator.sgml
|
2004-06-25 23:55:59 +02:00
|
|
|
PostgreSQL documentation
|
|
|
|
-->
|
|
|
|
|
2017-10-20 03:16:39 +02:00
|
|
|
<refentry id="sql-alteroperator">
|
2014-02-24 03:25:35 +01:00
|
|
|
<indexterm zone="sql-alteroperator">
|
|
|
|
<primary>ALTER OPERATOR</primary>
|
|
|
|
</indexterm>
|
|
|
|
|
2004-06-25 23:55:59 +02:00
|
|
|
<refmeta>
|
2010-04-03 09:23:02 +02:00
|
|
|
<refentrytitle>ALTER OPERATOR</refentrytitle>
|
2008-11-14 11:22:48 +01:00
|
|
|
<manvolnum>7</manvolnum>
|
2004-06-25 23:55:59 +02:00
|
|
|
<refmiscinfo>SQL - Language Statements</refmiscinfo>
|
|
|
|
</refmeta>
|
|
|
|
|
|
|
|
<refnamediv>
|
|
|
|
<refname>ALTER OPERATOR</refname>
|
|
|
|
<refpurpose>change the definition of an operator</refpurpose>
|
2010-11-23 21:27:50 +01:00
|
|
|
</refnamediv>
|
|
|
|
|
2004-06-25 23:55:59 +02:00
|
|
|
<refsynopsisdiv>
|
|
|
|
<synopsis>
|
Remove support for postfix (right-unary) operators.
This feature has been a thorn in our sides for a long time, causing
many grammatical ambiguity problems. It doesn't seem worth the
pain to continue to support it, so remove it.
There are some follow-on improvements we can make in the grammar,
but this commit only removes the bare minimum number of productions,
plus assorted backend support code.
Note that pg_dump and psql continue to have full support, since
they may be used against older servers. However, pg_dump warns
about postfix operators. There is also a check in pg_upgrade.
Documentation-wise, I (tgl) largely removed the "left unary"
terminology in favor of saying "prefix operator", which is
a more standard and IMO less confusing term.
I included a catversion bump, although no initial catalog data
changes here, to mark the boundary at which oprkind = 'r'
stopped being valid in pg_operator.
Mark Dilger, based on work by myself and Robert Haas;
review by John Naylor
Discussion: https://postgr.es/m/38ca86db-42ab-9b48-2902-337a0d6b8311@2ndquadrant.com
2020-09-18 01:38:05 +02:00
|
|
|
ALTER OPERATOR <replaceable>name</replaceable> ( { <replaceable>left_type</replaceable> | NONE } , <replaceable>right_type</replaceable> )
|
2020-09-17 11:39:28 +02:00
|
|
|
OWNER TO { <replaceable>new_owner</replaceable> | CURRENT_ROLE | CURRENT_USER | SESSION_USER }
|
Allow CURRENT/SESSION_USER to be used in certain commands
Commands such as ALTER USER, ALTER GROUP, ALTER ROLE, GRANT, and the
various ALTER OBJECT / OWNER TO, as well as ad-hoc clauses related to
roles such as the AUTHORIZATION clause of CREATE SCHEMA, the FOR clause
of CREATE USER MAPPING, and the FOR ROLE clause of ALTER DEFAULT
PRIVILEGES can now take the keywords CURRENT_USER and SESSION_USER as
user specifiers in place of an explicit user name.
This commit also fixes some quite ugly handling of special standards-
mandated syntax in CREATE USER MAPPING, which in particular would fail
to work in presence of a role named "current_user".
The special role specifiers PUBLIC and NONE also have more consistent
handling now.
Also take the opportunity to add location tracking to user specifiers.
Authors: Kyotaro Horiguchi. Heavily reworked by Álvaro Herrera.
Reviewed by: Rushabh Lathia, Adam Brightwell, Marti Raudsepp.
2015-03-09 19:41:54 +01:00
|
|
|
|
Remove support for postfix (right-unary) operators.
This feature has been a thorn in our sides for a long time, causing
many grammatical ambiguity problems. It doesn't seem worth the
pain to continue to support it, so remove it.
There are some follow-on improvements we can make in the grammar,
but this commit only removes the bare minimum number of productions,
plus assorted backend support code.
Note that pg_dump and psql continue to have full support, since
they may be used against older servers. However, pg_dump warns
about postfix operators. There is also a check in pg_upgrade.
Documentation-wise, I (tgl) largely removed the "left unary"
terminology in favor of saying "prefix operator", which is
a more standard and IMO less confusing term.
I included a catversion bump, although no initial catalog data
changes here, to mark the boundary at which oprkind = 'r'
stopped being valid in pg_operator.
Mark Dilger, based on work by myself and Robert Haas;
review by John Naylor
Discussion: https://postgr.es/m/38ca86db-42ab-9b48-2902-337a0d6b8311@2ndquadrant.com
2020-09-18 01:38:05 +02:00
|
|
|
ALTER OPERATOR <replaceable>name</replaceable> ( { <replaceable>left_type</replaceable> | NONE } , <replaceable>right_type</replaceable> )
|
2015-07-10 13:28:34 +02:00
|
|
|
SET SCHEMA <replaceable>new_schema</replaceable>
|
2015-07-14 17:17:55 +02:00
|
|
|
|
Remove support for postfix (right-unary) operators.
This feature has been a thorn in our sides for a long time, causing
many grammatical ambiguity problems. It doesn't seem worth the
pain to continue to support it, so remove it.
There are some follow-on improvements we can make in the grammar,
but this commit only removes the bare minimum number of productions,
plus assorted backend support code.
Note that pg_dump and psql continue to have full support, since
they may be used against older servers. However, pg_dump warns
about postfix operators. There is also a check in pg_upgrade.
Documentation-wise, I (tgl) largely removed the "left unary"
terminology in favor of saying "prefix operator", which is
a more standard and IMO less confusing term.
I included a catversion bump, although no initial catalog data
changes here, to mark the boundary at which oprkind = 'r'
stopped being valid in pg_operator.
Mark Dilger, based on work by myself and Robert Haas;
review by John Naylor
Discussion: https://postgr.es/m/38ca86db-42ab-9b48-2902-337a0d6b8311@2ndquadrant.com
2020-09-18 01:38:05 +02:00
|
|
|
ALTER OPERATOR <replaceable>name</replaceable> ( { <replaceable>left_type</replaceable> | NONE } , <replaceable>right_type</replaceable> )
|
2015-07-14 17:17:55 +02:00
|
|
|
SET ( { RESTRICT = { <replaceable class="parameter">res_proc</replaceable> | NONE }
|
|
|
|
| JOIN = { <replaceable class="parameter">join_proc</replaceable> | NONE }
|
|
|
|
} [, ... ] )
|
2004-06-25 23:55:59 +02:00
|
|
|
</synopsis>
|
|
|
|
</refsynopsisdiv>
|
2010-11-23 21:27:50 +01:00
|
|
|
|
2004-06-25 23:55:59 +02:00
|
|
|
<refsect1>
|
|
|
|
<title>Description</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
<command>ALTER OPERATOR</command> changes the definition of
|
2015-07-14 17:17:55 +02:00
|
|
|
an operator.
|
2004-06-25 23:55:59 +02:00
|
|
|
</para>
|
2005-10-14 00:44:51 +02:00
|
|
|
|
|
|
|
<para>
|
2017-10-09 03:44:17 +02:00
|
|
|
You must own the operator to use <command>ALTER OPERATOR</command>.
|
2005-10-14 00:44:51 +02:00
|
|
|
To alter the owner, you must also be a direct or indirect member of the new
|
|
|
|
owning role, and that role must have <literal>CREATE</literal> privilege on
|
|
|
|
the operator's schema. (These restrictions enforce that altering the owner
|
|
|
|
doesn't do anything you couldn't do by dropping and recreating the operator.
|
|
|
|
However, a superuser can alter ownership of any operator anyway.)
|
|
|
|
</para>
|
2004-06-25 23:55:59 +02:00
|
|
|
</refsect1>
|
2010-11-23 21:27:50 +01:00
|
|
|
|
2004-06-25 23:55:59 +02:00
|
|
|
<refsect1>
|
|
|
|
<title>Parameters</title>
|
|
|
|
|
|
|
|
<variablelist>
|
|
|
|
<varlistentry>
|
|
|
|
<term><replaceable class="parameter">name</replaceable></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The name (optionally schema-qualified) of an existing operator.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2009-09-19 12:23:27 +02:00
|
|
|
<term><replaceable class="parameter">left_type</replaceable></term>
|
2004-06-25 23:55:59 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The data type of the operator's left operand; write
|
|
|
|
<literal>NONE</literal> if the operator has no left operand.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2009-09-19 12:23:27 +02:00
|
|
|
<term><replaceable class="parameter">right_type</replaceable></term>
|
2004-06-25 23:55:59 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
Remove support for postfix (right-unary) operators.
This feature has been a thorn in our sides for a long time, causing
many grammatical ambiguity problems. It doesn't seem worth the
pain to continue to support it, so remove it.
There are some follow-on improvements we can make in the grammar,
but this commit only removes the bare minimum number of productions,
plus assorted backend support code.
Note that pg_dump and psql continue to have full support, since
they may be used against older servers. However, pg_dump warns
about postfix operators. There is also a check in pg_upgrade.
Documentation-wise, I (tgl) largely removed the "left unary"
terminology in favor of saying "prefix operator", which is
a more standard and IMO less confusing term.
I included a catversion bump, although no initial catalog data
changes here, to mark the boundary at which oprkind = 'r'
stopped being valid in pg_operator.
Mark Dilger, based on work by myself and Robert Haas;
review by John Naylor
Discussion: https://postgr.es/m/38ca86db-42ab-9b48-2902-337a0d6b8311@2ndquadrant.com
2020-09-18 01:38:05 +02:00
|
|
|
The data type of the operator's right operand.
|
2004-06-25 23:55:59 +02:00
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
2009-09-19 12:23:27 +02:00
|
|
|
<term><replaceable class="parameter">new_owner</replaceable></term>
|
2004-06-25 23:55:59 +02:00
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The new owner of the operator.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2010-11-26 23:27:23 +01:00
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><replaceable class="parameter">new_schema</replaceable></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The new schema for the operator.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
2015-07-14 17:17:55 +02:00
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><replaceable class="parameter">res_proc</replaceable></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The restriction selectivity estimator function for this operator; write NONE to remove existing selectivity estimator.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
|
|
|
<varlistentry>
|
|
|
|
<term><replaceable class="parameter">join_proc</replaceable></term>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
The join selectivity estimator function for this operator; write NONE to remove existing selectivity estimator.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
</varlistentry>
|
|
|
|
|
2004-06-25 23:55:59 +02:00
|
|
|
</variablelist>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>Examples</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Change the owner of a custom operator <literal>a @@ b</literal> for type <type>text</type>:
|
|
|
|
<programlisting>
|
|
|
|
ALTER OPERATOR @@ (text, text) OWNER TO joe;
|
2011-08-07 09:49:45 +02:00
|
|
|
</programlisting></para>
|
2015-07-14 17:17:55 +02:00
|
|
|
|
|
|
|
<para>
|
2017-09-06 17:22:43 +02:00
|
|
|
Change the restriction and join selectivity estimator functions of a custom operator <literal>a && b</literal> for type <type>int[]</type>:
|
2015-07-14 17:17:55 +02:00
|
|
|
<programlisting>
|
2017-09-06 17:22:43 +02:00
|
|
|
ALTER OPERATOR && (_int4, _int4) SET (RESTRICT = _int_contsel, JOIN = _int_contjoinsel);
|
2015-07-14 17:17:55 +02:00
|
|
|
</programlisting></para>
|
|
|
|
|
2004-06-25 23:55:59 +02:00
|
|
|
</refsect1>
|
2010-11-23 21:27:50 +01:00
|
|
|
|
2004-06-25 23:55:59 +02:00
|
|
|
<refsect1>
|
|
|
|
<title>Compatibility</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
There is no <command>ALTER OPERATOR</command> statement in
|
|
|
|
the SQL standard.
|
|
|
|
</para>
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
<refsect1>
|
|
|
|
<title>See Also</title>
|
|
|
|
|
|
|
|
<simplelist type="inline">
|
2017-11-23 15:39:47 +01:00
|
|
|
<member><xref linkend="sql-createoperator"/></member>
|
|
|
|
<member><xref linkend="sql-dropoperator"/></member>
|
2004-06-25 23:55:59 +02:00
|
|
|
</simplelist>
|
|
|
|
</refsect1>
|
|
|
|
</refentry>
|