Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
0e6d72db
Commit
0e6d72db
authored
Jan 14, 2000
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make PSQLexec's behavior on loss of connection more reasonable;
report original error before attempting reset, not after.
parent
19ff2e4d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
25 deletions
+36
-25
src/bin/psql/common.c
src/bin/psql/common.c
+36
-25
No files found.
src/bin/psql/common.c
View file @
0e6d72db
...
...
@@ -364,34 +364,43 @@ PSQLexec(PsqlSettings *pset, const char *query)
pqsignal
(
SIGINT
,
SIG_DFL
);
/* now control-C is back to normal */
if
(
PQstatus
(
pset
->
db
)
==
CONNECTION_BAD
)
{
fputs
(
"The connection to the server was lost. Attempting reset: "
,
stderr
);
PQreset
(
pset
->
db
);
if
(
PQstatus
(
pset
->
db
)
==
CONNECTION_BAD
)
{
fputs
(
"Failed.
\n
"
,
stderr
);
PQfinish
(
pset
->
db
);
PQclear
(
res
);
pset
->
db
=
NULL
;
return
NULL
;
}
else
fputs
(
"Succeeded.
\n
"
,
stderr
);
}
if
(
res
&&
(
PQresultStatus
(
res
)
==
PGRES_COMMAND_OK
||
PQresultStatus
(
res
)
==
PGRES_TUPLES_OK
||
PQresultStatus
(
res
)
==
PGRES_COPY_IN
||
PQresultStatus
(
res
)
==
PGRES_COPY_OUT
)
)
return
res
;
else
if
(
PQstatus
(
pset
->
db
)
==
CONNECTION_OK
)
{
if
(
res
&&
(
PQresultStatus
(
res
)
==
PGRES_COMMAND_OK
||
PQresultStatus
(
res
)
==
PGRES_TUPLES_OK
||
PQresultStatus
(
res
)
==
PGRES_COPY_IN
||
PQresultStatus
(
res
)
==
PGRES_COPY_OUT
)
)
return
res
;
/* Normal success case... */
/* Normal failure case --- display error and return NULL */
fputs
(
PQerrorMessage
(
pset
->
db
),
pset
->
queryFout
);
PQclear
(
res
);
return
NULL
;
}
/* Lost connection. Report whatever libpq has to say,
* then consider recovery.
*/
fputs
(
PQerrorMessage
(
pset
->
db
),
pset
->
queryFout
);
PQclear
(
res
);
if
(
!
pset
->
cur_cmd_interactive
)
{
fprintf
(
stderr
,
"%s: connection to server was lost
\n
"
,
pset
->
progname
);
exit
(
EXIT_BADCONN
);
}
fputs
(
"The connection to the server was lost. Attempting reset: "
,
stderr
);
fflush
(
stderr
);
PQreset
(
pset
->
db
);
if
(
PQstatus
(
pset
->
db
)
==
CONNECTION_BAD
)
{
fputs
(
"Failed.
\n
"
,
stderr
);
PQfinish
(
pset
->
db
);
pset
->
db
=
NULL
;
}
else
fputs
(
"Succeeded.
\n
"
,
stderr
);
return
NULL
;
}
...
...
@@ -517,17 +526,19 @@ SendQuery(PsqlSettings *pset, const char *query)
{
if
(
!
pset
->
cur_cmd_interactive
)
{
fprintf
(
stderr
,
"%s: connection to server was lost"
,
pset
->
progname
);
fprintf
(
stderr
,
"%s: connection to server was lost
\n
"
,
pset
->
progname
);
exit
(
EXIT_BADCONN
);
}
fputs
(
"The connection to the server was lost. Attempting reset: "
,
stderr
);
fflush
(
stderr
);
PQreset
(
pset
->
db
);
if
(
PQstatus
(
pset
->
db
)
==
CONNECTION_BAD
)
{
fputs
(
"Failed.
\n
"
,
stderr
);
PQfinish
(
pset
->
db
);
PQclear
(
results
);
pset
->
db
=
NULL
;
PQclear
(
results
);
return
false
;
}
else
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment