From 154146d208de7518bb6c8131dc8d2361f7f36f56 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 12 Jun 2014 15:39:09 -0400 Subject: [PATCH] Rename lo_create(oid, bytea) to lo_from_bytea(). The previous naming broke the query that libpq's lo_initialize() uses to collect the OIDs of the server-side functions it requires, because that query effectively assumes that there is only one function named lo_create in the pg_catalog schema (and likewise only one lo_open, etc). While we should certainly make libpq more robust about this, the naive query will remain in use in the field for the foreseeable future, so it seems the only workable choice is to use a different name for the new function. lo_from_bytea() won a small straw poll. Back-patch into 9.4 where the new function was introduced. --- doc/src/sgml/lobj.sgml | 6 +++--- src/backend/libpq/be-fsstubs.c | 4 ++-- src/include/catalog/catversion.h | 2 +- src/include/catalog/pg_proc.h | 4 ++-- src/include/libpq/be-fsstubs.h | 2 +- src/test/regress/input/largeobject.source | 2 +- src/test/regress/output/largeobject.source | 2 +- src/test/regress/output/largeobject_1.source | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/doc/src/sgml/lobj.sgml b/doc/src/sgml/lobj.sgml index d403586a05..c0174b71be 100644 --- a/doc/src/sgml/lobj.sgml +++ b/doc/src/sgml/lobj.sgml @@ -547,16 +547,16 @@ int lo_unlink(PGconn *conn, Oid lobjId); - lo_create + lo_from_bytea - lo_create(loid oid, string bytea) + lo_from_bytea(loid oid, string bytea) oid Create a large object and store data there, returning its OID. Pass 0 to have the system choose an OID. - lo_create(0, E'\\xffffff00') + lo_from_bytea(0, E'\\xffffff00') 24528 diff --git a/src/backend/libpq/be-fsstubs.c b/src/backend/libpq/be-fsstubs.c index 4a6bcf5598..52bac4337d 100644 --- a/src/backend/libpq/be-fsstubs.c +++ b/src/backend/libpq/be-fsstubs.c @@ -862,10 +862,10 @@ lo_get_fragment(PG_FUNCTION_ARGS) } /* - * Create LO with initial contents + * Create LO with initial contents given by a bytea argument */ Datum -lo_create_bytea(PG_FUNCTION_ARGS) +lo_from_bytea(PG_FUNCTION_ARGS) { Oid loOid = PG_GETARG_OID(0); bytea *str = PG_GETARG_BYTEA_PP(1); diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h index 93afbbe033..f0926e9148 100644 --- a/src/include/catalog/catversion.h +++ b/src/include/catalog/catversion.h @@ -53,6 +53,6 @@ */ /* yyyymmddN */ -#define CATALOG_VERSION_NO 201406051 +#define CATALOG_VERSION_NO 201406121 #endif diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 1d0c2a9091..762ce6ca09 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -1061,8 +1061,8 @@ DESCR("truncate large object"); DATA(insert OID = 3172 ( lo_truncate64 PGNSP PGUID 12 1 0 0 0 f f f f t f v 2 0 23 "23 20" _null_ _null_ _null_ _null_ lo_truncate64 _null_ _null_ _null_ )); DESCR("truncate large object (64 bit)"); -DATA(insert OID = 3457 ( lo_create PGNSP PGUID 12 1 0 0 0 f f f f t f v 2 0 26 "26 17" _null_ _null_ _null_ _null_ lo_create_bytea _null_ _null_ _null_ )); -DESCR("create new large object with content"); +DATA(insert OID = 3457 ( lo_from_bytea PGNSP PGUID 12 1 0 0 0 f f f f t f v 2 0 26 "26 17" _null_ _null_ _null_ _null_ lo_from_bytea _null_ _null_ _null_ )); +DESCR("create new large object with given content"); DATA(insert OID = 3458 ( lo_get PGNSP PGUID 12 1 0 0 0 f f f f t f v 1 0 17 "26" _null_ _null_ _null_ _null_ lo_get _null_ _null_ _null_ )); DESCR("read entire large object"); DATA(insert OID = 3459 ( lo_get PGNSP PGUID 12 1 0 0 0 f f f f t f v 3 0 17 "26 20 23" _null_ _null_ _null_ _null_ lo_get_fragment _null_ _null_ _null_ )); diff --git a/src/include/libpq/be-fsstubs.h b/src/include/libpq/be-fsstubs.h index 84ee49690c..b6c8f7f8cb 100644 --- a/src/include/libpq/be-fsstubs.h +++ b/src/include/libpq/be-fsstubs.h @@ -25,7 +25,7 @@ extern Datum lo_export(PG_FUNCTION_ARGS); extern Datum lo_creat(PG_FUNCTION_ARGS); extern Datum lo_create(PG_FUNCTION_ARGS); -extern Datum lo_create_bytea(PG_FUNCTION_ARGS); +extern Datum lo_from_bytea(PG_FUNCTION_ARGS); extern Datum lo_open(PG_FUNCTION_ARGS); extern Datum lo_close(PG_FUNCTION_ARGS); diff --git a/src/test/regress/input/largeobject.source b/src/test/regress/input/largeobject.source index 996304ba79..ecb5340a47 100644 --- a/src/test/regress/input/largeobject.source +++ b/src/test/regress/input/largeobject.source @@ -207,7 +207,7 @@ SELECT lo_unlink(loid) FROM lotest_stash_values; \set newloid_1 :LASTOID -SELECT lo_create(0, lo_get(:newloid_1)) AS newloid_2 +SELECT lo_from_bytea(0, lo_get(:newloid_1)) AS newloid_2 \gset SELECT md5(lo_get(:newloid_1)) = md5(lo_get(:newloid_2)); diff --git a/src/test/regress/output/largeobject.source b/src/test/regress/output/largeobject.source index e6dd97e700..56a50c0a15 100644 --- a/src/test/regress/output/largeobject.source +++ b/src/test/regress/output/largeobject.source @@ -393,7 +393,7 @@ SELECT lo_unlink(loid) FROM lotest_stash_values; \lo_unlink :newloid \lo_import 'results/lotest.txt' \set newloid_1 :LASTOID -SELECT lo_create(0, lo_get(:newloid_1)) AS newloid_2 +SELECT lo_from_bytea(0, lo_get(:newloid_1)) AS newloid_2 \gset SELECT md5(lo_get(:newloid_1)) = md5(lo_get(:newloid_2)); ?column? diff --git a/src/test/regress/output/largeobject_1.source b/src/test/regress/output/largeobject_1.source index 8665822a67..c3b537c4ba 100644 --- a/src/test/regress/output/largeobject_1.source +++ b/src/test/regress/output/largeobject_1.source @@ -393,7 +393,7 @@ SELECT lo_unlink(loid) FROM lotest_stash_values; \lo_unlink :newloid \lo_import 'results/lotest.txt' \set newloid_1 :LASTOID -SELECT lo_create(0, lo_get(:newloid_1)) AS newloid_2 +SELECT lo_from_bytea(0, lo_get(:newloid_1)) AS newloid_2 \gset SELECT md5(lo_get(:newloid_1)) = md5(lo_get(:newloid_2)); ?column?