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

Commitb034369

Browse files
committed
psql: Catch and report errors while printing result table
Errors (for example I/O errors or disk full) while printing out resulttables were completely ignored, which could result in silentlytruncated output in scripts, for example. Fix by adding some basicerror checking and reporting.Author: Daniel Verite <daniel@manitou-mail.org>Author: David Zhang <david.zhang@highgo.ca>Discussion:https://www.postgresql.org/message-id/flat/9a0b3c8d-ee14-4b1d-9d0a-2c993bdabacc@manitou-mail.org
1 parent85f6b49 commitb034369

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

‎src/bin/psql/common.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,7 @@ static bool
708708
PrintQueryTuples(constPGresult*results)
709709
{
710710
printQueryOptmy_popt=pset.popt;
711+
boolresult= true;
711712

712713
/* one-shot expanded output requested via \gx */
713714
if (pset.g_expanded)
@@ -725,6 +726,11 @@ PrintQueryTuples(const PGresult *results)
725726
disable_sigpipe_trap();
726727

727728
printQuery(results,&my_popt,fout, false,pset.logfile);
729+
if (ferror(fout))
730+
{
731+
pg_log_error("could not print result table: %m");
732+
result= false;
733+
}
728734

729735
if (is_pipe)
730736
{
@@ -735,9 +741,16 @@ PrintQueryTuples(const PGresult *results)
735741
fclose(fout);
736742
}
737743
else
744+
{
738745
printQuery(results,&my_popt,pset.queryFout, false,pset.logfile);
746+
if (ferror(pset.queryFout))
747+
{
748+
pg_log_error("could not print result table: %m");
749+
result= false;
750+
}
751+
}
739752

740-
returntrue;
753+
returnresult;
741754
}
742755

743756

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp