*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.101 2003/08/04 23:59:39 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/command.c,v 1.102 2003/09/16 17:59:02 tgl Exp $
*/
#include "postgres_fe.h"
#include "command.h"
if (!encoding)
{
- /* show encoding --- first check for change sent from server */
- if (pset.encoding != PQclientEncoding(pset.db) &&
- PQclientEncoding(pset.db) >= 0)
- {
- pset.encoding = PQclientEncoding(pset.db);
- pset.popt.topt.encoding = pset.encoding;
- SetVariable(pset.vars, "ENCODING",
- pg_encoding_to_char(pset.encoding));
- }
+ /* show encoding */
puts(pg_encoding_to_char(pset.encoding));
}
else
*
* Copyright (c) 2000-2003, PostgreSQL Global Development Group
*
- * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.73 2003/09/03 22:05:08 petere Exp $
+ * $Header: /cvsroot/pgsql/src/bin/psql/common.c,v 1.74 2003/09/16 17:59:02 tgl Exp $
*/
#include "postgres_fe.h"
#include "common.h"
#include "prompt.h"
#include "print.h"
#include "mainloop.h"
+#include "mb/pg_wchar.h"
/* Workarounds for Windows */
* In autocommit-off mode, a new transaction block is started if start_xact
* is true; nothing special is done when start_xact is false. Typically,
* start_xact = false is used for SELECTs and explicit BEGIN/COMMIT commands.
+ *
+ * Note: we don't bother to check PQclientEncoding; it is assumed that no
+ * caller uses this path to issue "SET CLIENT_ENCODING".
*/
PGresult *
PSQLexec(const char *query, bool start_xact)
/*
* PrintNotifications: check for asynchronous notifications, and print them out
- *
*/
static void
PrintNotifications(void)
{
fprintf(pset.queryFout, gettext("Asynchronous notification \"%s\" received from server process with PID %d.\n"),
notify->relname, notify->be_pid);
- PQfreemem(notify);
fflush(pset.queryFout);
+ PQfreemem(notify);
}
}
OK = (AcceptResult(results) && PrintQueryResults(results, &before, &after));
PQclear(results);
+ /* check for events that may occur during query execution */
+
+ if (pset.encoding != PQclientEncoding(pset.db) &&
+ PQclientEncoding(pset.db) >= 0)
+ {
+ /* track effects of SET CLIENT_ENCODING */
+ pset.encoding = PQclientEncoding(pset.db);
+ pset.popt.topt.encoding = pset.encoding;
+ SetVariable(pset.vars, "ENCODING",
+ pg_encoding_to_char(pset.encoding));
+ }
+
PrintNotifications();
+
return OK;
}