Skip to content

Commit 7caba16

Browse files
committed
Merge branch 'master' into fast-codecs
2 parents 121cf3b + e9577e9 commit 7caba16

24 files changed

+444
-120
lines changed

.travis.yml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1+
# Travis CI configuration file for psycopg2
2+
3+
dist: trusty
4+
sudo: required
15
language: python
26

37
python:
4-
- 2.6
58
- 2.7
6-
7-
before_script:
8-
- psql -c 'create database psycopg2_test;' -U postgres
9+
- 3.6-dev
10+
- 2.6
11+
- 3.5
12+
- 3.4
13+
- 3.3
14+
- 3.2
915

1016
install:
1117
- python setup.py install
18+
- sudo scripts/travis_prepare.sh
19+
20+
script:
21+
- scripts/travis_test.sh
1222

13-
script: make check
23+
notifications:
24+
email: false

NEWS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ New features:
2424
adapter is deprecated (:tickets:`#317, #343, #387`).
2525
- Added `~psycopg2.extensions.quote_ident()` function (:ticket:`#359`).
2626
- Added `~connection.get_dsn_parameters()` connection method (:ticket:`#364`).
27+
- `~cursor.callproc()` now accepts a dictionary of parameters (:ticket:`#381`).
2728

2829
Other changes:
2930

@@ -36,7 +37,7 @@ What's new in psycopg 2.6.3
3637
^^^^^^^^^^^^^^^^^^^^^^^^^^^
3738

3839
- Throw an exception trying to pass ``NULL`` chars as parameters
39-
(:ticket:`#420).
40+
(:ticket:`#420`).
4041
- Make `~psycopg2.extras.Range` objects picklable (:ticket:`#462`).
4142

4243

README.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,8 @@ For any other resource (source code repository, bug tracker, mailing list)
4444
please check the `project homepage`__.
4545

4646
.. __: http://initd.org/psycopg/
47+
48+
49+
.. image:: https://travis-ci.org/psycopg/psycopg2.svg?branch=master
50+
:target: https://travis-ci.org/psycopg/psycopg2
51+
:alt: Build Status

doc/src/conf.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
release = version
6262

6363
intersphinx_mapping = {
64-
'py': ('http://docs.python.org/', None),
65-
'py3': ('http://docs.python.org/3.4', None),
64+
'py': ('http://docs.python.org/2', None),
65+
'py3': ('http://docs.python.org/3', None),
6666
}
6767

6868
# Pattern to generate links to the bug tracker

doc/src/cursor.rst

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,19 @@ The ``cursor`` class
201201

202202
Call a stored database procedure with the given name. The sequence of
203203
parameters must contain one entry for each argument that the procedure
204-
expects. The result of the call is returned as modified copy of the
205-
input sequence. Input parameters are left untouched, output and
206-
input/output parameters replaced with possibly new values.
207-
208-
The procedure may also provide a result set as output. This must then
209-
be made available through the standard |fetch*|_ methods.
204+
expects. Overloaded procedures are supported. Named parameters can be
205+
used by supplying the parameters as a dictionary.
206+
207+
This function is, at present, not DBAPI-compliant. The return value is
208+
supposed to consist of the sequence of parameters with modified output
209+
and input/output parameters. In future versions, the DBAPI-compliant
210+
return value may be implemented, but for now the function returns None.
211+
212+
The procedure may provide a result set as output. This is then made
213+
available through the standard |fetch*|_ methods.
210214

215+
.. versionchanged:: 2.7
216+
added support for named arguments.
211217

212218
.. method:: mogrify(operation [, parameters])
213219

doc/src/faq.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ How do I interrupt a long-running query in an interactive shell?
241241

242242
.. code-block:: pycon
243243
244-
>>> psycopg2.extensions.set_wait_callback(psycopg2.extensions.wait_select)
244+
>>> psycopg2.extensions.set_wait_callback(psycopg2.extras.wait_select)
245245
>>> cnn = psycopg2.connect('')
246246
>>> cur = cnn.cursor()
247247
>>> cur.execute("select pg_sleep(10)")

lib/extras.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ def get_oids(self, conn_or_curs):
908908

909909
def register_hstore(conn_or_curs, globally=False, unicode=False,
910910
oid=None, array_oid=None):
911-
"""Register adapter and typecaster for `!dict`\-\ |hstore| conversions.
911+
r"""Register adapter and typecaster for `!dict`\-\ |hstore| conversions.
912912
913913
:param conn_or_curs: a connection or cursor: the typecaster will be
914914
registered only on this object unless *globally* is set to `!True`

psycopg/connection_int.c

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -521,6 +521,25 @@ conn_setup_cancel(connectionObject *self, PGconn *pgconn)
521521
return 0;
522522
}
523523

524+
/* Return 1 if the "replication" keyword is set in the DSN, 0 otherwise */
525+
static int
526+
dsn_has_replication(char *pgdsn)
527+
{
528+
int ret = 0;
529+
PQconninfoOption *connopts, *ptr;
530+
531+
connopts = PQconninfoParse(pgdsn, NULL);
532+
533+
for(ptr = connopts; ptr->keyword != NULL; ptr++) {
534+
if(strcmp(ptr->keyword, "replication") == 0 && ptr->val != NULL)
535+
ret = 1;
536+
}
537+
538+
PQconninfoFree(connopts);
539+
540+
return ret;
541+
}
542+
524543

525544
/* Return 1 if the server datestyle allows us to work without problems,
526545
0 if it needs to be set to something better, e.g. ISO. */
@@ -549,47 +568,53 @@ conn_setup(connectionObject *self, PGconn *pgconn)
549568
{
550569
PGresult *pgres = NULL;
551570
char *error = NULL;
571+
int rv = -1;
552572

553573
self->equote = conn_get_standard_conforming_strings(pgconn);
554574
self->server_version = conn_get_server_version(pgconn);
555575
self->protocol = conn_get_protocol_version(self->pgconn);
556576
if (3 != self->protocol) {
557577
PyErr_SetString(InterfaceError, "only protocol 3 supported");
558-
return -1;
578+
goto exit;
559579
}
560580

561581
if (0 > conn_read_encoding(self, pgconn)) {
562-
return -1;
582+
goto exit;
563583
}
564584

565585
if (0 > conn_setup_cancel(self, pgconn)) {
566-
return -1;
586+
goto exit;
567587
}
568588

569589
Py_BEGIN_ALLOW_THREADS;
570590
pthread_mutex_lock(&self->lock);
571591
Py_BLOCK_THREADS;
572592

573-
if (!conn_is_datestyle_ok(self->pgconn)) {
593+
if (!dsn_has_replication(self->dsn) && !conn_is_datestyle_ok(self->pgconn)) {
574594
int res;
575595
Py_UNBLOCK_THREADS;
576596
res = pq_set_guc_locked(self, "datestyle", "ISO",
577597
&pgres, &error, &_save);
578598
Py_BLOCK_THREADS;
579599
if (res < 0) {
580600
pq_complete_error(self, &pgres, &error);
581-
return -1;
601+
goto unlock;
582602
}
583603
}
584604

585605
/* for reset */
586606
self->autocommit = 0;
587607

608+
/* success */
609+
rv = 0;
610+
611+
unlock:
588612
Py_UNBLOCK_THREADS;
589613
pthread_mutex_unlock(&self->lock);
590614
Py_END_ALLOW_THREADS;
591615

592-
return 0;
616+
exit:
617+
return rv;
593618
}
594619

595620
/* conn_connect - execute a connection to the database */
@@ -886,8 +911,11 @@ _conn_poll_setup_async(connectionObject *self)
886911
self->autocommit = 1;
887912

888913
/* If the datestyle is ISO or anything else good,
889-
* we can skip the CONN_STATUS_DATESTYLE step. */
890-
if (!conn_is_datestyle_ok(self->pgconn)) {
914+
* we can skip the CONN_STATUS_DATESTYLE step.
915+
* Note that we cannot change the datestyle on a replication
916+
* connection.
917+
*/
918+
if (!dsn_has_replication(self->dsn) && !conn_is_datestyle_ok(self->pgconn)) {
891919
Dprintf("conn_poll: status -> CONN_STATUS_DATESTYLE");
892920
self->status = CONN_STATUS_DATESTYLE;
893921
if (0 == pq_send_query(self, psyco_datestyle)) {

psycopg/cursor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ struct cursorObject {
8080
char *qattr; /* quoting attr, used when quoting strings */
8181
char *notice; /* a notice from the backend */
8282
char *name; /* this cursor name */
83+
char *qname; /* this cursor name, quoted */
8384

8485
PyObject *string_types; /* a set of typecasters for string types */
8586
PyObject *binary_types; /* a set of typecasters for binary types */

0 commit comments

Comments
 (0)