|
3 | 3 | *
|
4 | 4 | * Copyright 2000 by PostgreSQL Global Development Group
|
5 | 5 | *
|
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 $ |
7 | 7 | */
|
8 | 8 | #include"postgres.h"
|
9 | 9 | #include"command.h"
|
@@ -354,27 +354,32 @@ exec_command(const char *cmd,
|
354 | 354 | fputs("\n",fout);
|
355 | 355 | }
|
356 | 356 |
|
357 |
| -/* \encoding -- set client side encoding */ |
| 357 | +/* \encoding -- set/show client side encoding */ |
358 | 358 | elseif (strcmp(cmd,"encoding")==0)
|
359 | 359 | {
|
360 | 360 | char*encoding=scan_option(&string,OT_NORMAL,NULL);
|
361 | 361 |
|
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 | +{ |
366 | 367 | #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); |
369 | 371 |
|
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 | +} |
373 | 378 | #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); |
375 | 380 | #endif
|
376 |
| -} |
377 |
| -free(encoding); |
| 381 | +free(encoding); |
| 382 | +} |
378 | 383 | }
|
379 | 384 |
|
380 | 385 | /* \f -- change field separator */
|
|