tursodatabase / libsql-shell-go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

SQL runtime errors are missing a proper error message

CodingDoug opened this issue · comments

Any SQL that causes a problem during execution (not parsing) yields a generic error message that does not help resolve the problem. It should instead yield the actual SQLite error message. This happens for SQL_INPUT_ERROR and SQLITE_CONSTRAINT codes.

Examples:

create table t (x int) strict;
create table t (x int) strict;

The above should yield the SQLite code and error message:

SQL_INPUT_ERROR
SQL input error: table t already exists (at offset 13)

create table t (x int) strict;
insert into t values ('a');

The above should yield the SQLite code and error message:

SQLITE_CONSTRAINT
SQLite error: cannot store TEXT value in INT column t.x

Error cases are alerady outputting useful messages:

create table t (x int) strict;
create table t (x int) strict;

Error: table t already exists

create table t (x int) strict;
create table t (x int) strict;

Error: cannot store TEXT value in INT column t.x

Feel free to reopen if you think we need different error messages

The original request asks to also include the specific SQLlite error codes in the output, examples being SQL_INPUT_ERROR and SQLITE_CONSTRAINT above. These are easily searchable, and give more context to the problem at hand.

Unless I'm mistaken, these are provided in the API response from sqld.

@CodingDoug after furthers inspection this looks blocked

If I run

docker run -p 8080:8080 ghcr.io/libsql/sqld:latest

To create an instance of sqld, and then

curl --location 'http://127.0.0.1:8080' \
--header 'Content-Type: application/json' \
--data '{
    "statements": [
        {
            "q": "create table t(x int);"
        }
    ]
}'

I get the error, without the Result Code:

[{"error":"table t already exists in create table t(x int); at offset 13"}]

@WilsonNet Looks like a sqld bug to me. Can you please open a ticket on sqld.git so the issue isn't lost here in the comments?

The companion bug that was filed against sqld was closed.