pgsql: psql: Reset query buffer of \e, \ef and \ev on error

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема pgsql: psql: Reset query buffer of \e, \ef and \ev on error
Дата
Msg-id E1qil8v-004rFw-Qt@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
psql: Reset query buffer of \e, \ef and \ev on error

If any of these commands fail during editing or pre-processing, the
command stored in the query buffer would remain around without being
executed immediately as PSQL_CMD_ERROR is returned as status.  The next
command provided by the user would run it, likely causing failures as
this could include silently some of the contents generated automatically
for 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 while
doing an object lookup or while creating an object command.  A failure
while editing is equally problematic, but the class of failures
happening in the code path of do_edit() are unlikely.  The query reset
is 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 file
number provided, whose value check is done before filling up the query
buffer.

This is a slight change of behavior compared to the past for some of the
predictable error patterns for \ev and \ef, so for now I have made the
choice to not backpatch this commit (argument particularly available for
v11 that's going to be EOL'd soon).  Perhaps this could be revisited
later depending on the feedback of this new behavior.

Author: Ryoga Yoshida, Michael Paquier
Reviewed-by: Aleksander Alekseev, Kyotaro Horiguchi
Discussion: https://postgr.es/m/01419622d84ef093fd4fe585520bf03c@oss.nttdata.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/cb943054f3f6d67c858dd63192afaa488f8cb51e

Modified Files
--------------
src/bin/psql/command.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Nathan Bossart
Дата:
Сообщение: pgsql: Convert pg_restore's ready_list to a priority queue.
Следующее
От: Michael Paquier
Дата:
Сообщение: pgsql: Fix typos in pgoutput.c