1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-23 03:21:12 +03:00

libpq's query to get the OIDs of large-object support functions was not

schema-safe.  Make it so, and improve the internal support for knowledge
of server version.
This commit is contained in:
Tom Lane
2004-03-05 01:53:59 +00:00
parent d91acf8401
commit 44611f6e6d
4 changed files with 58 additions and 21 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.47 2004/01/26 22:35:32 tgl Exp $
* $PostgreSQL: pgsql/src/interfaces/libpq/fe-lobj.c,v 1.48 2004/03/05 01:53:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -534,6 +534,7 @@ lo_initialize(PGconn *conn)
PGresult *res;
PGlobjfuncs *lobjfuncs;
int n;
const char *query;
const char *fname;
Oid foid;
@ -550,17 +551,34 @@ lo_initialize(PGconn *conn)
MemSet((char *) lobjfuncs, 0, sizeof(PGlobjfuncs));
/*
* Execute the query to get all the functions at once
* Execute the query to get all the functions at once. In 7.3 and later
* we need to be schema-safe.
*/
res = PQexec(conn, "select proname, oid from pg_proc \
where proname = 'lo_open' \
or proname = 'lo_close' \
or proname = 'lo_creat' \
or proname = 'lo_unlink' \
or proname = 'lo_lseek' \
or proname = 'lo_tell' \
or proname = 'loread' \
or proname = 'lowrite'");
if (conn->sversion >= 70300)
query = "select proname, oid from pg_catalog.pg_proc "
"where proname in ("
"'lo_open', "
"'lo_close', "
"'lo_creat', "
"'lo_unlink', "
"'lo_lseek', "
"'lo_tell', "
"'loread', "
"'lowrite') "
"and pronamespace = (select oid from pg_catalog.pg_namespace "
"where nspname = 'pg_catalog')";
else
query = "select proname, oid from pg_proc "
"where proname = 'lo_open' "
"or proname = 'lo_close' "
"or proname = 'lo_creat' "
"or proname = 'lo_unlink' "
"or proname = 'lo_lseek' "
"or proname = 'lo_tell' "
"or proname = 'loread' "
"or proname = 'lowrite'";
res = PQexec(conn, query);
if (res == NULL)
{
free(lobjfuncs);