Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SQL runtime errors are missing a proper error message #128

Open
CodingDoug opened this issue Jun 28, 2023 · 5 comments
Open

SQL runtime errors are missing a proper error message #128

CodingDoug opened this issue Jun 28, 2023 · 5 comments
Assignees

Comments

@CodingDoug
Copy link
Contributor

CodingDoug commented Jun 28, 2023

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

@WilsonNet
Copy link
Contributor

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

@CodingDoug
Copy link
Contributor Author

CodingDoug commented Aug 12, 2023

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 CodingDoug reopened this Aug 12, 2023
@WilsonNet
Copy link
Contributor

WilsonNet commented Aug 15, 2023

@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"}]

@penberg
Copy link
Contributor

penberg commented Aug 15, 2023

@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?

@CodingDoug
Copy link
Contributor Author

The companion bug that was filed against sqld was closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants