Jason Erickson
2cdc8d61a2
Fix Windows 64bit lobject support for very (>2GB) large objects
...
The type 'long' with Windows Visual C is 32bits in size for both 32bit and 64bit platforms. Changed type of variables that could be > 2GB from long to Py_ssize_t.
2016-03-10 12:02:00 +00:00
Oleksandr Shulgin
a7887fab07
Merge remote-tracking branch 'zalando/feature/replication-protocol' into feature/replication-protocol-c-connection-object
2016-03-08 18:56:58 +01:00
Oleksandr Shulgin
2de2ed7c63
Remove some dead code
2016-03-08 18:52:29 +01:00
Oleksandr Shulgin
1d52f34e60
We don't need to expose cursor_init(), call tp_init() on the type instead.
2016-03-08 18:52:21 +01:00
Oleksandr Shulgin
da6e061ee8
Use python-defined make_dsn() for ReplicationConnection class
2016-03-08 18:52:21 +01:00
Oleksandr Shulgin
cb7032554e
Merge branch 'master' into feature/replication-protocol-c-connection-object
2016-03-04 10:52:10 +01:00
Daniele Varrazzo
7aab934ae5
Validate output result from make_dsn()
...
The output is not necessarily munged anyway: if no keyword is passed,
validate the input but return it untouched.
2016-03-03 17:09:15 +00:00
Daniele Varrazzo
d40f81865f
Added parse_dsn() docstring
2016-03-03 03:25:47 +00:00
Oleksandr Shulgin
09a4bb70a1
Allow retrying start_replication after syntax or data error.
2016-01-05 12:31:57 +01:00
mrmilosz
0772d187e9
Return input tuple in cur.callproc, factor code to use PQescapeIdentifier in single place
2015-12-13 01:10:03 -05:00
Daniele Varrazzo
92109e4bba
Correctly handle an empty error message from PQescapeIdentifier
2015-12-12 17:52:56 -05:00
Daniele Varrazzo
54e5349f53
Set an exception in case of PQescapeIdentifier error
...
Ifdeffed surface reduced.
2015-12-12 17:52:56 -05:00
Daniele Varrazzo
4003b7c977
Fixed callproc return value refcount
...
Temporary anyway: I want to go back returning a list (or dict).
2015-12-12 17:51:45 -05:00
Daniele Varrazzo
021f6d22ad
More straightforward param refcount handling in callproc
2015-12-12 17:51:45 -05:00
Daniele Varrazzo
d297976d6d
Raise TypeError if the dict in callproc param contains non-strings
...
Check-and-conversion chain fixed and simplified. 'spname' was a
reference leak.
2015-12-12 17:51:08 -05:00
Daniele Varrazzo
a3eed9c9f5
Added guard on params with no length on callproc
2015-12-12 17:51:08 -05:00
Daniele Varrazzo
04ce14b251
Avoid clobbering the exceptions raised by other calls
2015-12-12 17:49:59 -05:00
mrmilosz
c205f140a0
callproc: tests, docs, and comment/error-reporting touchups.
2015-12-12 17:49:59 -05:00
mrmilosz
37a80e9de8
callproc: checking for libpq 9.0+ on compile. yes: use PQescapeIdentifier. no: error
2015-12-12 17:49:44 -05:00
mrmilosz
3948e909e4
callproc: now more compliant with local coding standards.
2015-12-12 17:49:44 -05:00
mrmilosz
e9bb4a86f9
cursor.callproc: added a missing memory check
2015-12-12 17:49:25 -05:00
mrmilosz
31c95c0922
callproc using a dict now uses connection encoding and sanitizes parameter names
2015-12-12 17:49:25 -05:00
mrmilosz
1205bf9c2b
callproc using a dict now has a type check to make sure the keys are strings.
2015-12-12 17:49:25 -05:00
mrmilosz
23d279945f
cursor.callproc now also accepts dict for PostgreSQL 9+ "named notation"
2015-12-12 17:49:25 -05:00
Oleksandr Shulgin
e61db578cf
Add dbname=replication for physical replication type.
2015-10-30 13:00:55 +01:00
Oleksandr Shulgin
a4cbb088fe
Add connection.get_dsn_parameters()
2015-10-30 11:10:41 +01:00
Oleksandr Shulgin
fbcf99ad07
Move replication connection to C level.
2015-10-27 18:21:24 +01:00
Oleksandr Shulgin
433fb957cb
Merge branch 'feature/connect2' into feature/replication-protocol
2015-10-27 17:37:18 +01:00
Oleksandr Shulgin
7aba8b3ed0
Rework psycopg2.connect() interface.
2015-10-27 17:35:57 +01:00
Oleksandr Shulgin
4b9a6f48f3
Merge branch 'master' into feature/replication-protocol
2015-10-27 12:16:41 +01:00
Oleksandr Shulgin
fe4cb0d493
Fix stale Dprintfs in pqpath.c referring to 'status'
2015-10-26 17:40:39 +01:00
Oleksandr Shulgin
8b79bf43ac
Drop ReplicationCursor.flush_feedback(), rectify pq_*_replication_*() interface.
2015-10-23 18:30:18 +02:00
Oleksandr Shulgin
e69dafbecc
Move the decode
parameter to start_replication()
.
...
It makes more sense this way, because otherwise it must be passed to every call
of `read_message()`.
2015-10-23 11:31:55 +02:00
Oleksandr Shulgin
76c7f4a0b5
Use direct call to consume() callable in pq_copy_both()
2015-10-22 16:17:08 +02:00
Oleksandr Shulgin
089e745af6
Fix cursor_init() declaration for use in replication_cursor_type.c
2015-10-20 12:55:43 +02:00
Oleksandr Shulgin
b3f8e9adb5
Fix send_time printf format in replmsg_repr().
2015-10-20 12:54:22 +02:00
Oleksandr Shulgin
23abe4f501
Add quick start to the replication doc, minor doc fixes.
2015-10-20 12:36:13 +02:00
Oleksandr Shulgin
0bb81fc848
Properly subclass ReplicationCursor on C level.
2015-10-19 20:00:39 +02:00
Oleksandr Shulgin
4ab7cf0157
Replace stop_replication with requirement for an exception.
2015-10-19 15:42:42 +02:00
Oleksandr Shulgin
8e518d4954
Merge branch 'master' into feature/replication-protocol
2015-10-15 12:27:43 +02:00
Oleksandr Shulgin
89bb6b0711
Proper unicode handling in quote_ident.
2015-10-15 11:52:18 +02:00
Oleksandr Shulgin
9ab38ee8c5
Add psyco_curs_datetime_init
2015-10-14 18:39:48 +02:00
Oleksandr Shulgin
28a1a00d1c
Remove commented copy_both code in pqfetch.
2015-10-14 18:39:20 +02:00
Oleksandr Shulgin
822d671e8b
Clear repl_stop flag after the consume loop.
2015-10-14 17:40:39 +02:00
Oleksandr Shulgin
e05b4fd267
Add checks on replication state, have to have a separate check for consume loop.
2015-10-14 17:36:50 +02:00
Oleksandr Shulgin
9295bce154
Add psycopg2.extensions.quote_ident.
2015-10-14 17:00:25 +02:00
Oleksandr Shulgin
a0b42a12ff
Update stop_repl, require replication consumer to be a callable.
2015-10-14 15:15:07 +02:00
Oleksandr Shulgin
fea2260fc5
Fix stop_replication: always raise outside the loop.
2015-10-14 12:50:08 +02:00
Oleksandr Shulgin
0233620c26
Rework replication connection/cursor classes
2015-10-01 19:33:27 +02:00
Oleksandr Shulgin
937a7a9024
Cleanup start replication wrt. slot type a bit.
2015-10-01 19:33:16 +02:00
Oleksandr Shulgin
f872a2aabb
Remove typedef for uint32, include internal/c.h
2015-10-01 19:33:12 +02:00
Oleksandr Shulgin
862eda10c2
Merge remote-tracking branch 'origin/master' into repl
2015-10-01 19:29:17 +02:00
Daniele Varrazzo
c73c1c5771
Decref the ssl module after importing
2015-10-01 17:04:29 +01:00
Daniele Varrazzo
5afeee3613
Added unicode support to parse_dsn
...
Also added support for the argument as a keyword.
2015-10-01 13:20:11 +01:00
Daniele Varrazzo
d1af12187c
Merge branch 'master' into parse-dsn
2015-10-01 11:39:51 +01:00
Daniele Varrazzo
6803341f21
Report NotSupportedError for PGRES_COPY_BOTH and PGRES_SINGLE_TUPLE
...
Fixes #352 .
2015-09-30 12:28:07 +01:00
Daniele Varrazzo
0e3f5214c5
Report the server response status on errors with no message
...
Suggested by Craig Ringer in pull request #353 , should also give more
information for other cases we were reported on flaky servers (AWS,
digital ocean...), see bug #281 .
2015-09-30 12:28:07 +01:00
Photonios
71925fcc00
Fix for MSVC 2015: round has been added to this version
2015-09-22 18:26:14 +02:00
Photonios
ac25ba0a3f
Fix for MSVC 2015: isnan is supported in this version
2015-09-22 18:25:53 +02:00
Oleksandr Shulgin
26fe1f230f
Fix use of PQconsumeInput() in pq_read_replication_message()
...
The libpq's PQconsumeInput() returns 0 in case of an error only, but
we need to know if it was able to actually read something. Work
around this by setting an internal flag before retry.
2015-07-07 19:04:32 +02:00
Oleksandr Shulgin
eac16d048a
Fix missing GC flag in ReplicationMessage type
2015-07-03 15:44:45 +02:00
Oleksandr Shulgin
06f18237f7
Fix missing free in replmsg_dealloc
2015-07-03 11:40:00 +02:00
Oleksandr Shulgin
9c1f2acf3e
Check return value of PQsocket
...
When connection is closed by the server, we might get -1 there.
2015-07-02 14:39:51 +02:00
Oleksandr Shulgin
dab41c699a
Fix PQconsumeInput usage.
...
Only call when no data is available in the internal buffer.
2015-07-02 14:34:09 +02:00
Oleksandr Shulgin
0d731aa12e
Comment on special handling of PGRES_COPY_BOTH
2015-06-30 16:34:17 +02:00
Oleksandr Shulgin
058db56430
Merge remote-tracking branch 'zalando/feature/replication-protocol' into feature/replication-protocol
2015-06-30 10:40:52 +02:00
Oleksandr Shulgin
61e52ce879
Rework replication protocol
...
This change exposes lower level functions for operating the
(logical) replication protocol, while keeping the high-level
start_replication function that does all the job for you in
case of a synchronous connection.
A number of other changes and fixes are put into this commit.
2015-06-30 10:38:18 +02:00
Oleksandr Shulgin
e3c3a2c19e
Merge branch 'master' into feature/replication-message-object
...
Conflicts:
lib/extensions.py
2015-06-30 10:30:32 +02:00
Oleksandr Shulgin
9ed90b1216
Refer cursor from ReplicationMessage object. At the same time, for the sync use LSN instead of msg reference in cursor.
2015-06-11 14:52:01 +02:00
Oleksandr Shulgin
35a3262fe3
Expose ReplicationMessage type in extras
2015-06-11 12:20:52 +02:00
Oleksandr Shulgin
9fc5bf4436
Add handling of send_time field in replmsg
2015-06-10 18:21:06 +02:00
Oleksandr Shulgin
453830f80c
Add ReplicationMessage object
2015-06-05 17:44:09 +02:00
Oleksandr Shulgin
50df864f8c
Add timersub for Win32. Fix gettimeofday on MinGW.
2015-06-04 11:00:08 +02:00
Oleksandr Shulgin
f14521f8cb
Add libpq_support.c and win32_support.c
...
Move libpq-specific code for streaming replication support into a
separate file. Also provide gettimeofday() on Win32, implementation
copied from Postgres core.
2015-06-03 14:10:20 +02:00
Daniele Varrazzo
1f330e9cac
Allow connection.notices and notifies to be replaced.
...
Close #326
2015-06-02 17:02:04 +01:00
Daniele Varrazzo
2ad82b973b
Pending notice list converted into a forward list
...
This allows inserting the elements in order without using list.insert().
2015-06-02 14:25:46 +01:00
Daniele Varrazzo
b326a27774
Dropped unneeded constness on the notice message
...
That's a strdup result, we 0wn it.
2015-06-02 14:24:48 +01:00
Daniele Varrazzo
0a7261268b
Dropped unused notice_filter connection member
2015-06-02 13:11:46 +01:00
Daniele Varrazzo
b0058c0cc8
Fixed adaptation of lists of None
...
Note: lists of lists of None are not supported yet.
2015-06-02 12:48:24 +01:00
Oleksandr Shulgin
cc08e14162
Merge branch 'master' into feature/parse-dsn
...
Conflicts:
lib/extensions.py
2015-06-02 12:42:03 +02:00
Daniele Varrazzo
73d17e3c5e
Dropped PG_VERSION_HEX constant
...
At PostgreSQL 10.0 it would have become awkward.
2015-06-02 10:54:08 +01:00
Oleksandr Shulgin
80da76d43f
Get rid of postgres internal includes; check for Win32 for htonl()
2015-06-02 11:42:56 +02:00
Oleksandr Shulgin
4bb6f9cef2
Add libpq version discovery
2015-06-01 18:05:11 +02:00
Oleksandr Shulgin
6a2f21aa14
Move parse_dsn to extensions, add tests
2015-06-01 15:11:12 +02:00
Oleksandr Shulgin
e32e1b834e
Add support for streaming replication protocol
...
Introduce ReplicationConnection and ReplicationCursor classes, that
incapsulate initiation of special type of PostgreSQL connection and
handling of special replication commands only available in this special
connection mode.
The handling of stream of replication data from the server is modelled
largely after the existing support for "COPY table TO file" command and
pg_recvlogical tool supplied with PostgreSQL (though, it can also be
used for physical replication.)
2015-06-01 11:45:04 +02:00
Oleksandr Shulgin
6c57e4a648
Add parse_dsn module function
...
Calls PQconninfoParse to parse the dsn into a list of keyword and value
structs, then constructs a dictionary from that. Can be useful when one
needs to alter some part of the the connection string reliably, but
doesn't want to get into all the details of parsing a dsn string:
quoting, URL format, etc.
2015-06-01 10:16:07 +02:00
Jan Urbański
a59704cf93
Make sure libcrypto threadsafety callbacks are properly set up
...
Multithreaded programs using libcrypto (part of OpenSSL) need to set up
callbacks to ensure safe execution. Both Python and libpq set up those
callbacks, which might lead to a conflict.
To avoid leaving dangling function pointers when being unloaded, libpq sets up
and removes the callbacks every time a SSL connection it opened and closed. If
another Python thread is performing unrelated SSL operations (like connecting
to a HTTPS server), this might lead to deadlocks, as described in
http://www.postgresql.org/message-id/871tlzrlkq.fsf@wulczer.org
Even if the problem will be remediated in libpq, it's still useful to have it
fixed in psycopg2. The solution is to use Python's own libcrypto callbacks and
completely disable handling them in libpq.
2015-05-03 12:27:36 +01:00
Daniele Varrazzo
ad3e91a56f
Unlock the connection after PQflush error
...
Apparently this has never happened... anyway the code path was wrong.
Fixes #294 .
2015-05-03 12:01:05 +01:00
Hyunjun Kim
4eee1207f9
Fix several typos
2015-05-03 10:30:21 +01:00
Daniele Varrazzo
70fbc8bf1f
Fixed connection.poll() docstring
...
Fixes #312
2015-05-03 10:29:57 +01:00
Daniele Varrazzo
7ea56b112e
Make Column picklable on Python >= 3.3
...
Also expose the type from the extensions module, not from the main
module.
2015-02-08 11:27:10 +00:00
Owen Raccuglia
5af5fb4cc6
Allow pickling of cursor.description
...
This is for people using dtuple.py; a dtuple.DatabaseTuple instance
keeps a reference to cursor.description, which is not picklable because
psycopg2 doesn't export the Column namedtuple it uses.
This commit exports the Column namedtuple, and includes a test to verify
the pickle/unpickle works after exporting Column.
2015-02-08 02:31:33 +00:00
Daniele Varrazzo
7ce7fef322
Propagate read error messages in COPY FROM
...
Fix ticket #270 .
2015-02-08 01:42:21 +00:00
Daniele Varrazzo
d3c1ad5945
Convert Postgres time 24:00 into 00:00
...
Fix ticket #278 .
2015-02-08 00:41:50 +00:00
Daniele Varrazzo
2f862972c9
Guard against overflows when using the lo32 api
...
If psycopg supports lo64 but the server doesn't the user may pass values
that would overflow the api range, resulting in:
lo.seek((2<<30))
*** OperationalError: ERROR: invalid seek offset: -2147483648
Also improved the error messages and guard against INT_MIN for negative
seek offsets.
2014-12-25 15:06:18 +01:00
Daniele Varrazzo
79df47a146
Fixed mismatched types in debug print
2014-12-25 15:06:18 +01:00
Daniele Varrazzo
0205d6ca2e
Use ifdef instead of if to check LO64
2014-12-25 15:06:18 +01:00
Blake Rouse
e5bbde9554
Check server_version before using lo_*64 functions. If less tahn 9.3 old none 64bit functions will be use.
2014-12-25 15:06:18 +01:00
Blake Rouse
cd67d3d2fe
Modify truncate to use lo_truncate64. Use HAVE_LO64 define to use new lo_*64 methods. Check size of offset and length for versions without LO64.
2014-12-25 15:06:18 +01:00
Blake Rouse
e13ec67da3
Use lseek64 and ltell64 to support large object greater than 2gb in size.
2014-12-25 15:06:18 +01:00
Hyunjun Kim
4dbda02145
Cast time into timetz when the tzinfo field is set.
2014-11-13 17:32:06 +09:00
Daniele Varrazzo
1b48033345
Don't try to close the server cursor in error state
...
`close()` is implicitly called by `__exit__()`, so an exit on error
would run a query on a inerr connection, causing another exception
hiding the original one. The fix is on `close()`, not on `__exit__()`,
because the semantic of the latter is simply to call the former.
Closes #262 .
2014-09-16 06:57:34 +01:00
Daniele Varrazzo
2d601ef157
Fixed memory leak with large objects
...
Deallocating closed large objects failed to decrement the connection
refcount. The fact the lobject is closed doesn't matter for refcount.
Issue detected by the always useful scripts/refcounter.py
With an extra bit of unrequested whitespace love.
2014-08-28 02:17:52 +01:00
Daniele Varrazzo
54d904138d
Don't import psycopg2.tz into the C extension
...
This makes possible to import _psycopg directly, after adding the
package directory to the pythonpath. This enables hacks such as:
sys.path.insert(0, '/path/to/psycopg2')
import _psycopg
sys.modules['psycopg2._psycopg'] = _psycopg
sys.path.pop(0)
which can work around e.g. the problem of #201 , freeze that cannot
freeze psycopg2. Well, freeze cannot freeze it because it's just not
designed to deal with C extensions. At least now the frozen application
can hack the pythonpath and work around the limitation by importing
_psycopg as above and then doing the rest of the imports normally.
Keeping long-lived references to python objects is bad anyway: the
tz module couldn't be reloaded before.
2014-08-28 02:17:46 +01:00
Daniele Varrazzo
1d729ab40e
Dropped HAVE_PQFREEMEM flag
...
It was necessary before PG 7.4, in versions which have long been unsupported.
2014-08-24 01:43:12 +01:00
Daniele Varrazzo
68a4308c3d
Dropped PSYCOPG_NEW_BOOLEAN flag
...
Introduced in 2.0 beta 8, 2006 A.D. Went absolutely untouched in 8 years
of refactoring, when Python 2.5 and PostgreSQL 8.1 roamed the earth.
I would say it has stood the test of the time.
2014-08-24 01:25:02 +01:00
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
Alexey Borzenkov
13b0852619
Allow using named with hold cursors in autocommit
2014-08-21 05:35:11 +01:00
Alexey Borzenkov
478e66f761
No implicit transaction on named cursor close
...
Also, don't start an implicit transaction when fetching with
named with hold cursor, since it already returns results
from a previously committed transaction.
2014-08-21 05:35:10 +01:00
Daniele Varrazzo
a2b01cdf42
Dropped simple type wrapper functions
...
These functions don't need to exist: exposing the type in the module is
enough. It is actually better as one may use isinstance and such.
2014-08-15 02:54:31 +01:00
Daniele Varrazzo
1b322a9b19
Fixed segfault in List function
...
This function is never called: it segfaults 100%. To be removed.
2014-08-15 02:54:25 +01:00
Daniele Varrazzo
95165cef7d
Dropped almost-no-op customized objects repr()
...
The default repr is enough: it prints <TypeName at 0xADDR> instead of
<TypeName object at 0xADDR>.
The only people being hurt by this change are the ones using doctests:
they deserve it.
2014-08-15 02:54:10 +01:00
Daniele Varrazzo
669e787919
Name the types after the module they are exposed from
2014-08-15 01:47:19 +01:00
Daniele Varrazzo
56adc590ff
Fixed segfault if COPY statements are executed
...
Close ticket #219
2014-06-06 21:42:21 +02:00
Daniele Varrazzo
115ceea1eb
Don't ignore silently the cursor.callproc
argument without a length
2014-06-06 21:42:21 +02:00
Daniele Varrazzo
d0b35adeb6
Parse the rowcount as long
2014-05-13 14:34:10 +01:00
Daniele Varrazzo
81b5f1fb26
Copy operations correctly set the cursor.rowcount attribute
...
Fixes ticket #180 .
2014-05-05 23:53:50 +01:00
Daniele Varrazzo
69605e54ec
Fixed explicit connection.cursor(cursor_factory=None)
...
Fixes issue #210 .
2014-04-30 17:57:55 +01:00
Daniele Varrazzo
489658cfc5
Close the connection if discovered bad on poll()
2014-04-05 16:03:19 +01:00
Daniele Varrazzo
1654687d1b
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-05 16:03:06 +01:00
Daniele Varrazzo
3752880b7b
Fixed attempt of closing an already closed lobject on dealloc
...
This results in a "null without exception set" in the corrent state, which
is caused by the connection being unexpectedly closed anyway.
2014-04-05 16:03:06 +01:00
Daniele Varrazzo
2e55b35d5d
Don't set an exception witout GIL closing lobjects with a bad conn
...
We ended up in this branch only for an excessively aggressive closing
of the transaction that now I'm going to fix.
2014-04-05 16:03:06 +01:00
Daniele Varrazzo
696d123550
Close a connection if PQexec returned NULL
...
This happens for Socket connections, not for TCP ones, where a result
containing an error is returned and correctly handled by pq_raise()
Closes ticket #196 but not #192 : poll() still doesn't change the
connection closed.
2014-04-05 16:03:06 +01:00
Daniele Varrazzo
a31c1a1722
Allow get_transaction_status on closed connections
...
It's a local operation and the libpq functions has a NULL guard.
2014-04-05 16:02:43 +01:00
Daniele Varrazzo
9036299d54
Avoid printing the typecast name in debug statement
...
The way we were doing it is unsafe and causes assertion failures on Py3.
Fixes ticket #188
2014-04-04 19:25:09 +01:00
Daniele Varrazzo
ca98167ae4
Fixed use of Python object with refcount 0 in cursor_init
...
Caused segfault running test_cursor.CursorTests.test_invalid_name under
Python 3.4 built in debug mode.
2014-04-04 19:20:08 +01:00
Daniele Varrazzo
a8fdc74090
Fixed overflow opening a lobject with an oid not fitting in a signed int
...
Fixes 🎫 `203`.
2014-04-03 02:35:56 +01:00
Daniele Varrazzo
e7fc7f31b9
Fixed dsn and closed attributes in failing connection subclasses.
...
From ticket #192 discussion.
2014-04-03 01:42:35 +01:00
Daniele Varrazzo
7b82be936d
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
2014-02-26 19:41:59 +00:00
Daniele Varrazzo
618f7e41de
Use the do-while 0 idiom for cursor guards macro
2014-02-26 19:31:27 +00:00
Daniele Varrazzo
63e36e22d2
Set the connection async before polling for connection
...
It should fix ticket #194
2014-02-24 15:20:01 +00:00
Daniele Varrazzo
ca99579b76
Set the connection async earlier in green mode
...
The moment it is called shouldn't have really changed, but it's more
explicit when it happens. Previously it was sort of obfuscated behind a
roundtrip through the green callback and poll.
2014-02-24 15:20:01 +00:00
Daniele Varrazzo
85b1914ad6
Fixed dealloc of lobject->smode
...
I put it by mistake into the in the self->conn checked block in the
previous commit.
2013-11-27 13:00:16 +00:00
Daniele Varrazzo
e11d0d39ec
Check connection type in lobject init
...
Fixes ticket #187 .
2013-11-27 12:44:28 +00:00
Daniele Varrazzo
1e623a951c
Meaningful connection errors report a meaningful message
...
Fixes issue #173 .
2013-10-16 17:50:10 +01:00
Daniele Varrazzo
345077d5f7
Fixed pickling of exceptions with no pgerror/pgcode set
...
Fixes ticket #170 .
2013-07-19 16:05:59 +01:00
Daniele Varrazzo
921b676471
Untrack the connection before closing to avoid possible double-free
...
From Gangadharan S.A. Fixes issue #166 .
2013-06-20 16:35:43 +01:00
Piotr Kasprzyk
31b6ec63f8
Fix multiple misspellings
2013-04-26 09:59:40 +01:00
Daniele Varrazzo
e335eb98ce
Long ifdef reformatted for readibility
2013-04-20 02:21:58 +01:00
Daniel Enman
558f7ad929
Remove extra ||
2013-04-18 17:12:14 -03:00
Daniel Enman
cda0b6a8eb
Solaris 10+, and illumos distros have round()
2013-04-18 16:59:26 -03:00
Daniele Varrazzo
b214d10fff
Use NULL instead of an empty string as PyObject_CallMethod format
2013-04-07 17:26:57 +01:00
Daniele Varrazzo
9e15f54fe8
Added cursor_factory connection attribute and connect() parameter
2013-04-07 02:30:12 +01:00
Daniele Varrazzo
408c76fdb6
Fixed build on windows
...
Will fail with error: initializer element is not constant
2013-04-06 01:34:12 +01:00
Daniele Varrazzo
d36024dc1f
Use the Python heap for conn->dsn
2013-04-06 00:42:25 +01:00
Daniele Varrazzo
c63d623f65
Merge branch 'drop-py24' into devel
2013-04-05 01:29:25 +01:00
Daniele Varrazzo
beea32ef03
Use the Py_RETURN_NONE macro
2013-04-05 01:25:05 +01:00
Daniele Varrazzo
67c8250081
Added tp_clear method for objects with GC support
2013-04-05 01:05:12 +01:00
Daniele Varrazzo
1a93279fe7
Dropped bogus return in void function
2013-04-05 01:03:05 +01:00
Daniele Varrazzo
e14440d96d
Dropped GC support for several objects
...
Non-containers don't need GC. It was half-baked anyway
as the tp_clear was often not set. Dropped tp_traverse too
for these objects as unused.
2013-04-05 01:02:47 +01:00
Daniele Varrazzo
95ff64d739
Dropped encoding attribute from list adapter
2013-04-05 00:35:02 +01:00
Daniele Varrazzo
6bc4b23af5
Static-type psycopg_escape_string connection parameter
2013-04-05 00:07:36 +01:00
Daniele Varrazzo
736a78f3f6
Avoid encoding strdup in qstring adapter
...
Dropped encoding parameter in the constructor: it is used
nowhere and not documented. Use directly the connection
encoding if available, else the previous latin1 fallback.
2013-04-05 00:00:42 +01:00
Daniele Varrazzo
7a5a226b49
Set a memory exception in psycopg_escape_string
...
...otherwise all the callers should set it.
2013-04-04 22:48:53 +01:00
Daniele Varrazzo
7328aaf0fb
Dropped GC support from Xid and Notify types
...
These types are immutable and have only atomic types attributes, so it's
impossible to build loops out of them.
2013-04-02 01:50:31 +01:00
Daniele Varrazzo
5aafe38fd7
Some improvements to connection/cursor GC
...
Provide a tp_clear, make sure that GC_UnTrack is called before clearing.
2013-03-21 12:55:17 +00:00
Daniele Varrazzo
3b8abf3fc4
Clean the C members of Error in tp_dealloc instead of tp_clear
...
tp_clear should only be used to break the reference cycles. tp_clear was
causing a segfault because it was called twice (by the gc and by _dealloc) so
self->codec was freed twice.
Amazingly the double free was only causing a segfault on Python 3.3 (released
in late 2012) talking to Postgres 8.1 (released in 2005) in async mode... no
other combination crashed. Thank you buildbot.
2013-03-21 12:34:53 +00:00
Daniele Varrazzo
d5316d7eb2
PyType_GenericAlloc is the default allocator: no need to specify
2013-03-20 23:53:20 +00:00
Daniele Varrazzo
eb280c1da4
Better use of Py_CLEAR and implicit zeroed-out structures
2013-03-20 23:53:20 +00:00
Daniele Varrazzo
b6873ee1ab
Dropped support for Python 2.4
2013-03-20 23:40:13 +00:00
Daniele Varrazzo
e65392e0d8
PyType_GenericAlloc is the default allocator: no need to specify
2013-03-20 22:59:50 +00:00
Daniele Varrazzo
8a59e75d62
Better use of Py_CLEAR and implicit zeroed-out structures
2013-03-20 22:59:50 +00:00
Daniele Varrazzo
3410fee8d1
Fixed leak of cancel key on connection.reset()
...
Moving the final free into the destructor is not necessary but looks
appropriate.
2013-03-20 16:43:16 +00:00
Daniele Varrazzo
9813bac4fe
Added forgotten attributes to visit in error
2013-03-20 15:06:06 +00:00
Daniele Varrazzo
5dfba462da
Dropped "customized" pg_free functions
...
The defaut is already to call PyObject_GC_Del.
2013-03-20 01:48:21 +00:00
Daniele Varrazzo
0830deb790
Dropped IFCLEARPGRES macro
...
PQclear already guards against NULL, so the extra check is redundant
2013-03-20 01:48:17 +00:00
Daniele Varrazzo
16021dae6d
Use Py_CLEAR on self->query instead of if and decref
2013-03-20 01:48:11 +00:00
Daniele Varrazzo
a210859326
Notify and Xid objects and types renamed for consistency
...
They were the only objects starting with uppercase. My fault.
2013-03-20 01:48:05 +00:00
Daniele Varrazzo
73949cd1b8
Merge branch 'diagnostics' into devel
2013-03-20 01:47:14 +00:00
Daniele Varrazzo
b503db9ce6
psycopg2.Error object and type renamed more consistently
2013-03-20 00:03:58 +00: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
394312939e
Added a C structure to psycopg.Error
...
This will allow to store a PGresult in it.
2013-03-19 12:15:49 +00:00
Daniele Varrazzo
97311967e8
Merge branch 'diagnostics' into devel
2013-03-18 02:21:09 +00:00
Daniele Varrazzo
1cf9825035
Diagnostics is more GC friendly
2013-03-18 02:11:45 +00:00
Daniele Varrazzo
678f0dc949
Added documentation about the Diagnostics object
2013-03-18 02:11:45 +00:00
Daniele Varrazzo
819a551d01
Decode Diagnostics result on Python 3
2013-03-18 00:38:28 +00:00
Daniele Varrazzo
42b063b562
Added all supported properties to the Diagnostic object
2013-03-17 23:58:10 +00:00
Matthew Woodcraft
c75a3bbab4
Work-in-progress support for retrieving PG_DIAG result error fields.
2013-03-17 16:41:15 +00:00
Daniele Varrazzo
66d6c68dcc
Properly cleanup memory of broken connections
...
Fixed ticket #148 .
2013-03-16 11:56:38 +00:00
Daniele Varrazzo
16d96fd43c
Merge branch 'py33' into devel
2012-12-22 00:58:17 +01:00
Daniele Varrazzo
a04379210b
Doubt about 'c' buffer solved by Stefan Krah
2012-12-22 00:51:47 +01:00
Daniele Varrazzo
12645db754
Make sure to call subclasses methods on context exit
2012-12-03 03:37:47 +00:00
Daniele Varrazzo
cc605032f5
Added support for with statement for connection and cursor
...
The implementation should be conform to the DBAPI, although the "with"
extension has not been released yet.
2012-12-03 02:50:24 +00:00
Daniele Varrazzo
9f06df1820
Fixed signature for METH_NOARGS functions
2012-12-03 02:49:06 +00:00
Daniele Varrazzo
362c2ae597
Release the GIL around PQgetResult calls after COPY
...
It should fix ticket #140 .
2012-11-24 22:49:36 +00:00
Daniele Varrazzo
71393b9ae9
Discard any result produced by cursor.executemany()
2012-10-11 22:29:03 +01:00
Daniele Varrazzo
5fbf3ef147
Merge branch 'fix-113' into devel
2012-10-11 22:26:51 +01:00
Daniele Varrazzo
b61a2a34c4
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-06 11:58:52 +01:00
Daniele Varrazzo
2611d62283
Get the result from the connection after the green panic
...
Otherwise the connection won't be usable in case we manage
to put it back on track (libpq reports "another command is
already in progress")
2012-10-06 01:45:24 +01:00
Daniele Varrazzo
644b18a2c9
Dropped compiler warning on Py 2.4
2012-10-06 01:22:05 +01:00
Daniele Varrazzo
76815f1e92
Added compatibility PyErr_WarnEx macro for Python 2.4
2012-10-06 01:16:57 +01:00
Daniele Varrazzo
53b1c70f3a
Attempt to fix issue #113 .
...
If the network is down, trying to read blocking will hang the process hard
(ctrl-c not working). Send a cancel signal instead (as suggested in
http://archives.postgresql.org/pgsql-hackers/2012-07/msg00903.php ) and go
back into a green polling: this should allow a further error (e.g. another
ctrl-c) to break the loop. In this case we cannot assume anything about
the state of the connection, so we close it.
2012-10-06 01:10:41 +01:00
Daniele Varrazzo
2137db89d4
Added function conn_close_locked()
2012-10-06 01:03:12 +01:00
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