Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 1714B9FA5F3 for ; Fri, 10 Nov 2006 06:03:10 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 31106-08-3 for ; Fri, 10 Nov 2006 06:03:02 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from beth.coza.net.za (beth.coza.net.za [206.223.136.193]) by postgresql.org (Postfix) with ESMTP id E4F559FB2ED for ; Fri, 10 Nov 2006 06:02:58 -0400 (AST) Received: from theo-laptop.int.coza.net.za ([206.223.136.211]) by beth.coza.net.za (8.11.6/8.11.2) with ESMTP id kAAA2rC15534 for ; Fri, 10 Nov 2006 12:02:54 +0200 Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by theo-laptop.int.coza.net.za (8.13.7/8.13.7) with ESMTP id kAAA2sUo006900 for ; Fri, 10 Nov 2006 12:02:54 +0200 Subject: Re: Documentation update for PQexecParams From: Theo Kramer Reply-To: theo@flame.co.za To: pgsql-docs@postgresql.org In-Reply-To: <200611101050.43400.peter_e@gmx.net> References: <1163009239.2384.2.camel@josh> <20061109144348.GA10157@fetter.org> <1163084688.2448.28.camel@theo-laptop.int.coza.net.za> <200611101050.43400.peter_e@gmx.net> Content-Type: multipart/mixed; boundary="=-ZpspM0iUL2sY8cq1pD9+" Organization: Flame Computing Enterprises cc Date: Fri, 10 Nov 2006 12:02:53 +0200 Message-Id: <1163152973.2422.14.camel@theo-laptop.int.coza.net.za> Mime-Version: 1.0 X-Mailer: Evolution 2.6.3 (2.6.3-1.fc5.5) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/7 X-Sequence-Number: 3841 --=-ZpspM0iUL2sY8cq1pD9+ Content-Type: text/plain Content-Transfer-Encoding: 7bit On Fri, 2006-11-10 at 10:50 +0100, Peter Eisentraut wrote: > Am Donnerstag, 9. November 2006 16:04 schrieb Theo Kramer: > > Thanks - attached output of 'diff -c libpq.sgml libpq.sgml.org' where > > libpq.sgml contains my proposed changes and libpq.sgml.org originates > > from the 8.2 Beta 2 distribution for comment. > > The patch is backwards. > Thanks - re-done and re-attached -- Regards Theo --=-ZpspM0iUL2sY8cq1pD9+ Content-Disposition: attachment; filename=libpq.sgml.dif Content-Type: text/x-patch; name=libpq.sgml.dif; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit *** libpq.sgml.org Mon Oct 23 20:10:31 2006 --- libpq.sgml Tue Nov 7 22:06:37 2006 *************** *** 956,962 **** are connected to. The number is formed by converting the major, minor, and revision numbers into two-decimal-digit numbers and appending them together. For example, version 8.1.5 will be returned as 80105, and version ! 8.1 will be returned as 80100 (leading zeroes are not shown). Zero is returned if the connection is bad. --- 956,962 ---- are connected to. The number is formed by converting the major, minor, and revision numbers into two-decimal-digit numbers and appending them together. For example, version 8.1.5 will be returned as 80105, and version ! 8.2 will be returned as 80200 (leading zeroes are not shown). Zero is returned if the connection is bad. *************** *** 1138,1178 **** ! If parameters are used, they are referred to in the command string ! as $1, $2, etc. ! nParams is the number of parameters supplied; it is the length ! of the arrays paramTypes[], paramValues[], ! paramLengths[], and paramFormats[]. (The ! array pointers may be NULL when nParams is zero.) ! paramTypes[] specifies, by OID, the data types to be assigned to ! the parameter symbols. If paramTypes is NULL, or any particular ! element in the array is zero, the server assigns a data type to the parameter ! symbol in the same way it would do for an untyped literal string. ! paramValues[] specifies the actual values of the parameters. ! A null pointer in this array means the corresponding parameter is null; ! otherwise the pointer points to a zero-terminated text string (for text ! format) or binary data in the format expected by the server (for binary ! format). ! paramLengths[] specifies the actual data lengths of ! binary-format parameters. It is ignored for null parameters and text-format ! parameters. The array pointer may be null when there are no binary ! parameters. ! paramFormats[] specifies whether parameters are text (put a zero ! in the array) or binary (put a one in the array). If the array pointer is ! null then all parameters are presumed to be text. ! resultFormat is zero to obtain results in text format, or one to ! obtain results in binary format. (There is not currently a provision to ! obtain different result columns in different formats, although that is ! possible in the underlying protocol.) ! ! ! The primary advantage of PQexecParams over PQexec is that parameter values may be separated from the command string, thus avoiding the need for tedious and error-prone quoting and escaping. Unlike PQexec, PQexecParams allows at most one SQL command in the given string. (There can be semicolons in it, but not more than one nonempty command.) This is a limitation of the underlying protocol, --- 1138,1237 ---- ! ! ! ! command ! ! ! The SQL command to be executed. If parameters are used, they are referred to in the command string ! as $1, $2, etc. ! ! ! ! ! ! nParams ! ! ! The number of parameters supplied; it is the length ! of the arrays paramTypes[], paramValues[], ! paramLengths[], and paramFormats[]. (The array pointers ! may be NULL when nParams is zero.) ! ! ! ! ! ! paramTypes[] ! ! ! Specifies, by OID, the data types to be assigned to ! the parameter symbols. If paramTypes is NULL, or any particular ! element in the array is zero, the server assigns a data type to the parameter ! symbol in the same way it would do for an untyped literal string. ! ! ! ! ! ! paramValues[] ! ! ! Specifies the actual values of the parameters. ! A null pointer in this array means the corresponding parameter is null; ! otherwise the pointer points to a zero-terminated text string (for text ! format) or binary data in the format expected by the server (for binary ! format). ! ! ! ! ! ! paramLengths[] ! ! ! Specifies the actual data lengths of binary-format parameters. ! It is ignored for null parameters and text-format parameters. ! The array pointer may be null when there are no binary parameters. ! ! ! ! ! ! paramFormats[] ! ! ! Specifies whether parameters are text (put a zero in the array for ! the corresponding parameter) or binary (put a one in the array for ! the corresponding parameter). If the array pointer is null then all ! parameters are presumed to be zero terminated text strings. ! ! ! ! ! ! resultFormat ! ! ! Specify zero to obtain results in text format, or one to ! obtain results in binary format. (There is not currently a provision to ! obtain different result columns in different formats, although that is ! possible in the underlying protocol.) ! ! ! ! + + The primary advantage of PQexecParams over PQexec is that parameter values may be separated from the command string, thus avoiding the need for tedious and error-prone quoting and escaping. + + Unlike PQexec, PQexecParams allows at most one SQL command in the given string. (There can be semicolons in it, but not more than one nonempty command.) This is a limitation of the underlying protocol, *************** *** 1200,1205 **** --- 1259,1416 ---- + shows a range of typical values for + paramTypes[] in column PG Type, as determined from + pg_type.h, as well as the corresponding SQL attribute names, ODBC and C types, and lengths. + + + + Parameter Types + + + + Name + PG Type + ODBC Type + C Type + Length Text Format + Length Binary Format + Description + + + + + + character(n) + BPCHAROID + SQL_CHAR + char[n + 1] + 0 + n + Blanks are automatically padded for the length of the string. + + + + varchar(n) + VARCHAROID + SQL_VARCHAR + char[n + 1] + 0 + n + Not blank padded. + + + + text + TEXTOID + SQL_LONGVARCHAR + char * + 0 + n + String with appropriate size must be allocated. Care must be taken not to overflow allocated string. + + + + smallint + INT2OID + SQL_SHORT + short + 0 + 2 + 2 byte short integer + + + + integer + INT4OID + SQL_INTEGER + int + 0 + 4 + 4 byte integer + + + + real + FLOAT4OID + SQL_REAL + float + 0 + 4 + 4 byte floating point + + + + double precision + FLOAT8OID + SQL_DOUBLE + double + 0 + 8 + 8 byte floating point + + + + numeric[(p,s)] + NUMERICOID + SQL_NUMERIC + structure + 0 + variable + Cast to and from double if no bcd library and use 8 as binary length. Equivalent to decimal[(p,s)] + + + + timestamp + TIMESTAMPOID + SQL_TYPE_TIMESTAMP + long long + 0 + 8 + + + + + +
+ + + Column Details + + + + Name The SQL attribute type. + + + PG Type The equivalent PostgreSQL type from + pg_types.h for paramTypes[]. + + + ODBC Type The equivalent ODBC type. + + + C Type The equivalent C language type. + + + Length Text Format indicates value for paramLengths[] + for text format. + + + Length Binary Format indicates value for paramLengths[] + for binary format. + + + + Refer to table for further details on data types supported. + + + + + + +
+ + PQpreparePQprepare --=-ZpspM0iUL2sY8cq1pD9+--