SQLite User Forum

CLI fails to bind parameters in tabular output modes (3.33.0 pre-release)
Login

CLI fails to bind parameters in tabular output modes (3.33.0 pre-release)

(1) By jake on 2020-08-05 08:42:47 [source]

I've been playing with the new output modes from the upcoming 3.33.0 release and have discovered a bug when using tabular output modes (box/markdown/table/column).

The CLI tool does not bind parameters when using tabular output modes. Non-output queries also fail when in one of these modes.

This appears to be an issue in the following section of code (usage of sqlite3_get_table):

https://www.sqlite.org/src/artifact/352a0a63?ln=3050-3065

Examples using pre-release snapshot:

SQLite version 3.33.0 2020-07-31 23:34:53
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> .param init
sqlite> .param set $test 999
sqlite>
sqlite> --
sqlite> -- These modes work as expected
sqlite> --
sqlite> .mode ascii
sqlite> SELECT $test;
999sqlite> .mode csv
sqlite> SELECT $test;
999
sqlite> .mode html
sqlite> SELECT $test;
<TR><TD>999</TD>
</TR>
sqlite> .mode insert
sqlite> SELECT $test;
INSERT INTO "table" VALUES(999);
sqlite> .mode json
sqlite> SELECT $test;
[{"$test":999}]
sqlite> .mode line
sqlite> SELECT $test;
$test = 999
sqlite> .mode list
sqlite> SELECT $test;
999
sqlite> .mode quote
sqlite> SELECT $test;
999
sqlite> .mode tabs
sqlite> SELECT $test;
999
sqlite> .mode tcl
sqlite> SELECT $test;
"999"
sqlite>
sqlite> --
sqlite> -- The tabular modes do not work as expected (column mode does work in 3.32.3)
sqlite> --
sqlite> .mode box
sqlite> SELECT $test;
┌───────┐
│ $test │
├───────┤
│       │
└───────┘
sqlite> .mode markdown
sqlite> SELECT $test;
| $test |
|-------|
|       |
sqlite> .mode column
sqlite> SELECT $test;
$test
-----

sqlite> .mode table
sqlite> SELECT $test;
+-------+
| $test |
+-------+
|       |
+-------+
sqlite>
sqlite> --
sqlite> -- If we are in one of the tabular modes, then queries such as the following will also fail:
sqlite> --
sqlite> CREATE TEMPORARY TABLE t AS SELECT $test;
sqlite> .mode list
sqlite> SELECT * FROM t;
$test

sqlite>