Better PostgreSQL version check.

This commit is contained in:
Federico Di Gregorio 2006-05-26 05:22:49 +00:00
parent ec877b0ef9
commit bfb00b86fd
3 changed files with 19 additions and 11 deletions

View File

@ -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

View File

@ -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 *

View File

@ -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