From: Billy G. A. <bal...@us...> - 2001-09-30 07:09:12
|
Update of /cvsroot/pypgsql/pypgsql In directory usw-pr-cvs1:/tmp/cvs-serv5686 Modified Files: Announce ChangeLog README Log Message: 30SEP2001 bga Updated file prior to releasing pyPgSQL Version 6.0. Index: Announce =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/Announce,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Announce 2001/09/20 03:52:32 1.11 --- Announce 2001/09/30 07:09:09 1.12 *************** *** 47,52 **** =================================== ! The following regression test cases have been added. These tests are ! designed to rigorously test a specific part of pyPgSQL: pgresult.py - Test cases for the libpq.PgResult object. --- 47,52 ---- =================================== ! The following regression test cases have been added. Each regression test ! is designed to rigorously test a specific part of pyPgSQL: pgresult.py - Test cases for the libpq.PgResult object. *************** *** 56,59 **** --- 56,71 ---- Changes to PgSQL.py ------------------- + * Added support for the PostgreSQL BYTEA type. This will allow binary + values to be stored in the database without the use of Large Objects. + + * Changed how strings are escaped/quoted for use as parameter in queries. + Modified code so that array elements are quoted differently from regular + attributes. The repr() function is no longer used. + + * Changed code so that libpq notices are only converted to Warning exceptions + in certain specific cases. This will prevent Warning exceptions from + occuring when tables with serial fields are created, etc. When Python 2.2 + is released, it's Warning framework will be used for libpq notices. + * Cleaned up the logic in hadleArray(). *************** *** 78,81 **** --- 90,100 ---- Changes to libpqmodule.c ------------------------ + * Added a new function to escape/quote strings. These function will escape/ + quote values used as array elements differently from regular fields. + + * Added new functions to escape/un-escape strings used as input/output + to/from bytea fields. These function will escape/quote values used as + array elements differently from regular fields. + * Removed code related to PostgreSQL 6.5.x. We now only support PostgreSQL 7.0 and later. *************** *** 91,94 **** --- 110,122 ---- Changes to pgconnection.c ------------------------- + * Removed the pgFixEsc() function. It is no longer needed since repr() is + not used to escape/quote strings. + + * Changed code so that a PgConnection object's members are set to None if + the finish() method is called. + + * Corrected bugs found while developing a set of regression tests for + pgconnection.c. + * Re-ordered the items in PgConnection_members so that the attributes handled directly by PgConnection_getattr are grouped together and *************** *** 97,105 **** * Removed code related to PostgreSQL 6.5.x. We now only support PostgreSQL 7.0 and later. - - * Modified pgFixEsc so that any escaped sequence (\xHH) whose value is - greater than 127 is replaced by the actual character. This works - around an apparent problem in PostgreSQL involving encodings. [Bug - #455514] * Use PyObject_Del() instead of PyMem_Free() in dealloc() to delete the --- 125,128 ---- Index: ChangeLog =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/ChangeLog,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** ChangeLog 2001/09/20 03:52:32 1.11 --- ChangeLog 2001/09/30 07:09:09 1.12 *************** *** 13,16 **** --- 13,28 ---- Changes to PgSQL.py ------------------- + * Added support for the PostgreSQL BYTEA type. This will allow binary + values to be stored in the database without the use of Large Objects. + + * Changed how strings are escaped/quoted for use as parameter in queries. + Modified code so that array elements are quoted differently from regular + attributes. The repr() function is no longer used. + + * Changed code so that libpq notices are only converted to Warning exceptions + in certain specific cases. This will prevent Warning exceptions from + occuring when tables with serial fields are created, etc. When Python 2.2 + is released, it's Warning framework will be used for libpq notices. + * Cleaned up the logic in hadleArray(). *************** *** 35,38 **** --- 47,57 ---- Changes to libpqmodule.c ------------------------ + * Added a new function to escape/quote strings. These function will escape/ + quote values used as array elements differently from regular fields. + + * Added new functions to escape/un-escape strings used as input/output + to/from bytea fields. These function will escape/quote values used as + array elements differently from regular fields. + * Removed code related to PostgreSQL 6.5.x. We now only support PostgreSQL 7.0 and later. *************** *** 48,51 **** --- 67,76 ---- Changes to pgconnection.c ------------------------- + * Removed the pgFixEsc() function. It is no longer needed since repr() is + not used to escape/quote strings. + + * Corrected some bugs found while developing a set of regression tests for + pgconnection.c. + * Re-ordered the items in PgConnection_members so that the attributes handled directly by PgConnection_getattr are grouped together and *************** *** 54,62 **** * Removed code related to PostgreSQL 6.5.x. We now only support PostgreSQL 7.0 and later. - - * Modified pgFixEsc so that any escaped sequence (\xHH) whose value is - greater than 127 is replaced by the actual character. This works - around an apparent problem in PostgreSQL involving encodings. [Bug - #455514] * Use PyObject_Del() instead of PyMem_Free() in dealloc() to delete the --- 79,82 ---- Index: README =================================================================== RCS file: /cvsroot/pypgsql/pypgsql/README,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** README 2001/09/20 03:52:32 1.12 --- README 2001/09/30 07:09:09 1.13 *************** *** 95,99 **** test/PgSQLTestCases.py - A set of functional test cases built using the Python Unit Testing Framework (pyunit) ! test/regression/* - Test cases to test specific object in pyPgSQL. examples/demo1a.py - Some example programs using libpq and PgSQL examples/demo1b.py --- 95,99 ---- test/PgSQLTestCases.py - A set of functional test cases built using the Python Unit Testing Framework (pyunit) ! test/regression/* - Test cases to test specific sections of pyPgSQL. examples/demo1a.py - Some example programs using libpq and PgSQL examples/demo1b.py *************** *** 222,225 **** --- 222,230 ---- PgInt2 - creates a PgInt2 object from a string or number. PgInt8 - creates a PgInt8 object from a string or number. + PgQuoteString - Quotes a string, escaping any characters as needed, + for use as input to a character/text field. + PgQuoteBytea - Escapes a string, which can contain NUL characters, + so that it can used as an input to a bytea field. + PgUnQuoteBytea - Reverses the action of PgQuoteBytes(). There are a number of constants defined in libpq. They are intended to be used *************** *** 417,420 **** --- 422,500 ---- Returns: A PgInt8 object initialized with the value of 'object'. + 2.1.11 PgLargeObject + -------------------- + + Syntax: o = PgLargeObject(PgConnection, OID) + + Description: This function will create a PgLargeObject object given a + PgConnection object and a PostgreSQL large object identifier + (OID). + + Returns: A closed PgLargeObject object. + + 2.1.12 PgQuoteString + -------------------- + + Syntax: s = PgQuoteString(string, forArray) + + Description: This function returns a copy of the input string with the fol- + lowing characters escaped: + 1. The backslash character (as '\\') + 2. The single quote (as "\'") + 3. The <CR> character (as '\r') + 4. The <NL> character (as '\n') + 5. The <BS> character (as '\b') + 6. The <FF> character (as '\f') + 7. The <TAB> character (as '\t') + 8. All other control characters as '\OOO' where OOO is + the octal representation of the character's ordinal + number. + The string is also quoted with single quotes. + + If forArray is one (1), the escaping is changed as follows: + 1. The backslash character (as '\\\\') + (2 through 7 remain the same) + 8. All other control characters as '\\\\000' + 9. The double quote (as '\"') + The string is also quoted with double quotes, instead of single + quotes. + + Returns: A quoted, escaped copy of the input string. + + 2.1.13 PgQuoteBytea + ------------------- + + Syntax: s = PgQuoteBytea(string) + + Description: This function returns a copy of the input string with char- + acters escaped as follows: + 1. <NUL> characters: '\\000' (Note: with 2 backslahes) + 2. Non-printable charactes: '\OOO' (Note OOO is the octal + representation of the characters ordinal number) + 3. Backslashes: '\\\\' (Note: with 4 backslashes) + 4. Single quote: "\'" + The string is also quoted with single quotes. + + If forArray is one (1), the escaping is changed as follows: + 1. <NUL> characters: '\\\\000' (Note: with 4 backslahes) + 2. Non-printable characters: '\\\\OOO' + 3. Backslashes: '\\\\\\\\' (Note: with 8 backslahes) + 4. Single quote: "\'" + 9. The double quote (as '\\"') + The string is also quoted with double quotes, instead of single + quotes. + + Returns: A quoted, escaped copy of the input string. + + 2.1.14 PgUnQuoteBytea + --------------------- + + Syntax: s = PgUnQuoteBytea(string) + + Description: This function un-escapes a string retrieved from a bytea field. + + Returns: A copy of the input string with any escaped character returned + to thier original value. + 2.2 The PgConnection Object --------------------------- *************** *** 479,484 **** endcopy - Sync with the backend (after a Copy-In/Copy-Out operation). lo_creat - Create a new, empty PgLargeObject. - lo_get - Create a PgLargeObject from an existing PostgreSQL large - object. lo_import - Import a file as a PostgreSQL large object, returning a PgLargeObject. --- 559,562 ---- *************** *** 730,745 **** Note: See the PostgreSQL C API documentation for details. - 2.2.17 lo_get - ------------- - - Syntax: lo = c.lo_get(oid) - - Returns: A PgLargeObject - - Description: Create a PgLargeObject from the given oid. This method has no - equivalent function in the PostgreSQL C API. - - Exceptions: InterfaceError, TypeError - 2.2.18 lo_import ---------------- --- 808,811 ---- *************** *** 800,806 **** resultStatus - The result status of the query. It returns the out- put of the PQresultStatus PostgreSQL C API function. - resultErrorMessage- The error message associated with the query, if any. - It returns The output of the PQresultErrorMessage - function. ntuples - The number of tuples (instances) in the query result. It returns the output of the PQntuples function call. --- 866,869 ---- *************** *** 932,944 **** PostgreSQL Type Returned Python Object --------------- ---------------------- ! PG_BOOL PgBoolean PG_OID Integer or PgLargeObject(1) ! PG_INT2 PgInt2 ! PG_INT4 Integer ! PG_INT8 PgInt8(2) or Long ! PG_MONEY Float ! PG_FLOAT4 Float ! PG_FLOAT8 Float ! All Other Types String (1) getvalue() will determine if the OID represents a --- 995,1008 ---- PostgreSQL Type Returned Python Object --------------- ---------------------- ! PG_BOOL PgBoolean PG_OID Integer or PgLargeObject(1) ! PG_INT2 PgInt2 ! PG_INT4 Integer ! PG_INT8 PgInt8(2) or Long ! PG_MONEY Float ! PG_FLOAT4 Float ! PG_FLOAT8 Float ! PG_BYTEA String(3) ! All Other Types String (1) getvalue() will determine if the OID represents a *************** *** 947,950 **** --- 1011,1016 ---- (2) PgInt8 type is only available on system that have long long (64 bit integer) support. + (3) Any escaped characters in the string will be returned + to thier original value in the returned string. getvalue implements and extends the PQgetvalue function. *************** *** 1170,1173 **** --- 1236,1243 ---- a Python Float can be used with a PgMoney object. + PgBytea - This class supports the PG_BYTEA data type. It is a wrapper + arround a Python String that provides for proper escaping of + the string when used in a query. + PgOther - This class supports all the other PostgreSQL data types that do not map directly into a Python object or one of the support *************** *** 1190,1193 **** --- 1260,1265 ---- PgInt2 - Construct a PgInt2 from a Python numeric or string. PgInt8 - Construct a PgInt8 from a Python numeric or string. + PgLargeObject - Construct a PgLargeObject from a PgConnection object and + a OID identifying a PostgreSQL large object. These constructors are documented in the libpq section of this document. *************** *** 1280,1281 **** --- 1352,1361 ---- a new transaction is created on the next call to execute(). + -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + + If a PostgreSQL array (represented by a Python list) is the only parameter to + a query, then it must be passed in a singleton tuple. For example: + + cnx.query('insert into table values(%s)', (list,)) + + -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= |