1998-07-24 05:32:46 +02:00
|
|
|
/*
|
|
|
|
* This file contains some public functions
|
|
|
|
* related to show/set/reset variable commands.
|
|
|
|
* Tatsuo Ishii
|
2000-04-21 00:40:18 +02:00
|
|
|
* $Id: variable.c,v 1.7 2000/04/20 22:40:18 tgl Exp $
|
1998-07-24 05:32:46 +02:00
|
|
|
*/
|
|
|
|
|
1999-07-17 18:25:28 +02:00
|
|
|
#include "postgres.h"
|
2000-01-18 14:44:48 +01:00
|
|
|
#include "miscadmin.h"
|
1998-07-24 05:32:46 +02:00
|
|
|
#include "mb/pg_wchar.h"
|
|
|
|
|
|
|
|
bool
|
2000-04-21 00:40:18 +02:00
|
|
|
parse_client_encoding(char *value)
|
1998-07-24 05:32:46 +02:00
|
|
|
{
|
1998-09-01 06:40:42 +02:00
|
|
|
int encoding;
|
1998-07-24 05:32:46 +02:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
encoding = pg_valid_client_encoding(value);
|
1999-05-25 18:15:34 +02:00
|
|
|
if (encoding < 0)
|
|
|
|
{
|
|
|
|
if (value)
|
1999-05-13 12:28:26 +02:00
|
|
|
elog(ERROR, "Client encoding %s is not supported", value);
|
1999-05-25 18:15:34 +02:00
|
|
|
else
|
1999-05-13 12:28:26 +02:00
|
|
|
elog(ERROR, "No client encoding is specified");
|
|
|
|
}
|
1998-09-01 06:40:42 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (pg_set_client_encoding(encoding))
|
|
|
|
{
|
|
|
|
elog(ERROR, "Conversion between %s and %s is not supported",
|
|
|
|
value, pg_encoding_to_char(GetDatabaseEncoding()));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return TRUE;
|
1998-07-24 05:32:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
show_client_encoding()
|
|
|
|
{
|
1998-09-01 06:40:42 +02:00
|
|
|
elog(NOTICE, "Current client encoding is %s",
|
|
|
|
pg_encoding_to_char(pg_get_client_encoding()));
|
|
|
|
return TRUE;
|
1998-07-24 05:32:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
reset_client_encoding()
|
|
|
|
{
|
1998-09-01 06:40:42 +02:00
|
|
|
int encoding;
|
|
|
|
char *env = getenv("PGCLIENTENCODING");
|
1998-07-24 05:32:46 +02:00
|
|
|
|
1998-09-01 06:40:42 +02:00
|
|
|
if (env)
|
|
|
|
{
|
|
|
|
encoding = pg_char_to_encoding(env);
|
|
|
|
if (encoding < 0)
|
|
|
|
encoding = GetDatabaseEncoding();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
encoding = GetDatabaseEncoding();
|
|
|
|
pg_set_client_encoding(encoding);
|
|
|
|
return TRUE;
|
1998-07-24 05:32:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
2000-04-21 00:40:18 +02:00
|
|
|
parse_server_encoding(char *value)
|
1998-07-24 05:32:46 +02:00
|
|
|
{
|
1998-09-01 06:40:42 +02:00
|
|
|
elog(NOTICE, "SET SERVER_ENCODING is not supported");
|
|
|
|
return TRUE;
|
1998-07-24 05:32:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
show_server_encoding()
|
|
|
|
{
|
1998-09-01 06:40:42 +02:00
|
|
|
elog(NOTICE, "Current server encoding is %s",
|
|
|
|
pg_encoding_to_char(GetDatabaseEncoding()));
|
|
|
|
return TRUE;
|
1998-07-24 05:32:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
reset_server_encoding()
|
|
|
|
{
|
1998-09-01 06:40:42 +02:00
|
|
|
elog(NOTICE, "RESET SERVER_ENCODING is not supported");
|
|
|
|
return TRUE;
|
1998-07-24 05:32:46 +02:00
|
|
|
}
|