Commit Graph

322 Commits

Author SHA1 Message Date
Daniele Varrazzo
755a5b143f Skip rowcount on copy test on postgres < 8.2
It looks like the server doesn't send the message.
2014-05-13 14:20:56 +01:00
Daniele Varrazzo
e7fc781280 Copy operations correctly set the cursor.rowcount attribute
Fixes ticket #180.
2014-05-13 12:07:21 +01:00
Daniele Varrazzo
a1344f30f3 Fixed explicit connection.cursor(cursor_factory=None)
Fixes issue #210.
2014-04-30 18:05:36 +01:00
Daniele Varrazzo
e1eb7a71b0 Fixed merge errors in the test suite
All the bugfixes from psycopg 2.5 backported on 2.4. I've done this
because I've noticed Ubuntu 14.04 LTS is being released with psycopg
2.4.6: if they don't plan to switch to 2.5.x better have these bugs
fixed.
2014-04-07 18:38:47 +01:00
Daniele Varrazzo
cdb206d3e7 Check the connection is really bad on exception before closing it
We end up here without a pgres sometimes (e.g. from lobject errors)
2014-04-07 18:29:35 +01:00
Daniele Varrazzo
06b1db942f Fixed overflow opening a lobject with an oid not fitting in a signed int
Fixes 🎫`203`.

Conflicts:

	NEWS
2014-04-07 17:55:26 +01:00
Daniele Varrazzo
0f6122242c Dropped unneeded pass in test 2014-04-07 17:53:52 +01:00
Daniele Varrazzo
eddb0e3d90 Fixed dsn and closed attributes in failing connection subclasses.
From ticket #192 discussion.

Conflicts:

	NEWS
	tests/test_connection.py
2014-04-07 17:53:38 +01:00
Daniele Varrazzo
6b43b0088e Don't segfault on uninitialized cursor
It can happen with bad cursor subclasses not calling super's init. Raise
an exception instead of segfaulting.

Closes #195

Conflicts:

	NEWS
2014-04-07 17:51:53 +01:00
Daniele Varrazzo
ff341077e0 Check connection type in lobject init
Fixes ticket #187.

Conflicts:

	NEWS
2014-04-07 17:43:37 +01:00
Daniele Varrazzo
5a55339e11 Really test named cursors in test_scroll_named() 2014-04-07 17:40:32 +01:00
Daniele Varrazzo
fb5e14c701 Meaningful connection errors report a meaningful message
Fixes issue #173.

Conflicts:

	NEWS
2014-04-07 17:38:17 +01:00
Daniele Varrazzo
00c1d867c2 Added regression test for infinity parsing in dates
...and a couple of typos.
2014-04-07 17:30:58 +01:00
Daniele Varrazzo
0914323328 Added test to verify copysize handling in copy_expert
Not an original psycopg2 bug but present in pure python implementation,
e.g. ctypes issue #25 and cffi issue #5.

https://github.com/mvantellingen/psycopg2-ctypes/issues/25
https://github.com/chtd/psycopg2cffi/pull/5
2014-04-07 17:29:50 +01:00
Daniele Varrazzo
d0f49f9887 Skip tests on python implementations without getrefcount()
PyPy is one of these.

Conflicts:

	tests/test_cursor.py
	tests/test_module.py
2014-04-07 17:29:36 +01:00
Piotr Kasprzyk
5a74117118 Fix multiple misspellings
Conflicts:

	NEWS
	doc/src/usage.rst
	psycopg/pqpath.c
	setup.cfg
2013-04-26 10:17:17 +01:00
Daniele Varrazzo
802381358a Fixed broken test decorator preventing 3 tests to run 2013-03-20 17:33:42 +00:00
Daniele Varrazzo
c111ef5dff Properly cleanup memory of broken connections
Fixed ticket #148.
2013-03-20 11:45:17 +00:00
Daniele Varrazzo
67445dfbea Fixed pickling of DictRow objects too 2012-12-11 01:40:02 +00:00
Daniele Varrazzo
5bee4d3379 Fixed pickling of RealDictRow objects 2012-12-11 01:40:02 +00:00
Daniele Varrazzo
0653861bc4 Fixed empty strings handling in composite caster
Closes ticket #141.
2012-12-03 14:20:08 +00:00
Daniele Varrazzo
5e6eabd9f8 Fixed pickling of FixedOffsetTimezone objects
I have also verified that the fixed class can unpickle instance pickled with
the buggy one and viceversa.

Fixes ticket #135.
2012-10-21 21:47:32 +01:00
Daniele Varrazzo
58d048198f Close the connection on error in callback
Unfortunately PQcancel blocks, so it's not better than PQgetResult.
It has been suggested to use PQreset in non-blocking way but this would give
the Python program the burden of handling a connection done but not configured
in an unexpected place.
2012-10-09 02:01:29 +01:00
Daniele Varrazzo
74e6efd717 Raise TypeError instead of InterfaceError on bad params on connect()
TypeError is the standard Python error raised in this case:

    $ python -c "(lambda a: None)(b=10)"
    TypeError: <lambda>() got an unexpected keyword argument 'b'

We only used to raise InterfaceError when connect was used without
any parameter at all, so it's hard to think a program depending on
that design. Furthermore the function has always raised (and still
does) OperationalError too, if the bad argument is detected by the
libpq, and that cannot be changed because we can't tell the
difference from a normal connection error.
2012-09-26 11:55:21 +01:00
Daniele Varrazzo
32fae728b3 Dropped quirks in connection arguments handling
Now connect() raises an exception instead of swallowing keyword arguments
when a connection string is specified as well

Closes ticket #131.
2012-09-25 23:46:46 +01:00
Daniele Varrazzo
c7bee92160 Fixed infinite loop when parsing '{' as array 2012-09-20 03:19:24 +01:00
Daniele Varrazzo
72e9cf7b6d Fixed return value after malformed arrays 2012-09-10 04:20:39 +01:00
Daniele Varrazzo
bc400f6961 Fixed tests to run with PG 8.3 2012-09-04 21:23:19 +01:00
Daniele Varrazzo
cc951b5fbe Fixed tpc_recover() with RealDictStuff
Same problem and correction of ticket #114.
2012-08-14 23:29:19 +01:00
Daniele Varrazzo
fd4153d632 Fixed register_hstore and register_composite with non-dbapi objects
Closed ticket #114.
2012-08-14 23:26:17 +01:00
Daniele Varrazzo
365a1b20a7 Added tests to verify cursor() arguments propagation 2012-04-11 18:00:18 +01:00
Daniele Varrazzo
27421f1e41 Name can be passed as None to cursor()
Makes invocation from subclasses and generic code easier.

Code simplified by using default values for keyword arguments
and avoiding needless conversions back and forth between Python and C
strings. Also added connection type check to cursor's init.
2012-04-11 17:32:10 +01:00
Daniele Varrazzo
37aa62ca52 Merge branch 'close-idempotent' into devel 2012-03-05 02:47:52 +00:00
Daniele Varrazzo
84f2a370f6 close() methods don't raise errors if called on closed objects 2012-03-04 05:10:07 +00:00
Daniele Varrazzo
2cbedbee45 Dropped test about close() on closed connection raising an exception
This seems unnecessary and has caused problems to a few. The DB-SIG seems
agreeing on the change:
http://mail.python.org/pipermail/db-sig/2011-October/005811.html
2012-03-04 05:10:06 +00:00
Marti Raudsepp
b97599166e Update all links to PostgreSQL docs to the current version.
I also checked all links and anchors to make sure they're still valid.
2012-02-28 18:28:07 +02:00
Daniele Varrazzo
5fcbe7bd0f Check/set connection status at commit inside the critical section
Failing to do so was causing the issue reported in ticket #103. The issue
as reported was fixed when SET ISOLATION LEVEL was dropped, but the real
problem wasn't fixed.
2012-02-24 03:28:20 +00:00
Daniele Varrazzo
0c337a2029 Added support for inet array 2012-02-23 23:56:55 +00:00
Daniele Varrazzo
9ffa1f4b59 Fixed inet test that wasn't testing anything 2012-02-23 23:35:05 +00:00
Daniele Varrazzo
98d6d96ee3 Fixed exception testing on Python 3
...and so caught exceptions are local to the except suite in Py3.
(Lo sapevate? Sapevatelo!)
2012-02-23 23:15:42 +00:00
Daniele Varrazzo
b8597dc1d3 Fixed NamedTupleCursor rownumber during iteration.
The correction is similar to the other one for the other subclasses.

Also added tests for rowcount and rownumber during different fetch styles.
Just in case.
2012-02-23 22:58:58 +00:00
Daniele Varrazzo
ebec522a07 Fixed rownumber for cursor subclasses during iterations
Regression introduced to fix ticket #80. Don't use fetchmany to get the
chunks of values. I did it that way because I was ending up into infinite
recursion calling __iter__ from __iter__: the solution has been the
"while 1: yield next()" idiom.
2012-02-23 22:55:13 +00:00
Daniele Varrazzo
7221ea9ec5 Added test to check rowcount behaves fine during named cursor iteration
Actually *it doesn't*: once we iterate the first itersize records, rowcount
is reset to zero. If we want to fix it we need an extra member in the
cursor.
2012-02-23 22:04:22 +00:00
Daniele Varrazzo
71d1690870 Test methods reordered to improve readability 2012-02-23 21:27:45 +00:00
Menno Smits
bca7200b3f Cache FixedOffsetTimezone instances
Avoid creating new a new FixedOffsetTimezone instance if one with the
same offset and name has been created before. This will save memory
when returning many rows containing "timestamp with timezone" columns,
and also improves comparability.
2012-01-30 13:27:40 +00:00
Menno Smits
1469a56512 Fixed repr for FixedOffsetTimezone for offsets west of UTC (negative)
The offset displayed was always positive and somewhat confusing. The
offset displayed now is the offset that the instance was created
with.

Also added some tests for initialisation.
2012-01-30 13:27:01 +00:00
Menno Smits
35ff2def34 Renamed shadowed test method 2012-01-29 19:35:38 +00:00
Daniele Varrazzo
43daba38e7 Make Error and subclasses picklable
Useful for multiprocessing interaction.
Closes ticket #90.
2012-01-14 17:34:09 +00:00
Daniele Varrazzo
28f1013c2a Dropped duplicate import 2012-01-14 17:28:37 +00:00
Daniele Varrazzo
05fb0e2fbf Added tests to verify ticket #84
fetchmany() with no arg is broken in cursor subclasses.
2012-01-10 01:27:43 +00:00