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

Commit9138922

Browse files
committed
psql: give ^D hint for \q in place where \q is ignored
Also add comment on why exit/quit are not documented.Discussion:https://postgr.es/m/20180202053928.GA13472@momjian.us
1 parent5c9f256 commit9138922

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

‎src/bin/psql/mainloop.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ MainLoop(FILE *source)
223223
char*rest_of_line=NULL;
224224
boolfound_help= false;
225225
boolfound_exit_or_quit= false;
226+
boolfound_q= false;
226227

227228
/* Search for the words we recognize; must be first word */
228229
if (pg_strncasecmp(first_word,"help",4)==0)
@@ -237,10 +238,18 @@ MainLoop(FILE *source)
237238
found_exit_or_quit= true;
238239
}
239240

241+
elseif (strncmp(first_word,"\\q",2)==0)
242+
{
243+
rest_of_line=first_word+2;
244+
found_q= true;
245+
}
246+
240247
/*
241248
* If we found a command word, check whether the rest of the line
242249
* contains only whitespace plus maybe one semicolon. If not,
243-
* ignore the command word after all.
250+
* ignore the command word after all. These commands are only
251+
* for compatibility with other SQL clients and are not
252+
* documented.
244253
*/
245254
if (rest_of_line!=NULL)
246255
{
@@ -288,6 +297,7 @@ MainLoop(FILE *source)
288297
continue;
289298
}
290299
}
300+
291301
/*
292302
* "quit" and "exit" are only commands when the query buffer is
293303
* empty, but we emit a one-line message even when it isn't to
@@ -318,6 +328,21 @@ MainLoop(FILE *source)
318328
break;
319329
}
320330
}
331+
332+
/*
333+
* If they typed "\q" in a place where "\q" is not active,
334+
* supply a hint. The text is still added to the query
335+
* buffer.
336+
*/
337+
if (found_q&&query_buf->len!=0&&
338+
prompt_status!=PROMPT_READY&&
339+
prompt_status!=PROMPT_CONTINUE&&
340+
prompt_status!=PROMPT_PAREN)
341+
#ifndefWIN32
342+
puts(_("Use control-D to quit."));
343+
#else
344+
puts(_("Use control-C to quit."));
345+
#endif
321346
}
322347

323348
/* echo back if flag is set, unless interactive */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp