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

Commit7e06dbe

Browse files
committed
Make psql correctly track the effects of SET CLIENT_ENCODING commands.
I thought I'd fixed this earlier, but I didn't get it right ...
1 parent7b05ef5 commit7e06dbe

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

‎src/bin/psql/command.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.101 2003/08/04 23:59:39 tgl Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.102 2003/09/16 17:59:02 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"command.h"
@@ -458,15 +458,7 @@ exec_command(const char *cmd,
458458

459459
if (!encoding)
460460
{
461-
/* show encoding --- first check for change sent from server */
462-
if (pset.encoding!=PQclientEncoding(pset.db)&&
463-
PQclientEncoding(pset.db) >=0)
464-
{
465-
pset.encoding=PQclientEncoding(pset.db);
466-
pset.popt.topt.encoding=pset.encoding;
467-
SetVariable(pset.vars,"ENCODING",
468-
pg_encoding_to_char(pset.encoding));
469-
}
461+
/* show encoding */
470462
puts(pg_encoding_to_char(pset.encoding));
471463
}
472464
else

‎src/bin/psql/common.c

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
55
*
6-
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.73 2003/09/03 22:05:08 petere Exp $
6+
* $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.74 2003/09/16 17:59:02 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"common.h"
@@ -33,6 +33,7 @@
3333
#include"prompt.h"
3434
#include"print.h"
3535
#include"mainloop.h"
36+
#include"mb/pg_wchar.h"
3637

3738

3839
/* Workarounds for Windows */
@@ -360,6 +361,9 @@ AcceptResult(const PGresult *result)
360361
* In autocommit-off mode, a new transaction block is started if start_xact
361362
* is true; nothing special is done when start_xact is false. Typically,
362363
* start_xact = false is used for SELECTs and explicit BEGIN/COMMIT commands.
364+
*
365+
* Note: we don't bother to check PQclientEncoding; it is assumed that no
366+
* caller uses this path to issue "SET CLIENT_ENCODING".
363367
*/
364368
PGresult*
365369
PSQLexec(constchar*query,boolstart_xact)
@@ -416,7 +420,6 @@ PSQLexec(const char *query, bool start_xact)
416420

417421
/*
418422
* PrintNotifications: check for asynchronous notifications, and print them out
419-
*
420423
*/
421424
staticvoid
422425
PrintNotifications(void)
@@ -427,8 +430,8 @@ PrintNotifications(void)
427430
{
428431
fprintf(pset.queryFout,gettext("Asynchronous notification \"%s\" received from server process with PID %d.\n"),
429432
notify->relname,notify->be_pid);
430-
PQfreemem(notify);
431433
fflush(pset.queryFout);
434+
PQfreemem(notify);
432435
}
433436
}
434437

@@ -625,7 +628,20 @@ SendQuery(const char *query)
625628
OK= (AcceptResult(results)&&PrintQueryResults(results,&before,&after));
626629
PQclear(results);
627630

631+
/* check for events that may occur during query execution */
632+
633+
if (pset.encoding!=PQclientEncoding(pset.db)&&
634+
PQclientEncoding(pset.db) >=0)
635+
{
636+
/* track effects of SET CLIENT_ENCODING */
637+
pset.encoding=PQclientEncoding(pset.db);
638+
pset.popt.topt.encoding=pset.encoding;
639+
SetVariable(pset.vars,"ENCODING",
640+
pg_encoding_to_char(pset.encoding));
641+
}
642+
628643
PrintNotifications();
644+
629645
returnOK;
630646
}
631647

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp