SQLite Forum

.read command breaks on reading from named pipes
Login

.read command breaks on reading from named pipes

(1) By Daniƫl van de Giessen (DvdGiessen) on 2021-09-13 21:54:42 [source]

In check-in 6d258c3c7ecafa11 the ".read" command added a check to not error on directories, by checking if the file is a regular file.

However, there are other types of files one might want to read, for example a named pipe.

Use case for this is generating SQL on the fly and piping it to the sqlite executable. It is a bit more flexible compared to the .read '|script.sh' approach.

Minimal reproduction:

sqlite3 :memory: ".read "<(echo "SELECT 1;")

Run with for example bash or any other shell that supports process substitution.

On older versions, this would correctly print 1. Now we instead get Error: cannot open "/dev/fd/63".

Suggested fix would be to replace the notNormalFile() function with one that also accepts named pipes.

(Perhaps other people have use cases for even more unsual types such as character devices? Transmitting SQL commands straight over a serial port into sqlite seems funky, but I guess in good Unix tradition we should give people the freedom to shoot themselves in the foot. :) )

(2) By Larry Brasfield (larrybr) on 2021-09-13 23:15:24 in reply to 1 [link] [source]

This modification should cure that woe. Please let me know if that is not the case.