1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

o note that now pg_database has a new attribuite "encoding" even

if MULTIBYTE is not enabled. So be sure to run initdb.

o these patches are made against the latest source tree (after
Bruce's massive patch, I think) BTW, I noticed that after running
regression, the oid field of pg_type seems disappeared.

	regression=> select oid from pg_type; ERROR:  attribute
	'oid' not found

this happens after the constraints test. This occures with/without
my patches. strange...

o pg_database_mb.h, pg_class_mb.h, pg_attribute_mb.h are no longer
used, and shoud be removed.

o GetDatabaseInfo() in utils/misc/database.c removed (actually in
#ifdef 0). seems nobody uses.

t-ishii@sra.co.jp
This commit is contained in:
Bruce Momjian
1998-08-24 01:14:24 +00:00
parent 9438fe5d09
commit c0b01461db
27 changed files with 171 additions and 815 deletions

View File

@@ -6,7 +6,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.53 1998/08/19 02:01:44 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.54 1998/08/24 01:13:39 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -37,6 +37,10 @@
#include "commands/trigger.h"
#include <storage/fd.h>
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
#endif
#define ISOCTAL(c) (((c) >= '0') && ((c) <= '7'))
#define VALUE(c) ((c) - '0')
@@ -61,7 +65,7 @@ static char *CopyReadAttribute(FILE *fp, bool *isnull, char *delim, int *newline
static char *CopyReadAttribute(FILE *fp, bool *isnull, char *delim);
#endif
static void CopyAttributeOut(FILE *fp, char *string, char *delim, int is_array);
static void CopyAttributeOut(FILE *fp, unsigned char *string, char *delim, int is_array);
static int CountTuples(Relation relation);
extern FILE *Pfout,
@@ -1006,6 +1010,17 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
char c;
int done = 0;
int i = 0;
#ifdef MULTIBYTE
int mblen;
int encoding;
unsigned char s[2];
int j;
#endif
#ifdef MULTIBYTE
encoding = pg_get_client_encoding();
s[1] = 0;
#endif
#ifdef COPY_PATCH
/* if last delimiter was a newline return a NULL attribute */
@@ -1108,19 +1123,53 @@ CopyReadAttribute(FILE *fp, bool *isnull, char *delim)
}
if (!done)
attribute[i++] = c;
#ifdef MULTIBYTE
s[0] = c;
mblen = pg_encoding_mblen(encoding, s);
mblen--;
for(j=0;j<mblen;j++) {
c = getc(fp);
if (feof(fp))
return (NULL);
attribute[i++] = c;
}
#endif
if (i == EXT_ATTLEN - 1)
elog(ERROR, "CopyReadAttribute - attribute length too long. line: %d", lineno);
}
attribute[i] = '\0';
#ifdef MULTIBYTE
return(pg_client_to_server((unsigned char*)attribute, strlen(attribute)));
#else
return (&attribute[0]);
#endif
}
static void
CopyAttributeOut(FILE *fp, char *string, char *delim, int is_array)
CopyAttributeOut(FILE *fp, unsigned char *server_string, char *delim, int is_array)
{
unsigned char *string;
char c;
#ifdef MULTIBYTE
int mblen;
int encoding;
int i;
#endif
#ifdef MULTIBYTE
string = pg_server_to_client(server_string, strlen(server_string));
encoding = pg_get_client_encoding();
#else
string = server_string;
#endif
#ifdef MULTIBYTE
for (; (mblen = pg_encoding_mblen(encoding, string)) &&
((c = *string) != '\0'); string += mblen)
#else
for (; (c = *string) != '\0'; string++)
#endif
{
if (c == delim[0] || c == '\n' ||
(c == '\\' && !is_array))
@@ -1142,7 +1191,13 @@ CopyAttributeOut(FILE *fp, char *string, char *delim, int is_array)
fputc('\\', fp);
}
}
#ifdef MULTIBYTE
for (i=0;i<mblen;i++) {
fputc(*(string+i), fp);
}
#else
fputc(*string, fp);
#endif
}
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.20 1998/08/19 02:01:46 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.21 1998/08/24 01:13:40 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -43,7 +43,7 @@ static HeapTuple get_pg_dbtup(char *command, char *dbname, Relation dbrel);
static void stop_vacuum(char *dbpath, char *dbname);
void
createdb(char *dbname, char *dbpath)
createdb(char *dbname, char *dbpath, int encoding)
{
Oid db_id,
user_id;
@@ -90,8 +90,9 @@ createdb(char *dbname, char *dbpath)
dbname, user_id, dbname);
#endif
sprintf(buf, "insert into pg_database (datname, datdba, datpath)"
" values (\'%s\', \'%d\', \'%s\');", dbname, user_id, loc);
sprintf(buf, "insert into pg_database (datname, datdba, encoding, datpath)"
" values (\'%s\', \'%d\', \'%d\', \'%s\');", dbname, user_id, encoding, loc);
pg_exec_query(buf);
}

View File

@@ -7,7 +7,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.14 1998/08/19 02:01:52 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.15 1998/08/24 01:13:42 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -31,11 +31,7 @@
#include <utils/excid.h>
#include <utils/mcxt.h>
#include <catalog/pg_proc.h>
#ifdef MULTIBYTE
#include <catalog/pg_class_mb.h>
#else
#include <catalog/pg_class.h>
#endif
#include <optimizer/internal.h>
#include <optimizer/prep.h> /* for find_all_inheritors */
#ifndef NO_SECURITY