1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-14 18:42:34 +03:00

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 ...
This commit is contained in:
Tom Lane
2001-04-16 02:42:01 +00:00
parent 6ccb2af725
commit fbee97664e
3 changed files with 10 additions and 7 deletions

View File

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

View File

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

View File

@ -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()
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));
} }