1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-19 13:42:17 +03:00

Hi, here are the patches to enhance existing MB handling. This time

I have implemented a framework of encoding translation between the
backend and the frontend. Also I have added a new variable setting
command:

SET CLIENT_ENCODING TO 'encoding';

Other features include:
	Latin1 support more 8 bit cleaness

See doc/README.mb for more details. Note that the pacthes are
against May 30 snapshot.

Tatsuo Ishii
This commit is contained in:
Bruce Momjian
1998-06-16 07:29:54 +00:00
parent 0d8e7f6381
commit cb7cbc16fa
37 changed files with 1115 additions and 341 deletions

View File

@@ -7,7 +7,7 @@
#
#
# IDENTIFICATION
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.21 1998/06/16 03:17:47 momjian Exp $
# $Header: /cvsroot/pgsql/src/interfaces/libpq/Attic/Makefile.in,v 1.22 1998/06/16 07:29:45 momjian Exp $
#
#-------------------------------------------------------------------------
@@ -25,9 +25,17 @@ ifdef KRBVERS
CFLAGS+= $(KRBFLAGS)
endif
ifdef MB
CFLAGS+= -DMB=$(MB)
endif
OBJS= fe-auth.o fe-connect.o fe-exec.o fe-misc.o fe-print.o fe-lobj.o \
dllist.o pqsignal.o
ifdef MB
OBJS+= pqutils.o pqmbutils.o
endif
# Shared library stuff
shlib :=
install-shlib-dep :=

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.67 1998/06/15 19:30:23 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.68 1998/06/16 07:29:47 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -120,7 +120,11 @@ struct EnvironmentOptions
{
"PGTZ", "timezone"
},
#ifdef MB
{
"PGCLIENTENCODING", "client_encoding"
},
#endif
/* internal performance-related settings */
{
"PGCOSTHEAP", "cost_heap"
@@ -371,7 +375,8 @@ PQsetdbLogin(const char *pghost, const char *pgport, const char *pgoptions, cons
}
else
for (i = 0; conn->dbName[i]; i++)
if (isupper(conn->dbName[i]))
if (isascii((unsigned char)conn->dbName[i]) &&
isupper(conn->dbName[i]))
conn->dbName[i] = tolower(conn->dbName[i]);
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.53 1998/06/15 19:30:25 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.54 1998/06/16 07:29:48 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1264,7 +1264,8 @@ PQfnumber(PGresult *res, const char *field_name)
}
else
for (i = 0; field_case[i]; i++)
if (isupper(field_case[i]))
if (isascii((unsigned char)field_case[i]) &&
isupper(field_case[i]))
field_case[i] = tolower(field_case[i]);
for (i = 0; i < res->numAttributes; i++)
@@ -1466,8 +1467,6 @@ PQgetvalue(PGresult *res, int tup_num, int field_num)
return res->tuples[tup_num][field_num].value;
}
/* PQgetlength:
returns the length of a field value in bytes. If res is binary,
i.e. a result of a binary portal, then the length returned does

View File

@@ -9,7 +9,7 @@
* didn't really belong there.
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.4 1998/06/16 06:57:27 momjian Exp $
* $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-print.c,v 1.5 1998/06/16 07:29:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -28,6 +28,10 @@
#include <termios.h>
#endif
#ifdef MB
#include "regex/pg_wchar.h"
#include "commands/variable.h"
#endif
#ifdef TIOCGWINSZ
static struct winsize screen_size;
@@ -469,7 +473,29 @@ PQprintTuples(PGresult *res,
}
}
#ifdef MB
/*
* returns the byte length of the word beginning s.
* Client side encoding is determined by the environment variable
* "PGCLIENTENCODING".
* if this variable is not defined, the same encoding as
* the backend is assumed.
*/
int PQmblen(unsigned char *s)
{
char *str;
int encoding = -1;
str = getenv("PGCLIENTENCODING");
if (str) {
encoding = pg_char_to_encoding(str);
}
if (encoding < 0) {
encoding = MB;
}
return(pg_encoding_mblen(encoding, s));
}
#endif
static void
do_field(PQprintOpt *po, PGresult *res,
@@ -504,7 +530,15 @@ do_field(PQprintOpt *po, PGresult *res,
if (!skipit)
{
#ifdef MB
int len;
for (p = pval, o = buf; *p;
len = PQmblen(p),memcpy(o,p,len),
o+=len, p+=len)
#else
for (p = pval, o = buf; *p; *(o++) = *(p++))
#endif
{
if ((fs_len == 1 && (*p == *(po->fieldSep))) || *p == '\\' || *p == '\n')
*(o++) = '\\';

View File

@@ -6,7 +6,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: libpq-fe.h,v 1.29 1998/05/06 23:51:16 momjian Exp $
* $Id: libpq-fe.h,v 1.30 1998/06/16 07:29:49 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -364,6 +364,10 @@ extern "C"
* 0, use variable width */
);
#ifdef MB
extern int PQmblen(unsigned char *s);
#endif
/* === in fe-auth.c === */
extern MsgType fe_getauthsvc(char *PQerrormsg);
extern void fe_setauthsvc(const char *name, char *PQerrormsg);