mirror of
https://github.com/psycopg/psycopg2.git
synced 2024-11-22 17:06:33 +03:00
Better PostgreSQL version check.
This commit is contained in:
parent
ec877b0ef9
commit
bfb00b86fd
|
@ -1,3 +1,7 @@
|
|||
2006-05-26 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* Applied better PostgreSQL patch from AA.
|
||||
|
||||
2006-05-24 Federico Di Gregorio <fog@initd.org>
|
||||
|
||||
* Enabled 8.1.4 security fix only when the version is >= 8.1.4, fall
|
||||
|
|
|
@ -41,12 +41,14 @@ static unsigned char *
|
|||
binary_escape(unsigned char *from, unsigned int from_length,
|
||||
unsigned int *to_length, PGconn *conn)
|
||||
{
|
||||
#if PG_MAJOR_VERSION >= 8 && PG_MINOR_VERSION >= 1 && PG_PATCH_VERSION >= 4
|
||||
if (conn)
|
||||
return PQescapeByteaConn(conn, from, from_length, to_length);
|
||||
else
|
||||
#if PG_MAJOR_VERSION > 8 || \
|
||||
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION > 1) || \
|
||||
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION == 1 && PG_PATCH_VERSION >= 4)
|
||||
return PQescapeByteaConn(conn, from, from_length, to_length);
|
||||
#else
|
||||
#warning "YOUR POSTGRESQL VERSION IS TOO OLD AND IT CAN BE INSECURE"
|
||||
return PQescapeBytea(from, from_length, to_length);
|
||||
#endif
|
||||
return PQescapeBytea(from, from_length, to_length);
|
||||
}
|
||||
#else
|
||||
static unsigned char *
|
||||
|
|
|
@ -41,13 +41,15 @@
|
|||
static size_t
|
||||
qstring_escape(char *to, char *from, size_t len, PGconn *conn)
|
||||
{
|
||||
int err = 0;
|
||||
#if PG_MAJOR_VERSION >= 8 && PG_MINOR_VERSION >= 1 && PG_PATCH_VERSION >= 4
|
||||
if (conn)
|
||||
return PQescapeStringConn(conn, to, from, len, &err);
|
||||
else
|
||||
#if PG_MAJOR_VERSION > 8 || \
|
||||
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION > 1) || \
|
||||
(PG_MAJOR_VERSION == 8 && PG_MINOR_VERSION == 1 && PG_PATCH_VERSION >= 4)
|
||||
int err;
|
||||
return PQescapeStringConn(conn, to, from, len, &err);
|
||||
#else
|
||||
#warning "YOUR POSTGRESQL VERSION IS TOO OLD AND IT CAN BE INSECURE"
|
||||
return PQescapeString(to, from, len);
|
||||
#endif
|
||||
return PQescapeString(to, from, len);
|
||||
}
|
||||
#else
|
||||
static size_t
|
||||
|
|
Loading…
Reference in New Issue
Block a user