Commit Graph

47 Commits

Author SHA1 Message Date
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
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
0e832b97ea Proper type check in prepare() methods for list, binary, qstring 2012-03-04 17:59:51 +00:00
Daniele Varrazzo
836f8a1aa1 Make Binary(None) work as expected, adapting to NULL
Issue reported by Stefano Dal Pra.
2011-02-18 14:19:57 +00:00
Daniele Varrazzo
bccbcf42d0 Added adaptation for objects supporting the new-style buffer interface
Supporting this interface is required to adapt memoryview on Python 2.7 as they
don't support the old style. But because the old style is long deprecated it
makes sense to start supporting the new one.
2011-02-16 01:30:25 +00:00
Daniele Varrazzo
3ae2f221b3 Adapt bytearray and memoryview to bytes if available 2011-02-15 17:30:43 +00:00
Daniele Varrazzo
e4a84b9ce9 Fixed error message on Binary(str) in Python 3 2011-02-15 15:53:07 +00:00
Daniele Varrazzo
3214c23f51 Fixed adaptation in several adapters.
The getquoted methods always return bytes. The str() convert this
representation to string on the fly.
2010-12-31 03:18:27 +01:00
Daniele Varrazzo
56e4c2bd55 Redefining the microprotocol on Py3 as returning bytes. 2010-12-31 03:18:26 +01:00
Daniele Varrazzo
cb6b52945b The library can be compiled with Python 3.
Just compiled! No test run yet and many points to review, marked in the
code.

The patch is largely Martin von Löwis work, simplified after refactoring
in the previous commits and adapted to the new code (as the patch was
originally for Psycopg 2.0.9)
2010-12-21 04:24:36 +00:00
Daniele Varrazzo
4635c2aa4f Import structmember/stringobject headers from python.h.
stringobject is not to be imported with Python 3.
2010-12-21 04:02:13 +00:00
Daniele Varrazzo
9b30147341 Using PyVarObject_HEAD_INIT macro. 2010-12-21 04:02:13 +00:00
Daniele Varrazzo
8dfa9915eb Using Py_TYPE and Py_REFCNT macros. 2010-12-21 04:02:13 +00:00
Daniele Varrazzo
89f70bdb3c Changed Python const RO -> READONLY. 2010-12-12 13:39:32 +00: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
ed6a4c8b1a Dropped PyArg_ParseTuple() calls in functions taking no arguments. 2010-11-09 03:18:54 +00:00
Daniele Varrazzo
422fede38e Replaced PyObject_CallFunction() with *ObjArgs() where more efficient. 2010-11-09 01:49:22 +00:00
Daniele Varrazzo
6e71b3db05 Dropped PSYCOPG_OWN_QUOTING.
It was deprecated for version 2.1. There are bugs to be fixed made more
complex by its presence and it doesn't keep into account PostgreSQL 9.0
new binary format.

Time to go!
2010-10-08 12:27:47 +01:00
Daniele Varrazzo
c8aef26e15 Adapt buffer objects using an explicit cast on the string literal.
Don't rely on Postgres casting the literal according to the context:
this doesn't work e.g. passing the object as function argument where a
function with the same name but taking a text exists. It doesn't work
either when the object is in an ARRAY construct.

Added test to check the type is respected in a complete Py -> PG -> Py
roundtrip without context.

Bug and solution reported by Peter Eisentraut.
2010-05-15 14:27:23 +01:00
Federico Di Gregorio
611606d532 Changes license to LGPL3 + OpenSSL exception on all source files 2010-02-12 23:34:53 +01:00
James Henstridge
9067bde803 * psycopg/utils.c (psycopg_escape_string): same here.
* psycopg/adapter_binary.c (binary_escape): simplify PostgreSQL
	version check.

	* setup.py (psycopg_build_ext.finalize_options): use a single
	define of the PostgreSQL version in a form that can easily be used
	by #ifdefs.
2009-02-17 16:00:52 +09:00
James Henstridge
2273b79be9 Use Py_CLEAR() in a few more places, and do INCREF's before setting
struct members rather than afterwards.
2008-07-21 13:41:54 +08:00
James Henstridge
590542e973 * psycopg/adapter_binary.c (binary_traverse): add cyclic GC
traversal for binary adapters.
2008-07-01 11:59:25 +08:00
James Henstridge
f18881983b * psycopg/typecast_array.c (typecast_array_scan): set an initial
value for quotes to keep gcc happy.

	* psycopg/*.c: add missing static modifier on many functions.
2008-01-13 16:05:59 +00:00
James Henstridge
86597f6939 * psycopg/adapter_binary.c (binary_quote): apply Brandon Rhodes'
patch from ticket #209 to check return value from
	PyObject_AsCharBuffer().  This fixes the segfault.
	(binary_quote): switch from PyObject_AsCharBuffer() to
	PyObject_AsReadBuffer() to support buffer objects that don't
	implement the bf_getcharbuf protocol.

	* tests/types_basic.py (TypesBasicTests.testBinary): Test round
	tripping of bytea buffers.  Currently segfaults.
2008-01-10 22:19:23 +00:00
Daniele Varrazzo
75cb5d75d7 Use escape string syntax for string escape if connected to a server
requiring it.

Added a connection flag to store whether E''-style quoting is required: this
avoids repeated PQparameterStatus() calls.

Added a test case to verify correct behavior on strings, unicode and binary 
data. Tested with PG versions from 7.4 to 8.3b2, with any server
'standard_conforming_strings' setting and with 'PSYCOPG_OWN_QUOTING' too.
2007-11-11 08:53:44 +00:00
Daniele Varrazzo
70e555585e Fixed selection of the proper binary string quoting. 2007-11-09 13:00:37 +00:00
Daniele Varrazzo
272140f5c1 Use escape string syntax for binary escape if connected with a
server with ver >= 8.2.

The feature is only enabled when compiling psycopg with libpq
ver >= 8.0.
2007-11-09 05:51:12 +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
474d8b9d51 Piet Delport patches: 2 of 3. 2006-09-23 05:14:24 +00:00
Federico Di Gregorio
3e0d8792a8 Preparing 2.0.5. 2006-09-01 12:42:03 +00:00
Federico Di Gregorio
9f9af5f907 Fixed patch from #119. 2006-09-01 12:36:38 +00:00
Federico Di Gregorio
f88b973bd1 Empty binary buffer segfault fix (closes: #119). 2006-09-01 08:23:51 +00:00
Federico Di Gregorio
b9fcde1b39 Fixed segfault in Binary/QString. 2006-06-18 05:57:01 +00:00
Federico Di Gregorio
0ce5207871 #warning fix. 2006-06-11 04:04:04 +00:00
Federico Di Gregorio
bfb00b86fd Better PostgreSQL version check. 2006-05-26 05:22:49 +00:00
Federico Di Gregorio
ec877b0ef9 Final of 8.1.4 securiy patch. 2006-05-24 10:29:35 +00:00
Federico Di Gregorio
5f8eddfcab Second half of 8.1.4 securiy patch. 2006-05-24 10:02:33 +00:00
Federico Di Gregorio
6b0b634bae Code cleanup. 2005-10-18 01:29:47 +00:00
Federico Di Gregorio
20013f6ff9 Fixing gcc 4 warnings. 2005-07-26 14:49:30 +00:00
Federico Di Gregorio
b1745ff139 Various fixes. 2005-05-09 08:54:32 +00:00
Federico Di Gregorio
4805a93569 mingw patch from Daniele Varazzo. 2005-04-10 03:05:39 +00:00
Federico Di Gregorio
5db7764207 Fixed .rowcount (closes: #6). 2005-03-31 06:26:19 +00:00
Federico Di Gregorio
e816aa07b6 Adding missing __conform__ methods before release. 2005-03-02 14:51:24 +00:00
Federico Di Gregorio
cd672525e1 Adaptation fixes (a lot.) 2005-02-28 15:50:55 +00:00
Federico Di Gregorio
06ef93271a Renaming types. 2004-12-13 14:29:42 +00:00
Federico Di Gregorio
c904d97f69 Initial psycopg 2 import after SVN crash. 2004-10-19 03:17:12 +00:00