mirror of
https://github.com/postgres/postgres.git
synced 2025-11-04 20:11:56 +03:00
Add new backslash command \eset and \eshow.
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Copyright 2000 by PostgreSQL Global Development Group
|
||||
*
|
||||
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.19 2000/02/16 13:15:26 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.20 2000/02/19 05:01:15 ishii Exp $
|
||||
*/
|
||||
#include "postgres.h"
|
||||
#include "command.h"
|
||||
@@ -33,6 +33,11 @@
|
||||
#include "settings.h"
|
||||
#include "variables.h"
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
#include "miscadmin.h"
|
||||
#include "mb/pg_wchar.h"
|
||||
#endif
|
||||
|
||||
|
||||
/* functions for use in this file */
|
||||
|
||||
@@ -346,6 +351,30 @@ exec_command(const char *cmd,
|
||||
fputs("\n", fout);
|
||||
}
|
||||
|
||||
#ifdef MULTIBYTE
|
||||
/* \eset -- set client side encoding */
|
||||
else if (strcmp(cmd, "eset") == 0)
|
||||
{
|
||||
char *encoding = scan_option(&string, OT_NORMAL, NULL);
|
||||
if (PQsetClientEncoding(pset.db, encoding) == -1)
|
||||
{
|
||||
psql_error("\\%s: invalid encoding\n", cmd);
|
||||
}
|
||||
/* save encoding info into psql internal data */
|
||||
pset.encoding = PQclientEncoding(pset.db);
|
||||
free(encoding);
|
||||
}
|
||||
/* \eshow -- show encoding info */
|
||||
else if (strcmp(cmd, "eshow") == 0)
|
||||
{
|
||||
int encoding = PQclientEncoding(pset.db);
|
||||
if (encoding == -1)
|
||||
{
|
||||
psql_error("\\%s: there is no connection\n", cmd);
|
||||
}
|
||||
printf("%s\n", pg_encoding_to_char(encoding));
|
||||
}
|
||||
#endif
|
||||
/* \f -- change field separator */
|
||||
else if (strcmp(cmd, "f") == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user