mirror of
https://github.com/postgres/postgres.git
synced 2025-11-15 03:41:20 +03:00
Support SET/SHOW/RESET client_encoding and server_encoding even when
MULTIBYTE support is not compiled (you just can't set them to anything but SQL_ASCII). This should reduce interoperability problems between MB-enabled clients and non-MB-enabled servers.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
# Makefile for utils/mb
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.12 2000/10/20 21:03:53 petere Exp $
|
||||
# $Header: /cvsroot/pgsql/src/backend/utils/mb/Makefile,v 1.13 2000/10/25 19:44:44 tgl Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -12,8 +12,7 @@ subdir = src/backend/utils/mb
|
||||
top_builddir = ../../../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
||||
OBJS = common.o conv.o mbutils.o wchar.o wstrcmp.o wstrncmp.o variable.o \
|
||||
big5.o
|
||||
OBJS = common.o conv.o mbutils.o wchar.o wstrcmp.o wstrncmp.o big5.o
|
||||
|
||||
all: SUBSYS.o
|
||||
|
||||
@@ -22,13 +21,13 @@ SUBSYS.o: $(OBJS)
|
||||
|
||||
utftest.o: utftest.c conv.c wchar.c mbutils.c
|
||||
|
||||
sjistest: sjistest.o palloc.o common.o mbutils.o wchar.o wstrcmp.o wstrncmp.o variable.o big5.o
|
||||
sjistest: sjistest.o palloc.o common.o mbutils.o wchar.o wstrcmp.o wstrncmp.o big5.o
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
liketest: liketest.o palloc.o $(OBJS)
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
utftest: utftest.o palloc.o common.o wstrcmp.o wstrncmp.o variable.o big5.o
|
||||
utftest: utftest.o palloc.o common.o wstrcmp.o wstrncmp.o big5.o
|
||||
$(CC) -o $@ $^ $(CFLAGS) $(LDFLAGS)
|
||||
|
||||
uconv: uconv.o palloc.o common.o conv.o wchar.o big5.o mbutils.o
|
||||
|
||||
@@ -7,7 +7,6 @@ mbutilc.c: public functions for the backend only.
|
||||
requires conv.c and wchar.c
|
||||
wstrcmp.c: strcmp for mb
|
||||
wstrncmp.c: strncmp for mb
|
||||
varable.c: public functions for show/set/reset variable commands
|
||||
alt.c: a tool to generate KOI8 <--> CP866 conversion table
|
||||
iso.c: a tool to generate KOI8 <--> ISO8859-5 conversion table
|
||||
win.c: a tool to generate KOI8 <--> CP1251 conversion table
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
/*
|
||||
* This file contains some public functions
|
||||
* related to show/set/reset variable commands.
|
||||
* Tatsuo Ishii
|
||||
* $Id: variable.c,v 1.7 2000/04/20 22:40:18 tgl Exp $
|
||||
*/
|
||||
|
||||
#include "postgres.h"
|
||||
#include "miscadmin.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
|
||||
bool
|
||||
parse_client_encoding(char *value)
|
||||
{
|
||||
int encoding;
|
||||
|
||||
encoding = pg_valid_client_encoding(value);
|
||||
if (encoding < 0)
|
||||
{
|
||||
if (value)
|
||||
elog(ERROR, "Client encoding %s is not supported", value);
|
||||
else
|
||||
elog(ERROR, "No client encoding is specified");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pg_set_client_encoding(encoding))
|
||||
{
|
||||
elog(ERROR, "Conversion between %s and %s is not supported",
|
||||
value, pg_encoding_to_char(GetDatabaseEncoding()));
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool
|
||||
show_client_encoding()
|
||||
{
|
||||
elog(NOTICE, "Current client encoding is %s",
|
||||
pg_encoding_to_char(pg_get_client_encoding()));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool
|
||||
reset_client_encoding()
|
||||
{
|
||||
int encoding;
|
||||
char *env = getenv("PGCLIENTENCODING");
|
||||
|
||||
if (env)
|
||||
{
|
||||
encoding = pg_char_to_encoding(env);
|
||||
if (encoding < 0)
|
||||
encoding = GetDatabaseEncoding();
|
||||
}
|
||||
else
|
||||
encoding = GetDatabaseEncoding();
|
||||
pg_set_client_encoding(encoding);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool
|
||||
parse_server_encoding(char *value)
|
||||
{
|
||||
elog(NOTICE, "SET SERVER_ENCODING is not supported");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool
|
||||
show_server_encoding()
|
||||
{
|
||||
elog(NOTICE, "Current server encoding is %s",
|
||||
pg_encoding_to_char(GetDatabaseEncoding()));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool
|
||||
reset_server_encoding()
|
||||
{
|
||||
elog(NOTICE, "RESET SERVER_ENCODING is not supported");
|
||||
return TRUE;
|
||||
}
|
||||
Reference in New Issue
Block a user