Commit Graph

1839 Commits

Author SHA1 Message Date
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
9386653d72 Update docs on ReplicationCursor 2015-07-01 14:08:32 +02:00
Oleksandr Shulgin
0d731aa12e Comment on special handling of PGRES_COPY_BOTH 2015-06-30 16:34:17 +02:00
Oleksandr Shulgin
318706f28c Update docs for Replication protocol 2015-06-30 16:17:31 +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
1ac385d1fb Fix logical decoding plugin options adaptation on python3 2015-06-10 13:39:35 +02:00
Oleksandr Shulgin
453830f80c Add ReplicationMessage object 2015-06-05 17:44:09 +02:00
Oleksandr Shulgin
f7b84ce843 Add {libpq,win32}_support.* to the .cproj file 2015-06-04 11:01: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
925fdf5731 Fixed doc about libpq version availability 2015-06-02 17:11:09 +01:00
btubbs
06b4b1de94 Notify example should pop the oldest message in conn.notifies, not the newest. 2015-06-02 17:07:10 +01:00
Daniele Varrazzo
6002c524d6 Merge branch 'notice-lists-replaceable' 2015-06-02 17:04:25 +01:00
Daniele Varrazzo
1f330e9cac Allow connection.notices and notifies to be replaced.
Close #326
2015-06-02 17:02:04 +01:00
Oleksandr Shulgin
44b705f88f Improve identify_system: don't hardcode column names 2015-06-02 16:52:48 +02: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
Oleksandr Shulgin
d6041271bc Separate parse_dsn test on URI, for libpq >= 9.2 2015-06-02 14:02:29 +02:00
Pete Hollobon
5712f30169 Change "non desiderable" to "undesirable" in docs
"desiderable" is considered obsolete
2015-06-02 13:00:25 +01:00
Daniele Varrazzo
7e5715617e Merge branch 'adapt-list-of-none' 2015-06-02 12:49:15 +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
8d4ac25b56 Merge branch 'libpq-version' 2015-06-02 11:20:28 +01:00
Daniele Varrazzo
c2955fb8fc Version function/constant docs improved 2015-06-02 11:20:02 +01:00
Daniele Varrazzo
5a21da43ee Mention libpq version inspection in news file 2015-06-02 11:19:55 +01: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
ffd98a82c0 Add test for libpq_version 2015-06-02 11:12:16 +02:00
Oleksandr Shulgin
4bb6f9cef2 Add libpq version discovery 2015-06-01 18:05:11 +02:00
Oleksandr Shulgin
3200cd77bf One more parse_dsn test for unquoted space 2015-06-01 15:18:03 +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
Daniele Varrazzo
d66165232e OpenSSL deadlock fix noted in NEWSfile 2015-05-03 12:27:37 +01: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
1b7e3c6da4 Improve docs about connection's with only closing the transaction 2015-05-03 12:01:06 +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
Daniele Varrazzo
4078b89521 Added makefile target to upload docs 2015-05-03 10:30:33 +01:00
Daniele Varrazzo
1d006ccbe9 Added note about table names to be escaped in copy_*() methods. 2015-05-03 10:30:28 +01:00