diff options
| author | Bruce Momjian | 1998-06-16 07:29:54 +0000 |
|---|---|---|
| committer | Bruce Momjian | 1998-06-16 07:29:54 +0000 |
| commit | cb7cbc16fa4b5933fb5d63052568e3ed6859857b (patch) | |
| tree | bed17594c4880549288373de4d400512cbe2f82d /src/interfaces | |
| parent | 0d8e7f6381291b85ad6264365e01143357d70a75 (diff) | |
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
Diffstat (limited to 'src/interfaces')
| -rw-r--r-- | src/interfaces/libpq/Makefile.in | 10 | ||||
| -rw-r--r-- | src/interfaces/libpq/fe-connect.c | 11 | ||||
| -rw-r--r-- | src/interfaces/libpq/fe-exec.c | 7 | ||||
| -rw-r--r-- | src/interfaces/libpq/fe-print.c | 38 | ||||
| -rw-r--r-- | src/interfaces/libpq/libpq-fe.h | 6 |
5 files changed, 61 insertions, 11 deletions
diff --git a/src/interfaces/libpq/Makefile.in b/src/interfaces/libpq/Makefile.in index 460debb82fa..5e59f566631 100644 --- a/src/interfaces/libpq/Makefile.in +++ b/src/interfaces/libpq/Makefile.in @@ -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 := diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 20c02950b1d..ba386d6392e 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -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]); } diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index 8b4a55e290e..506edc8b1a3 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -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 diff --git a/src/interfaces/libpq/fe-print.c b/src/interfaces/libpq/fe-print.c index 140658b9422..ae820561c06 100644 --- a/src/interfaces/libpq/fe-print.c +++ b/src/interfaces/libpq/fe-print.c @@ -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++) = '\\'; diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 7b932762761..1bfd0f5a3e4 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -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); |
