Commit Graph

2822 Commits

Author SHA1 Message Date
James Henstridge
ee235478bd * psycopg/lobject.h (lobjectObject): remove "mode" struct member,
since it was unused.
2008-05-06 18:12:50 +08:00
James Henstridge
9d20f5c09c * psycopg/lobject_*.c: replace uses of the closed struct member,
and change the Python level attribute to a getset.

	* psycopg/lobject.h (lobjectObject): remove the closed member,
	since "fd < 0" gives us the same information.  Reorder the struct
	members for better packing.
2008-05-06 18:07:54 +08:00
James Henstridge
2046ae34fb * psycopg/lobject*: const'ify the code. 2008-05-06 17:09:43 +08:00
James Henstridge
7d66c20edb * tests/test_lobject.py (LargeObjectTests): add more tests,
including behaviour on closed lobjects and stale lobjects.

	* psycopg/lobject_type.c (psyco_lobj_close): don't mark the
	connection closed here because it is done by
	lobject_close_locked().

	* psycopg/lobject_int.c (lobject_open): mark objects as not closed
	if we successfully open them.
	(lobject_close_locked): mark the lobject closed here.
	(lobject_export): ensure we are in a transaction, since
	lo_export() issues multiple queries.

	* psycopg/lobject_type.c (lobject_setup): make lobjects start closed.
2008-05-06 17:04:26 +08:00
James Henstridge
e627948a6b * psycopg/lobject.h: don't export the lobjectType symbol. 2008-05-05 22:51:15 +08:00
Federico Di Gregorio
0319bc8cc4 Fixed build error on SUN 2008-05-05 15:55:51 +02:00
James Henstridge
975d2286e8 Merge lobject work from trunk, plus fixes to make it work with current
psycopg2.
2008-05-05 19:23:33 +08:00
James Henstridge
9a48c261be Add basic tests for large object code. Fix lobject.seek() to actually
work.
2008-05-05 15:33:44 +08:00
James Henstridge
e192c603fa Fix up structmember definitions to match real types. T_LONG is not the
same as T_INT/T_UINT on AMD64 ...
2008-05-05 15:00:50 +08:00
James Henstridge
82557e65a2 Fix up pq_complete_error() calls. 2008-05-05 15:00:34 +08:00
James Henstridge
5beef38bfc Fix double free in case where PGresult is NULL. 2008-05-05 14:16:57 +08:00
James Henstridge
ec20fa8912 Some changes to the lobject code to match changes in pqpath.[ch]. 2008-05-05 12:07:24 +08:00
James Henstridge
3cfe438b74 Add an #endif I accidentally removed 2008-05-05 10:43:38 +08:00
James Henstridge
e01da0a540 add ignores 2008-05-05 10:39:13 +08:00
James Henstridge
938c456cee Merge changes from psycopg2/trunk via psycopg2.r243. 2008-05-05 10:37:24 +08:00
James Henstridge
31ef9355c2 Merge psycopg2/trunk into psycopg2/branches/2_0_x r243 (which is the
last revision merged into trunk).  Where file ID conflicts exist, but 
the content was equivalent, I've picked the 2_0_x version.
2008-05-05 10:22:22 +08:00
Fabio Tranchitella
fedfd53d54 Added encoding. 2008-04-09 09:49:55 +00:00
Fabio Tranchitella
5930078ec7 Add the encoding property into the ZMI add form (debian bug #475123). 2008-04-09 09:47:45 +00:00
Federico Di Gregorio
3b1c2b24de Signed all commits 2008-04-25 23:09:04 +02:00
James Henstridge
331c942800 2008-04-21 James Henstridge <james@jamesh.id.au>
* tests/test_quote.py (QuotingTestCase.test_unicode): If the
	server encoding is not UTF8, skip the unicode test and emit a
	warning.
2008-04-20 23:19:42 +00:00
James Henstridge
2f3f4c1258 2008-04-21 Jorgen Austvik <Jorgen.Austvik@sun.com>
* tests/*.py: use the DSN constructed in tests/__init__.py.

	* tests/__init__.py: allow setting the host, port and user for the
	DSN used by the tests through the environment.
2008-04-20 23:12:21 +00:00
Federico Di Gregorio
962c5a9a5f Preparing release 2.0.7. 2008-04-14 05:23:15 +00:00
Federico Di Gregorio
f3438f2961 Preparing release 2.0.7. 2008-04-14 04:27:22 +00:00
Federico Di Gregorio
1fddaa8562 Added a couple of files used for tests. 2008-04-14 04:13:07 +00:00
James Henstridge
23866bc35d * psycopg/connection_type.c (connection_dealloc): free
connection->encoding with free() instead of PyMem_Free().

	* psycopg/connection_int.c (conn_connect): use malloc() to
	allocate connection->encoding instead of PyMem_Malloc(), since it
	is freed in other places with free() and assigned to with
	strdup().
2008-03-30 22:15:21 +00:00
James Henstridge
e848585b90 * psycopg/typecast.c (typecast_from_c): fix up some reference
leaks.  This leak affected a bounded set of objects, so doesn't
	account for any gradual leaks.
2008-03-25 23:21:00 +00:00
James Henstridge
af1478feb9 * psycopg/connection_int.c (conn_notice_callback): don't leak
notice messages.
2008-03-19 01:01:26 +00:00
Federico Di Gregorio
8103f44a12 Fixed test segfault due to double decref. 2008-03-17 08:13:16 +00:00
James Henstridge
cceaa7331b * psycopg/typecast.c (typecast_parse_time): give the correct
return value for partially parsed time values.

	* psycopg/typecast_mxdatetime.c (typecast_MXDATE_cast): return
	NULL after setting DataError.  Also, don't treat it as an error if
	typecast_parse_time() returns 0 (as might happen if the remainder
	of the string is " BC").

	* psycopg/typecast_datetime.c (typecast_PYDATE_cast): return NULL
	after setting DataError.
	(typecast_PYDATETIME_cast): same here.
	(typecast_PYTIME_cast): same here.

	* tests/test_dates.py
	(CommonDatetimeTestsMixin.test_parse_incomplete_date): test that
	parsing incomplete date values results in DataError.
	(CommonDatetimeTestsMixin.test_parse_incomplete_time): same for
	times.
	(CommonDatetimeTestsMixin.test_parse_incomplete_time): same for
	datetimes.
2008-03-17 04:06:44 +00:00
James Henstridge
1ea0cd4980 Missed the last bit of the commit message. 2008-03-06 19:35:47 +00:00
James Henstridge
475df5ebd6 2008-03-07 Jason Erickson <jerickso@stickpeople.com>
* psycopg/pqpath.c (pq_raise): if PSYCOPG_EXTENSIONS is not
	defined, raise OperationalError rather than
	TransactionRollbackError for deadlock or serialisation errors for
	protocol versions less than 3.
2008-03-06 18:41:07 +00:00
James Henstridge
89cadcb553 2008-03-07 Jason Erickson <jerickso@stickpeople.com>
* psycopg/psycopgmodule.c (psyco_connect): fix off by one error in
	calculating the length of the DSN.
2008-03-06 16:15:41 +00:00
James Henstridge
e55e2683cf * psycopg/pqpath.c (_pq_fetch_tuples): Don't call Python APIs
without holding the GIL.
2008-03-06 15:12:40 +00:00
James Henstridge
14135c1d7e * NEWS: add some draft NEWS items for a 2.0.7 release. 2008-02-27 04:42:56 +00:00
James Henstridge
fc2b684843 * runtests.py: add a harness to run all the psycopg tests against
the version built by distutils.
2008-02-27 02:29:55 +00:00
James Henstridge
b5f4a5f6c2 Fix off-by-one error in PyMem_Malloc() call in
psyco_conn_set_client_encoding().  Fixes #211
2008-02-13 16:01:10 +00:00
James Henstridge
6c2e3ab49b * Add HIDDEN attribute to datetime related global variables.
* Make const strings static, which essentially makes them labels for the 
  strings.
2008-01-22 00:13:42 +00: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
e054004e8f Add more const qualifiers. 2008-01-21 21:01:08 +00:00
James Henstridge
eae563ac96 * psycopg/*.[ch]: add const qualifier to various string arguments
to functions (typecast functions and conn_switch_isolation_level).
2008-01-21 17:34:08 +00:00
James Henstridge
9fa039326c * setup.cfg (define): remove PSYCOPG_DISPLAY_SIZE from default
list of defines, as discussed on mailing list.  It slows down
	queries with very little benefit.
2008-01-21 05:59:03 +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
3265dd172d * tests/test_connection.py (ConnectionTests): add simple tests for
the Connection and Cursor "closed" attributes.

	* psycopg/cursor_type.c (psyco_curs_get_closed): add a "closed"
	attribute to cursors.  It will be True if either the cursor or its
	associated connection are closed.  This fixes bug #164.
2008-01-19 03:32:42 +00:00
James Henstridge
11b017fcbe * psycopg/pqpath.c (pq_raise): remove unused arguments to
function, and simplify.
	(pq_resolve_critical): make function static, since it isn't being
	used outside of pqpath.c any more.
2008-01-19 02:16:57 +00:00
James Henstridge
e744242fe1 Update the debian directory (debian release 2.0.6-3). 2008-01-17 23:59:42 +00:00
James Henstridge
abb0a6f52c (App.ImageFile): simplify ImageFile import using patch from
chrism, fixing bug #198.
2008-01-16 23:16:59 +00:00
James Henstridge
6d9b6a977c * ZPsycopgDA/DA.py (Connection.__init__): Default the encoding to
UTF-8, fixing bug #190.
2008-01-16 18:56:13 +00:00
James Henstridge
bc663111b6 Split the binary tests out a bit. 2008-01-16 18:08:12 +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
46bf23caf4 * tests/__init__.py (test_suite): add date tests to test suite.
* tests/test_dates.py: add tests for date/time typecasting and
	adaption.

	* psycopg/adapter_mxdatetime.c (mxdatetime_str): add support for
	outputting BC dates (which involves switching them to one-based
	dates).  Also remove broken handling of microseconds.

	* psycopg/typecast.c (typecast_parse_date): if the string ends
	with "BC" adjust the year value to be a zero-based BC value as
	used by mx.DateTime (datetime doesn't support BC dates).
	(typecast_parse_time): ignore ' ', 'B' and 'C' in time strings
	rather than treating them as part of the seconds part of the time.
2008-01-16 01:43:50 +00:00