Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit320d3e0

Browse files
committed
Fixes for \encoding command.
1) freeing null pointer2) invalid encoding info may be stored into psql variable3) fix indentation
1 parentf72aad5 commit320d3e0

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

‎src/bin/psql/command.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright 2000 by PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.22 2000/02/20 14:28:20 petere Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.23 2000/02/21 02:05:12 ishii Exp $
77
*/
88
#include"postgres.h"
99
#include"command.h"
@@ -354,27 +354,32 @@ exec_command(const char *cmd,
354354
fputs("\n",fout);
355355
}
356356

357-
/* \encoding -- set client side encoding */
357+
/* \encoding -- set/show client side encoding */
358358
elseif (strcmp(cmd,"encoding")==0)
359359
{
360360
char*encoding=scan_option(&string,OT_NORMAL,NULL);
361361

362-
if (!encoding)
363-
puts(pg_encoding_to_char(pset.encoding));
364-
else
365-
{
362+
if (!encoding)
363+
/* show encoding */
364+
puts(pg_encoding_to_char(pset.encoding));
365+
else
366+
{
366367
#ifdefMULTIBYTE
367-
if (PQsetClientEncoding(pset.db,encoding)==-1)
368-
psql_error("%s: invalid encoding name\n",encoding);
368+
/* set encoding */
369+
if (PQsetClientEncoding(pset.db,encoding)==-1)
370+
psql_error("%s: invalid encoding name\n",encoding);
369371

370-
/* save encoding info into psql internal data */
371-
pset.encoding=PQclientEncoding(pset.db);
372-
SetVariable(pset.vars,"ENCODING",pg_encoding_to_char(pset.encoding));
372+
else
373+
{
374+
/* save encoding info into psql internal data */
375+
pset.encoding=PQclientEncoding(pset.db);
376+
SetVariable(pset.vars,"ENCODING",pg_encoding_to_char(pset.encoding));
377+
}
373378
#else
374-
psql_error("\\%s: multi-byte support is not enabled\n",cmd);
379+
psql_error("\\%s: multi-byte support is not enabled\n",cmd);
375380
#endif
376-
}
377-
free(encoding);
381+
free(encoding);
382+
}
378383
}
379384

380385
/* \f -- change field separator */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp