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

Commit626e6ed

Browse files
committed
Improve behavior of \watch with non-tuple-returning commands.
Print the command tag if we get PGRES_COMMAND_OK, and throw an error forother cases. Per gripe from Michael Paquier.In passing, add an fflush(), just to be real sure the output appearsbefore we sleep.
1 parent083d8fa commit626e6ed

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

‎src/bin/psql/command.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,18 +2648,33 @@ do_watch(PQExpBuffer query_buf, long sleep)
26482648
printQuery(res,&myopt,pset.queryFout,pset.logfile);
26492649
break;
26502650

2651+
casePGRES_COMMAND_OK:
2652+
fprintf(pset.queryFout,"%s\n%s\n\n",title,PQcmdStatus(res));
2653+
break;
2654+
26512655
casePGRES_EMPTY_QUERY:
26522656
psql_error(_("\\watch cannot be used with an empty query\n"));
26532657
PQclear(res);
26542658
return false;
26552659

2660+
casePGRES_COPY_OUT:
2661+
casePGRES_COPY_IN:
2662+
casePGRES_COPY_BOTH:
2663+
psql_error(_("\\watch cannot be used with COPY\n"));
2664+
PQclear(res);
2665+
return false;
2666+
26562667
default:
2657-
/* should we fail for non-tuple-result commands? */
2658-
break;
2668+
/* other cases should have been handled by PSQLexec */
2669+
psql_error(_("unexpected result status for \\watch\n"));
2670+
PQclear(res);
2671+
return false;
26592672
}
26602673

26612674
PQclear(res);
26622675

2676+
fflush(pset.queryFout);
2677+
26632678
/*
26642679
* Set up cancellation of 'watch' via SIGINT. We redo this each time
26652680
* through the loop since it's conceivable something inside PSQLexec

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp