Commit fbee9766 authored by Tom Lane's avatar Tom Lane

getdatabaseencoding() and PG_encoding_to_char() were being sloppy about

converting char* strings to type 'name'.  Imagine my surprise when 7.1
release coredumped upon start when compiled --enable-multibyte ...
parent 6ccb2af7
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.64 2001/03/22 04:00:00 momjian Exp $ * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.65 2001/04/16 02:42:01 tgl Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -168,13 +168,13 @@ SetDataDir(const char *dir) ...@@ -168,13 +168,13 @@ SetDataDir(const char *dir)
Datum Datum
getdatabaseencoding(PG_FUNCTION_ARGS) getdatabaseencoding(PG_FUNCTION_ARGS)
{ {
PG_RETURN_NAME("SQL_ASCII"); return DirectFunctionCall1(namein, CStringGetDatum("SQL_ASCII"));
} }
Datum Datum
PG_encoding_to_char(PG_FUNCTION_ARGS) PG_encoding_to_char(PG_FUNCTION_ARGS)
{ {
PG_RETURN_NAME("SQL_ASCII"); return DirectFunctionCall1(namein, CStringGetDatum("SQL_ASCII"));
} }
Datum Datum
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* This file contains some public functions * This file contains some public functions
* usable for both the backend and the frontend. * usable for both the backend and the frontend.
* Tatsuo Ishii * Tatsuo Ishii
* $Id: common.c,v 1.12 2001/02/11 01:59:22 ishii Exp $ * $Id: common.c,v 1.13 2001/04/16 02:42:01 tgl Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -91,8 +91,9 @@ Datum ...@@ -91,8 +91,9 @@ Datum
PG_encoding_to_char(PG_FUNCTION_ARGS) PG_encoding_to_char(PG_FUNCTION_ARGS)
{ {
int32 encoding = PG_GETARG_INT32(0); int32 encoding = PG_GETARG_INT32(0);
const char *encoding_name = pg_encoding_to_char(encoding);
PG_RETURN_NAME(pg_encoding_to_char(encoding)); return DirectFunctionCall1(namein, CStringGetDatum(encoding_name));
} }
#endif #endif
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* client encoding and server internal encoding. * client encoding and server internal encoding.
* (currently mule internal code (mic) is used) * (currently mule internal code (mic) is used)
* Tatsuo Ishii * Tatsuo Ishii
* $Id: mbutils.c,v 1.16 2001/03/08 00:24:34 tgl Exp $ * $Id: mbutils.c,v 1.17 2001/04/16 02:42:01 tgl Exp $
*/ */
#include "postgres.h" #include "postgres.h"
...@@ -287,5 +287,7 @@ GetDatabaseEncoding() ...@@ -287,5 +287,7 @@ GetDatabaseEncoding()
Datum Datum
getdatabaseencoding(PG_FUNCTION_ARGS) getdatabaseencoding(PG_FUNCTION_ARGS)
{ {
PG_RETURN_NAME(pg_encoding_to_char(DatabaseEncoding)); const char *encoding_name = pg_encoding_to_char(DatabaseEncoding);
return DirectFunctionCall1(namein, CStringGetDatum(encoding_name));
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment