Commit Graph

34 Commits

Author SHA1 Message Date
Daniele Varrazzo
6e841a41e6 Dropped PSYCOPG_EXTENSIONS flag
Building without extensions has been long broken and nobody really cares
about a pure-DBAPI implementation (which could be created using a wrapper
instead).
2014-08-23 19:30:48 +01:00
Piotr Kasprzyk
31b6ec63f8 Fix multiple misspellings 2013-04-26 09:59:40 +01:00
Daniele Varrazzo
6bc4b23af5 Static-type psycopg_escape_string connection parameter 2013-04-05 00:07:36 +01:00
Daniele Varrazzo
7177f815a6 Store a PGresult in the Exception error
This makes the Diagnostics independent from further operations on the cursor
and allows using it with exceptions not generated by a cursor.
2013-03-19 23:42:54 +00:00
Daniele Varrazzo
5bfb6cdefe Use more compact macros to annotate functions for the static checker 2012-03-01 02:53:28 +00:00
Daniele Varrazzo
f2e4a8ed78 Functions setting exception return a negative value on error
This works around another shortcoming of the static checker; also to be
discussed with the author.
2012-03-01 02:53:28 +00:00
Daniele Varrazzo
a167822e26 Use the newly provided attributes to validate exceptions raising
Be more consistent in using 0 for success, <0 for failure, and to check
for values < 0 instead of specific -1.
2012-03-01 02:53:28 +00:00
Daniele Varrazzo
a6df55f4e3 Flag the psycopg_ensure_*() functions as stealing a ref 2012-02-24 10:41:02 +00:00
Daniele Varrazzo
1db9c9b8ce The cursor name can be a non-valid PostgreSQL identifier 2011-02-23 01:53:25 +00:00
Daniele Varrazzo
beffb02d56 Stricter declaration and correct use of psyco_set_error
It has long been used in wrong ways, with the function receiving a
connection or lobject instead of a cursor. It has always been unnoticed
(nobody has noticed the wrong object attached to the exception in the
wrong cases) but it started crashing the interpreter with Python 3.2 on
Windows.

Thanks to Jason Erickson for finding the problem and helping fixing it.
2011-02-21 00:31:09 +00:00
Daniele Varrazzo
b6d6fbbe8c Use a global object for NULL
Small optimization as NULL is a frequent value to build.
2011-02-17 20:09:52 +00:00
Daniele Varrazzo
b544354db2 COPY sends unicode to a file if it derives from io.TextIoBase
Fixes ticket #36.
2011-02-05 15:12:37 +01:00
Daniele Varrazzo
2e22eef727 Added utility function to convert bytes to string in Python 3. 2010-12-31 03:18:27 +01:00
Daniele Varrazzo
b4685bba4a Added utility function to get bytes from a str/unicode. 2010-12-31 03:18:26 +01:00
Daniele Varrazzo
ae06fb03e7 Added psycopg_strdup utility function. 2010-12-21 04:02:14 +00:00
Federico Di Gregorio
557608f715 Applied spelling fixes patch from Peter Eisentraut 2010-07-18 12:14:46 +02:00
Federico Di Gregorio
611606d532 Changes license to LGPL3 + OpenSSL exception on all source files 2010-02-12 23:34:53 +01:00
James Henstridge
e7b8d6505e Remove backward compatibility support for Python versions older than
2.4, since we don't really support them any way.
2008-12-26 09:37:44 +09:00
Federico Di Gregorio
5c982d90f0 Unified string quoting 2008-11-25 19:18:17 +01:00
Federico Di Gregorio
c1d6073531 Applied COPY patch from Alejandro Dubrovsky 2008-11-25 17:45:22 +01:00
James Henstridge
cc2aa0a9ca * psycopg/psycopg.h (NotSupportedError_doc): clean up
spelling/grammar a bit, using exception description from the PEP.
2008-09-23 17:22:37 +08:00
Federico Di Gregorio
f6a25ccdf0 Build fix from Jorgen Austvik 2008-08-02 10:30:36 +02:00
Federico Di Gregorio
e95a4d9d2e get_backend_pid() patch and fixes 2008-07-26 15:09:20 +02:00
James Henstridge
fe853d0261 * psycopg/typecast.c (typecast_pydatetime): make array static.
(typecast_mxdatetime): same here.

	* psycopg/typecast_builtins.c (typecast_builtins): make array
	static.

	* psycopg/psycopgmodule.c: add hidden visibility to a bunch of
	global variables here.

	* psycopg/psycopg.h: add set QueryCanceledError and
	TransactionRollbackError to hidden visibility.
2008-01-21 21:41:17 +00:00
James Henstridge
864d107325 * psycypg/*.h: apply HIDDEN to all global variables and functions
that should not be exported from the module.  This results in a 5%
	reduction in code size and shortens the dynamic symbol table.

	* psycopg/config.h: If GCC >= 4.0 is installed, define the HIDDEN
	symbol to apply the "hidden" visibility attribute.
2008-01-21 05:54:01 +00:00
James Henstridge
f64cbeda46 * tests/test_transaction.py (DeadlockSerializationTestCase): port
over some tests for serialisation and deadlock errors,
	demonstrating that TransactionRollbackError is generated.
	(QueryCancelationTests): add a test to show that
	QueryCanceledError is raised on statement timeouts.

	* psycopg2da/adapter.py (_handle_psycopg_exception): rather than
	checking exception messages, check for TransactionRollbackError.

	* psycopg/pqpath.c (exception_from_sqlstate): return
	TransactionRollbackError for 40xxx errors, and QueryCanceledError
	for 57014 errors.
	(pq_raise): If we are using an old server, use
	TransactionRollbackError if the error message contains "could not
	serialize" or "deadlock detected".

	* psycopg/psycopgmodule.c (_psyco_connect_fill_exc): remove
	function, since we no longer need to store pointers to the
	exceptions in the connection.  This also fixes a reference leak.
	(psyco_connect): remove _psyco_connect_fill_exc() function call.

	* psycopg/connection.h (connectionObject): remove exception
	members from struct.

	* psycopg/connection_type.c (connectionObject_getsets): modify the
	exception attributes on the connection object from members to
	getsets.  This reduces the size of the struct.

	* lib/extensions.py: import the two new extensions.

	* psycopg/psycopgmodule.c (exctable): add new QueryCanceledError
	and TransactionRollbackError exceptions.
2008-01-16 05:14:24 +00:00
James Henstridge
fd5d2d5238 * psycopg/pqpath.c (pq_raise): only remove the first 8 characters
of the exception message if it actually gives the severity.

	* psycopg/pqpath.h (pq_resolve_critical): add prototype, since
	this function is being used from connection_int.c.

	* psycopg/psycopg.h: update psyco_set_error() prototype.

	* psycopg/psycopgmodule.c (psyco_errors_init): set pgerror, pgcode
	and cursor class attributes to None on psycopg2.Error so that the
	attributes will always be available (simplifies error handling).
	(psyco_set_error): add const qualifiers to msg, pgerror and pgcode
	arguments.
	Don't bother setting pgerror, pgcode or cursor to None if they are
	not provided -- the class defaults take care of this.
2007-12-19 14:29:03 +00:00
Daniele Varrazzo
e1dd9ca843 Fixed bug #192 (Decimal support not safe for use with multiple sub
interpreters) as proposed by Graham Dumpleton.

If running in the main interpreter, use a cached version of the Decimal
object. Else repeat the object lookup.
2007-10-21 03:22:55 +00:00
Federico Di Gregorio
d6e232e2b9 Various fixes, now all examples work. 2007-04-13 14:07:11 +00:00
Federico Di Gregorio
e5829292cd Fixed both Python 2.5 and 64 bit problems. 2007-04-10 06:36:18 +00:00
Federico Di Gregorio
1fe6269904 Piet Delport patches: final cleanup and PEP 353 macros. 2006-09-23 05:19:30 +00:00
Daniele Varrazzo
202c002c5c * Docstrings added/fixed
* Added __all__ attributes to Python modules to explicit the package API
2006-01-12 18:36:57 +00:00
Federico Di Gregorio
96ff591d79 Extra attributes for ProgrammingError exception. 2006-01-05 08:13:03 +00:00
Federico Di Gregorio
c904d97f69 Initial psycopg 2 import after SVN crash. 2004-10-19 03:17:12 +00:00