From cff25fa049f42c9091e7ba0a4e8f080d2519a1f8 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 3 May 2005 19:18:31 +0000 Subject: [PATCH] Alter the signature for encoding conversion functions to declare the output area as INTERNAL not CSTRING. This is to prevent people from calling the functions by hand. This is a permanent solution for the back branches but I hope it is just a stopgap for HEAD. --- doc/src/sgml/ref/create_conversion.sgml | 14 ++++++++------ src/backend/commands/conversioncmds.c | 4 ++-- src/backend/utils/mb/conversion_procs/Makefile | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/doc/src/sgml/ref/create_conversion.sgml b/doc/src/sgml/ref/create_conversion.sgml index cea5a2fa9e1..0bb8cbf4015 100644 --- a/doc/src/sgml/ref/create_conversion.sgml +++ b/doc/src/sgml/ref/create_conversion.sgml @@ -1,4 +1,4 @@ - + @@ -8,7 +8,7 @@ CREATE CONVERSION - define a new conversion + define a new encoding conversion @@ -26,10 +26,12 @@ CREATE [DEFAULT] CONVERSION name Description - CREATE CONVERSION defines a new encoding - conversion. Conversion names may be used in the convert function + CREATE CONVERSION defines a new conversion between + character set encodings. Conversion names may be used in the + convert function to specify a particular encoding conversion. Also, conversions that - are marked DEFAULT can be used for automatic encoding conversion between + are marked DEFAULT can be used for automatic encoding + conversion between client and server. For this purpose, two conversions, from encoding A to B and from encoding B to A, must be defined. @@ -109,7 +111,7 @@ conv_proc( integer, -- source encoding ID integer, -- destination encoding ID cstring, -- source string (null terminated C string) - cstring, -- destination string (null terminated C string) + internal, -- destination (fill with a null terminated C string) integer -- source string length ) RETURNS void; diff --git a/src/backend/commands/conversioncmds.c b/src/backend/commands/conversioncmds.c index a3807bf77a5..0aa8a8cae5c 100644 --- a/src/backend/commands/conversioncmds.c +++ b/src/backend/commands/conversioncmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/conversioncmds.c,v 1.11 2003/08/04 02:39:58 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/conversioncmds.c,v 1.11.4.1 2005/05/03 19:18:31 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ CreateConversionCommand(CreateConversionStmt *stmt) const char *from_encoding_name = stmt->for_encoding_name; const char *to_encoding_name = stmt->to_encoding_name; List *func_name = stmt->func_name; - static Oid funcargs[] = {INT4OID, INT4OID, CSTRINGOID, CSTRINGOID, INT4OID}; + static Oid funcargs[] = {INT4OID, INT4OID, CSTRINGOID, INTERNALOID, INT4OID}; /* Convert list of names to a name and namespace */ namespaceId = QualifiedNameGetCreationNamespace(stmt->conversion_name, diff --git a/src/backend/utils/mb/conversion_procs/Makefile b/src/backend/utils/mb/conversion_procs/Makefile index 6b406cae542..e7d8b30d407 100644 --- a/src/backend/utils/mb/conversion_procs/Makefile +++ b/src/backend/utils/mb/conversion_procs/Makefile @@ -4,7 +4,7 @@ # Makefile for utils/mb/conversion_procs # # IDENTIFICATION -# $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/Makefile,v 1.9.2.1 2004/01/21 19:25:11 tgl Exp $ +# $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/Makefile,v 1.9.2.2 2005/05/03 19:18:31 tgl Exp $ # #------------------------------------------------------------------------- @@ -157,7 +157,7 @@ ifeq ($(enable_shared), yes) func=$$1; shift; \ obj=$$1; shift; \ echo "-- $$se --> $$de"; \ - echo "CREATE OR REPLACE FUNCTION $$func (INTEGER, INTEGER, CSTRING, CSTRING, INTEGER) RETURNS VOID AS '$$"libdir"/$$obj', '$$func' LANGUAGE 'c' STRICT;"; \ + echo "CREATE OR REPLACE FUNCTION $$func (INTEGER, INTEGER, CSTRING, INTERNAL, INTEGER) RETURNS VOID AS '$$"libdir"/$$obj', '$$func' LANGUAGE 'c' STRICT;"; \ echo "DROP CONVERSION pg_catalog.$$name;"; \ echo "CREATE DEFAULT CONVERSION pg_catalog.$$name FOR '$$se' TO '$$de' FROM $$func;"; \ done > $@