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

Commitcb94305

Browse files
committed
psql: Reset query buffer of \e, \ef and \ev on error
If any of these commands fail during editing or pre-processing, thecommand stored in the query buffer would remain around without beingexecuted immediately as PSQL_CMD_ERROR is returned as status. The nextcommand provided by the user would run it, likely causing failures asthis could include silently some of the contents generated automaticallyfor views or functions.The problems would be different depending on the psql meta-command used:- For \ev and \ef, some errors can happen in a predictable way whiledoing an object lookup or while creating an object command. A failurewhile editing is equally problematic, but the class of failureshappening in the code path of do_edit() are unlikely. The query resetis kept in exec_command_ef_ev() as a query may be unchanged.- For \e, error can happen while editing.In both cases, the query buffer is reset on error for an incorrect filenumber provided, whose value check is done before filling up the querybuffer.This is a slight change of behavior compared to the past for some of thepredictable error patterns for \ev and \ef, so for now I have made thechoice to not backpatch this commit (argument particularly available forv11 that's going to be EOL'd soon). Perhaps this could be revisitedlater depending on the feedback of this new behavior.Author: Ryoga Yoshida, Michael PaquierReviewed-by: Aleksander Alekseev, Kyotaro HoriguchiDiscussion:https://postgr.es/m/01419622d84ef093fd4fe585520bf03c@oss.nttdata.com
1 parent9bfd44b commitcb94305

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎src/bin/psql/command.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,14 @@ exec_command_edit(PsqlScanState scan_state, bool active_branch,
11271127
else
11281128
status=PSQL_CMD_ERROR;
11291129
}
1130+
1131+
/*
1132+
* On error while editing or if specifying an incorrect line
1133+
* number, reset the query buffer.
1134+
*/
1135+
if (status==PSQL_CMD_ERROR)
1136+
resetPQExpBuffer(query_buf);
1137+
11301138
free(fname);
11311139
free(ln);
11321140
}
@@ -1239,6 +1247,13 @@ exec_command_ef_ev(PsqlScanState scan_state, bool active_branch,
12391247
status=PSQL_CMD_NEWEDIT;
12401248
}
12411249

1250+
/*
1251+
* On error while doing object lookup or while editing, or if
1252+
* specifying an incorrect line number, reset the query buffer.
1253+
*/
1254+
if (status==PSQL_CMD_ERROR)
1255+
resetPQExpBuffer(query_buf);
1256+
12421257
free(obj_desc);
12431258
}
12441259
else

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp