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

Commita073a70

Browse files
committed
Have psql history save \e editor contents to history before query is
executed, like it did for 8.1.X.
1 parente4de635 commita073a70

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

‎src/bin/psql/mainloop.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2006, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.75 2006/06/04 04:35:55 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/mainloop.c,v 1.76 2006/06/05 03:55:00 momjian Exp $
77
*/
88
#include"postgres_fe.h"
99
#include"mainloop.h"
@@ -41,7 +41,7 @@ MainLoop(FILE *source)
4141
char*line;/* current line of input */
4242
intadded_nl_pos;
4343
boolsuccess;
44-
boolfirst_query_scan;
44+
boolline_saved_in_history;
4545

4646
volatileintsuccessResult=EXIT_SUCCESS;
4747
volatilebackslashResultslashCmdStatus=PSQL_CMD_UNKNOWN;
@@ -80,6 +80,8 @@ MainLoop(FILE *source)
8080
/* main loop to get queries and execute them */
8181
while (successResult==EXIT_SUCCESS)
8282
{
83+
line_saved_in_history= false;
84+
8385
/*
8486
* Welcome code for Control-C
8587
*/
@@ -154,6 +156,8 @@ MainLoop(FILE *source)
154156
*/
155157
pg_write_history(history_buf->data);
156158
pg_clear_history(history_buf);
159+
pg_write_history(line);
160+
line_saved_in_history= true;
157161
}
158162
}
159163
/* otherwise, get another line */
@@ -226,7 +230,6 @@ MainLoop(FILE *source)
226230
*/
227231
psql_scan_setup(scan_state,line,strlen(line));
228232
success= true;
229-
first_query_scan= true;
230233

231234
while (success|| !die_on_error)
232235
{
@@ -303,17 +306,16 @@ MainLoop(FILE *source)
303306
*down here so we can check for \g and other 'execute'
304307
*backslash commands, which should be appended.
305308
*/
306-
if (first_query_scan&&pset.cur_cmd_interactive)
309+
if (!line_saved_in_history&&pset.cur_cmd_interactive)
307310
{
308311
/* Sending a command (PSQL_CMD_SEND) zeros the length */
309312
if (scan_result==PSCAN_BACKSLASH&&history_buf->len!=0)
310313
pg_write_history(line);
311314
else
312315
pg_append_history(line,history_buf);
316+
line_saved_in_history= true;
313317
}
314318

315-
first_query_scan= false;
316-
317319
/* fall out of loop on \q or if lexer reached EOL */
318320
if (slashCmdStatus==PSQL_CMD_TERMINATE||
319321
scan_result==PSCAN_INCOMPLETE||

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp