Daniele Varrazzo
469b6f8aff
Return memoryview object of type "c" instead of "B" from bytea
...
In Python 3.3 items are returned as int instead of chars.
I'm not sure the way I did it is correct: worth asking some
hardcore Python dev.
Fixed tests after the stricter memview comparison rules in Py 3.3.
2012-09-21 00:54:37 +01:00
Daniele Varrazzo
62a54f64f7
Fixed infinite loop when parsing '{' as array
2012-09-20 03:24:47 +01:00
Daniele Varrazzo
0e644f6d95
Fixed return value after malformed arrays
2012-09-20 03:24:26 +01:00
Federico Di Gregorio
40a512fe46
Fixed always true comparaison
2012-08-17 14:52:59 +02:00
Daniele Varrazzo
a79a5292e7
Added support with cursors without scroll clause
...
Using nothing is different from NO SCROLL, see DECLARE notes
in PG docs.
2012-08-15 09:44:44 +01:00
Daniele Varrazzo
fa4994e471
Added scrollable cursor implementation
...
Patch provided by Jon Nelson (ticket #108 ).
2012-08-15 00:30:54 +01:00
Daniele Varrazzo
91c2ff9296
Fixed tpc_recover() with RealDictStuff
...
Same problem and correction of ticket #114 .
2012-08-14 23:29:19 +01:00
Daniele Varrazzo
f9a13eb563
connection.reset() implemented using DISCARD ALL
2012-06-25 16:37:11 +01:00
Daniele Varrazzo
e8fb84306d
Fixed cursor name as unicode string on Python 3
2012-05-27 08:58:55 +01:00
Daniele Varrazzo
7982a6ac0b
Dropped GIL release around function calling PyMem_Malloc
...
Closes ticket #110 .
2012-05-22 17:22:57 +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
c63891af8d
Fixed bad error return code from cursor's init
2012-04-11 17:26:11 +01:00
Federico Di Gregorio
550130b19e
Merge remote-tracking branch 'piro/devel' into devel
...
Conflicts:
psycopg/lobject_int.c
2012-03-08 12:28:52 +01:00
Daniele Varrazzo
b8c75d9de0
Merge branch 'gcc-python-plugin' into devel
2012-03-05 02:48:11 +00:00
Daniele Varrazzo
37aa62ca52
Merge branch 'close-idempotent' into devel
2012-03-05 02:47:52 +00:00
Daniele Varrazzo
8707d8c399
Fixed iterator refcount in case of memory error during COPY
2012-03-05 02:09:20 +00:00
Daniele Varrazzo
735d50c782
Check if the object wrapped in binary is not None before trying the other types
...
Otherwise it seems we clobber some result with NULL.
2012-03-05 02:08:45 +00:00
Daniele Varrazzo
a9dc1b83ad
Methods callbacks signatures match the flags they are exported with
2012-03-05 01:26:28 +00:00
Daniele Varrazzo
531084d561
Stricter types usage in several PyArg_ParseTuple calls
2012-03-04 18:01:08 +00:00
Daniele Varrazzo
0e832b97ea
Proper type check in prepare() methods for list, binary, qstring
2012-03-04 17:59:51 +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
76cc838a93
Expressions rewritten in a more normal way
...
(double)'0'? :)
2012-03-04 04:47:21 +00:00
Daniele Varrazzo
5bbfd38dfb
Check for errors in float adaptation
2012-03-04 04:43:14 +00:00
Daniele Varrazzo
6cece00958
Check failed list creation in array adaptation
2012-03-04 04:42:44 +00:00
Daniele Varrazzo
be35df3818
Fixed typecasters refcount
2012-03-04 04:41:36 +00:00
Daniele Varrazzo
dc4c3d3143
Guard from failed keys creation during adaptation
2012-03-04 04:40:44 +00:00
Daniele Varrazzo
18085201c8
Guard from NULL dereference if Xid allocation fails
2012-03-04 04:39:41 +00:00
Daniele Varrazzo
31812c01e6
Further modeling of exception raising
2012-03-04 04:38:44 +00:00
Daniele Varrazzo
d93732558d
Raise an exception in case of failed localtime_r call
2012-03-04 04:17:03 +00:00
Daniele Varrazzo
4d15b973b0
Attempt to enforce signature for the "O&" converter functions
...
It seems causing a traceback in the static checker. Enforcing it simplifies
the code, but doesn't help the checker.
2012-03-01 02:53:29 +00:00
Daniele Varrazzo
e1266d52cd
More functions annotated for static analysis
...
Also more return values checked for values < 0 for errors, instead of
checking == 0 and leaving the positive side unchecked
2012-03-01 02:53:28 +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
9432787279
Work around a false positive returned by the static checker
...
To be submitted to 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
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
67712e4226
Fixed possible NULL dereferencing in fetchmany()/fetchall()
2012-02-24 22:26:02 +00:00
Daniele Varrazzo
6d76e81166
Fixed possible NULL dereferencing in callproc()
2012-02-24 22:26:02 +00:00
Daniele Varrazzo
94a53b48df
Building rows simplified
...
Dropped repeated checks for tuple_factory.
Internal functions refactored a bit.
2012-02-24 22:26:02 +00:00
Daniele Varrazzo
efee049338
Added error check in _mogrify for failed tuple creation
2012-02-24 22:26:02 +00:00
Daniele Varrazzo
0ee641361b
Flag a few other functions returning borrowed refs
2012-02-24 22:26:01 +00:00
Daniele Varrazzo
4ecfd48671
Fixed possible NULL dereferencing in notice process
2012-02-24 22:25:56 +00:00
Daniele Varrazzo
a6df55f4e3
Flag the psycopg_ensure_*() functions as stealing a ref
2012-02-24 10:41:02 +00:00
Daniele Varrazzo
5f3f35a2c2
Mark getnextarg function as returning a borrowed reference
2012-02-24 04:25:08 +00:00
Daniele Varrazzo
fc78fb09c0
Dropped unused pq_resolve_critical() return value
2012-02-24 04:00:12 +00:00
Daniele Varrazzo
4eea8bc912
Dropped redundant check on the status before rollback
...
The check is better done inside the critical section.
2012-02-24 03:28:20 +00: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
3b36100ec1
Dropped hardcoded list of exceptions in init functions
...
Use the already available exctable array.
This stops the gcc-python-plugin complaining about access to potentially
uninitialized memory.
2012-02-23 20:09:28 +00:00
Daniele Varrazzo
09be4dc5d1
Fixed potential failures while setting exceptions attributes
2012-02-23 19:48:46 +00:00
Daniele Varrazzo
7d67ecbed3
Fixed potential NULL incref
2012-02-23 19:47:36 +00:00
Daniele Varrazzo
1b27820389
Fixed refcount of exceptions dicts
2012-02-23 19:36:30 +00:00
Daniele Varrazzo
08fbd86495
Check errors in module typecasters init
2012-02-23 19:20:51 +00:00
Daniele Varrazzo
ff61cf25b6
Fixed refcount of None if namedtuples are not available
2012-02-23 18:50:06 +00:00
Daniele Varrazzo
026899e0c1
Check errors when populating encodings map
2012-02-23 18:50:06 +00:00
Daniele Varrazzo
db987250c8
Avoid installing Error.__reduce_ex__ on Python 2.4
...
It is not used by the pickle protocol, and if called manually fails in an
unsettling way, probably because the exceptions were old-style classes.
2012-01-14 18:01:15 +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
6f21111a92
Docs/cleanup for the lo_creat patch
2012-01-10 21:51:34 +00:00
Giovanni Mascellani
e1700fe28b
Use lo_creat() instead of lo_create() when creating large objects without new_oid.
...
This enhances the compatibility with the pgpool-II replication middleware,
that doesn't support lo_create() calls.
2012-01-10 20:49:58 +00:00
Giovanni Mascellani
8ec9b0f3d9
Use lo_creat() instead of lo_create() when creating large objects without new_oid.
...
This enhances the compatibility with the pgpool-II replication middleware,
that doesn't support lo_create() calls.
2012-01-10 11:12:06 +01:00
Daniele Varrazzo
dcc60131a9
fetchmany accepts None as size, meaning the default arraysize
...
without this care, extending fetchmany in subclasses becomes tricky.
Closes ticket #84 .
2012-01-10 01:32:45 +00:00
Daniele Varrazzo
09a8e7bf1f
Fixed cursor.fetchmany docstring
2012-01-10 01:28:14 +00:00
Daniele Varrazzo
d6e0b284e7
Map error classes 20 and HV to more specific exceptions
2011-12-16 12:26:27 +00:00
Daniele Varrazzo
ba7a0a3008
Raise DatabaseError instead of error with bad exception informations
...
We can actually raise these exceptions in weird situations,
e.g. see ticket #82 .
2011-12-15 17:50:31 +00:00
Daniele Varrazzo
b5de04d2ff
Put back a distinct ISOLATION_LEVEL_READ_UNCOMMITTED value
2011-12-15 12:53:48 +00:00
Federico Di Gregorio
d2d94e203f
Reverted isolation level values to backward compatible values
...
This basically removes the READ UNCOMMITED level (that internally
PostgreSQL maps to READ COMMITED anyway) to keep the numeric values
compattible with old psycopg versions. For full details and discussion
see this thread:
http://archives.postgresql.org/psycopg/2011-12/msg00008.php
2011-12-15 12:25:19 +01:00
Daniele Varrazzo
088978e7b1
Typo fixed writeable -> writable
...
Closes ticket #79 .
2011-12-11 02:55:29 +00:00
Daniele Varrazzo
ad3a198919
Fixed reference leak with arguments referenced more than once in queries
...
Plus, some more care in objects life cycle, mostly in exceptions handling.
Closes ticket #81 .
2011-12-11 02:52:06 +00:00
Daniele Varrazzo
d2b67364fd
connect() supports generic keyword arguments passed to the dsn
2011-11-17 01:51:25 +00:00
Daniele Varrazzo
dc94a3cb2d
Check for connection closed before getting the isolation level
...
Closes ticket #74
Also added test to check regressions in isolation_level,
set_isolation_level, set_session, autocommit.
2011-11-16 23:51:05 +00:00
Daniele Varrazzo
a76d0525d1
Dropped unused variable
2011-11-01 07:42:22 +00:00
Daniele Varrazzo
2671472de8
Dropped leftover extra char, already accounted for before
2011-10-20 11:11:57 +01:00
Daniele Varrazzo
60b49f5c45
Avoid PyOS_snprintf to calculate the copy command buffer size
...
On windows it returns -1 instead of sometihing portable. So just ditch
the static buffer and just use a dynamic one to compose the command.
Also squashed a couple of buglets in copy_to: copyfile was decremented
before being set to null, size_t was used instead of Py_ssize_t.
2011-10-19 21:01:53 +01:00
Daniele Varrazzo
ff8158d7c0
Simplification in the COPY command composition
...
Dropped the branch if NULL is specified or not: just use the default \N.
Also fixed copy_from/copy_to docstrings.
2011-10-19 20:31:09 +01:00
Daniele Varrazzo
dde4c0de3d
Decimal adapter registration moved from C to Python
...
Fixes Decimal adaptation in sub-interpreter, where the Decimal class has
a different identity from the one in the main interpreter.
Closes ticket #52 .
2011-10-14 22:35:56 +01:00
Daniele Varrazzo
c4e6d7d982
Fixed typecasting of arrays containing consecutive backslashes
2011-09-22 18:14:16 +01:00
Daniele Varrazzo
e3054ac9f3
Added new_array_type() function
...
Allows the creation of a generic array typecaster from Python.
2011-09-22 15:51:21 +01:00
Daniele Varrazzo
8fb08efae7
Allocate dynamically memory for the list of columns in COPY
...
Some bloke finds the limit of 8K too restrictive... ticket #68 .
2011-09-12 02:21:59 +01:00
Federico Di Gregorio
880aa07a58
WITH HOLD documentation a argument parsing changes
...
Now any true value will do for the withhold parameter.
2011-08-10 19:21:12 +02:00
Federico Di Gregorio
a59d88c703
Merge remote-tracking branch 'piro/devel' into devel
2011-08-10 18:36:24 +02:00
Federico Di Gregorio
479bdf7458
New 'withhold' parameter for connection.cursor()
2011-08-10 18:25:46 +02:00
Daniele Varrazzo
de6f2ac387
Grab the GIL when checking for errors occurred
...
The problem was causing a segfault on BEGIN if the server is disconnected
after the connection is created.
2011-08-09 11:44:30 +01:00
Federico Di Gregorio
2f6336ea78
First try at curs.withhold implementation
2011-07-05 10:28:34 +02:00
Daniele Varrazzo
d2b28abced
Method set_transaction() renamed to set_session()
...
In fact it doesn't change "the transaction", as there has to be no
transaction when invoked. The effect instead is to execute SET SESSION
CHARACTERISTICS.
2011-06-08 14:22:11 +01:00
Daniele Varrazzo
1a51cfe274
Better error message if deferrable is used in PG < 9.1
2011-06-08 10:59:27 +01:00
Daniele Varrazzo
0a1bbb56cd
Dropped redundant semicolons at the end of internal queries
...
For consistency with other queries, and probably we give less work to do
to the server parser (a ridiculously tiny amount).
2011-06-08 09:22:35 +01:00
Daniele Varrazzo
6d907df14d
Fixed documentation for COPY methods
...
The size parameter in copy_from was undocumented (ticket #59 ).
2011-06-07 11:16:10 +01:00
Daniele Varrazzo
9b5ac79513
Fixed default size for read copy buffer
...
The original commit stated it should have been 8192.
2011-06-07 11:16:06 +01:00
Daniele Varrazzo
679af4a975
Fixed copyfile refcount in copy_expert
...
In case of early error, jumping to exit would have decref'd the borrowed
reference to file.
Issue spotted by Dave Malcolm, thanks!
2011-06-07 01:20:25 +01:00
Daniele Varrazzo
b6e710b0fc
Fixed refcount bug in copy_to() and copy_expert() methods too
2011-06-07 00:08:29 +01:00
Daniele Varrazzo
1888bf41c0
Added patch for refcount bug in copy_from
...
By Dave Malcolm. https://bugzilla.redhat.com/show_bug.cgi?id=711095
(slightly edited to increment the refcount before storing the pointer
in the cursor).
2011-06-07 00:08:29 +01:00
Jason Erickson
dd7ee7093a
No strcasecmp function with MSVC
...
The MSVC compiler does not have the strcasecmp(x, y) function, which is a
case insensitve string compare function. Instead, MSVC has a similar function,
lstrcmpi(x, y). Modified config.h to use this function when building with
MSVC.
2011-06-05 23:33:28 +01:00
Daniele Varrazzo
442a0606fe
Merge branch 'guc-cleanup' into devel
2011-06-05 16:31:25 +01:00
Daniele Varrazzo
709df38d79
Don't clobber an eventual Python exception set by a green thread
2011-06-05 16:30:37 +01:00
Daniele Varrazzo
869d48b6f0
Use the pqpath functions to get/set GUC parameters
...
Functions conn_setup(), conn_get_isolation_level(), conn_set_transaction(),
conn_switch_isolation_level(), conn_set_client_encoding() reimplemented
using the pqpath funtitons.
Dropped analogous function in the connection, as it had to take the lock,
thus it was hard to build consistent pieces of functionality with it.
2011-06-05 16:26:01 +01:00
Daniele Varrazzo
8f876d4b5d
Avoid a deadlock using concurrent green threads on the same connection
...
Use the async_cursor property to store an indication that something is
running (even if it is not necessarily a cursor running the query).
2011-06-05 16:22:54 +01:00
Daniele Varrazzo
cf6a4ec062
Added pqpath functions to get/set the value for GUC parameters
...
The aim of these function is to allow the connection to make a better use
of the pqpath functions instead of using PQexec for these small things.
Also, the functions are to be called with the connection lock: this makes
composing higher level functions using them easier.
2011-06-05 15:36:02 +01:00
Daniele Varrazzo
a0d16fcfb2
Avoid a ton of warnings when building on mingw
...
mingw doesn't support visibility hidden even if gcc can.
2011-06-04 22:19:56 +01:00
Daniele Varrazzo
c8ec747903
Don't fail import if mx.DateTime module is not found at import time
...
A better fix for ticket #53 .
2011-06-04 14:16:24 +01:00
Daniele Varrazzo
05659c0d16
Cleanup of notice processing
...
The function is always called in the context of functions grabbing the
connection lock, so just use the same critical section instead of releasing
and re-acquiring it. It is not a problem as serious as the notifies process
(ticket #55 ) as the notices are a psycopg structure, not libpq. However the
change allows again processing notices/notifies in the same place,
which makes sense conceptually, plus we save some lock dance.
2011-06-04 01:49:03 +01:00
Daniele Varrazzo
d9c0b8166f
Process notifies when data is received, not when the result is parsed
...
Notifies process access the connection, is not limited to the result, so
There is the possibility of loss of protocol sync in multithread programs.
Closes ticket #55 .
2011-06-04 01:31:36 +01:00
Daniele Varrazzo
0eb5e0430e
Merge branch 'transaction-control' into devel
2011-06-03 01:48:24 +01:00
Daniele Varrazzo
4d3c6865ee
Use only the isolation levels available on old PG versions
2011-06-03 00:40:54 +01:00
Daniele Varrazzo
c2d1f1f2e6
Dropped isolation level from the connection object
...
Don't issue a SET TRANSACTION ISOLATION LEVEL at every begin: use PG's
GUC default, eventually set by set_transaction.
Dropped the last query at connection, yay!
Method set_isolation_level() and property isolation_level refactored using
the new structures, keeping the previous semantic.
2011-06-03 00:10:24 +01:00
Daniele Varrazzo
389f2cf1d0
Added autocommit property on connection
2011-06-02 01:16:22 +01:00
Daniele Varrazzo
ea03ffbf76
Added partial implementation for set_transaction
...
autocommit to be implemented yet.
2011-06-01 09:07:02 +01:00
Daniele Varrazzo
531292bca5
Merge branch 'neg-escape' into devel
2011-05-30 22:09:23 +01:00
Daniele Varrazzo
281427f450
Fixed escape for negative numbers prefixed by minus operator
...
Closes ticket #57 .
2011-05-30 22:00:20 +01:00
Daniele Varrazzo
19ec8809fd
Use all the isolation levels accepted by PostgreSQL
...
In PG 9.1 repeatable read and serializable are distinct levels.
2011-05-11 13:01:20 +01:00
Daniele Varrazzo
834c7d1288
Fixed a few docstrings mixed up
2011-05-11 12:59:31 +01:00
Daniele Varrazzo
c08799b0b0
Fixed SystemError clobbering libpq errors raised without SQLSTATE
...
Bug vivisectioned by Eric Snow
<http://archives.postgresql.org/psycopg/2011-04/msg00019.php >.
2011-04-24 02:59:28 +01:00
Daniele Varrazzo
19653a88ec
Store a normalized version of the PG encoding in the connection
...
This way looking up into extensions.encodings will not break.
2011-04-08 13:48:11 +01:00
Daniele Varrazzo
88803695ac
Normalize the encoding name at connection
...
The encoding can be set by PGCLIENTENCODING, which may be an alternative
spelling. Bug reported by Peter Eisentraut.
At this point the idea of considering one of the random spellings such as
EUC_CN as somewhat "blessed" is debunked. So just store the cleaned-up
version of the encoding in the mapping table. Note that the cleaned-up
version was needed by the unicode adapter: this requirement has been
surpassed as the connection now contains a copy of the Python codec name
set whenever the client encoding is set.
2011-04-08 13:48:11 +01:00
Daniele Varrazzo
e0cd6f0f00
Added tests for our own bytea parser
...
Because the parse function is not supposed to be exposed in Python,
use ctypes to directly inspect the C function.
2011-03-26 12:59:14 +00:00
Daniele Varrazzo
66c543b16c
Parse bytea output format ourselves instead of using the libpq
...
PG 9.0 uses the hex format by default, and clients < 9.0 can't parse that
format, requiring client update and great care in what is linked at runtime,
and generally giving headache to users and transitively us.
2011-03-26 12:59:14 +00:00
Daniele Varrazzo
fcbe0466a6
Correctly detect an empty query sent to the backend
...
Closes ticket #46 .
2011-03-04 20:30:43 +00:00
Daniele Varrazzo
f1d69f6dec
Fixed detection of empty error from pq_raise
...
Avoid a system error in case err is set to an empty string.
2011-03-04 20:20:56 +00:00
Daniele Varrazzo
194447fbbf
Merge branch 'msvc-cleanup' into devel
...
Merged Jason Erickson devel branch after collapsing a few commits together
where it made sense.
2011-02-25 10:29:19 +00:00
Jason Erickson
7c2fa77c4b
Windows MSVC: Fixed warning of incompatible types
...
Fixed incompatible type warning from XidObject * to PyObject * by
casting.
2011-02-25 10:25:12 +00:00
Jason Erickson
961e855bbd
Windows MSVC: Fix Compiler Warning: getpid
...
Fix a compiler warning when using PSYCOPG_DEBUG on MSVC where getpid is
undefined.
2011-02-25 10:25:12 +00:00
Jason Erickson
631883f62f
Windows MSVC: Fix data loss compiler warnings
...
Fixed MSVC compiler warnings where it was indicating a conversion
from a larger data type to smaller data type might have data loss.
2011-02-25 10:25:12 +00:00
Daniele Varrazzo
29ac03ef04
Check for failed allocation in the notice callback
2011-02-24 10:14:06 +00:00
Daniele Varrazzo
894d3f653c
Raise an exception if the libpq fails to decode bytea in hex format
2011-02-23 14:04:27 +00:00
Daniele Varrazzo
f96b68d8c6
Fixed docstring for connection.lobject()
2011-02-23 01:53:56 +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
66555c5f11
Fixed call of memory functions without the GIL
2011-02-23 00:48:10 +00:00
Daniele Varrazzo
20f714f17c
Added error checking to _pq_fetch_tuples()
2011-02-23 00:32:23 +00:00
Daniele Varrazzo
c1715f66fe
More careful memory management
...
- Check return value of PyErr_Malloc and set an exception in case of error
- Avoid exposing variables with refcount 0 as connection attributes.
- PyErr_Free guards itself for NULL input
2011-02-23 00:32:23 +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
d74f777339
Check for memory errors in the connection init
2011-02-20 18:57:04 +00:00
Benjamin Poulain
5ee60571a5
Add a type converter to handle untyped empty arrays.
...
Empty array can be returned untyped by postgres. To handle
this case, a special handler is added for the type UNKNOWNOID.
If the value return by the database is strictly equal to "{}",
the value is converted. Otherwise, the conversion fallback on
the default handler.
2011-02-20 12:28:10 +00:00
Daniele Varrazzo
4bc4f85229
Merge remote branch 'jason/devel' into devel
...
Conflicts:
psycopg/notify_type.c
2011-02-19 16:25:31 +00:00
Daniele Varrazzo
556b4d461e
Documentation cleanup
...
Added several links to the Python documentation using the 'intersphinx'
extension.
2011-02-19 16:16:28 +00:00
Daniele Varrazzo
6098ced761
Assume there may be files returning Unicode in Python 2 too
...
This is the case in Python 2.7 with files implementing io.TextIOBase.
2011-02-19 14:24:15 +00:00
Daniele Varrazzo
8a08114314
Correctly handle exceptions with non-ascii chars in the message
...
Previous implementation would have barfed in canse of non-utf-8 data in
the message.
2011-02-19 14:16:53 +00:00
Jason Erickson
4bc47d47a5
Python 3.2 hash() return value is arch dependant
...
Python 3.2 hash() function will now return a 64bit value when run on a 64bit
architecture, where as previously, it would always return a 32bit value.
Modified the code to use the now Py_hash_t typedef and for Python versions
less than 3.2, hard code Py_hash_t to long and Py_uhash_t to unsigned long.
2011-02-18 23:57:25 -07:00
Daniele Varrazzo
837f1e5e4f
Set hidden visibility to a few functions not public
2011-02-19 00:25:23 +00:00
Daniele Varrazzo
c620f18be1
Provide cursor.description as named tuple if possible
...
If namedtuple() is not available, use regular tuples.
2011-02-19 00:05:43 +00:00
Daniele Varrazzo
836f8a1aa1
Make Binary(None) work as expected, adapting to NULL
...
Issue reported by Stefano Dal Pra.
2011-02-18 14:19:57 +00:00
Daniele Varrazzo
99b3c72312
Some cleanup in mogrify
...
- Raise an exception on incomplete placeholders.
- Minor speedups.
- Don't change the string in place (??!!) if the placeholder is not s
and the value is null.
The latter point can be done because downstream we don't accept anything
different from s anyway (in the Bytes_Format function).
Notice that now the format string is constant whatever the arguments.
This means that executemany is still more inefficient than it should be
as mogrify may work only on the parameters. However this is an
implementation only worthwhile if we start supporting real parameters.
Let's talk about that for the next release.
2011-02-18 02:33:42 +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
c51165e2aa
Indentation fixed
2011-02-17 19:53:04 +00:00
Daniele Varrazzo
63ac6cdde5
Added cursor.itersize
...
The value is used to control the number of records to fetch per network
roundtrip in named cursors iteration. Used to avoid the inefficient
arraysize default of 1 without giving this value the magic meaning of
2000.
2011-02-17 12:36:02 +00:00
Daniele Varrazzo
bccbcf42d0
Added adaptation for objects supporting the new-style buffer interface
...
Supporting this interface is required to adapt memoryview on Python 2.7 as they
don't support the old style. But because the old style is long deprecated it
makes sense to start supporting the new one.
2011-02-16 01:30:25 +00:00
Daniele Varrazzo
3ae2f221b3
Adapt bytearray and memoryview to bytes if available
2011-02-15 17:30:43 +00:00
Daniele Varrazzo
e4a84b9ce9
Fixed error message on Binary(str) in Python 3
2011-02-15 15:53:07 +00:00
Daniele Varrazzo
c1fe0b675a
Dropped correct roundtrip of empty array
...
The feature in itself is not extremely useful and instead PostgreSQL is
not always able to cast away from text[], which is a regression see
(ticket #42 ).
2011-02-15 10:27:47 +00:00
Daniele Varrazzo
8ab7fa596c
Merge remote branch 'jason/devel' into devel
2011-02-12 20:19:07 +00:00
Marti Raudsepp
9cb72a38da
Add negative infinity support for Python->pg conversion
2011-02-12 20:19:02 +00:00
Jason Erickson
560f52106c
Windows manifest changes based upon architecture
...
Apparently, using * for the architecture has the potential to not work on
on some amd64 systems. Added checks and split the manifest based upon
architecture.
2011-02-11 10:01:38 -07:00
Jason Erickson
b075017ad9
Pulled down changes from dvarrazzo branch on gh
...
Pulled the master branch from of Daniele's psycopg branch on github and
merged the changes.
2011-02-10 15:59:31 -07:00
Jason Erickson
8d28509f49
Change win32 build to reinsert VC Library Manifest
...
Added a change at the end of the build process that would reinsert the VC library manifest. This patch will fix issues when an embedded program does not have a manifest pointing to the VC 2008 runtime library, such as in an apache/mod_python situation.
Signed-off-by: Jason Erickson <jerickso@stickpeople.com>
2011-02-10 13:17:14 -07:00
Federico Di Gregorio
da27142882
Merge branch 'python3' into python2
2011-02-06 16:47:05 +01:00
Daniele Varrazzo
fab31e9441
Fetch 'arraysize' records per roundtrip in named cursors iteration
...
Closes ticket #33 .
2011-02-05 15:24:00 +01: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
b358c54f02
More efficient cursor.iter: fetch many records at time.
2011-02-04 12:22:07 +00:00
Daniele Varrazzo
d40b394c50
Merge branch 'python2' into python3
2011-02-01 02:27:45 +00:00
Daniele Varrazzo
a2dcf504b5
Hopefully really fixed crash in datetime adapter.
...
Verified with gcc 4.3. Notice that on gcc 4.4 the bug was not present.
2011-02-01 02:00:47 +00:00
Daniele Varrazzo
789dda1173
lobject read and write can deal with both bytes and unicode
...
On write, unicode is encoded in connection encoding.
On read, respect the lobject mode 't' or 'b'.
2011-01-10 00:46:51 +00:00
Daniele Varrazzo
ba1d77a297
Large object mode parsing refactored
...
Added parsing of text/binary mode.
2011-01-10 00:46:51 +00:00
Daniele Varrazzo
79048ff19a
Merge branch 'python2' into python3
...
Conflicts:
NEWS-2.3
tests/__init__.py
tests/test_lobject.py
tests/test_quote.py
tests/testutils.py
2011-01-10 00:46:02 +00:00
Daniele Varrazzo
48588e5f69
Invalidate large objects after a two-phase commit operation
2011-01-10 00:20:55 +00:00
Daniele Varrazzo
935c25730a
Fixed segfault in large object close.
...
Check that the connection is not closed/faulty before attempting lo_close.
2011-01-10 00:11:14 +00:00
Daniele Varrazzo
9deb16484d
Don't define a CObject API in Python 3.2
...
The API is not available: a PyCapsule should be used. Nobody seems
needing it for now.
2011-01-08 01:24:16 +00:00
Daniele Varrazzo
b8c8cddc2d
Fixed argument parsing in lobject.read
...
Using an int instead of a Py_ssize_t randomly crashed Python 3.1 64 bit.
2011-01-04 02:27:02 +01:00
Daniele Varrazzo
80bd6e2794
Merge branch 'python2' into python3
...
Conflicts:
NEWS-2.3
psycopg/connection_type.c
tests/test_connection.py
tests/types_basic.py
2011-01-03 21:43:02 +01:00
Daniele Varrazzo
abd7991968
Fixed refcount bug with connection destroyed in a 2PC transaction
2011-01-03 21:34:49 +01:00
Daniele Varrazzo
5f6e773575
Broken circular reference in async execution
...
If a connection is destroyed before an async operation is completed, the
`async_cursor` member creates a reference loop, leaving the connection and
the cursor alive. `async_cursor` is now a weak reference.
2011-01-03 21:34:49 +01:00
Daniele Varrazzo
19ff51ae75
The cursor is weakly referenceable
2011-01-03 21:34:49 +01:00
Daniele Varrazzo
04cf90cc21
The connection is weakly referenceable
2011-01-03 21:34:49 +01:00
Daniele Varrazzo
5888b03608
Fixed "historical" reference leak in TimestampFromTicks
...
Added an internal function with C signature to avoid the creation of a
tuple to be later unpacked. When the tuple was decref'd, Python 2.4 64
bits regularly segfaulted; Python 2.5 less regularly; don't know about
other versions.
2011-01-03 21:34:49 +01:00
Daniele Varrazzo
39dd577c90
Use the proper printf placeholders to avoid warnings on 64 bit builds
2011-01-03 20:44:57 +01:00
Daniele Varrazzo
b276e3b05d
Fixed compiling on Python versions before 2.6
...
Added a few macros not defined in Py 2.4. Don't know about 2.5.
2011-01-03 19:18:50 +01:00
Daniele Varrazzo
9eae66e8cf
Added Py3 compatibility macro for Py_TPFLAGS_HAVE_WEAKREFS
2011-01-03 16:56:26 +01:00
Daniele Varrazzo
929d62053a
Merge branch 'python2' into python3
...
Conflicts:
NEWS-2.3
setup.py
2011-01-02 03:28:00 +01:00
Daniele Varrazzo
159cda3688
Added cursor.cast() method
...
The method exposes the typecasters lookup algorithm. Useful to create
recursive typecasters.
2011-01-01 22:55:10 +01:00
Daniele Varrazzo
3e94375cf7
Merge branch 'python2' into python3
...
Conflicts:
ChangeLog
NEWS-2.3
lib/extensions.py
psycopg/microprotocols.c
setup.py
2011-01-01 17:14:54 +01:00
Daniele Varrazzo
30921b58a8
Dropped conversion from None to NULL in adapter.
...
It was an error as the string is not conform to the protocol. The error
is masked by the None fast path in _mogrify, but surfaces when adapting
a tuple contains a None.
2010-12-31 18:55:33 +01:00
Daniele Varrazzo
ac25816962
Use the same Bytes_Format function for both Python 2 and 3.
...
This makes the behaviour between the two versions similar. It also have
the effect of a more specific error message in case an user specifies a
placeholder different from 's'.
2010-12-31 03:22:19 +01:00
Daniele Varrazzo
2930ed3d59
Dropped support for all format specifiers except s in PyBytes_Format.
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
6882ac31d4
Dropped warnings in PyBytes_Format function.
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
96a950d3eb
Fixed 2-phase commit support in Python 3.
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
89fb60de4b
Column names in copy methods can be unicode.
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
73917c15e1
Fixed COPY FROM to deal with decoded files.
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
bc28cc8b00
Use unicode keys as strings in Py3.
...
This fixes pyformat style argument passing. Unicode and bytes don't
compare equal (even if they hash the same).
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
061079c918
In Py3, decode the tuple values before passing to the typecaster.
...
Not sure this is the best way to go: it is now impossible to write a
binary typecaster in Python; furthermore it is the opposite approach of
the codecs, which should return bytes.
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
f6fefbea64
Function psycopg_ensure_bytes converted in a "filter" stealing a ref.
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
3214c23f51
Fixed adaptation in several adapters.
...
The getquoted methods always return bytes. The str() convert this
representation to string on the fly.
2010-12-31 03:18:27 +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
d3f3f1caf0
Added utility method to return a string in the connection encoding.
...
In Py2 the result is plain string, in Py3 an unicode decoded in the
connection encoding.
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
56e4c2bd55
Redefining the microprotocol on Py3 as returning bytes.
2010-12-31 03:18:26 +01:00
Daniele Varrazzo
014b6a6d5b
Use psycopg_ensure_bytes() to unify Py2/3 code paths.
2010-12-31 03:18:26 +01:00
Daniele Varrazzo
89e4d4c7bb
Empty lists correctly roundtrip.
2010-12-31 03:18:26 +01:00
Daniele Varrazzo
b5ef5ef21d
Added typecasters repr().
2010-12-31 03:18:26 +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
03dde732f6
Datetime adaptation in bytes.
2010-12-31 03:18:26 +01:00
Daniele Varrazzo
87a7ebac10
Query mogrification in bytes.
2010-12-31 03:18:26 +01:00
Daniele Varrazzo
c3196ebd9d
Added PyBytes_Format function.
2010-12-31 03:18:26 +01:00
Daniele Varrazzo
cb6b52945b
The library can be compiled with Python 3.
...
Just compiled! No test run yet and many points to review, marked in the
code.
The patch is largely Martin von Löwis work, simplified after refactoring
in the previous commits and adapted to the new code (as the patch was
originally for Psycopg 2.0.9)
2010-12-21 04:24:36 +00:00
Daniele Varrazzo
e182201e6e
Added Python codec name to the connection.
...
This allows dropping repeated dictionary lookups with unicode
query/parameters.
2010-12-21 04:02:14 +00:00
Daniele Varrazzo
ae06fb03e7
Added psycopg_strdup utility function.
2010-12-21 04:02:14 +00:00