mirror of
https://github.com/postgres/postgres.git
synced 2025-07-30 11:03:19 +03:00
Remove --enable-recode feature, since it's been broken by IPv6 changes,
and seems to have too few users to justify maintaining.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.355 2003/08/04 02:40:04 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.356 2003/08/04 04:03:06 tgl Exp $
|
||||
*
|
||||
* NOTES
|
||||
* this is the "main" module of the postgres backend and
|
||||
@ -2613,14 +2613,6 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
on_shmem_exit(DumpFreeSpaceMap, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up additional info.
|
||||
*/
|
||||
|
||||
#ifdef CYR_RECODE
|
||||
SetCharSet();
|
||||
#endif
|
||||
|
||||
/*
|
||||
* General initialization.
|
||||
*
|
||||
@ -2651,7 +2643,7 @@ PostgresMain(int argc, char *argv[], const char *username)
|
||||
if (!IsUnderPostmaster)
|
||||
{
|
||||
puts("\nPOSTGRES backend interactive interface ");
|
||||
puts("$Revision: 1.355 $ $Date: 2003/08/04 02:40:04 $\n");
|
||||
puts("$Revision: 1.356 $ $Date: 2003/08/04 04:03:06 $\n");
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.101 2003/08/04 02:40:06 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.102 2003/08/04 04:03:10 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -130,10 +130,6 @@ bpcharin(PG_FUNCTION_ARGS)
|
||||
for (; i < maxlen; i++)
|
||||
*r++ = ' ';
|
||||
|
||||
#ifdef CYR_RECODE
|
||||
convertstr(VARDATA(result), len, 0);
|
||||
#endif
|
||||
|
||||
PG_RETURN_BPCHAR_P(result);
|
||||
}
|
||||
|
||||
@ -154,10 +150,6 @@ bpcharout(PG_FUNCTION_ARGS)
|
||||
memcpy(result, VARDATA(s), len);
|
||||
result[len] = '\0';
|
||||
|
||||
#ifdef CYR_RECODE
|
||||
convertstr(result, len, 1);
|
||||
#endif
|
||||
|
||||
PG_RETURN_CSTRING(result);
|
||||
}
|
||||
|
||||
@ -396,10 +388,6 @@ varcharin(PG_FUNCTION_ARGS)
|
||||
VARATT_SIZEP(result) = len + VARHDRSZ;
|
||||
memcpy(VARDATA(result), s, len);
|
||||
|
||||
#ifdef CYR_RECODE
|
||||
convertstr(VARDATA(result), len, 0);
|
||||
#endif
|
||||
|
||||
PG_RETURN_VARCHAR_P(result);
|
||||
}
|
||||
|
||||
@ -420,10 +408,6 @@ varcharout(PG_FUNCTION_ARGS)
|
||||
memcpy(result, VARDATA(s), len);
|
||||
result[len] = '\0';
|
||||
|
||||
#ifdef CYR_RECODE
|
||||
convertstr(result, len, 1);
|
||||
#endif
|
||||
|
||||
PG_RETURN_CSTRING(result);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.104 2003/08/04 02:40:06 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.105 2003/08/04 04:03:10 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -268,10 +268,6 @@ textin(PG_FUNCTION_ARGS)
|
||||
|
||||
memcpy(VARDATA(result), inputText, len);
|
||||
|
||||
#ifdef CYR_RECODE
|
||||
convertstr(VARDATA(result), len, 0);
|
||||
#endif
|
||||
|
||||
PG_RETURN_TEXT_P(result);
|
||||
}
|
||||
|
||||
@ -290,10 +286,6 @@ textout(PG_FUNCTION_ARGS)
|
||||
memcpy(result, VARDATA(t), len);
|
||||
result[len] = '\0';
|
||||
|
||||
#ifdef CYR_RECODE
|
||||
convertstr(result, len, 1);
|
||||
#endif
|
||||
|
||||
PG_RETURN_CSTRING(result);
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.112 2003/08/04 02:40:06 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.113 2003/08/04 04:03:10 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -48,13 +48,6 @@ ProcessingMode Mode = InitProcessing;
|
||||
static char directoryLockFile[MAXPGPATH];
|
||||
static char socketLockFile[MAXPGPATH];
|
||||
|
||||
#ifdef CYR_RECODE
|
||||
static unsigned char RecodeForwTable[128];
|
||||
static unsigned char RecodeBackTable[128];
|
||||
|
||||
static void GetCharSetByHost(char *TableName, int host, const char *DataDir);
|
||||
#endif
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* ignoring system indexes support stuff
|
||||
@ -181,295 +174,6 @@ SetDataDir(const char *dir)
|
||||
DataDir = new;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* CYR_RECODE support
|
||||
* ----------------------------------------------------------------
|
||||
*/
|
||||
|
||||
#ifdef CYR_RECODE
|
||||
|
||||
void
|
||||
SetCharSet(void)
|
||||
{
|
||||
FILE *file;
|
||||
char *filename;
|
||||
char *map_file;
|
||||
char buf[MAX_TOKEN];
|
||||
int i;
|
||||
unsigned char FromChar,
|
||||
ToChar;
|
||||
char ChTable[MAX_TOKEN];
|
||||
|
||||
for (i = 0; i < 128; i++)
|
||||
{
|
||||
RecodeForwTable[i] = i + 128;
|
||||
RecodeBackTable[i] = i + 128;
|
||||
}
|
||||
|
||||
if (IsUnderPostmaster)
|
||||
{
|
||||
GetCharSetByHost(ChTable, MyProcPort->raddr.in.sin_addr.s_addr, DataDir);
|
||||
filename = ChTable;
|
||||
}
|
||||
else
|
||||
filename = getenv("PG_RECODETABLE");
|
||||
|
||||
if (filename && *filename != '\0')
|
||||
{
|
||||
map_file = palloc(strlen(DataDir) + strlen(filename) + 2);
|
||||
sprintf(map_file, "%s/%s", DataDir, filename);
|
||||
file = AllocateFile(map_file, "r");
|
||||
pfree(map_file);
|
||||
if (file == NULL)
|
||||
return;
|
||||
|
||||
while (!feof(file))
|
||||
{
|
||||
next_token(file, buf, sizeof(buf));
|
||||
if (buf[0] != '\0')
|
||||
{
|
||||
FromChar = strtoul(buf, 0, 0);
|
||||
/* Read the ToChar */
|
||||
next_token(file, buf, sizeof(buf));
|
||||
if (buf[0] != '\0')
|
||||
{
|
||||
ToChar = strtoul(buf, 0, 0);
|
||||
RecodeForwTable[FromChar - 128] = ToChar;
|
||||
RecodeBackTable[ToChar - 128] = FromChar;
|
||||
|
||||
/* read to EOL */
|
||||
while (!feof(file) && buf[0])
|
||||
{
|
||||
next_token(file, buf, sizeof(buf));
|
||||
elog(LOG, "unexpected token %s in file %s",
|
||||
buf, filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
FreeFile(file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
char *
|
||||
convertstr(unsigned char *buff, int len, int dest)
|
||||
{
|
||||
int i;
|
||||
char *ch = buff;
|
||||
|
||||
for (i = 0; i < len; i++, buff++)
|
||||
{
|
||||
if (*buff > 127)
|
||||
{
|
||||
if (dest)
|
||||
*buff = RecodeForwTable[*buff - 128];
|
||||
else
|
||||
*buff = RecodeBackTable[*buff - 128];
|
||||
}
|
||||
}
|
||||
return ch;
|
||||
}
|
||||
|
||||
#define CHARSET_FILE "charset.conf"
|
||||
#define MAX_CHARSETS 10
|
||||
#define KEY_HOST 1
|
||||
#define KEY_BASE 2
|
||||
#define KEY_TABLE 3
|
||||
|
||||
struct CharsetItem
|
||||
{
|
||||
char Orig[MAX_TOKEN];
|
||||
char Dest[MAX_TOKEN];
|
||||
char Table[MAX_TOKEN];
|
||||
};
|
||||
|
||||
|
||||
static bool
|
||||
CharSetInRange(char *buf, int host)
|
||||
{
|
||||
int valid,
|
||||
i,
|
||||
FromAddr,
|
||||
ToAddr,
|
||||
tmp;
|
||||
struct in_addr file_ip_addr;
|
||||
char *p;
|
||||
unsigned int one = 0x80000000,
|
||||
NetMask = 0;
|
||||
unsigned char mask;
|
||||
|
||||
p = strchr(buf, '/');
|
||||
if (p)
|
||||
{
|
||||
*p++ = '\0';
|
||||
valid = inet_aton(buf, &file_ip_addr);
|
||||
if (valid)
|
||||
{
|
||||
mask = strtoul(p, 0, 0);
|
||||
FromAddr = ntohl(file_ip_addr.s_addr);
|
||||
ToAddr = ntohl(file_ip_addr.s_addr);
|
||||
for (i = 0; i < mask; i++)
|
||||
{
|
||||
NetMask |= one;
|
||||
one >>= 1;
|
||||
}
|
||||
FromAddr &= NetMask;
|
||||
ToAddr = ToAddr | ~NetMask;
|
||||
tmp = ntohl(host);
|
||||
return ((unsigned) tmp >= (unsigned) FromAddr &&
|
||||
(unsigned) tmp <= (unsigned) ToAddr);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p = strchr(buf, '-');
|
||||
if (p)
|
||||
{
|
||||
*p++ = '\0';
|
||||
valid = inet_aton(buf, &file_ip_addr);
|
||||
if (valid)
|
||||
{
|
||||
FromAddr = ntohl(file_ip_addr.s_addr);
|
||||
valid = inet_aton(p, &file_ip_addr);
|
||||
if (valid)
|
||||
{
|
||||
ToAddr = ntohl(file_ip_addr.s_addr);
|
||||
tmp = ntohl(host);
|
||||
return ((unsigned) tmp >= (unsigned) FromAddr &&
|
||||
(unsigned) tmp <= (unsigned) ToAddr);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
valid = inet_aton(buf, &file_ip_addr);
|
||||
if (valid)
|
||||
{
|
||||
FromAddr = file_ip_addr.s_addr;
|
||||
return (unsigned) FromAddr == (unsigned) host;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
GetCharSetByHost(char *TableName, int host, const char *DataDir)
|
||||
{
|
||||
FILE *file;
|
||||
char buf[MAX_TOKEN],
|
||||
BaseCharset[MAX_TOKEN],
|
||||
OrigCharset[MAX_TOKEN],
|
||||
DestCharset[MAX_TOKEN],
|
||||
HostCharset[MAX_TOKEN],
|
||||
*map_file;
|
||||
int key,
|
||||
ChIndex = 0,
|
||||
i,
|
||||
bufsize;
|
||||
struct CharsetItem *ChArray[MAX_CHARSETS];
|
||||
|
||||
*TableName = '\0';
|
||||
bufsize = (strlen(DataDir) + strlen(CHARSET_FILE) + 2) * sizeof(char);
|
||||
map_file = (char *) palloc(bufsize);
|
||||
snprintf(map_file, bufsize, "%s/%s", DataDir, CHARSET_FILE);
|
||||
file = AllocateFile(map_file, "r");
|
||||
pfree(map_file);
|
||||
if (file == NULL)
|
||||
{
|
||||
/* XXX should we log a complaint? */
|
||||
return;
|
||||
}
|
||||
|
||||
while (!feof(file))
|
||||
{
|
||||
next_token(file, buf, sizeof(buf));
|
||||
if (buf[0] != '\0')
|
||||
{
|
||||
key = 0;
|
||||
if (strcasecmp(buf, "HostCharset") == 0)
|
||||
key = KEY_HOST;
|
||||
else if (strcasecmp(buf, "BaseCharset") == 0)
|
||||
key = KEY_BASE;
|
||||
else if (strcasecmp(buf, "RecodeTable") == 0)
|
||||
key = KEY_TABLE;
|
||||
else
|
||||
elog(LOG, "unrecognized tag %s in file %s",
|
||||
buf, CHARSET_FILE);
|
||||
|
||||
switch (key)
|
||||
{
|
||||
case KEY_HOST:
|
||||
/* Read the host */
|
||||
next_token(file, buf, sizeof(buf));
|
||||
if (buf[0] != '\0')
|
||||
{
|
||||
if (CharSetInRange(buf, host))
|
||||
{
|
||||
/* Read the charset */
|
||||
next_token(file, buf, sizeof(buf));
|
||||
if (buf[0] != '\0')
|
||||
strcpy(HostCharset, buf);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case KEY_BASE:
|
||||
/* Read the base charset */
|
||||
next_token(file, buf, sizeof(buf));
|
||||
if (buf[0] != '\0')
|
||||
strcpy(BaseCharset, buf);
|
||||
break;
|
||||
case KEY_TABLE:
|
||||
/* Read the original charset */
|
||||
next_token(file, buf, sizeof(buf));
|
||||
if (buf[0] != '\0')
|
||||
{
|
||||
strcpy(OrigCharset, buf);
|
||||
/* Read the destination charset */
|
||||
next_token(file, buf, sizeof(buf));
|
||||
if (buf[0] != '\0')
|
||||
{
|
||||
strcpy(DestCharset, buf);
|
||||
/* Read the table filename */
|
||||
next_token(file, buf, sizeof(buf));
|
||||
if (buf[0] != '\0')
|
||||
{
|
||||
ChArray[ChIndex] =
|
||||
(struct CharsetItem *) palloc(sizeof(struct CharsetItem));
|
||||
strcpy(ChArray[ChIndex]->Orig, OrigCharset);
|
||||
strcpy(ChArray[ChIndex]->Dest, DestCharset);
|
||||
strcpy(ChArray[ChIndex]->Table, buf);
|
||||
ChIndex++;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* read to EOL */
|
||||
while (!feof(file) && buf[0])
|
||||
{
|
||||
next_token(file, buf, sizeof(buf));
|
||||
elog(LOG, "unrecognized tag %s in file %s",
|
||||
buf, CHARSET_FILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
FreeFile(file);
|
||||
|
||||
for (i = 0; i < ChIndex; i++)
|
||||
{
|
||||
if (strcasecmp(BaseCharset, ChArray[i]->Orig) == 0 &&
|
||||
strcasecmp(HostCharset, ChArray[i]->Dest) == 0)
|
||||
strncpy(TableName, ChArray[i]->Table, 79);
|
||||
pfree(ChArray[i]);
|
||||
}
|
||||
}
|
||||
#endif /* CYR_RECODE */
|
||||
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------
|
||||
* User ID things
|
||||
|
Reference in New Issue
Block a user