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

Commit63c3b99

Browse files
committed
Fix a couple of places where psql might fail to report a suitable error
if PQexec returns NULL. These don't seem significant enough to be worthback-patching, but they ought to get fixed ...
1 parentb9984ad commit63c3b99

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

‎src/bin/psql/common.c

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.139 2008/05/14 19:10:29 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/common.c,v 1.140 2008/08/16 01:36:35 tgl Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"common.h"
@@ -880,16 +880,20 @@ SendQuery(const char *query)
880880
/* If we made a temporary savepoint, possibly release/rollback */
881881
if (on_error_rollback_savepoint)
882882
{
883-
PGresult*svptres;
883+
constchar*svptcmd;
884884

885885
transaction_status=PQtransactionStatus(pset.db);
886886

887-
/* We always rollback on an error */
888887
if (transaction_status==PQTRANS_INERROR)
889-
svptres=PQexec(pset.db,"ROLLBACK TO pg_psql_temporary_savepoint");
890-
/* If they are no longer in a transaction, then do nothing */
888+
{
889+
/* We always rollback on an error */
890+
svptcmd="ROLLBACK TO pg_psql_temporary_savepoint";
891+
}
891892
elseif (transaction_status!=PQTRANS_INTRANS)
892-
svptres=NULL;
893+
{
894+
/* If they are no longer in a transaction, then do nothing */
895+
svptcmd=NULL;
896+
}
893897
else
894898
{
895899
/*
@@ -901,20 +905,27 @@ SendQuery(const char *query)
901905
(strcmp(PQcmdStatus(results),"SAVEPOINT")==0||
902906
strcmp(PQcmdStatus(results),"RELEASE")==0||
903907
strcmp(PQcmdStatus(results),"ROLLBACK")==0))
904-
svptres=NULL;
908+
svptcmd=NULL;
905909
else
906-
svptres=PQexec(pset.db,"RELEASE pg_psql_temporary_savepoint");
910+
svptcmd="RELEASE pg_psql_temporary_savepoint";
907911
}
908-
if (svptres&&PQresultStatus(svptres)!=PGRES_COMMAND_OK)
912+
913+
if (svptcmd)
909914
{
910-
psql_error("%s",PQerrorMessage(pset.db));
911-
PQclear(results);
915+
PGresult*svptres;
916+
917+
svptres=PQexec(pset.db,svptcmd);
918+
if (PQresultStatus(svptres)!=PGRES_COMMAND_OK)
919+
{
920+
psql_error("%s",PQerrorMessage(pset.db));
921+
PQclear(svptres);
922+
923+
PQclear(results);
924+
ResetCancelConn();
925+
return false;
926+
}
912927
PQclear(svptres);
913-
ResetCancelConn();
914-
return false;
915928
}
916-
917-
PQclear(svptres);
918929
}
919930

920931
PQclear(results);

‎src/bin/psql/tab-complete.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2008, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.170 2008/03/29 19:19:14 tgl Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.171 2008/08/16 01:36:35 tgl Exp $
77
*/
88

99
/*----------------------------------------------------------------------
@@ -2577,11 +2577,11 @@ exec_query(const char *query)
25772577

25782578
result=PQexec(pset.db,query);
25792579

2580-
if (result!=NULL&&PQresultStatus(result)!=PGRES_TUPLES_OK)
2580+
if (PQresultStatus(result)!=PGRES_TUPLES_OK)
25812581
{
25822582
#if0
2583-
psql_error("tab completion: %s failed -%s\n",
2584-
query,PQresStatus(PQresultStatus(result)));
2583+
psql_error("tab completion query failed: %s\nQuery was:\n%s\n",
2584+
PQerrorMessage(pset.db),query);
25852585
#endif
25862586
PQclear(result);
25872587
result=NULL;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp