Skip to content

Help wanted: testing our grammar parser #741

Closed

Description

@MKleusberg

Here's a task for all who want to contribute but don't feel ready to start C++-coding.

Our grammar parser needs some more stress-testing, I think. The grammar parser is the part that tries to understand the CREATE TABLE ... statements and extract all the information on the table. So testing it is as simple as creating a new database, adding a table (via SQL), opening it in the Edit Table dialog and see the SQL code it prints. If there is something missing, that's a bug. Or if you have a database and notice that some existing table isn't fully parsed, it's a bug, too, of course.

If you are more of a systematic person, you can check out the diagrams at https://sqlite.org/lang_createtable.html and try out the various combinations and keywords mentioned in there.

There are some features which we know are missing. These are:

  • Named constraints (names for unique/primary key/foreign key constraints)
  • Sorted indices (ASC/DESC in primary key/unique constraints)
  • The COLLATE keyword and all its uses
  • Primary keys with multiple columns in it

But there are certainly more 😃 So I want to encourage everybody who stumbles upon another issue to open a new issue for it.

Also there are some parts that our parser understands (multiple columns in a unique constraint for example) but you aren't able to create or edit using the UI - only using SQL. Every one of these is worth opening an issue, too 😉 Just make it clear whether it's a problem with the parser or the dialog.

Thanks to all helping to make the grammar parsing as complete as possible for the next release 😃

Activity

  1. MarqueIV commented on Aug 30, 2016

    @MarqueIV

    Not sure if this is related, but when modifying an existing table, adding a primary key to it, even after confirming that the data should support a primary key on the selected fields (i.e. no nulls and when running a group-by with a count on the fields, I never get anything but a '1') it just silently fails and doesn't add the key. No warnings, no errors, nothing. The dialog just gets dismissed and nothing actually happens. Same thing when I tried marking those columns as 'not null'.

    Since this is just a db of the public NJ Transit schedules (as imported from flat CSV files) I can send it along so you can try it yourself if interested. (It's 20+ mb so I figured I'd ask first. If so, lemme know how you want me to send it to you.)

  2. justinclift commented on Aug 31, 2016

    @justinclift
    Member

    @MarqueIV With the behaviour you're describing, how recent a build of DB4S is that?

    Asking because @MKleusberg has been improving the constraints handling code over the last few days, including adding a warning message when our parser can't understand all of the constraints.

    If you've the time/interest, trying the nightly build out (tomorrow) and seeing if that problem still happens would be useful. 😄

  3. MarqueIV commented on Aug 31, 2016

    @MarqueIV

    Definitely have both the time and the interest. Again, your product is an integral part of me being able to create mine so anything I can do to help I do so gladly! :) Just post the link here on where I need to go to get the daily to test and I'll let you know, just like I did with the black-on-black browsing issue.

  4. MarqueIV commented on Aug 31, 2016

    @MarqueIV

    Oh... and it's your just-released build... again, the one you linked to in the other question about preferences and colors.

  5. justinclift commented on Aug 31, 2016

    @justinclift
    Member

    Awesome. 😄

    The nightly builds for OSX are here:

        http://nightlies.sqlitebrowser.org/osx/

  6. MKleusberg commented on Sep 6, 2016

    @MKleusberg
    MemberAuthor

    @MarqueIV Yes, this might be related. But either way it definitely sounds like a bug 😃 Unfortunately I can't reproduce this using one of my test database. So I'm afraid you have to send me that 20MB file; maybe you can zip it though or upload it somewhere.

  7. chrisjlocke commented on Sep 9, 2016

    @chrisjlocke
    Member

    In the latest nightly (9 Sep) the parser seems broken for multiple lines...

    image

    This occurs if you click the 'Execute current line' button. Previous versions parsed the line to be up to the next semi colon.
    This only seems a recent 'breakage'...

  8. justinclift commented on Sep 10, 2016

    @justinclift
    Member

    It might be from this commit by @revolter yesterday: 55d8905

  9. chrisjlocke commented on Sep 10, 2016

    @chrisjlocke
    Member

    Oops, now I feel guilty...:wink:

  10. revolter commented on Sep 19, 2016

    @revolter
    Member

    Ups, sorry. So should a line mean a text line or an SQL line (up until the first semi colon)?

  11. chrisjlocke commented on Sep 19, 2016

    @chrisjlocke
    Member

    A line should be up to a semi-colon, so lines can be split. Its more readable creating a table like:
    create table blah (
    id text,
    dinDang real,
    piddlePop integer,
    diddleIDo text);

    but thats just me... 😉

  12. bernardosulzbach commented on Sep 19, 2016

    @bernardosulzbach
    Contributor

    So should a line mean a text line or an SQL line (up until the first semi colon)?

    Pretty much what was said above. Production SQLite code has many queries spanning multiple lines.

  13. revolter commented on Sep 19, 2016

    @revolter
    Member

    I'm working now on a fix.

  14. revolter commented on Sep 19, 2016

    @revolter
    Member

    Well, It didn't work ok in 3.8.0 too. I'm working of a proper fix.

  15. TWiStErRob commented on Jan 6, 2017

    @TWiStErRob
  16. MKleusberg commented on Sep 4, 2019

    @MKleusberg
    MemberAuthor

    Earlier today I noticed that no table and no index can be parsed which uses "/" for divisions in any expression. So even this simple table definition won't work:

    CREATE TABLE test(a INTEGER CHECK(a / 2 = 1));

    We had this issue from day 1 using the grammar parser, that's for more than six years now. This probably confirms the long-held theory that division is some sort of seldom-used higher mathematics.

    That made me curious. So I'll start collecting other missing bits and pieces in our grammar parser, especially in the expression rule, in this comment here 😉

    • Divisions in expressions don't work
    • BLOB literals don't work (see here)
    • The DISTINCT keyword is not recognised (see here in the function call part of the picture)
    • Unicode characters don't work (see issue Browse Data tab shows no fields and no data #60)
    • Hexadecimal numbers don't work (see here)
    • Bind parameters are not recognised (see here). Luckily we will never see them in our current use cases
    • CAST expressions (see here in the cast part of the picture) pass the parser but are scrambled when running through the AST. In the Edit Table dialog they are completely broken.
    • NOTNULL and ISNULL (without spaces) don't work (see here in the ISNULL branch of the picture)

    The list is probably going to grow. Except for the Unicode problem, this can all be fixed rather easily but it makes me wonder once again whether it would be better to rewrite the whole thing.

  17. MKleusberg commented on Sep 12, 2019

    @MKleusberg
    MemberAuthor

    I'm going to close this issue since #1990 is a more up-to-date now. All problems which are mentioned in this issue should be fixed in the new parser 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions