source: trunk/docs/contents/changelog.rst @ 798

Last change on this file since 798 was 798, checked in by cito, 4 years ago

Port type cache and typecasting from pgdb to pg

So far, the typecasting in the classic module was been only done by
the C extension module and was not extensible through typecasting
functions in Python. This has now been made extensible by adding
a cast hook to the C extension module which has been hooked up to
a new type cache object that holds information on the types and the
associated typecast functions. All of this works very similar to the
pgdb module now, except that the basic types are still handled by
the C extension module and the Python typecast functions are only
called via the hook for types which are not supported internally.

Also added tests and a chapter on the type cache in the documentation,
and cleaned up the error messages in the C extension module.

  • Property svn:keywords set to Author Date Id Revision
File size: 21.4 KB
4Version 5.0
6- This version now runs on both Python 2 and Python 3.
7- The supported versions are Python 2.6 to 2.7, and 3.3 to 3.5.
8- PostgreSQL is supported in all versions from 9.0 to 9.5.
9- Changes in the DB-API 2 module (pgdb):
10  - The DB-API 2 module now always returns result rows as named tuples
11    instead of simply lists as before. The documentation explains how
12    you can restore the old behavior or use custom row objects instead.
13  - The names of the various classes used by the classic and DB-API 2
14    modules have been renamed to become simpler, more intuitive and in
15    line with the names used in the DB-API 2 documentation.
16    Since the API provides only objects of these types through constructor
17    functions, this should not cause any incompatibilities.
18  - The DB-API 2 module now supports the callproc() cursor method. Note
19    that output parameters are currently not replaced in the return value.
20  - The DB-API 2 module now supports copy operations between data streams
21    on the client and database tables via the COPY command of PostgreSQL.
22    The cursor method copy_from() can be used to copy data from the database
23    to the client, and the cursor method copy_to() can be used to copy data
24    from the client to the database.
25  - The 7-tuples returned by the description attribute of a pgdb cursor
26    are now named tuples, i.e. their elements can be also accessed by name.
27    The column names and types can now also be requested through the
28    colnames and coltypes attributes, which are not part of DB-API 2 though.
29    The type_code provided by the description attribute is still equal to
30    the PostgreSQL internal type name, but now carries some more information
31    in additional attributes. The size, precision and scale information that
32    is part of the description is now properly set for numeric types.
33  - If you pass a Python list as one of the parameters to a DB-API 2 cursor,
34    it is now automatically bound using an ARRAY constructor. If you pass a
35    Python tuple, it is bound using a ROW constructor. This is useful for
36    passing records as well as making use of the IN syntax.
37  - Inversely, when a fetch method of a DB-API 2 cursor returns a PostgreSQL
38    array, it is passed to Python as a list, and when it returns a PostgreSQL
39    composite type, it is passed to Python as a named tuple. PyGreSQL uses
40    a new fast built-in parser to achieve this. Anonymous composite types are
41    also supported, but yield only an ordinary tuple containing text strings.
42- Changes in the classic PyGreSQL module (pg):
43  - The classic interface got two new methods get_as_list() and get_as_dict()
44    returning a database table as a Python list or dict. The amount of data
45    returned can be controlled with various parameters.
46  - A method upsert() has been added to the DB wrapper class that utilitses
47    the "upsert" feature that is new in PostgreSQL 9.5. The new method nicely
48    complements the existing get/insert/update/delete() methods.
49  - When using insert/update/upsert(), you can now pass PostgreSQL arrays as
50    lists and PostgreSQL records as tuples in the classic module.
51  - Conversely, when the query method returns a PostgreSQL array, it is passed
52    to Python as a list. PostgreSQL records are converted to named tuples as
53    well, but only if you use one of the get/insert/update/delete() methods.
54    PyGreSQL uses a new fast built-in parser to achieve this.
55  - The pkey() method of the classic interface now returns tuples instead
56    of frozenset. The order of the tuples is like in the primary key index.
57  - Like the DB-API 2 module, the classic module now also returns bytea columns
58    fetched from the database as byte strings, so you don't need to call
59    unescape_bytea() any more.
60  - A method set_jsondecode() has been added for changing or removing the
61    function that automatically decodes JSON data coming from the database.
62    By default, decoding JSON is now enabled and uses the decoder function
63    in the standard library with its default parameters.
64  - The table name that is affixed to the name of the OID column returned
65    by the get() method of the classic interface will not automatically
66    be fully qualified any more. This reduces overhead from the interface,
67    but it means you must always write the table name in the same way when
68    you call the methods using it and you are using tables with OIDs.
69    Also, OIDs are now only used when access via primary key is not possible.
70    Note that OIDs are considered deprecated anyway, and they are not created
71    by default any more in PostgreSQL 8.1 and later.
72  - The internal caching and automatic quoting of class names in the classic
73    interface has been simplified and improved, it should now perform better
74    and use less memory. Also, overhead for quoting values in the DB wrapper
75    methods has been reduced and security has been improved by passing the
76    values to libpq separately as parameters instead of inline.
77  - It is now possible to use regular type names instead of the simpler
78    type names that are used by default in PyGreSQL, without breaking any
79    of the mechanisms for quoting and typecasting, which rely on the type
80    information. This is achieved while maintaining simplicity and backward
81    compatibility by augmenting the type name string objects with all the
82    necessary information under the cover. To switch regular type names on
83    or off (this is the default), call the DB wrapper method use_regtypes().
84  - The methods for adapting and typecasting values pertaining to PostgreSQL
85    types have been refactored and swapped out to separate classes.
86- Changes concerning both modules:
87  - The modules now provide get_typecast() and set_typecast() methods
88    allowing to control the typecasting on the global level.  The connection
89    objects have got type caches with the same methods which give control
90    over the typecasting on the level of the current connection.
91    See the documentation on details about the type cache and the typecast
92    mechanisms provided by PyGreSQL.
93  - PyGreSQL now supports the JSON and JSONB data types, converting such
94    columns automatically to and from Python objects. If you want to insert
95    Python objects as JSON data using DB-API 2, you should wrap them in the
96    new Json() type constructor as a hint to PyGreSQL.
97  - Fast parsers for the input and output syntax for PostgreSQL arrays and
98    composite types have been added to the C module. Note that you can also
99    use multi-dimensional arrays with PyGreSQL.
100  - The tty parameter and attribute of database connections has been
101    removed since it is not supported any more since PostgreSQL 7.4.
103Version 4.2 (2016-01-21)
105- The supported Python versions are 2.4 to 2.7.
106- PostgreSQL is supported in all versions from 8.3 to 9.5.
107- Set a better default for the user option "escaping-funcs".
108- Force build to compile with no errors.
109- New methods get_parameters() and set_parameters() in the classic interface
110  which can be used to get or set run-time parameters.
111- New method truncate() in the classic interface that can be used to quickly
112  empty a table or a set of tables.
113- Fix decimal point handling.
114- Add option to return boolean values as bool objects.
115- Add option to return money values as string.
116- get_tables() does not list information schema tables any more.
117- Fix notification handler (Thanks Patrick TJ McPhee).
118- Fix a small issue with large objects.
119- Minor improvements of the NotificationHandler.
120- Converted documentation to Sphinx and added many missing parts.
121- The tutorial files have become a chapter in the documentation.
122- Greatly improved unit testing, tests run with Python 2.4 to 2.7 again.
124Version 4.1.1 (2013-01-08)
126- Add NotificationHandler class and method.  Replaces need for pgnotify.
127- Sharpen test for inserting current_timestamp.
128- Add more quote tests.  False and 0 should evaluate to NULL.
129- More tests - Any number other than 0 is True.
130- Do not use positional parameters internally.
131  This restores backward compatibility with version 4.0.
132- Add methods for changing the decimal point.
134Version 4.1 (2013-01-01)
136- Dropped support for Python below 2.5 and PostgreSQL below 8.3.
137- Added support for Python up to 2.7 and PostgreSQL up to 9.2.
138- Particularly, support PQescapeLiteral() and PQescapeIdentifier().
139- The query method of the classic API now supports positional parameters.
140  This an effective way to pass arbitrary or unknown data without worrying
141  about SQL injection or syntax errors (contribution by Patrick TJ McPhee).
142- The classic API now supports a method namedresult() in addition to
143  getresult() and dictresult(), which returns the rows of the result
144  as named tuples if these are supported (Python 2.6 or higher).
145- The classic API has got the new methods begin(), commit(), rollback(),
146  savepoint() and release() for handling transactions.
147- Both classic and DBAPI 2 connections can now be used as context
148  managers for encapsulating transactions.
149- The execute() and executemany() methods now return the cursor object,
150  so you can now write statements like "for row in cursor.execute(...)"
151  (as suggested by Adam Frederick).
152- Binary objects are now automatically escaped and unescaped.
153- Bug in money quoting fixed.  Amounts of $0.00 handled correctly.
154- Proper handling of date and time objects as input.
155- Proper handling of floats with 'nan' or 'inf' values as input.
156- Fixed the set_decimal() function.
157- All DatabaseError instances now have a sqlstate attribute.
158- The getnotify() method can now also return payload strings (#15).
159- Better support for notice processing with the new methods
160  set_notice_receiver() and get_notice_receiver()
161  (as suggested by Michael Filonenko, see #37).
162- Open transactions are rolled back when pgdb connections are closed
163  (as suggested by Peter Harris, see #46).
164- Connections and cursors can now be used with the "with" statement
165  (as suggested by Peter Harris, see #46).
166- New method use_regtypes() that can be called to let getattnames()
167  return regular type names instead of the simplified classic types (#44).
169Version 4.0 (2009-01-01)
171- Dropped support for Python below 2.3 and PostgreSQL below 7.4.
172- Improved performance of fetchall() for large result sets
173  by speeding up the type casts (as suggested by Peter Schuller).
174- Exposed exceptions as attributes of the connection object.
175- Exposed connection as attribute of the cursor object.
176- Cursors now support the iteration protocol.
177- Added new method to get parameter settings.
178- Added customizable row_factory as suggested by Simon Pamies.
179- Separated between mandatory and additional type objects.
180- Added keyword args to insert, update and delete methods.
181- Added exception handling for direct copy.
182- Start transactions only when necessary, not after every commit().
183- Release the GIL while making a connection
184  (as suggested by Peter Schuller).
185- If available, use decimal.Decimal for numeric types.
186- Allow DB wrapper to be used with DB-API 2 connections
187  (as suggested by Chris Hilton).
188- Made private attributes of DB wrapper accessible.
189- Dropped dependence on mx.DateTime module.
190- Support for PQescapeStringConn() and PQescapeByteaConn();
191  these are now also used by the internal _quote() functions.
192- Added 'int8' to INTEGER types. New SMALLINT type.
193- Added a way to find the number of rows affected by a query()
194  with the classic pg module by returning it as a string.
195  For single inserts, query() still returns the oid as an integer.
196  The pgdb module already provides the "rowcount" cursor attribute
197  for the same purpose.
198- Improved getnotify() by calling PQconsumeInput() instead of
199  submitting an empty command.
200- Removed compatibility code for old OID munging style.
201- The insert() and update() methods now use the "returning" clause
202  if possible to get all changed values, and they also check in advance
203  whether a subsequent select is possible, so that ongoing transactions
204  won't break if there is no select privilege.
205- Added "protocol_version" and "server_version" attributes.
206- Revived the "user" attribute.
207- The pg module now works correctly with composite primary keys;
208  these are represented as frozensets.
209- Removed the undocumented and actually unnecessary "view" parameter
210  from the get() method.
211- get() raises a nicer ProgrammingError instead of a KeyError
212  if no primary key was found.
213- delete() now also works based on the primary key if no oid available
214  and returns whether the row existed or not.
216Version 3.8.1 (2006-06-05)
218- Use string methods instead of deprecated string functions.
219- Only use SQL-standard way of escaping quotes.
220- Added the functions escape_string() and escape/unescape_bytea()
221  (as suggested by Charlie Dyson and Kavous Bojnourdi a long time ago).
222- Reverted code in clear() method that set date to current.
223- Added code for backwards compatibility in OID munging code.
224- Reorder attnames tests so that "interval" is checked for before "int."
225- If caller supplies key dictionary, make sure that all has a namespace.
227Version 3.8 (2006-02-17)
229- Installed new favicon.ico from Matthew Sporleder <>
230- Replaced snprintf by PyOS_snprintf.
231- Removed NO_SNPRINTF switch which is not needed any longer
232- Clean up some variable names and namespace
233- Add get_relations() method to get any type of relation
234- Rewrite get_tables() to use get_relations()
235- Use new method in get_attnames method to get attributes of views as well
236- Add Binary type
237- Number of rows is now -1 after executing no-result statements
238- Fix some number handling
239- Non-simple types do not raise an error any more
240- Improvements to documentation framework
241- Take into account that nowadays not every table must have an oid column
242- Simplification and improvement of the inserttable() function
243- Fix up unit tests
244- The usual assortment of minor fixes and enhancements
246Version 3.7 (2005-09-07)
248Improvement of pgdb module:
250- Use Python standard `datetime` if `mxDateTime` is not available
252Major improvements and clean-up in classic pg module:
254- All members of the underlying connection directly available in `DB`
255- Fixes to quoting function
256- Add checks for valid database connection to methods
257- Improved namespace support, handle `search_path` correctly
258- Removed old dust and unnessesary imports, added docstrings
259- Internal sql statements as one-liners, smoothed out ugly code
261Version 3.6.2 (2005-02-23)
263- Further fixes to namespace handling
265Version 3.6.1 (2005-01-11)
267- Fixes to namespace handling
269Version 3.6 (2004-12-17)
271- Better DB-API 2.0 compliance
272- Exception hierarchy moved into C module and made available to both APIs
273- Fix error in update method that caused false exceptions
274- Moved to standard exception hierarchy in classic API
275- Added new method to get transaction state
276- Use proper Python constants where appropriate
277- Use Python versions of strtol, etc. Allows Win32 build.
278- Bug fixes and cleanups
280Version 3.5 (2004-08-29)
282Fixes and enhancements:
284- Add interval to list of data types
285- fix up method wrapping especially close()
286- retry pkeys once if table missing in case it was just added
287- wrap query method separately to handle debug better
288- use isinstance instead of type
289- fix free/PQfreemem issue - finally
290- miscellaneous cleanups and formatting
292Version 3.4 (2004-06-02)
294Some cleanups and fixes.
295This is the first version where PyGreSQL is moved back out of the
296PostgreSQL tree. A lot of the changes mentioned below were actually
297made while in the PostgreSQL tree since their last release.
299- Allow for larger integer returns
300- Return proper strings for true and false
301- Cleanup convenience method creation
302- Enhance debugging method
303- Add reopen method
304- Allow programs to preload field names for speedup
305- Move OID handling so that it returns long instead of int
306- Miscellaneous cleanups and formatting
308Version 3.3 (2001-12-03)
310A few cleanups.  Mostly there was some confusion about the latest version
311and so I am bumping the number to keep it straight.
313- Added NUMERICOID to list of returned types. This fixes a bug when
314  returning aggregates in the latest version of PostgreSQL.
316Version 3.2 (2001-06-20)
318Note that there are very few changes to PyGreSQL between 3.1 and 3.2.
319The main reason for the release is the move into the PostgreSQL
320development tree.  Even the WIN32 changes are pretty minor.
322- Add Win32 support (
323- Fix some DB-API quoting problems (
324- Moved development into PostgreSQL development tree.
326Version 3.1 (2000-11-06)
328- Fix some quoting functions.  In particular handle NULLs better.
329- Use a method to add primary key information rather than direct
330  manipulation of the class structures
331- Break decimal out in `_quote` (in and treat it as float
332- Treat timestamp like date for quoting purposes
333- Remove a redundant SELECT from the `get` method speeding it,
334  and `insert` (since it calls `get`) up a little.
335- Add test for BOOL type in typecast method to `pgdbTypeCache` class
336  (
337- Fix to send port as integer to lower level function
338  (
339- Change to speed up some operations
340- Allow updates on tables with no primary keys
342Version 3.0 (2000-05-30)
344- Remove strlen() call from pglarge_write() and get size from object
345  (
346- Add a little more error checking to the quote function in the wrapper
347- Add extra checking in `_quote` function
348- Wrap query in for debugging
349- Add DB-API 2.0 support to pgmodule.c (
350- Add DB-API 2.0 wrapper (
351- Correct keyword clash (temp) in tutorial
352- Clean up layout of tutorial
353- Return NULL values as None (
354  (WARNING: This will cause backwards compatibility issues)
355- Change None to NULL in insert and update
356- Change hash-bang lines to use /usr/bin/env
357- Clearing date should be blank (NULL) not TODAY
358- Quote backslashes in strings in `_quote` (brian@CSUA.Berkeley.EDU)
359- Expanded and clarified build instructions (
360- Make code thread safe (
361- Add README.distutils ( &
362- Many fixes and increased DB-API compliance by,
363, and others to get the final
364  version ready to release.
366Version 2.4 (1999-06-15)
368- Insert returns None if the user doesn't have select permissions
369  on the table.  It can (and does) happen that one has insert but
370  not select permissions on a table.
371- Added ntuples() method to query object (
372- Corrected a bug related to getresult() and the money type
373- Corrected a bug related to negative money amounts
374- Allow update based on primary key if munged oid not available and
375  table has a primary key
376- Add many __doc__ strings (
377- Get method works with views if key specified
379Version 2.3 (1999-04-17)
381- returns "localhost" when connected to Unix socket
382  (
383- Use `PyArg_ParseTupleAndKeywords` in connect() (
384- fixes and cleanups (
385- Fixed memory leak in dictresult() (
386- Deprecated - functionality now in
387- More cleanups to the tutorial
388- Added fileno() method - (Mikhail Terekhov)
389- added money type to quoting function
390- Compiles cleanly with more warnings turned on
391- Returns PostgreSQL error message on error
392- Init accepts keywords (Jarkko Torppa)
393- Convenience functions can be overridden (Jarkko Torppa)
394- added close() method
396Version 2.2 (1998-12-21)
398- Added user and password support thanks to Ng Pheng Siong (
399- Insert queries return the inserted oid
400- Add new `pg` wrapper (C module renamed to _pg)
401- Wrapped database connection in a class
402- Cleaned up some of the tutorial.  (More work needed.)
403- Added `version` and `__version__`.
404  Thanks to for the suggestion.
406Version 2.1 (1998-03-07)
408- return fields as proper Python objects for field type
409- Cleaned up
410- Added dictresult method
412Version 2.0  (1997-12-23)
414- Updated code for PostgreSQL 6.2.1 and Python 1.5
415- Reformatted code and converted to use full ANSI style prototypes
416- Changed name to PyGreSQL (from PyGres95)
417- Changed order of arguments to connect function
418- Created new type `pgqueryobject` and moved certain methods to it
419- Added a print function for pgqueryobject
420- Various code changes - mostly stylistic
422Version 1.0b (1995-11-04)
424- Keyword support for connect function moved from library file to C code
425  and taken away from library
426- Rewrote documentation
427- Bug fix in connect function
428- Enhancements in large objects interface methods
430Version 1.0a (1995-10-30)
432A limited release.
434- Module adapted to standard Python syntax
435- Keyword support for connect function in library file
436- Rewrote default parameters interface (internal use of strings)
437- Fixed minor bugs in module interface
438- Redefinition of error messages
440Version 0.9b (1995-10-10)
442The first public release.
444- Large objects implementation
445- Many bug fixes, enhancements, ...
447Version 0.1a (1995-10-07)
449- Basic libpq functions (SQL access)
Note: See TracBrowser for help on using the repository browser.