aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/mb/variable.c
blob: 12cc23d3f30f5552c77e463bf3b3444e652cb43d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
 * This file contains some public functions
 * related to show/set/reset variable commands.
 * Tatsuo Ishii
 * $Id: variable.c,v 1.1 1998/07/24 03:31:57 scrappy Exp $
 */

#include "mb/pg_wchar.h"

bool
parse_client_encoding(const char *value)
{
  int encoding;

  encoding = pg_valid_client_encoding(value);
  if (encoding < 0) {
    elog(ERROR, "Client encoding %s is not supported", value);
  } 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;
}

bool
show_client_encoding()
{
  elog(NOTICE, "Current client encoding is %s",
       pg_encoding_to_char(pg_get_client_encoding()));
  return TRUE;
}

bool
reset_client_encoding()
{
  int encoding;
  char *env = getenv("PGCLIENTENCODING");

  if (env) {
    encoding = pg_char_to_encoding(env);
    if (encoding < 0) {
      encoding = GetDatabaseEncoding();
    }
  } else {
    encoding = GetDatabaseEncoding();
  }
  pg_set_client_encoding(encoding);
  return TRUE;
}

bool
parse_server_encoding(const char *value)
{
  elog(NOTICE, "SET SERVER_ENCODING is not supported");
  return TRUE;
}

bool
show_server_encoding()
{
  elog(NOTICE, "Current server encoding is %s",
       pg_encoding_to_char(GetDatabaseEncoding()));
  return TRUE;
}

bool
reset_server_encoding()
{
  elog(NOTICE, "RESET SERVER_ENCODING is not supported");
  return TRUE;
}