edit() function should be disabled in batch mode

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

edit() function should be disabled in batch mode

Liyu L
With recent versions of sqlite3 (not seen with OSX Mojave 10.14.6 stock SQLite version 3.16.2 or before), a convenient function edit() was introduced. However it is not disabled for batch mode where it is never intended.

For batch mode it is preferable to keep backward compatible behavior to ease script maintenance.

Pre-existence behavior

$ sqlite3 testdb
SQLite version 3.16.2 2017-01-06 16:32:41
Enter ".help" for usage hints.
sqlite> UPDATE docs SET body=edit(body) WHERE name='report-15';
Error: no such function: edit
sqlite> ^D

$ sqlite3 -batch testdb
UPDATE docs SET body=edit(body) WHERE name='report-15';
Error: near line 1: no such function: edit
$

Current behavior:

$ sqlite3
SQLite version 3.28.0 2019-04-16 19:49:53
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> create table docs(name, body);
sqlite> UPDATE docs SET body=edit(body) WHERE name='report-15';
sqlite> ^C
sqlite>

$ sqlite3 -batch
create table docs(name, body);
.tables
docs
UPDATE docs SET body=edit(body) WHERE name='report-15';
(hang again and has to be killed by ^C)

This issue also impact certain ssh/telnet sessions.

-Liyu

PS: a minor and separate issue is there's no way to reset line number for error reporting. As a result one has to keep track of all the sql text lines in the session to pinpoint error. It is better to allow reset between queries. For example

$ sqlite3 -batch testdb
UPDATE docs SET body=edit(body) WHERE name='report-15';
Error: near line 1: no such function: edit
UPDATE docs SET body=edit(body) WHERE name='report-15';
Error: near line 2: no such function: edit
UPDATE docs SET body=edit(body) WHERE name='report-15';
Error: near line 3: no such function: edit
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users