mirror of
https://github.com/postgres/postgres.git
synced 2025-12-21 05:21:08 +03:00
Commit 2453ea142 redefined pg_proc.proargtypes to include the types of
OUT parameters, for procedures only. While that had some advantages
for implementing the SQL-spec behavior of DROP PROCEDURE, it was pretty
disastrous from a number of other perspectives. Notably, since the
primary key of pg_proc is name + proargtypes, this made it possible to
have multiple procedures with identical names + input arguments and
differing output argument types. That would make it impossible to call
any one of the procedures by writing just NULL (or "?", or any other
data-type-free notation) for the output argument(s). The change also
seems likely to cause grave confusion for client applications that
examine pg_proc and expect the traditional definition of proargtypes.
Hence, revert the definition of proargtypes to what it was, and
undo a number of complications that had been added to support that.
To support the SQL-spec behavior of DROP PROCEDURE, when there are
no argmode markers in the command's parameter list, we perform the
lookup both ways (that is, matching against both proargtypes and
proallargtypes), succeeding if we get just one unique match.
In principle this could result in ambiguous-function failures
that would not happen when using only one of the two rules.
However, overloading of procedure names is thought to be a pretty
rare usage, so this shouldn't cause many problems in practice.
Postgres-specific code such as pg_dump can defend against any
possibility of such failures by being careful to specify argmodes
for all procedure arguments.
This also fixes a few other bugs in the area of CALL statements
with named parameters, and improves the documentation a little.
catversion bump forced because the representation of procedures
with OUT arguments changes.
Discussion: https://postgr.es/m/3742981.1621533210@sss.pgh.pa.us
124 lines
3.9 KiB
Plaintext
124 lines
3.9 KiB
Plaintext
<!--
|
|
doc/src/sgml/ref/drop_routine.sgml
|
|
PostgreSQL documentation
|
|
-->
|
|
|
|
<refentry id="sql-droproutine">
|
|
<indexterm zone="sql-droproutine">
|
|
<primary>DROP ROUTINE</primary>
|
|
</indexterm>
|
|
|
|
<refmeta>
|
|
<refentrytitle>DROP ROUTINE</refentrytitle>
|
|
<manvolnum>7</manvolnum>
|
|
<refmiscinfo>SQL - Language Statements</refmiscinfo>
|
|
</refmeta>
|
|
|
|
<refnamediv>
|
|
<refname>DROP ROUTINE</refname>
|
|
<refpurpose>remove a routine</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsynopsisdiv>
|
|
<synopsis>
|
|
DROP ROUTINE [ IF EXISTS ] <replaceable class="parameter">name</replaceable> [ ( [ [ <replaceable class="parameter">argmode</replaceable> ] [ <replaceable class="parameter">argname</replaceable> ] <replaceable class="parameter">argtype</replaceable> [, ...] ] ) ] [, ...]
|
|
[ CASCADE | RESTRICT ]
|
|
</synopsis>
|
|
</refsynopsisdiv>
|
|
|
|
<refsect1>
|
|
<title>Description</title>
|
|
|
|
<para>
|
|
<command>DROP ROUTINE</command> removes the definition of one or more
|
|
existing routines. The term <quote>routine</quote> includes
|
|
aggregate functions, normal functions, and procedures. See
|
|
under <xref linkend="sql-dropaggregate"/>, <xref linkend="sql-dropfunction"/>,
|
|
and <xref linkend="sql-dropprocedure"/> for the description of the
|
|
parameters, more examples, and further details.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 id="sql-droproutine-notes">
|
|
<title>Notes</title>
|
|
|
|
<para>
|
|
The lookup rules used by <command>DROP ROUTINE</command> are
|
|
fundamentally the same as for <command>DROP PROCEDURE</command>; in
|
|
particular, <command>DROP ROUTINE</command> shares that command's
|
|
behavior of considering an argument list that has
|
|
no <replaceable class="parameter">argmode</replaceable> markers to be
|
|
possibly using the SQL standard's definition that <literal>OUT</literal>
|
|
arguments are included in the list. (<command>DROP AGGREGATE</command>
|
|
and <command>DROP FUNCTION</command> do not do that.)
|
|
</para>
|
|
|
|
<para>
|
|
In some cases where the same name is shared by routines of different
|
|
kinds, it is possible for <command>DROP ROUTINE</command> to fail with
|
|
an ambiguity error when a more specific command (<command>DROP
|
|
FUNCTION</command>, etc.) would work. Specifying the argument type
|
|
list more carefully will also resolve such problems.
|
|
</para>
|
|
|
|
<para>
|
|
These lookup rules are also used by other commands that
|
|
act on existing routines, such as <command>ALTER ROUTINE</command>
|
|
and <command>COMMENT ON ROUTINE</command>.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 id="sql-droproutine-examples">
|
|
<title>Examples</title>
|
|
|
|
<para>
|
|
To drop the routine <literal>foo</literal> for type
|
|
<type>integer</type>:
|
|
<programlisting>
|
|
DROP ROUTINE foo(integer);
|
|
</programlisting>
|
|
This command will work independent of whether <literal>foo</literal> is an
|
|
aggregate, function, or procedure.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 id="sql-droproutine-compatibility">
|
|
<title>Compatibility</title>
|
|
|
|
<para>
|
|
This command conforms to the SQL standard, with
|
|
these <productname>PostgreSQL</productname> extensions:
|
|
<itemizedlist>
|
|
<listitem>
|
|
<para>The standard only allows one routine to be dropped per command.</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>The <literal>IF EXISTS</literal> option is an extension.</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>The ability to specify argument modes and names is an
|
|
extension, and the lookup rules differ when modes are given.</para>
|
|
</listitem>
|
|
<listitem>
|
|
<para>User-definable aggregate functions are an extension.</para>
|
|
</listitem>
|
|
</itemizedlist></para>
|
|
</refsect1>
|
|
|
|
<refsect1>
|
|
<title>See Also</title>
|
|
|
|
<simplelist type="inline">
|
|
<member><xref linkend="sql-dropaggregate"/></member>
|
|
<member><xref linkend="sql-dropfunction"/></member>
|
|
<member><xref linkend="sql-dropprocedure"/></member>
|
|
<member><xref linkend="sql-alterroutine"/></member>
|
|
</simplelist>
|
|
|
|
<para>
|
|
Note that there is no <literal>CREATE ROUTINE</literal> command.
|
|
</para>
|
|
</refsect1>
|
|
|
|
</refentry>
|