Daniele Varrazzo
b9d0808f95
Added PY_2, PY_3 macros and used uniformly
2019-03-16 19:54:40 +00:00
Daniele Varrazzo
8448b3b840
Dropped conditional compiling dealing with unsupported versions
...
Also dropped shameful use of PY_MINOR_VERSION.
2019-03-16 19:54:40 +00:00
Jon Dufresne
432fdd7d32
Removed support for mxDateTime as the default date and time adapter
...
The use_pydatetime configuration option has been removed. Now, always
default to Python's builtin datetime. mxDatetime support continues to be
available as an alternative to Python's builtin datetime.
2019-03-16 16:36:49 +00:00
Daniele Varrazzo
c929f20048
Fixed building with Python 3.8
...
Not released yet, and using an internal API, so for the moment better
not declare it supported.
Close #854
2019-03-05 17:30:52 +00:00
Daniele Varrazzo
a68df50c7b
Added ConnectionInfo.dsn_parameters attribute
2019-02-17 02:37:09 +00:00
Daniele Varrazzo
599432552a
Copyright year updated
...
ag -l Copyright | xargs sed -i \
"s/\(.*copyright (C) [0-9]\+\)\(-[0-9]\+\)\?\(.*\)/\1-$(date +%Y)\3/I"
2019-02-17 01:36:36 +00:00
Daniele Varrazzo
7c7bbb9742
Added connection.pgconn_ptr and cursor.pgresult_ptr
...
Allow interacting with libpq in Python via ctypes.
See #782 .
2019-02-16 18:12:52 +01:00
Daniele Varrazzo
99f680b6fe
Allow importing _psycopg even if the 'errors' module is not available
2019-02-10 04:25:06 +00:00
Daniele Varrazzo
30c1befa64
SQLSTATE error classes implemented in C
...
The module is only used to export them to Python.
2019-02-10 03:45:14 +00:00
Daniele Varrazzo
4298718978
Dropped PSYCOPG_DISPLAY_SIZE build parameter
...
Big and complex _pq_fetch_tuples simplified by moving per-column
calculation to a separate function.
2019-01-25 17:31:39 +00:00
Daniele Varrazzo
00cb2636f5
Merge branch 'module-init-cleanup'
2019-01-23 14:17:07 +00:00
Daniele Varrazzo
65a2a18a1b
General cleanup of module init shenanigans
...
Pass around the module instead of its dict (getting the latter is fast
if needed), mark function raising with negative results, check all errors,
consistent names...
2019-01-23 09:46:18 +00:00
Daniele Varrazzo
66d5c6da07
Incref an object which will be held forever in a static var
2019-01-23 09:46:18 +00:00
Daniele Varrazzo
e9c476266c
Decrement the refcount of temporary objects in module init failed
...
We are going to die anyway, but let's do it in style.
2019-01-22 19:40:42 +00:00
Daniele Varrazzo
92e615a1a4
Assign the PGresult to the cursor in the execute critical section
...
Possible cause of the issue reported in #346 (in concurrent
environments).
2019-01-22 11:02:09 +00:00
Daniele Varrazzo
37891500d9
Split pq_execute into sync/async parts
2019-01-22 10:51:27 +00:00
Daniele Varrazzo
eab5d5d93f
Date/time modules initialized in separate functions
2019-01-22 09:09:07 +00:00
Daniele Varrazzo
111a71ccee
Dropped psyco_errors_fill()
...
Just use psyco_errors_init() for complete errors initialization
2019-01-21 20:18:53 +00:00
Daniele Varrazzo
1839806c3c
Dropped project wide type to define encodings table
2019-01-21 20:18:53 +00:00
Daniele Varrazzo
8f17ccf784
Dropped C API interface
...
I guess it was unused as it only contained two init functions. The
Capsule should do things better now I guess.
2019-01-21 20:18:53 +00:00
Daniele Varrazzo
7b2e8f0aa4
Respect refcount with PyModule_AddObject()
...
The function steals a ref. The module is never destroyed so things work
fine but the refcount is wrong.
2019-01-21 20:18:53 +00:00
Daniele Varrazzo
549beeea84
Module constants definition moved in a separate function for clarity
2019-01-21 20:18:53 +00:00
Daniele Varrazzo
e67028f4bc
Handle failed allocation in list adaptation
2019-01-21 02:49:38 +00:00
Daniele Varrazzo
7a3bce8fc3
Dropped funny handling of REPLICATION_* constants
2019-01-21 02:49:38 +00:00
Daniele Varrazzo
c77615adc9
_psyco_curs_execute() simplified
...
Dropped code duplications, more regular increc/decref pattern.
Check the return value of formatting named cursor: would have segfaulted
in case of error.
2019-01-21 02:49:38 +00:00
Daniele Varrazzo
594df09a63
More straightforward semantics for psyco_GetDecimalType
...
Raise an exception when returning NULL, leave the caller cleaning it.
2019-01-21 02:41:58 +00:00
Daniele Varrazzo
2ad2b27065
Dropped use of converter function to verify copy argument
...
They weren't really converters, and they confused the static checker
2019-01-21 02:41:58 +00:00
Daniele Varrazzo
3768d9047d
Mark psyco_set_error as returning a borrowed object
2019-01-21 02:41:58 +00:00
Daniele Varrazzo
7a1fb9a2e4
Added utils.h file
...
utils.c functions definition moved out of psycopg.h
Some utility functions defined into psycopgmodule.c moved into utils.c.
2019-01-21 02:41:58 +00:00
Daniele Varrazzo
daff2ea1be
Mark setter as raising on negative results
...
Fixed static check of psyco_conn_cursor().
2019-01-21 02:41:58 +00:00
Daniele Varrazzo
4644715164
Consider the case dereferencing weakref in conn_poll returns NULL
...
It shouldn't but handle the case to avoid a possible null pointer
dereferencing.
2019-01-21 02:41:58 +00:00
Daniele Varrazzo
5b28d7b9c9
Dropped possible wrong code path in conn_decode
...
It shouldn't happen for both cdecoder and pydecoder to be null,
but just in case...
2019-01-21 02:41:58 +00:00
Daniele Varrazzo
117f7d33f8
Wrap _Bytes_Resize into a function with clearer semantic
...
Limit the static checker hacking to a simpler function.
2019-01-21 02:00:04 +00:00
Daniele Varrazzo
f9b798aca9
Avoid unlikely leaks in case of memory errors in Bytes_Format
2019-01-21 02:00:04 +00:00
Daniele Varrazzo
2a05aa2c43
Move var setting into the only case using it
...
The original function was more complex than this. This refactoring
avoids a false positive in the static checker
2019-01-21 02:00:04 +00:00
Daniele Varrazzo
43d779966b
Avoid using PyErr_BadInternalCall as the static checker doesn't get it
2019-01-21 02:00:04 +00:00
Daniele Varrazzo
003fc6dde1
Use the real definition of Py_LOCAL_INLINE
2019-01-21 02:00:04 +00:00
Daniele Varrazzo
fe915ac461
Bytes_Format: use a couple of macros instead of functions
...
The type was already checked upstream in the func body.
2019-01-21 02:00:04 +00:00
Daniele Varrazzo
15cba69a20
psycopg_escape_string: don't make me cringe
...
Just reformatted.
2019-01-21 02:00:04 +00:00
Daniele Varrazzo
79de02d7d5
Stricter use of PyArg_ParseTuple typed objects
...
The function expect PyObject *, not subclasses.
2019-01-21 02:00:04 +00:00
Daniele Varrazzo
3e66022912
Respect PyCFunction signature in METH_NOARGS functions
...
A second parameter does exist, although it's always NULL.
2019-01-21 02:00:04 +00:00
Daniele Varrazzo
ddbe495d70
Added BYTESARRAY typecaster
2019-01-18 15:47:01 +00:00
Daniele Varrazzo
fd31a7d41b
Fixed typecast definition order
...
Didn't notice that the order matter: the last typecaster registered is
the effective one so let STRING win over UNICODE and BYTES.
2019-01-18 15:09:20 +00:00
Daniele Varrazzo
f713dc9fc1
Preliminary test for a BYTES adapter.
...
Allow returning unparsed bytes from databases with mixed encodings. See
issue #519 .
2019-01-18 13:17:02 +00:00
Daniele Varrazzo
07d9fb8718
Don't call CLEARPGRES on the cursor state without holding the gil
...
There is a chance it is executed by two different threads resulting in
issue #384 .
I havent't found any other case that may lead to double free.
2019-01-02 13:15:00 +01:00
Daniele Varrazzo
672bdba679
Merge pull request #821 from jdufresne/skip-libpq
...
Remove workarounds for unsupported libpq < 9.1
2018-12-04 14:13:18 +00:00
Jon Dufresne
17dc5a85a3
Remove workarounds for unsupported libpq < 9.1
...
Per http://initd.org/psycopg/docs/install.html#prerequisites :
> PostgreSQL client library version from 9.1
2018-12-01 08:58:39 -08:00
Jon Dufresne
b796ca0c0a
Simplify PyBool usage with Python convenience macros/functions
...
https://docs.python.org/3/c-api/bool.html
2018-11-30 17:09:30 -08:00
Daniele Varrazzo
73a680f45d
Convert int subclasses to long before adapting
...
Fixes adaptation of int/long subclasses whose str() is not the number,
such IntEnum
Close #591
Note that I thought it would have needed a new adapter, so I considered
it a new feature. But it is more a shortcoming of the int adapter
failing to do something reasonable (poor Liskov, always mistreated) so I
may actually backport it if there is a new 2.7 release.
2018-11-16 18:16:03 +00:00
Federico Di Gregorio
01f8475f53
Merge branch 'master' into feature-expose-pgconn
2018-11-07 14:15:29 +01:00
Daniele Varrazzo
a83696fc50
Fixed adaptation of lists of empty lists
...
...somehow. Postgres doesn't support them and converts them into a
simple empty array. However this is not really our concern: the syntax
we return is valid.
Close #788
2018-10-30 01:48:51 +00:00
Daniele Varrazzo
0236c68da9
Merge branch 'connection-info'
2018-10-15 01:24:00 +01:00
Daniele Varrazzo
b205764fdd
Merge branch 'master' into errors-module
2018-10-15 00:58:32 +01:00
Daniele Varrazzo
44bd2927c5
Use the connection.info properties instead of the legacy methods
2018-10-13 03:28:42 +01:00
Daniele Varrazzo
704e6797e7
Guard from some info functions not available in some libpq versions
2018-10-13 03:09:39 +01:00
Daniele Varrazzo
d138e42ee5
Added ConnectionInfo.parameter_status()
2018-10-13 02:40:17 +01:00
Daniele Varrazzo
9f6a3a5e96
Added ConnectionInfo.ssl_attribute()
2018-10-13 02:21:38 +01:00
Daniele Varrazzo
cb3d5f9d92
Added all the missing ConnectionInfo attributes
2018-10-13 01:36:07 +01:00
Daniele Varrazzo
439dff974d
Added ConnectionInfo.error_message
2018-10-13 00:47:04 +01:00
Daniele Varrazzo
d29aa1c437
Fixed refcount in connection's readonly and deferrable getters
...
Close #790
2018-10-12 23:32:13 +01:00
Daniele Varrazzo
1ac6359fef
Added other members to the ConnectionInfo class
...
Starting deprecating softly some of the methods bloating the connection
class.
2018-10-12 04:18:59 +01:00
Daniele Varrazzo
0a04c8892d
Added several ConnectionInfo attributes
2018-10-12 04:18:59 +01:00
Daniele Varrazzo
9ddf59959f
Adding ConnectionInfo object documentation
...
I'm still fought whether docs should be in the C module or in the .rst.
I'd prefer the first because DRY, but writing multiline strings in C
really sucks.
2018-10-12 03:25:06 +01:00
Daniele Varrazzo
0e2b516a3c
Moving host attribute to a connection.info object
2018-10-11 22:42:52 +01:00
Daniele Varrazzo
f99a8de6d0
Added table_oid, table_column on cursor.description items
...
Close #661
2018-10-11 03:37:09 +01:00
Daniele Varrazzo
b3b225a9da
Added C implementation for a Column type
...
Currently behaving exactly like the previous (named)tuple.
2018-10-11 02:59:45 +01:00
Daniele Varrazzo
c314512115
Fixed infinite loop in pq_get_last_result after COPY
...
There will be an error downstream but we have to get out of this
function first.
Close #781
2018-10-10 23:57:34 +01:00
Daniele Varrazzo
9148157697
Merge branch 'master' into https
2018-10-10 22:07:33 +01:00
Daniele Varrazzo
cd9d74c462
Merge branch 'conn-get-host'
2018-10-10 22:03:36 +01:00
Federico Di Gregorio
81addddaee
Added connection.get_native_connection()
2018-10-07 13:54:24 +02:00
Marco De Paoli
1c553bb703
Added connection.host
...
Return the server host name of the current connect.
2018-10-06 15:19:01 +02:00
Daniele Varrazzo
4e0b2ec9c9
Added Diagnostics.severity_nonlocalized attribute
...
Close #783 .
2018-10-04 16:13:46 +01:00
Federico Di Gregorio
ccae5cae34
Expose PGconn* raw pointer on the connection as a PyCapsule
2018-09-27 10:15:40 +02:00
Jon Dufresne
b07e34e0b8
Prefer https:// URLs when available
2018-09-22 19:02:33 -07:00
Dmitry Marakasov
5ec573c83b
Remove obsolete and incorrect FreeBSD version condition
...
The FreeBSD-related condition which enables custom round() implementation is incorrect: one must include <sys/param.h> to get __FreeBSD_version value, and since it's not included here, the check succeeds while it shouldn't. Before it worked somehow, but since python 3.7 it results in conflicting declarations of round(). The condition is also no longer needed since FreeBSD 5.3 is unsupported for 12 years.
2018-09-07 23:57:33 +01:00
Daniele Varrazzo
782fa39647
Generating the whole errors file from script
2018-08-17 02:00:40 +01:00
Daniele Varrazzo
ce1ac3aea9
Read exceptions to raise from a Python module
2018-08-17 02:00:01 +01:00
Daniele Varrazzo
97a4fb92c6
Fixed compile error on windows
...
Because const int + 1 is not const, right???
Also fixed other occurrences of magic numbers and failed DRY around
PyOS_snprintf() calls.
2018-07-24 21:16:36 +01:00
Daniele Varrazzo
6d8f4f9f0d
Close named cursor if exist, even if we didn't run execute
...
Close #746
2018-07-24 21:16:36 +01:00
Daniele Varrazzo
9cf658ec6e
Fixed refcount handling in encrypt_password
...
Added tests to check bad types, which discovered the above problem: on
type error we would have decref'd on exit something that was only
borrowed (because we wouldn't have performed matching increfs).
2018-05-20 21:18:36 +01:00
Daniele Varrazzo
abca14d601
Fixed keywords support for encrypt_password and tests completed
2018-05-20 20:50:04 +01:00
Daniele Varrazzo
a3063900ee
Fixed code flow in encrypt_password()
...
Fixed several shortcomings highlighted in #576 and not fixed as
requested.
Also fixed broken behaviour of ignoring the algorithm if the connection
is missing.
2018-05-20 19:18:42 +01:00
Daniele Varrazzo
0161d54dbb
Merge branch 'master' into encrypt-pass
2018-05-20 17:57:34 +01:00
Daniele Varrazzo
068b15c57f
Merge branch 'fix-716'
2018-05-20 17:00:13 +01:00
Daniele Varrazzo
c4da939909
Don't raise an exception closing an unused named cursor
...
Close #716
2018-05-20 14:00:09 +01:00
Daniele Varrazzo
3f389593f5
Raise NotSupportedError fetching iso_8601 intervals
...
Previously it would have failed parsing and resulted in ValueError
Close #707
2018-05-20 13:22:38 +01:00
Daniele Varrazzo
b5e4a040f8
Fixed adaptation of arrays of arrays of nulls
...
Close #325 , close #706 .
2018-05-18 12:10:20 +01:00
Ashesh Vashi
36f0db81d2
Fixed the string format error reported by Travis-CI.
...
Reference: https://travis-ci.org/psycopg/psycopg2/jobs/376288585
2018-05-08 15:29:16 +05:30
Ashesh Vashi
1bec2bdc43
Merge branch 'master' into master
2018-05-08 15:17:59 +05:30
Daniele Varrazzo
ea923b63a4
Allow strings subclasses in ensure_bytes
...
Fix #679
2018-02-21 10:27:28 +00:00
Daniele Varrazzo
32f5a9fc1d
Avoid quoting the string in the psycopg version macro
...
Use a macro trick to add the quotes. This seems more portable than
passing the quotes to the command line (see #658 ).
https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html
2018-02-19 13:53:50 +00:00
Mike Gerdts
f766d90704
Fixed building on SmartOS
...
timeradd is missing on Solaris 10, but is present as a macro in
<sys/time.h> on SmartOS, illumos, and likely Solaris 11.
2018-02-19 11:40:05 +00:00
Daniele Varrazzo
5309da117d
Autocommit shouldn't change deferrable on servers not supporting it
...
Regression on unsupported Postgres versions after fixing bug #580
2018-02-08 15:00:38 +00:00
Daniele Varrazzo
74d2c4bef9
Fixed idempotence check changing connection characteristics
2018-01-11 02:23:27 +00:00
Daniele Varrazzo
e0226fc46a
'cursor.mogrify()' can be called on closed cursors
...
Fix #579 .
2018-01-11 08:55:31 +09:00
Daniele Varrazzo
bad9b8b383
Merge branch 'macro-accessors'
2018-01-10 22:47:59 +00:00
Daniele Varrazzo
77c703395b
Moved datatime compatibility macros with others
2018-01-10 22:29:16 +00:00
Ronan Amicel
b8f2f71819
Fix typo in comment in utils.c
2017-12-14 14:00:36 +01:00
Glyph
3fcb035126
define a "polyfill" inline for python 2 compatibility
2017-12-12 03:15:21 -08:00
Glyph
852884e086
use accessor macros for pypy3 compatibility
2017-12-12 03:06:18 -08:00