Commit 676bb1ab authored by Tom Lane's avatar Tom Lane

Add a hack requested by the JDBC driver writers: when a function's

argument list contains parameter symbols ($n) declared as type VOID,
discard these arguments.  This allows the driver to avoid renumbering
mixed IN and OUT argument placeholders (the JDBC syntax involves writing
? for both IN and OUT parameters, but on the server side we don't think
that OUT parameters are arguments).  This doesn't break any currently-
useful cases since VOID is not used as an input argument type.
parent 738df437
<!-- $PostgreSQL: pgsql/doc/src/sgml/protocol.sgml,v 1.58 2005/01/23 00:30:18 momjian Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/protocol.sgml,v 1.59 2005/06/22 15:19:43 tgl Exp $ -->
<chapter id="protocol"> <chapter id="protocol">
<title>Frontend/Backend Protocol</title> <title>Frontend/Backend Protocol</title>
...@@ -295,7 +295,7 @@ ...@@ -295,7 +295,7 @@
<listitem> <listitem>
<para> <para>
The frontend must now send a PasswordMessage containing the The frontend must now send a PasswordMessage containing the
password in clear-text form. If password in clear-text form. If
this is the correct password, the server responds with an this is the correct password, the server responds with an
AuthenticationOk, otherwise it responds with an ErrorResponse. AuthenticationOk, otherwise it responds with an ErrorResponse.
</para> </para>
...@@ -307,8 +307,8 @@ ...@@ -307,8 +307,8 @@
<listitem> <listitem>
<para> <para>
The frontend must now send a PasswordMessage containing the The frontend must now send a PasswordMessage containing the
password encrypted via crypt(3), using the 2-character salt password encrypted via crypt(3), using the 2-character salt
specified in the AuthenticationCryptPassword message. If specified in the AuthenticationCryptPassword message. If
this is the correct password, the server responds with an this is the correct password, the server responds with an
AuthenticationOk, otherwise it responds with an ErrorResponse. AuthenticationOk, otherwise it responds with an ErrorResponse.
</para> </para>
...@@ -320,8 +320,8 @@ ...@@ -320,8 +320,8 @@
<listitem> <listitem>
<para> <para>
The frontend must now send a PasswordMessage containing the The frontend must now send a PasswordMessage containing the
password encrypted via MD5, using the 4-character salt password encrypted via MD5, using the 4-character salt
specified in the AuthenticationMD5Password message. If specified in the AuthenticationMD5Password message. If
this is the correct password, the server responds with an this is the correct password, the server responds with an
AuthenticationOk, otherwise it responds with an ErrorResponse. AuthenticationOk, otherwise it responds with an ErrorResponse.
</para> </para>
...@@ -333,12 +333,12 @@ ...@@ -333,12 +333,12 @@
<listitem> <listitem>
<para> <para>
This response is only possible for local Unix-domain connections This response is only possible for local Unix-domain connections
on platforms that support SCM credential messages. The frontend on platforms that support SCM credential messages. The frontend
must issue an SCM credential message and then send a single data must issue an SCM credential message and then send a single data
byte. (The contents of the data byte are uninteresting; it's byte. (The contents of the data byte are uninteresting; it's
only used to ensure that the server waits long enough to receive only used to ensure that the server waits long enough to receive
the credential message.) If the credential is acceptable, the credential message.) If the credential is acceptable,
the server responds with an the server responds with an
AuthenticationOk, otherwise it responds with an ErrorResponse. AuthenticationOk, otherwise it responds with an ErrorResponse.
</para> </para>
</listitem> </listitem>
...@@ -497,9 +497,9 @@ ...@@ -497,9 +497,9 @@
<listitem> <listitem>
<para> <para>
Indicates that rows are about to be returned in response to Indicates that rows are about to be returned in response to
a <command>SELECT</command>, <command>FETCH</command>, etc query. a <command>SELECT</command>, <command>FETCH</command>, etc query.
The contents of this message describe the column layout of the rows. The contents of this message describe the column layout of the rows.
This will be followed by a DataRow message for each row being returned This will be followed by a DataRow message for each row being returned
to the frontend. to the frontend.
</para> </para>
</listitem> </listitem>
...@@ -510,7 +510,7 @@ ...@@ -510,7 +510,7 @@
<listitem> <listitem>
<para> <para>
One of the set of rows returned by One of the set of rows returned by
a <command>SELECT</command>, <command>FETCH</command>, etc query. a <command>SELECT</command>, <command>FETCH</command>, etc query.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -639,6 +639,24 @@ ...@@ -639,6 +639,24 @@
constants. constants.
</para> </para>
<note>
<para>
A parameter data type can be left unspecified by setting it to zero,
or by making the array of parameter type OIDs shorter than the
number of parameter symbols (<literal>$</><replaceable>n</>)
used in the query string. Another special case is that a parameter's
type can be specified as <type>void</> (that is, the OID of the
<type>void</> pseudotype). This is meant to allow parameter symbols
to be used for function parameters that are actually OUT parameters.
Ordinarily there is no context in which a <type>void</> parameter
could be used, but if such a parameter symbol appears in a function's
parameter list, it is effectively ignored. For example, a function
call such as <literal>foo($1,$2,$3,$4)</> could match a function with
two IN and two OUT arguments, if <literal>$3</> and <literal>$4</>
are specified as having type <type>void</>.
</para>
</note>
<note> <note>
<para> <para>
The query string contained in a Parse message cannot include more The query string contained in a Parse message cannot include more
...@@ -670,6 +688,8 @@ ...@@ -670,6 +688,8 @@
the values to use for any parameter placeholders present in the prepared the values to use for any parameter placeholders present in the prepared
statement. The statement. The
supplied parameter set must match those needed by the prepared statement. supplied parameter set must match those needed by the prepared statement.
(If you declared any <type>void</> parameters in the Parse message,
pass NULL values for them in the Bind message.)
Bind also specifies the format to use for any data returned Bind also specifies the format to use for any data returned
by the query; the format can be specified overall, or per-column. by the query; the format can be specified overall, or per-column.
The response is either BindComplete or ErrorResponse. The response is either BindComplete or ErrorResponse.
...@@ -900,9 +920,9 @@ ...@@ -900,9 +920,9 @@
<listitem> <listitem>
<para> <para>
The function call was completed and returned the result given The function call was completed and returned the result given
in the message. in the message.
(Note that the Function Call protocol can only handle a single (Note that the Function Call protocol can only handle a single
scalar result, not a row type or set of results.) scalar result, not a row type or set of results.)
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1259,10 +1279,10 @@ This section describes the base data types used in messages. ...@@ -1259,10 +1279,10 @@ This section describes the base data types used in messages.
<listitem> <listitem>
<para> <para>
An <replaceable>n</replaceable>-bit integer in network byte An <replaceable>n</replaceable>-bit integer in network byte
order (most significant byte first). order (most significant byte first).
If <replaceable>i</replaceable> is specified it If <replaceable>i</replaceable> is specified it
is the exact value that will appear, otherwise the value is the exact value that will appear, otherwise the value
is variable. Eg. Int16, Int32(42). is variable. Eg. Int16, Int32(42).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1273,11 +1293,11 @@ This section describes the base data types used in messages. ...@@ -1273,11 +1293,11 @@ This section describes the base data types used in messages.
</term> </term>
<listitem> <listitem>
<para> <para>
An array of <replaceable>k</replaceable> An array of <replaceable>k</replaceable>
<replaceable>n</replaceable>-bit integers, each in network <replaceable>n</replaceable>-bit integers, each in network
byte order. The array length <replaceable>k</replaceable> byte order. The array length <replaceable>k</replaceable>
is always determined by an earlier field in the message. is always determined by an earlier field in the message.
Eg. Int16[M]. Eg. Int16[M].
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1289,9 +1309,9 @@ This section describes the base data types used in messages. ...@@ -1289,9 +1309,9 @@ This section describes the base data types used in messages.
<listitem> <listitem>
<para> <para>
A null-terminated string (C-style string). There is no A null-terminated string (C-style string). There is no
specific length limitation on strings. specific length limitation on strings.
If <replaceable>s</replaceable> is specified it is the exact If <replaceable>s</replaceable> is specified it is the exact
value that will appear, otherwise the value is variable. value that will appear, otherwise the value is variable.
Eg. String, String("user"). Eg. String, String("user").
</para> </para>
...@@ -1314,8 +1334,8 @@ characters that don't fit into your fixed-size buffer. ...@@ -1314,8 +1334,8 @@ characters that don't fit into your fixed-size buffer.
<listitem> <listitem>
<para> <para>
Exactly <replaceable>n</replaceable> bytes. If the field Exactly <replaceable>n</replaceable> bytes. If the field
width <replaceable>n</replaceable> is not a constant, it is width <replaceable>n</replaceable> is not a constant, it is
always determinable from an earlier field in the message. always determinable from an earlier field in the message.
If <replaceable>c</replaceable> is specified it is the exact If <replaceable>c</replaceable> is specified it is the exact
value. Eg. Byte2, Byte1('\n'). value. Eg. Byte2, Byte1('\n').
</para> </para>
...@@ -1767,7 +1787,7 @@ Bind (F) ...@@ -1767,7 +1787,7 @@ Bind (F)
<listitem> <listitem>
<para> <para>
The name of the destination portal The name of the destination portal
(an empty string selects the unnamed portal). (an empty string selects the unnamed portal).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1778,7 +1798,7 @@ Bind (F) ...@@ -1778,7 +1798,7 @@ Bind (F)
<listitem> <listitem>
<para> <para>
The name of the source prepared statement The name of the source prepared statement
(an empty string selects the unnamed prepared statement). (an empty string selects the unnamed prepared statement).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1788,13 +1808,13 @@ Bind (F) ...@@ -1788,13 +1808,13 @@ Bind (F)
</term> </term>
<listitem> <listitem>
<para> <para>
The number of parameter format codes that follow The number of parameter format codes that follow
(denoted <replaceable>C</> below). (denoted <replaceable>C</> below).
This can be zero to indicate that there are no parameters This can be zero to indicate that there are no parameters
or that the parameters all use the default format (text); or that the parameters all use the default format (text);
or one, in which case the specified format code is applied or one, in which case the specified format code is applied
to all parameters; or it can equal the actual number of to all parameters; or it can equal the actual number of
parameters. parameters.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1805,7 +1825,7 @@ Bind (F) ...@@ -1805,7 +1825,7 @@ Bind (F)
<listitem> <listitem>
<para> <para>
The parameter format codes. Each must presently be The parameter format codes. Each must presently be
zero (text) or one (binary). zero (text) or one (binary).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1816,7 +1836,7 @@ Bind (F) ...@@ -1816,7 +1836,7 @@ Bind (F)
<listitem> <listitem>
<para> <para>
The number of parameter values that follow (possibly zero). The number of parameter values that follow (possibly zero).
This must match the number of parameters needed by the query. This must match the number of parameters needed by the query.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1830,9 +1850,9 @@ Bind (F) ...@@ -1830,9 +1850,9 @@ Bind (F)
<listitem> <listitem>
<para> <para>
The length of the parameter value, in bytes (this count The length of the parameter value, in bytes (this count
does not include itself). Can be zero. does not include itself). Can be zero.
As a special case, -1 indicates a NULL parameter value. As a special case, -1 indicates a NULL parameter value.
No value bytes follow in the NULL case. No value bytes follow in the NULL case.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1843,7 +1863,7 @@ Bind (F) ...@@ -1843,7 +1863,7 @@ Bind (F)
<listitem> <listitem>
<para> <para>
The value of the parameter, in the format indicated by the The value of the parameter, in the format indicated by the
associated format code. associated format code.
<replaceable>n</replaceable> is the above length. <replaceable>n</replaceable> is the above length.
</para> </para>
</listitem> </listitem>
...@@ -1857,14 +1877,14 @@ Bind (F) ...@@ -1857,14 +1877,14 @@ Bind (F)
</term> </term>
<listitem> <listitem>
<para> <para>
The number of result-column format codes that follow The number of result-column format codes that follow
(denoted <replaceable>R</> below). (denoted <replaceable>R</> below).
This can be zero to indicate that there are no result columns This can be zero to indicate that there are no result columns
or that the result columns should all use the default format or that the result columns should all use the default format
(text); (text);
or one, in which case the specified format code is applied or one, in which case the specified format code is applied
to all result columns (if any); or it can equal the actual to all result columns (if any); or it can equal the actual
number of result columns of the query. number of result columns of the query.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -1875,7 +1895,7 @@ Bind (F) ...@@ -1875,7 +1895,7 @@ Bind (F)
<listitem> <listitem>
<para> <para>
The result-column format codes. Each must presently be The result-column format codes. Each must presently be
zero (text) or one (binary). zero (text) or one (binary).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2024,8 +2044,8 @@ Close (F) ...@@ -2024,8 +2044,8 @@ Close (F)
<listitem> <listitem>
<para> <para>
The name of the prepared statement or portal to close The name of the prepared statement or portal to close
(an empty string selects the unnamed prepared statement (an empty string selects the unnamed prepared statement
or portal). or portal).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2115,19 +2135,19 @@ CommandComplete (B) ...@@ -2115,19 +2135,19 @@ CommandComplete (B)
<replaceable>rows</replaceable> is the number of rows <replaceable>rows</replaceable> is the number of rows
inserted. <replaceable>oid</replaceable> is the object ID inserted. <replaceable>oid</replaceable> is the object ID
of the inserted row if <replaceable>rows</replaceable> is 1 of the inserted row if <replaceable>rows</replaceable> is 1
and the target table has OIDs; and the target table has OIDs;
otherwise <replaceable>oid</replaceable> is 0. otherwise <replaceable>oid</replaceable> is 0.
</para> </para>
<para> <para>
For a <command>DELETE</command> command, the tag is For a <command>DELETE</command> command, the tag is
<literal>DELETE <replaceable>rows</replaceable></literal> where <literal>DELETE <replaceable>rows</replaceable></literal> where
<replaceable>rows</replaceable> is the number of rows deleted. <replaceable>rows</replaceable> is the number of rows deleted.
</para> </para>
<para> <para>
For an <command>UPDATE</command> command, the tag is For an <command>UPDATE</command> command, the tag is
<literal>UPDATE <replaceable>rows</replaceable></literal> where <literal>UPDATE <replaceable>rows</replaceable></literal> where
<replaceable>rows</replaceable> is the number of rows updated. <replaceable>rows</replaceable> is the number of rows updated.
</para> </para>
...@@ -2187,9 +2207,9 @@ CopyData (F &amp; B) ...@@ -2187,9 +2207,9 @@ CopyData (F &amp; B)
<listitem> <listitem>
<para> <para>
Data that forms part of a <command>COPY</command> data stream. Messages sent Data that forms part of a <command>COPY</command> data stream. Messages sent
from the backend will always correspond to single data rows, from the backend will always correspond to single data rows,
but messages sent by frontends may divide the data stream but messages sent by frontends may divide the data stream
arbitrarily. arbitrarily.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2295,7 +2315,7 @@ CopyInResponse (B) ...@@ -2295,7 +2315,7 @@ CopyInResponse (B)
<para> <para>
Identifies the message as a Start Copy In response. Identifies the message as a Start Copy In response.
The frontend must now send copy-in data (if not The frontend must now send copy-in data (if not
prepared to do so, send a CopyFail message). prepared to do so, send a CopyFail message).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2316,12 +2336,12 @@ CopyInResponse (B) ...@@ -2316,12 +2336,12 @@ CopyInResponse (B)
<listitem> <listitem>
<para> <para>
0 indicates the overall <command>COPY</command> format is textual (rows 0 indicates the overall <command>COPY</command> format is textual (rows
separated by newlines, columns separated by separator separated by newlines, columns separated by separator
characters, etc). characters, etc).
1 indicates the overall copy format is binary (similar 1 indicates the overall copy format is binary (similar
to DataRow format). to DataRow format).
See <xref linkend="sql-copy" endterm="sql-copy-title"> See <xref linkend="sql-copy" endterm="sql-copy-title">
for more information. for more information.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2331,8 +2351,8 @@ CopyInResponse (B) ...@@ -2331,8 +2351,8 @@ CopyInResponse (B)
</term> </term>
<listitem> <listitem>
<para> <para>
The number of columns in the data to be copied The number of columns in the data to be copied
(denoted <replaceable>N</> below). (denoted <replaceable>N</> below).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2343,8 +2363,8 @@ CopyInResponse (B) ...@@ -2343,8 +2363,8 @@ CopyInResponse (B)
<listitem> <listitem>
<para> <para>
The format codes to be used for each column. The format codes to be used for each column.
Each must presently be zero (text) or one (binary). Each must presently be zero (text) or one (binary).
All must be zero if the overall copy format is textual. All must be zero if the overall copy format is textual.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2405,8 +2425,8 @@ CopyOutResponse (B) ...@@ -2405,8 +2425,8 @@ CopyOutResponse (B)
</term> </term>
<listitem> <listitem>
<para> <para>
The number of columns in the data to be copied The number of columns in the data to be copied
(denoted <replaceable>N</> below). (denoted <replaceable>N</> below).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2417,8 +2437,8 @@ CopyOutResponse (B) ...@@ -2417,8 +2437,8 @@ CopyOutResponse (B)
<listitem> <listitem>
<para> <para>
The format codes to be used for each column. The format codes to be used for each column.
Each must presently be zero (text) or one (binary). Each must presently be zero (text) or one (binary).
All must be zero if the overall copy format is textual. All must be zero if the overall copy format is textual.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2476,9 +2496,9 @@ DataRow (B) ...@@ -2476,9 +2496,9 @@ DataRow (B)
<listitem> <listitem>
<para> <para>
The length of the column value, in bytes (this count The length of the column value, in bytes (this count
does not include itself). Can be zero. does not include itself). Can be zero.
As a special case, -1 indicates a NULL column value. As a special case, -1 indicates a NULL column value.
No value bytes follow in the NULL case. No value bytes follow in the NULL case.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2489,7 +2509,7 @@ DataRow (B) ...@@ -2489,7 +2509,7 @@ DataRow (B)
<listitem> <listitem>
<para> <para>
The value of the column, in the format indicated by the The value of the column, in the format indicated by the
associated format code. associated format code.
<replaceable>n</replaceable> is the above length. <replaceable>n</replaceable> is the above length.
</para> </para>
</listitem> </listitem>
...@@ -2547,8 +2567,8 @@ Describe (F) ...@@ -2547,8 +2567,8 @@ Describe (F)
<listitem> <listitem>
<para> <para>
The name of the prepared statement or portal to describe The name of the prepared statement or portal to describe
(an empty string selects the unnamed prepared statement (an empty string selects the unnamed prepared statement
or portal). or portal).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2573,7 +2593,7 @@ EmptyQueryResponse (B) ...@@ -2573,7 +2593,7 @@ EmptyQueryResponse (B)
<listitem> <listitem>
<para> <para>
Identifies the message as a response to an empty query string. Identifies the message as a response to an empty query string.
(This substitutes for CommandComplete.) (This substitutes for CommandComplete.)
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2624,8 +2644,8 @@ ErrorResponse (B) ...@@ -2624,8 +2644,8 @@ ErrorResponse (B)
</varlistentry> </varlistentry>
</variablelist> </variablelist>
The message body consists of one or more identified fields, The message body consists of one or more identified fields,
followed by a zero byte as a terminator. Fields may appear in followed by a zero byte as a terminator. Fields may appear in
any order. For each field there is the following: any order. For each field there is the following:
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term> <term>
...@@ -2634,12 +2654,12 @@ ErrorResponse (B) ...@@ -2634,12 +2654,12 @@ ErrorResponse (B)
<listitem> <listitem>
<para> <para>
A code identifying the field type; if zero, this is A code identifying the field type; if zero, this is
the message terminator and no string follows. the message terminator and no string follows.
The presently defined field types are listed in The presently defined field types are listed in
<xref linkend="protocol-error-fields">. <xref linkend="protocol-error-fields">.
Since more field types may be added in future, Since more field types may be added in future,
frontends should silently ignore fields of unrecognized frontends should silently ignore fields of unrecognized
type. type.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2695,7 +2715,7 @@ Execute (F) ...@@ -2695,7 +2715,7 @@ Execute (F)
<listitem> <listitem>
<para> <para>
The name of the portal to execute The name of the portal to execute
(an empty string selects the unnamed portal). (an empty string selects the unnamed portal).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2706,8 +2726,8 @@ Execute (F) ...@@ -2706,8 +2726,8 @@ Execute (F)
<listitem> <listitem>
<para> <para>
Maximum number of rows to return, if portal contains Maximum number of rows to return, if portal contains
a query that returns rows (ignored otherwise). Zero a query that returns rows (ignored otherwise). Zero
denotes <quote>no limit</>. denotes <quote>no limit</>.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2796,13 +2816,13 @@ FunctionCall (F) ...@@ -2796,13 +2816,13 @@ FunctionCall (F)
</term> </term>
<listitem> <listitem>
<para> <para>
The number of argument format codes that follow The number of argument format codes that follow
(denoted <replaceable>C</> below). (denoted <replaceable>C</> below).
This can be zero to indicate that there are no arguments This can be zero to indicate that there are no arguments
or that the arguments all use the default format (text); or that the arguments all use the default format (text);
or one, in which case the specified format code is applied or one, in which case the specified format code is applied
to all arguments; or it can equal the actual number of to all arguments; or it can equal the actual number of
arguments. arguments.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2813,7 +2833,7 @@ FunctionCall (F) ...@@ -2813,7 +2833,7 @@ FunctionCall (F)
<listitem> <listitem>
<para> <para>
The argument format codes. Each must presently be The argument format codes. Each must presently be
zero (text) or one (binary). zero (text) or one (binary).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2838,9 +2858,9 @@ FunctionCall (F) ...@@ -2838,9 +2858,9 @@ FunctionCall (F)
<listitem> <listitem>
<para> <para>
The length of the argument value, in bytes (this count The length of the argument value, in bytes (this count
does not include itself). Can be zero. does not include itself). Can be zero.
As a special case, -1 indicates a NULL argument value. As a special case, -1 indicates a NULL argument value.
No value bytes follow in the NULL case. No value bytes follow in the NULL case.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2851,7 +2871,7 @@ FunctionCall (F) ...@@ -2851,7 +2871,7 @@ FunctionCall (F)
<listitem> <listitem>
<para> <para>
The value of the argument, in the format indicated by the The value of the argument, in the format indicated by the
associated format code. associated format code.
<replaceable>n</replaceable> is the above length. <replaceable>n</replaceable> is the above length.
</para> </para>
</listitem> </listitem>
...@@ -2866,7 +2886,7 @@ FunctionCall (F) ...@@ -2866,7 +2886,7 @@ FunctionCall (F)
<listitem> <listitem>
<para> <para>
The format code for the function result. Must presently be The format code for the function result. Must presently be
zero (text) or one (binary). zero (text) or one (binary).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2912,9 +2932,9 @@ FunctionCallResponse (B) ...@@ -2912,9 +2932,9 @@ FunctionCallResponse (B)
<listitem> <listitem>
<para> <para>
The length of the function result value, in bytes (this count The length of the function result value, in bytes (this count
does not include itself). Can be zero. does not include itself). Can be zero.
As a special case, -1 indicates a NULL function result. As a special case, -1 indicates a NULL function result.
No value bytes follow in the NULL case. No value bytes follow in the NULL case.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -2925,7 +2945,7 @@ FunctionCallResponse (B) ...@@ -2925,7 +2945,7 @@ FunctionCallResponse (B)
<listitem> <listitem>
<para> <para>
The value of the function result, in the format indicated by The value of the function result, in the format indicated by
the associated format code. the associated format code.
<replaceable>n</replaceable> is the above length. <replaceable>n</replaceable> is the above length.
</para> </para>
</listitem> </listitem>
...@@ -3002,8 +3022,8 @@ NoticeResponse (B) ...@@ -3002,8 +3022,8 @@ NoticeResponse (B)
</varlistentry> </varlistentry>
</variablelist> </variablelist>
The message body consists of one or more identified fields, The message body consists of one or more identified fields,
followed by a zero byte as a terminator. Fields may appear in followed by a zero byte as a terminator. Fields may appear in
any order. For each field there is the following: any order. For each field there is the following:
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term> <term>
...@@ -3012,12 +3032,12 @@ NoticeResponse (B) ...@@ -3012,12 +3032,12 @@ NoticeResponse (B)
<listitem> <listitem>
<para> <para>
A code identifying the field type; if zero, this is A code identifying the field type; if zero, this is
the message terminator and no string follows. the message terminator and no string follows.
The presently defined field types are listed in The presently defined field types are listed in
<xref linkend="protocol-error-fields">. <xref linkend="protocol-error-fields">.
Since more field types may be added in future, Since more field types may be added in future,
frontends should silently ignore fields of unrecognized frontends should silently ignore fields of unrecognized
type. type.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3093,8 +3113,8 @@ NotificationResponse (B) ...@@ -3093,8 +3113,8 @@ NotificationResponse (B)
<listitem> <listitem>
<para> <para>
Additional information passed from the notifying process. Additional information passed from the notifying process.
(Currently, this feature is unimplemented so the field (Currently, this feature is unimplemented so the field
is always an empty string.) is always an empty string.)
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3140,7 +3160,7 @@ ParameterDescription (B) ...@@ -3140,7 +3160,7 @@ ParameterDescription (B)
<listitem> <listitem>
<para> <para>
The number of parameters used by the statement The number of parameters used by the statement
(may be zero). (may be zero).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3252,7 +3272,7 @@ Parse (F) ...@@ -3252,7 +3272,7 @@ Parse (F)
<listitem> <listitem>
<para> <para>
The name of the destination prepared statement The name of the destination prepared statement
(an empty string selects the unnamed prepared statement). (an empty string selects the unnamed prepared statement).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3273,10 +3293,10 @@ Parse (F) ...@@ -3273,10 +3293,10 @@ Parse (F)
<listitem> <listitem>
<para> <para>
The number of parameter data types specified The number of parameter data types specified
(may be zero). Note that this is not an indication of (may be zero). Note that this is not an indication of
the number of parameters that might appear in the the number of parameters that might appear in the
query string, only the number that the frontend wants to query string, only the number that the frontend wants to
prespecify types for. prespecify types for.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3290,8 +3310,8 @@ Parse (F) ...@@ -3290,8 +3310,8 @@ Parse (F)
<listitem> <listitem>
<para> <para>
Specifies the object ID of the parameter data type. Specifies the object ID of the parameter data type.
Placing a zero here is equivalent to leaving the type Placing a zero here is equivalent to leaving the type
unspecified. unspecified.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3395,8 +3415,8 @@ PortalSuspended (B) ...@@ -3395,8 +3415,8 @@ PortalSuspended (B)
<listitem> <listitem>
<para> <para>
Identifies the message as a portal-suspended indicator. Identifies the message as a portal-suspended indicator.
Note this only appears if an Execute message's row-count limit Note this only appears if an Execute message's row-count limit
was reached. was reached.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3498,10 +3518,10 @@ ReadyForQuery (B) ...@@ -3498,10 +3518,10 @@ ReadyForQuery (B)
<listitem> <listitem>
<para> <para>
Current backend transaction status indicator. Current backend transaction status indicator.
Possible values are '<literal>I</>' if idle (not in Possible values are '<literal>I</>' if idle (not in
a transaction block); '<literal>T</>' if in a transaction a transaction block); '<literal>T</>' if in a transaction
block; or '<literal>E</>' if in a failed transaction block; or '<literal>E</>' if in a failed transaction
block (queries will be rejected until block is ended). block (queries will be rejected until block is ended).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3570,7 +3590,7 @@ RowDescription (B) ...@@ -3570,7 +3590,7 @@ RowDescription (B)
<listitem> <listitem>
<para> <para>
If the field can be identified as a column of a specific If the field can be identified as a column of a specific
table, the object ID of the table; otherwise zero. table, the object ID of the table; otherwise zero.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3581,7 +3601,7 @@ RowDescription (B) ...@@ -3581,7 +3601,7 @@ RowDescription (B)
<listitem> <listitem>
<para> <para>
If the field can be identified as a column of a specific If the field can be identified as a column of a specific
table, the attribute number of the column; otherwise zero. table, the attribute number of the column; otherwise zero.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3602,7 +3622,7 @@ RowDescription (B) ...@@ -3602,7 +3622,7 @@ RowDescription (B)
<listitem> <listitem>
<para> <para>
The data type size (see <varname>pg_type.typlen</>). The data type size (see <varname>pg_type.typlen</>).
Note that negative values denote variable-width types. Note that negative values denote variable-width types.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3613,7 +3633,7 @@ RowDescription (B) ...@@ -3613,7 +3633,7 @@ RowDescription (B)
<listitem> <listitem>
<para> <para>
The type modifier (see <varname>pg_attribute.atttypmod</>). The type modifier (see <varname>pg_attribute.atttypmod</>).
The meaning of the modifier is type-specific. The meaning of the modifier is type-specific.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3624,9 +3644,9 @@ RowDescription (B) ...@@ -3624,9 +3644,9 @@ RowDescription (B)
<listitem> <listitem>
<para> <para>
The format code being used for the field. Currently will The format code being used for the field. Currently will
be zero (text) or one (binary). In a RowDescription be zero (text) or one (binary). In a RowDescription
returned from the statement variant of Describe, the returned from the statement variant of Describe, the
format code is not yet known and will always be zero. format code is not yet known and will always be zero.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3701,18 +3721,18 @@ StartupMessage (F) ...@@ -3701,18 +3721,18 @@ StartupMessage (F)
<para> <para>
The protocol version number. The most significant 16 bits are The protocol version number. The most significant 16 bits are
the major version number (3 for the protocol described here). the major version number (3 for the protocol described here).
The least significant 16 bits are the minor version number The least significant 16 bits are the minor version number
(0 for the protocol described here). (0 for the protocol described here).
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
The protocol version number is followed by one or more pairs of The protocol version number is followed by one or more pairs of
parameter name and value strings. A zero byte is required as a parameter name and value strings. A zero byte is required as a
terminator after the last name/value pair. terminator after the last name/value pair.
Parameters can appear in any Parameters can appear in any
order. <literal>user</> is required, others are optional. order. <literal>user</> is required, others are optional.
Each parameter is specified as: Each parameter is specified as:
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term> <term>
...@@ -3730,7 +3750,7 @@ StartupMessage (F) ...@@ -3730,7 +3750,7 @@ StartupMessage (F)
<listitem> <listitem>
<para> <para>
The database user name to connect as. Required; The database user name to connect as. Required;
there is no default. there is no default.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3751,18 +3771,18 @@ StartupMessage (F) ...@@ -3751,18 +3771,18 @@ StartupMessage (F)
<listitem> <listitem>
<para> <para>
Command-line arguments for the backend. (This is Command-line arguments for the backend. (This is
deprecated in favor of setting individual run-time deprecated in favor of setting individual run-time
parameters.) parameters.)
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
</variablelist> </variablelist>
In addition to the above, any run-time parameter that can be In addition to the above, any run-time parameter that can be
set at backend start time may be listed. Such settings set at backend start time may be listed. Such settings
will be applied during backend start (after parsing the will be applied during backend start (after parsing the
command-line options if any). The values will act as command-line options if any). The values will act as
session defaults. session defaults.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3879,9 +3899,9 @@ message. ...@@ -3879,9 +3899,9 @@ message.
Severity: the field contents are Severity: the field contents are
<literal>ERROR</>, <literal>FATAL</>, or <literal>ERROR</>, <literal>FATAL</>, or
<literal>PANIC</> (in an error message), or <literal>PANIC</> (in an error message), or
<literal>WARNING</>, <literal>NOTICE</>, <literal>DEBUG</>, <literal>WARNING</>, <literal>NOTICE</>, <literal>DEBUG</>,
<literal>INFO</>, or <literal>LOG</> (in a notice message), <literal>INFO</>, or <literal>LOG</> (in a notice message),
or a localized translation of one of these. Always present. or a localized translation of one of these. Always present.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3893,7 +3913,7 @@ message. ...@@ -3893,7 +3913,7 @@ message.
<listitem> <listitem>
<para> <para>
Code: the SQLSTATE code for the error (see <xref Code: the SQLSTATE code for the error (see <xref
linkend="errcodes-appendix">). Not localizable. Always present. linkend="errcodes-appendix">). Not localizable. Always present.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3930,9 +3950,9 @@ message. ...@@ -3930,9 +3950,9 @@ message.
<listitem> <listitem>
<para> <para>
Hint: an optional suggestion what to do about the problem. Hint: an optional suggestion what to do about the problem.
This is intended to differ from Detail in that it offers advice This is intended to differ from Detail in that it offers advice
(potentially inappropriate) rather than hard facts. (potentially inappropriate) rather than hard facts.
May run to multiple lines. May run to multiple lines.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3944,9 +3964,9 @@ message. ...@@ -3944,9 +3964,9 @@ message.
<listitem> <listitem>
<para> <para>
Position: the field value is a decimal ASCII integer, indicating Position: the field value is a decimal ASCII integer, indicating
an error cursor position as an index into the original query string. an error cursor position as an index into the original query string.
The first character has index 1, and positions are measured in The first character has index 1, and positions are measured in
characters not bytes. characters not bytes.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -3998,7 +4018,7 @@ message. ...@@ -3998,7 +4018,7 @@ message.
<listitem> <listitem>
<para> <para>
File: the file name of the source-code location where the error File: the file name of the source-code location where the error
was reported. was reported.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -4010,7 +4030,7 @@ message. ...@@ -4010,7 +4030,7 @@ message.
<listitem> <listitem>
<para> <para>
Line: the line number of the source-code location where the error Line: the line number of the source-code location where the error
was reported. was reported.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.180 2005/05/31 01:03:23 tgl Exp $ * $PostgreSQL: pgsql/src/backend/parser/parse_func.c,v 1.181 2005/06/22 15:19:43 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -64,9 +64,9 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, ...@@ -64,9 +64,9 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
Oid rettype; Oid rettype;
Oid funcid; Oid funcid;
ListCell *l; ListCell *l;
ListCell *nextl;
Node *first_arg = NULL; Node *first_arg = NULL;
int nargs = list_length(fargs); int nargs;
int argn;
Oid actual_arg_types[FUNC_MAX_ARGS]; Oid actual_arg_types[FUNC_MAX_ARGS];
Oid *declared_arg_types; Oid *declared_arg_types;
Node *retval; Node *retval;
...@@ -79,12 +79,38 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, ...@@ -79,12 +79,38 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
* protect against array overruns, etc. Of course, this may not be a * protect against array overruns, etc. Of course, this may not be a
* function, but the test doesn't hurt. * function, but the test doesn't hurt.
*/ */
if (nargs > FUNC_MAX_ARGS) if (list_length(fargs) > FUNC_MAX_ARGS)
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS), (errcode(ERRCODE_TOO_MANY_ARGUMENTS),
errmsg("cannot pass more than %d arguments to a function", errmsg("cannot pass more than %d arguments to a function",
FUNC_MAX_ARGS))); FUNC_MAX_ARGS)));
/*
* Extract arg type info in preparation for function lookup.
*
* If any arguments are Param markers of type VOID, we discard them
* from the parameter list. This is a hack to allow the JDBC driver
* to not have to distinguish "input" and "output" parameter symbols
* while parsing function-call constructs. We can't use foreach()
* because we may modify the list ...
*/
nargs = 0;
for (l = list_head(fargs); l != NULL; l = nextl)
{
Node *arg = lfirst(l);
Oid argtype = exprType(arg);
nextl = lnext(l);
if (argtype == VOIDOID && IsA(arg, Param) && !is_column)
{
fargs = list_delete_ptr(fargs, arg);
continue;
}
actual_arg_types[nargs++] = argtype;
}
if (fargs) if (fargs)
{ {
first_arg = linitial(fargs); first_arg = linitial(fargs);
...@@ -99,7 +125,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, ...@@ -99,7 +125,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
*/ */
if (nargs == 1 && !agg_star && !agg_distinct && list_length(funcname) == 1) if (nargs == 1 && !agg_star && !agg_distinct && list_length(funcname) == 1)
{ {
Oid argtype = exprType(first_arg); Oid argtype = actual_arg_types[0];
if (argtype == RECORDOID || ISCOMPLEX(argtype)) if (argtype == RECORDOID || ISCOMPLEX(argtype))
{ {
...@@ -117,18 +143,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, ...@@ -117,18 +143,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs,
} }
/* /*
* Okay, it's not a column projection, so it must really be a * Okay, it's not a column projection, so it must really be a function.
* function. Extract arg type info in preparation for function lookup.
*/
argn = 0;
foreach(l, fargs)
{
Node *arg = lfirst(l);
actual_arg_types[argn++] = exprType(arg);
}
/*
* func_get_detail looks up the function in the catalogs, does * func_get_detail looks up the function in the catalogs, does
* disambiguation for polymorphic functions, handles inheritance, and * disambiguation for polymorphic functions, handles inheritance, and
* returns the funcid and type and set or singleton status of the * returns the funcid and type and set or singleton status of the
......
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