mirror of
https://github.com/postgres/postgres.git
synced 2025-11-12 05:01:15 +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:
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.20 1998/08/19 02:01:23 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.21 1998/08/24 01:13:36 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -31,13 +31,8 @@
|
||||
#include "bootstrap/bootstrap.h"
|
||||
#include "catalog/heap.h"
|
||||
#include "catalog/pg_am.h"
|
||||
#ifdef MULTIBYTE
|
||||
#include "catalog/pg_attribute_mb.h"
|
||||
#include "catalog/pg_class_mb.h"
|
||||
#else
|
||||
#include "catalog/pg_attribute.h"
|
||||
#include "catalog/pg_class.h"
|
||||
#endif
|
||||
#include "commands/defrem.h"
|
||||
#include "nodes/nodes.h"
|
||||
#include "nodes/parsenodes.h"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.10 1998/07/26 04:30:19 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootscanner.l,v 1.11 1998/08/24 01:13:38 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -20,11 +20,7 @@
|
||||
#include "storage/block.h"
|
||||
#include "storage/off.h"
|
||||
#include "storage/itemptr.h"
|
||||
#ifdef MULTIBYTE
|
||||
#include "catalog/pg_attribute_mb.h"
|
||||
#else
|
||||
#include "catalog/pg_attribute.h"
|
||||
#endif
|
||||
#include "access/attnum.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#include "access/tupdesc.h"
|
||||
@@ -32,11 +28,7 @@
|
||||
#include "access/funcindex.h"
|
||||
#include "storage/fd.h"
|
||||
#include "catalog/pg_am.h"
|
||||
#ifdef MULTIBYTE
|
||||
#include "catalog/pg_class_mb.h"
|
||||
#else
|
||||
#include "catalog/pg_class.h"
|
||||
#endif
|
||||
#include "nodes/nodes.h"
|
||||
#include "rewrite/prs2lock.h"
|
||||
#include "access/skey.h"
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.23 1998/08/18 00:48:55 scrappy Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.24 1998/08/24 01:13:44 momjian Exp $
|
||||
*
|
||||
* HISTORY
|
||||
* AUTHOR DATE MAJOR EVENT
|
||||
@@ -2142,6 +2142,7 @@ CreatedbStmt: CREATE DATABASE database_name WITH opt_database1 opt_database2
|
||||
#else
|
||||
if ($6 != NULL)
|
||||
elog(ERROR, "WITH ENCODING is not supported");
|
||||
n->encoding = 0;
|
||||
#endif
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
@@ -2152,6 +2153,8 @@ CreatedbStmt: CREATE DATABASE database_name WITH opt_database1 opt_database2
|
||||
n->dbpath = NULL;
|
||||
#ifdef MULTIBYTE
|
||||
n->encoding = GetTemplateEncoding();
|
||||
#else
|
||||
n->encoding = 0;
|
||||
#endif
|
||||
$$ = (Node *)n;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.17 1998/08/19 02:02:40 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.18 1998/08/24 01:13:46 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -41,11 +41,7 @@
|
||||
|
||||
#include "catalog/catname.h"
|
||||
#include "catalog/catalog.h"
|
||||
#ifdef MULTIBYTE
|
||||
#include "catalog/pg_class_mb.h"
|
||||
#else
|
||||
#include "catalog/pg_class.h"
|
||||
#endif
|
||||
|
||||
#include "nodes/memnodes.h"
|
||||
#include "storage/bufmgr.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.36 1998/08/11 18:28:15 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.37 1998/08/24 01:13:48 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -568,15 +568,9 @@ mdblindwrt(char *dbstr,
|
||||
int4 owner;
|
||||
Oid id;
|
||||
char *tmpPath;
|
||||
#ifdef MULTIBYTE
|
||||
int tmpEncoding;
|
||||
#endif
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
GetRawDatabaseInfo(dbstr, &owner, &id, dbpath, &tmpEncoding);
|
||||
#else
|
||||
GetRawDatabaseInfo(dbstr, &owner, &id, dbpath);
|
||||
#endif
|
||||
|
||||
if (id != dbid)
|
||||
elog(FATAL, "mdblindwrt: oid of db %s is not %u", dbstr, dbid);
|
||||
@@ -613,16 +607,9 @@ mdblindwrt(char *dbstr,
|
||||
int4 owner;
|
||||
Oid id;
|
||||
char *tmpPath;
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
int tmpEncoding;
|
||||
#endif
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
GetRawDatabaseInfo(dbstr, &owner, &id, dbpath, &tmpEncoding);
|
||||
#else
|
||||
GetRawDatabaseInfo(dbstr, &owner, &id, dbpath);
|
||||
#endif
|
||||
|
||||
if (id != dbid)
|
||||
elog(FATAL, "mdblindwrt: oid of db %s is not %u", dbstr, dbid);
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.45 1998/08/06 05:12:48 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.46 1998/08/24 01:13:50 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -558,11 +558,7 @@ ProcessUtility(Node *parsetree,
|
||||
|
||||
*ps_status = commandTag = "CREATEDB";
|
||||
CHECK_IF_ABORTED();
|
||||
#ifdef MULTIBYTE
|
||||
createdb(stmt->dbname, stmt->dbpath, stmt->encoding);
|
||||
#else
|
||||
createdb(stmt->dbname, stmt->dbpath);
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
5
src/backend/utils/cache/Makefile
vendored
5
src/backend/utils/cache/Makefile
vendored
@@ -4,7 +4,7 @@
|
||||
# Makefile for utils/cache
|
||||
#
|
||||
# IDENTIFICATION
|
||||
# $Header: /cvsroot/pgsql/src/backend/utils/cache/Makefile,v 1.8 1998/07/26 04:30:54 scrappy Exp $
|
||||
# $Header: /cvsroot/pgsql/src/backend/utils/cache/Makefile,v 1.9 1998/08/24 01:13:52 momjian Exp $
|
||||
#
|
||||
#-------------------------------------------------------------------------
|
||||
|
||||
@@ -12,9 +12,6 @@ SRCDIR = ../../..
|
||||
include ../../../Makefile.global
|
||||
|
||||
CFLAGS += -I../..
|
||||
ifdef MULTIBYTE
|
||||
CFLAGS+= $(MBFLAGS)
|
||||
endif
|
||||
|
||||
OBJS = catcache.o inval.o rel.o relcache.o syscache.o lsyscache.o fcache.o
|
||||
|
||||
|
||||
6
src/backend/utils/cache/fcache.c
vendored
6
src/backend/utils/cache/fcache.c
vendored
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.15 1998/08/19 02:03:09 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.16 1998/08/24 01:13:54 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -22,11 +22,7 @@
|
||||
#include "catalog/pg_type.h"
|
||||
#include "catalog/pg_proc.h"
|
||||
#include "catalog/pg_language.h"
|
||||
#ifdef MULTIBYTE
|
||||
#include "catalog/pg_class_mb.h"
|
||||
#else
|
||||
#include "catalog/pg_class.h"
|
||||
#endif
|
||||
#include "parser/parsetree.h" /* for getrelname() */
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/fcache.h"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.33 1998/08/11 18:28:28 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.34 1998/08/24 01:13:56 momjian Exp $
|
||||
*
|
||||
* NOTES
|
||||
* InitPostgres() is the function called from PostgresMain
|
||||
@@ -67,10 +67,7 @@
|
||||
|
||||
#include "catalog/catname.h"
|
||||
#ifdef MULTIBYTE
|
||||
#include "catalog/pg_database_mb.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
#else
|
||||
#include "catalog/pg_database.h"
|
||||
#endif
|
||||
|
||||
#include "libpq/libpq.h"
|
||||
@@ -83,11 +80,7 @@ static void InitStdio(void);
|
||||
static void InitUserid(void);
|
||||
|
||||
extern char *ExpandDatabasePath(char *name);
|
||||
#ifdef MULTIBYTE
|
||||
extern void GetRawDatabaseInfo(char *name, int4 *owner, Oid *db_id, char *path, int *encoding);
|
||||
#else
|
||||
extern void GetRawDatabaseInfo(char *name, int4 *owner, Oid *db_id, char *path);
|
||||
#endif
|
||||
|
||||
static IPCKey PostgresIpcKey;
|
||||
|
||||
@@ -128,16 +121,10 @@ InitMyDatabaseInfo(char *name)
|
||||
int4 owner;
|
||||
char *path,
|
||||
myPath[MAXPGPATH + 1];
|
||||
#ifdef MULTIBYTE
|
||||
int encoding;
|
||||
#endif
|
||||
|
||||
SetDatabaseName(name);
|
||||
#ifdef MULTIBYTE
|
||||
GetRawDatabaseInfo(name, &owner, &MyDatabaseId, myPath, &encoding);
|
||||
#else
|
||||
GetRawDatabaseInfo(name, &owner, &MyDatabaseId, myPath);
|
||||
#endif
|
||||
|
||||
if (!OidIsValid(MyDatabaseId))
|
||||
elog(FATAL,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* conversion between client encoding and server internal encoding
|
||||
* (currently mule internal code (mic) is used)
|
||||
* Tatsuo Ishii
|
||||
* $Id: conv.c,v 1.1 1998/07/24 03:31:56 scrappy Exp $
|
||||
* $Id: conv.c,v 1.2 1998/08/24 01:13:59 momjian Exp $
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
@@ -369,7 +369,38 @@ static void mic2latin5(unsigned char *mic, unsigned char *p, int len)
|
||||
mic2latin(mic, p, len, LC_ISO8859_5);
|
||||
}
|
||||
|
||||
/*
|
||||
* ASCII ---> MIC
|
||||
*/
|
||||
static void ascii2mic(unsigned char *l, unsigned char *p, int len)
|
||||
{
|
||||
int c1;
|
||||
|
||||
while (len-- > 0 && (c1 = *l++)) {
|
||||
*p++ = (c1 & 0x7f);
|
||||
}
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
/*
|
||||
* MIC ---> ASCII
|
||||
*/
|
||||
static void mic2ascii(unsigned char *mic, unsigned char *p, int len)
|
||||
{
|
||||
int c1;
|
||||
|
||||
while (len > 0 && (c1 = *mic)) {
|
||||
if (c1 > 0x7f) {
|
||||
printBogusChar(&mic, &p);
|
||||
} else { /* should be ASCII */
|
||||
*p++ = c1;
|
||||
}
|
||||
}
|
||||
*p = '\0';
|
||||
}
|
||||
|
||||
pg_encoding_conv_tbl pg_conv_tbl[] = {
|
||||
{SQL_ASCII, "SQL_ASCII", 0, ascii2mic, mic2ascii}, /* SQL/ACII */
|
||||
{EUC_JP, "EUC_JP", 0, euc_jp2mic, mic2euc_jp}, /* EUC_JP */
|
||||
{EUC_CN, "EUC_CN", 0, euc_cn2mic, mic2euc_cn}, /* EUC_CN */
|
||||
{EUC_KR, "EUC_KR", 0, euc_kr2mic, mic2euc_kr}, /* EUC_KR */
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/*
|
||||
* conversion functions between pg_wchar and multi-byte streams.
|
||||
* Tatsuo Ishii
|
||||
* $Id: wchar.c,v 1.1 1998/07/24 03:31:57 scrappy Exp $
|
||||
* $Id: wchar.c,v 1.2 1998/08/24 01:14:01 momjian Exp $
|
||||
*/
|
||||
|
||||
#include "mb/pg_wchar.h"
|
||||
@@ -316,6 +316,7 @@ static int pg_sjis_mblen(const unsigned char *s)
|
||||
}
|
||||
|
||||
pg_wchar_tbl pg_wchar_table[] = {
|
||||
{0, 0},
|
||||
{pg_eucjp2wchar_with_len, pg_eucjp_mblen},
|
||||
{pg_euccn2wchar_with_len, pg_euccn_mblen},
|
||||
{pg_euckr2wchar_with_len, pg_euckr_mblen},
|
||||
@@ -347,7 +348,6 @@ pg_wchar_tbl pg_wchar_table[] = {
|
||||
{0, 0},
|
||||
{0, 0},
|
||||
{0, 0},
|
||||
{0, 0},
|
||||
{0, pg_sjis_mblen}
|
||||
};
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.16 1998/08/19 02:03:24 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.17 1998/08/24 01:14:02 momjian Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -30,7 +30,11 @@
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/syscache.h"
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
#include "mb/pg_wchar.h"
|
||||
#endif
|
||||
|
||||
#ifdef 0
|
||||
/* GetDatabaseInfo()
|
||||
* Pull database information from pg_database.
|
||||
*/
|
||||
@@ -102,6 +106,7 @@ GetDatabaseInfo(char *name, int4 *owner, char *path)
|
||||
|
||||
return FALSE;
|
||||
} /* GetDatabaseInfo() */
|
||||
#endif
|
||||
|
||||
char *
|
||||
ExpandDatabasePath(char *dbpath)
|
||||
@@ -175,7 +180,7 @@ ExpandDatabasePath(char *dbpath)
|
||||
* --------------------------------
|
||||
*/
|
||||
void
|
||||
GetRawDatabaseInfo(char *name, int4 *owner, Oid *db_id, char *path)
|
||||
GetRawDatabaseInfo(char *name, int4 *owner, Oid *db_id, char *path, int *encoding)
|
||||
{
|
||||
int dbfd;
|
||||
int fileflags;
|
||||
@@ -262,13 +267,25 @@ GetRawDatabaseInfo(char *name, int4 *owner, Oid *db_id, char *path)
|
||||
* means of getting at sys cat attrs.
|
||||
*/
|
||||
tup_db = (Form_pg_database) GETSTRUCT(tup);
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
/* get encoding from template database.
|
||||
This is the "default for default" for
|
||||
create database command.
|
||||
*/
|
||||
if (strcmp("template1",tup_db->datname.data) == 0)
|
||||
{
|
||||
SetTemplateEncoding(tup_db->encoding);
|
||||
}
|
||||
#endif
|
||||
if (strcmp(name, tup_db->datname.data) == 0)
|
||||
{
|
||||
*db_id = tup->t_oid;
|
||||
strncpy(path, VARDATA(&(tup_db->datpath)),
|
||||
(VARSIZE(&(tup_db->datpath)) - VARHDRSZ));
|
||||
*(path + VARSIZE(&(tup_db->datpath)) - VARHDRSZ) = '\0';
|
||||
#ifdef MULTIBYTE
|
||||
*encoding = tup_db->encoding;
|
||||
#endif
|
||||
|
||||
goto done;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user