Commit Graph

49 Commits

Author SHA1 Message Date
Oleksandr Shulgin
089e745af6 Fix cursor_init() declaration for use in replication_cursor_type.c 2015-10-20 12:55:43 +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
9ab38ee8c5 Add psyco_curs_datetime_init 2015-10-14 18:39:48 +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
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
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
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
453830f80c Add ReplicationMessage object 2015-06-05 17:44:09 +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
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
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
5bfb6cdefe Use more compact macros to annotate functions for the static checker 2012-03-01 02:53:28 +00:00
Daniele Varrazzo
0ee641361b Flag a few other functions returning borrowed refs 2012-02-24 22:26:01 +00:00
Federico Di Gregorio
2f6336ea78 First try at curs.withhold implementation 2011-07-05 10:28:34 +02: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
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
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
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
19ff51ae75 The cursor is weakly referenceable 2011-01-03 21:34:49 +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
6d7916cfe1 Internal imports simplified.
.c files only need to import psycopg.h: it will in turn import
dependencies from Python and libpq and configure.h. psycopg.h should be
the first to be imported, so the basic imports are not required in
the .h's

As a guideline I'm trying to import from the most specific to the most
generic to detect missing imports in the .h's.
2010-12-12 13:39:32 +00:00
Daniele Varrazzo
e29424a230 Dropped large object support when psycopg is in green mode.
Async mode and large object are not compatible, albeit I haven't found
an authoritative source yet.
2010-05-09 20:34:02 +01:00
Daniele Varrazzo
1edbd16577 Dropped curs_get_last_result function.
The result is read from a pqpath function and put on the async_cursor by
a function that also checks for is presence and dismiss it after its
usage.
2010-04-23 13:24:35 +01:00
Daniele Varrazzo
d915cb12a8 Functions to poll in ready state moved on the connection. 2010-04-23 13:24:35 +01:00
Daniele Varrazzo
8fed0aa57d Forbid COPY-related methods in green mode.
With the current implementation, at best they would silently block. They
actually hang everything.

Implementation posponed after some refactoring of the polling system,
because it will be probably possible to provide an implementation for
'poll()' during COPY which is good for both async and green modes.
2010-04-21 15:21:33 +01:00
Jan Urbański
c4ebc0f702 Handle errors in asynchronous queries.
Do it by keeping the reference to the last PGresult in the cursor and
calling pq_fetch() before ending the asynchronous execution. This
takes care of handling the possible error state of the PGresult and
also allows the removal of the needsfetch flag, since now after
execution ends the results are already fetched and parsed.
2010-04-20 23:01:01 +01:00
Federico Di Gregorio
c1a24f4ca2 NOTIFYs fix and poll status changes
POLL_OK has been changed from 3 to 0 to let the user specify a short loop
just as "if not curs.poll()" instead of having to check for write and read
separately. For an example of this, see examples/notify.py.
2010-04-05 16:52:25 +02:00
Jan Urbański
58eb868db6 Avoid the possibility when curs_get_last_result would block
It was trying to get all pending results from the connection and if
the client sent many and anyone except the first one would not be
immediately available the loop in curs_get_last_result would call
PQgetResult blockingly.
Avoid that by calling PQisBusy every time and telling the client to
wait for more data if it returns 1.
2010-04-05 16:27:39 +02:00
Jan Urbański
727670c269 Make some methods raise an exception in asynchronous mode
The methods changed are connection.commit(), rollback(), reset(),
set_isolation_level(), set_client_encoding(), lobject(), cursor(str)
as well as cursor.execute() and cursor.callproc() if another query is
in progress and cursor.executemany(), cursor.copy_{from,to,expert)().
2010-04-05 16:23:44 +02:00
Jan Urbański
91ef0e09ed Change the API for asynchronous queries to use cursor.poll()
The isread() API was not safe, because the query might have not been
sent fully to the server after calling execute(). To make the async
API complete, a similar mechanism to async connections must be used.

The cursor now has a poll() method that you would use identically to
the poll() method of the connection class.
2010-04-05 11:31:50 +02:00
Jan Urbański
cc37fd1ea9 Add curs_get_last_result, a function to get the last result from a connection 2010-04-05 11:24:57 +02:00
Federico Di Gregorio
611606d532 Changes license to LGPL3 + OpenSSL exception on all source files 2010-02-12 23:34:53 +01:00
Federico Di Gregorio
4c3e2ad94b Fixed problem with lots of columns in COPY operations 2009-08-09 15:13:42 +02:00
James Henstridge
864d107325 * psycypg/*.h: apply HIDDEN to all global variables and functions
that should not be exported from the module.  This results in a 5%
	reduction in code size and shortens the dynamic symbol table.

	* psycopg/config.h: If GCC >= 4.0 is installed, define the HIDDEN
	symbol to apply the "hidden" visibility attribute.
2008-01-21 05:54:01 +00:00
Federico Di Gregorio
d6e232e2b9 Various fixes, now all examples work. 2007-04-13 14:07:11 +00:00
Federico Di Gregorio
e5829292cd Fixed both Python 2.5 and 64 bit problems. 2007-04-10 06:36:18 +00:00
Federico Di Gregorio
f4dc6936a2 Builds again on win32 (closes: #132). 2006-10-29 03:12:51 +00:00
Federico Di Gregorio
3009a29b11 Piet Delport patches: 1 of 3. 2006-09-23 05:10:58 +00:00
Federico Di Gregorio
ef3430d24f Implemented named cursors. 2005-10-22 06:59:31 +00:00
Federico Di Gregorio
ec31179c9e NOTIFY works again. 2005-10-18 14:07:17 +00:00
Federico Di Gregorio
def14d5925 Array support works, at least for INTEGERS. 2005-03-22 16:33:57 +00:00
Federico Di Gregorio
08a4965342 isready/prefetch fix. 2004-12-14 03:33:03 +00:00
Federico Di Gregorio
1b74bb897f async fixes and better connection/cursor management. 2004-12-10 10:34:57 +00:00
Federico Di Gregorio
c904d97f69 Initial psycopg 2 import after SVN crash. 2004-10-19 03:17:12 +00:00