-
+
Frontend/Backend Protocol
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
AuthenticationOk, otherwise it responds with an ErrorResponse.
The frontend must now send a PasswordMessage containing the
- password encrypted via crypt(3), using the 2-character salt
- specified in the AuthenticationCryptPassword message. If
+ password encrypted via crypt(3), using the 2-character salt
+ specified in the AuthenticationCryptPassword message. If
this is the correct password, the server responds with an
AuthenticationOk, otherwise it responds with an ErrorResponse.
The frontend must now send a PasswordMessage containing the
- password encrypted via MD5, using the 4-character salt
- specified in the AuthenticationMD5Password message. If
+ password encrypted via MD5, using the 4-character salt
+ specified in the AuthenticationMD5Password message. If
this is the correct password, the server responds with an
AuthenticationOk, otherwise it responds with an ErrorResponse.
This response is only possible for local Unix-domain connections
- on platforms that support SCM credential messages. The frontend
- must issue an SCM credential message and then send a single data
- byte. (The contents of the data byte are uninteresting; it's
- only used to ensure that the server waits long enough to receive
- the credential message.) If the credential is acceptable,
- the server responds with an
+ on platforms that support SCM credential messages. The frontend
+ must issue an SCM credential message and then send a single data
+ byte. (The contents of the data byte are uninteresting; it's
+ only used to ensure that the server waits long enough to receive
+ the credential message.) If the credential is acceptable,
+ the server responds with an
AuthenticationOk, otherwise it responds with an ErrorResponse.
Indicates that rows are about to be returned in response to
- a SELECT, FETCH, etc query.
- 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
+ a SELECT, FETCH, etc query.
+ 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
to the frontend.
One of the set of rows returned by
- a SELECT, FETCH, etc query.
+ a SELECT, FETCH, etc query.
constants.
+
+ 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 ($>n>)
+ used in the query string. Another special case is that a parameter's
+ type can be specified as void> (that is, the OID of the
+ 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 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 foo($1,$2,$3,$4)> could match a function with
+ two IN and two OUT arguments, if $3> and $4>
+ are specified as having type void>.
+
+
+
The query string contained in a Parse message cannot include more
the values to use for any parameter placeholders present in the prepared
statement. The
supplied parameter set must match those needed by the prepared statement.
+ (If you declared any 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
by the query; the format can be specified overall, or per-column.
The response is either BindComplete or ErrorResponse.
The function call was completed and returned the result given
- in the message.
- (Note that the Function Call protocol can only handle a single
- scalar result, not a row type or set of results.)
+ in the message.
+ (Note that the Function Call protocol can only handle a single
+ scalar result, not a row type or set of results.)
An n-bit integer in network byte
- order (most significant byte first).
+ order (most significant byte first).
If i is specified it
is the exact value that will appear, otherwise the value
- is variable. Eg. Int16, Int32(42).
+ is variable. Eg. Int16, Int32(42).
- An array of k
+ An array of k
n-bit integers, each in network
- byte order. The array length k
- is always determined by an earlier field in the message.
- Eg. Int16[M].
+ byte order. The array length k
+ is always determined by an earlier field in the message.
+ Eg. Int16[M].
A null-terminated string (C-style string). There is no
- specific length limitation on strings.
+ specific length limitation on strings.
If s 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").
Exactly n bytes. If the field
- width n is not a constant, it is
- always determinable from an earlier field in the message.
+ width n is not a constant, it is
+ always determinable from an earlier field in the message.
If c is specified it is the exact
value. Eg. Byte2, Byte1('\n').
The name of the destination portal
- (an empty string selects the unnamed portal).
+ (an empty string selects the unnamed portal).
The name of the source prepared statement
- (an empty string selects the unnamed prepared statement).
+ (an empty string selects the unnamed prepared statement).
- The number of parameter format codes that follow
- (denoted C> below).
- This can be zero to indicate that there are no parameters
- or that the parameters all use the default format (text);
- or one, in which case the specified format code is applied
- to all parameters; or it can equal the actual number of
- parameters.
+ The number of parameter format codes that follow
+ (denoted C> below).
+ This can be zero to indicate that there are no parameters
+ or that the parameters all use the default format (text);
+ or one, in which case the specified format code is applied
+ to all parameters; or it can equal the actual number of
+ parameters.
The parameter format codes. Each must presently be
- zero (text) or one (binary).
+ zero (text) or one (binary).
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.
The length of the parameter value, in bytes (this count
- does not include itself). Can be zero.
- As a special case, -1 indicates a NULL parameter value.
- No value bytes follow in the NULL case.
+ does not include itself). Can be zero.
+ As a special case, -1 indicates a NULL parameter value.
+ No value bytes follow in the NULL case.
The value of the parameter, in the format indicated by the
- associated format code.
+ associated format code.
n is the above length.
- The number of result-column format codes that follow
- (denoted R> below).
- This can be zero to indicate that there are no result columns
- or that the result columns should all use the default format
- (text);
- or one, in which case the specified format code is applied
- to all result columns (if any); or it can equal the actual
- number of result columns of the query.
+ The number of result-column format codes that follow
+ (denoted R> below).
+ This can be zero to indicate that there are no result columns
+ or that the result columns should all use the default format
+ (text);
+ or one, in which case the specified format code is applied
+ to all result columns (if any); or it can equal the actual
+ number of result columns of the query.
The result-column format codes. Each must presently be
- zero (text) or one (binary).
+ zero (text) or one (binary).
The name of the prepared statement or portal to close
- (an empty string selects the unnamed prepared statement
- or portal).
+ (an empty string selects the unnamed prepared statement
+ or portal).
rows is the number of rows
inserted. oid is the object ID
of the inserted row if rows is 1
- and the target table has OIDs;
- otherwise oid is 0.
+ and the target table has OIDs;
+ otherwise oid is 0.
For a DELETE command, the tag is
- DELETE rows where
+ DELETE rows where
rows is the number of rows deleted.
For an UPDATE command, the tag is
- UPDATE rows where
+ UPDATE rows where
rows is the number of rows updated.
Data that forms part of a COPY data stream. Messages sent
- from the backend will always correspond to single data rows,
- but messages sent by frontends may divide the data stream
- arbitrarily.
+ from the backend will always correspond to single data rows,
+ but messages sent by frontends may divide the data stream
+ arbitrarily.
Identifies the message as a Start Copy In response.
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).
0 indicates the overall COPY format is textual (rows
- separated by newlines, columns separated by separator
- characters, etc).
- 1 indicates the overall copy format is binary (similar
- to DataRow format).
- See
- for more information.
+ separated by newlines, columns separated by separator
+ characters, etc).
+ 1 indicates the overall copy format is binary (similar
+ to DataRow format).
+ See
+ for more information.
- The number of columns in the data to be copied
- (denoted N> below).
+ The number of columns in the data to be copied
+ (denoted N> below).
The format codes to be used for each column.
- Each must presently be zero (text) or one (binary).
- All must be zero if the overall copy format is textual.
+ Each must presently be zero (text) or one (binary).
+ All must be zero if the overall copy format is textual.
- The number of columns in the data to be copied
- (denoted N> below).
+ The number of columns in the data to be copied
+ (denoted N> below).
The format codes to be used for each column.
- Each must presently be zero (text) or one (binary).
- All must be zero if the overall copy format is textual.
+ Each must presently be zero (text) or one (binary).
+ All must be zero if the overall copy format is textual.
The length of the column value, in bytes (this count
- does not include itself). Can be zero.
- As a special case, -1 indicates a NULL column value.
- No value bytes follow in the NULL case.
+ does not include itself). Can be zero.
+ As a special case, -1 indicates a NULL column value.
+ No value bytes follow in the NULL case.
The value of the column, in the format indicated by the
- associated format code.
+ associated format code.
n is the above length.
The name of the prepared statement or portal to describe
- (an empty string selects the unnamed prepared statement
- or portal).
+ (an empty string selects the unnamed prepared statement
+ or portal).
Identifies the message as a response to an empty query string.
- (This substitutes for CommandComplete.)
+ (This substitutes for CommandComplete.)
The message body consists of one or more identified fields,
- followed by a zero byte as a terminator. Fields may appear in
- any order. For each field there is the following:
+ followed by a zero byte as a terminator. Fields may appear in
+ any order. For each field there is the following:
A code identifying the field type; if zero, this is
- the message terminator and no string follows.
- The presently defined field types are listed in
- .
- Since more field types may be added in future,
- frontends should silently ignore fields of unrecognized
- type.
+ the message terminator and no string follows.
+ The presently defined field types are listed in
+ .
+ Since more field types may be added in future,
+ frontends should silently ignore fields of unrecognized
+ type.
The name of the portal to execute
- (an empty string selects the unnamed portal).
+ (an empty string selects the unnamed portal).
Maximum number of rows to return, if portal contains
- a query that returns rows (ignored otherwise). Zero
- denotes no limit>.
+ a query that returns rows (ignored otherwise). Zero
+ denotes no limit>.
- The number of argument format codes that follow
- (denoted C> below).
- This can be zero to indicate that there are no arguments
- or that the arguments all use the default format (text);
- or one, in which case the specified format code is applied
- to all arguments; or it can equal the actual number of
- arguments.
+ The number of argument format codes that follow
+ (denoted C> below).
+ This can be zero to indicate that there are no arguments
+ or that the arguments all use the default format (text);
+ or one, in which case the specified format code is applied
+ to all arguments; or it can equal the actual number of
+ arguments.
The argument format codes. Each must presently be
- zero (text) or one (binary).
+ zero (text) or one (binary).
The length of the argument value, in bytes (this count
- does not include itself). Can be zero.
- As a special case, -1 indicates a NULL argument value.
- No value bytes follow in the NULL case.
+ does not include itself). Can be zero.
+ As a special case, -1 indicates a NULL argument value.
+ No value bytes follow in the NULL case.
The value of the argument, in the format indicated by the
- associated format code.
+ associated format code.
n is the above length.
The format code for the function result. Must presently be
- zero (text) or one (binary).
+ zero (text) or one (binary).
The length of the function result value, in bytes (this count
- does not include itself). Can be zero.
- As a special case, -1 indicates a NULL function result.
- No value bytes follow in the NULL case.
+ does not include itself). Can be zero.
+ As a special case, -1 indicates a NULL function result.
+ No value bytes follow in the NULL case.
The value of the function result, in the format indicated by
- the associated format code.
+ the associated format code.
n is the above length.
The message body consists of one or more identified fields,
- followed by a zero byte as a terminator. Fields may appear in
- any order. For each field there is the following:
+ followed by a zero byte as a terminator. Fields may appear in
+ any order. For each field there is the following:
A code identifying the field type; if zero, this is
- the message terminator and no string follows.
- The presently defined field types are listed in
- .
- Since more field types may be added in future,
- frontends should silently ignore fields of unrecognized
- type.
+ the message terminator and no string follows.
+ The presently defined field types are listed in
+ .
+ Since more field types may be added in future,
+ frontends should silently ignore fields of unrecognized
+ type.
Additional information passed from the notifying process.
- (Currently, this feature is unimplemented so the field
- is always an empty string.)
+ (Currently, this feature is unimplemented so the field
+ is always an empty string.)
The number of parameters used by the statement
- (may be zero).
+ (may be zero).
The name of the destination prepared statement
- (an empty string selects the unnamed prepared statement).
+ (an empty string selects the unnamed prepared statement).
The number of parameter data types specified
- (may be zero). Note that this is not an indication of
- the number of parameters that might appear in the
- query string, only the number that the frontend wants to
- prespecify types for.
+ (may be zero). Note that this is not an indication of
+ the number of parameters that might appear in the
+ query string, only the number that the frontend wants to
+ prespecify types for.
Specifies the object ID of the parameter data type.
- Placing a zero here is equivalent to leaving the type
- unspecified.
+ Placing a zero here is equivalent to leaving the type
+ unspecified.
Identifies the message as a portal-suspended indicator.
- Note this only appears if an Execute message's row-count limit
- was reached.
+ Note this only appears if an Execute message's row-count limit
+ was reached.
Current backend transaction status indicator.
- Possible values are 'I>' if idle (not in
- a transaction block); 'T>' if in a transaction
- block; or 'E>' if in a failed transaction
- block (queries will be rejected until block is ended).
+ Possible values are 'I>' if idle (not in
+ a transaction block); 'T>' if in a transaction
+ block; or 'E>' if in a failed transaction
+ block (queries will be rejected until block is ended).
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.
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.
The data type size (see pg_type.typlen>).
- Note that negative values denote variable-width types.
+ Note that negative values denote variable-width types.
The type modifier (see pg_attribute.atttypmod>).
- The meaning of the modifier is type-specific.
+ The meaning of the modifier is type-specific.
The format code being used for the field. Currently will
- be zero (text) or one (binary). In a RowDescription
- returned from the statement variant of Describe, the
- format code is not yet known and will always be zero.
+ be zero (text) or one (binary). In a RowDescription
+ returned from the statement variant of Describe, the
+ format code is not yet known and will always be zero.
The protocol version number. The most significant 16 bits are
the major version number (3 for the protocol described here).
- The least significant 16 bits are the minor version number
- (0 for the protocol described here).
+ The least significant 16 bits are the minor version number
+ (0 for the protocol described here).
The protocol version number is followed by one or more pairs of
- parameter name and value strings. A zero byte is required as a
- terminator after the last name/value pair.
- Parameters can appear in any
- order. user> is required, others are optional.
- Each parameter is specified as:
+ parameter name and value strings. A zero byte is required as a
+ terminator after the last name/value pair.
+ Parameters can appear in any
+ order. user> is required, others are optional.
+ Each parameter is specified as:
The database user name to connect as. Required;
- there is no default.
+ there is no default.
Command-line arguments for the backend. (This is
- deprecated in favor of setting individual run-time
- parameters.)
+ deprecated in favor of setting individual run-time
+ parameters.)
In addition to the above, any run-time parameter that can be
- set at backend start time may be listed. Such settings
- will be applied during backend start (after parsing the
- command-line options if any). The values will act as
- session defaults.
+ set at backend start time may be listed. Such settings
+ will be applied during backend start (after parsing the
+ command-line options if any). The values will act as
+ session defaults.
Severity: the field contents are
ERROR>, FATAL>, or
PANIC> (in an error message), or
- WARNING>, NOTICE>, DEBUG>,
- INFO>, or LOG> (in a notice message),
- or a localized translation of one of these. Always present.
+ WARNING>, NOTICE>, DEBUG>,
+ INFO>, or LOG> (in a notice message),
+ or a localized translation of one of these. Always present.
Code: the SQLSTATE code for the error (see
- linkend="errcodes-appendix">). Not localizable. Always present.
+ linkend="errcodes-appendix">). Not localizable. Always present.
Hint: an optional suggestion what to do about the problem.
- This is intended to differ from Detail in that it offers advice
- (potentially inappropriate) rather than hard facts.
- May run to multiple lines.
+ This is intended to differ from Detail in that it offers advice
+ (potentially inappropriate) rather than hard facts.
+ May run to multiple lines.
Position: the field value is a decimal ASCII integer, indicating
- an error cursor position as an index into the original query string.
- The first character has index 1, and positions are measured in
- characters not bytes.
+ an error cursor position as an index into the original query string.
+ The first character has index 1, and positions are measured in
+ characters not bytes.
File: the file name of the source-code location where the error
- was reported.
+ was reported.
Line: the line number of the source-code location where the error
- was reported.
+ was reported.
*
*
* 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 $
*
*-------------------------------------------------------------------------
*/
Oid rettype;
Oid funcid;
ListCell *l;
+ ListCell *nextl;
Node *first_arg = NULL;
- int nargs = list_length(fargs);
- int argn;
+ int nargs;
Oid actual_arg_types[FUNC_MAX_ARGS];
Oid *declared_arg_types;
Node *retval;
* protect against array overruns, etc. Of course, this may not be a
* function, but the test doesn't hurt.
*/
- if (nargs > FUNC_MAX_ARGS)
+ if (list_length(fargs) > FUNC_MAX_ARGS)
ereport(ERROR,
(errcode(ERRCODE_TOO_MANY_ARGUMENTS),
errmsg("cannot pass more than %d arguments to a function",
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)
{
first_arg = linitial(fargs);
*/
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))
{
}
/*
- * Okay, it's not a column projection, so it must really be a
- * 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);
- }
-
- /*
+ * Okay, it's not a column projection, so it must really be a function.
* func_get_detail looks up the function in the catalogs, does
* disambiguation for polymorphic functions, handles inheritance, and
* returns the funcid and type and set or singleton status of the