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

feat: Add set operation (select ... union select ...) for insert stat… #200

Merged
merged 11 commits into from
Oct 16, 2023

Conversation

antoineB
Copy link
Contributor

@antoineB antoineB commented Oct 8, 2023

…ements.

Copy link
Collaborator

@dmfay dmfay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

something interesting's happening here: state count is much higher in this branch (7776 vs 4536 on main), which I think is largely down to the addition of function argument modes -- invocation punches way above its weight class (big increases also in binary_expression, between_expression, implicit_cast, and a bunch of types like double and tinyint -- maybe due to the time additions?). Large state count has dropped by a lot, though, 775 in main to 333 here, and build time from an empty src/ is actually around ten seconds faster on my machine. Do you know what's happening here?

also if you have more changes in the mean time please create separate pull requests! this one's getting unwieldy

grammar.js Show resolved Hide resolved
grammar.js Outdated
@@ -551,8 +558,21 @@ module.exports = grammar({
nchar: $ => parametric_type($, $.keyword_nchar),
nvarchar: $ => parametric_type($, $.keyword_nvarchar),

_time_zone: $ => seq(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_time_zone: $ => seq(
_include_time_zone: $ => seq(

this is clearer imo, but I definitely like the more detailed deconstruction of timestamps overall!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fine by me.

@antoineB
Copy link
Contributor Author

How do you get the number of parser states ?

@matthias-Q
Copy link
Collaborator

The state count is shown in the generated parser.c

@dmfay
Copy link
Collaborator

dmfay commented Oct 12, 2023

yeah, head -18 src/parser.c shows you all the potentially useful counts.

@antoineB
Copy link
Contributor Author

Here is all the numbers

f75b8ea
1,4M target/parser.so
#define LANGUAGE_VERSION 14
#define STATE_COUNT 7637
#define LARGE_STATE_COUNT 328
#define SYMBOL_COUNT 702
#define ALIAS_COUNT 0
#define TOKEN_COUNT 407
#define EXTERNAL_TOKEN_COUNT 0
#define FIELD_COUNT 42
#define MAX_ALIAS_SEQUENCE_LENGTH 16
#define PRODUCTION_ID_COUNT 197

531d243
1,4M target/parser.so
#define LANGUAGE_VERSION 14
#define STATE_COUNT 7528
#define LARGE_STATE_COUNT 323
#define SYMBOL_COUNT 702
#define ALIAS_COUNT 0
#define TOKEN_COUNT 407
#define EXTERNAL_TOKEN_COUNT 0
#define FIELD_COUNT 42
#define MAX_ALIAS_SEQUENCE_LENGTH 16
#define PRODUCTION_ID_COUNT 190

bec206c
1,4M target/parser.so
#define LANGUAGE_VERSION 14
#define STATE_COUNT 7362
#define LARGE_STATE_COUNT 317
#define SYMBOL_COUNT 698
#define ALIAS_COUNT 0
#define TOKEN_COUNT 406
#define EXTERNAL_TOKEN_COUNT 0
#define FIELD_COUNT 42
#define MAX_ALIAS_SEQUENCE_LENGTH 16
#define PRODUCTION_ID_COUNT 190

c223823
1,4M target/parser.so
#define LANGUAGE_VERSION 14
#define STATE_COUNT 7362
#define LARGE_STATE_COUNT 317
#define SYMBOL_COUNT 698
#define ALIAS_COUNT 0
#define TOKEN_COUNT 406
#define EXTERNAL_TOKEN_COUNT 0
#define FIELD_COUNT 42
#define MAX_ALIAS_SEQUENCE_LENGTH 16
#define PRODUCTION_ID_COUNT 190

1e3f464
1,4M target/parser.so
#define LANGUAGE_VERSION 14
#define STATE_COUNT 7362
#define LARGE_STATE_COUNT 317
#define SYMBOL_COUNT 698
#define ALIAS_COUNT 0
#define TOKEN_COUNT 406
#define EXTERNAL_TOKEN_COUNT 0
#define FIELD_COUNT 42
#define MAX_ALIAS_SEQUENCE_LENGTH 16
#define PRODUCTION_ID_COUNT 190

bde914f
1,4M target/parser.so
#define LANGUAGE_VERSION 14
#define STATE_COUNT 7362
#define LARGE_STATE_COUNT 317
#define SYMBOL_COUNT 698
#define ALIAS_COUNT 0
#define TOKEN_COUNT 406
#define EXTERNAL_TOKEN_COUNT 0
#define FIELD_COUNT 42
#define MAX_ALIAS_SEQUENCE_LENGTH 16
#define PRODUCTION_ID_COUNT 190

1a2b0da
1,4M target/parser.so
#define LANGUAGE_VERSION 14
#define STATE_COUNT 7373
#define LARGE_STATE_COUNT 322
#define SYMBOL_COUNT 696
#define ALIAS_COUNT 0
#define TOKEN_COUNT 406
#define EXTERNAL_TOKEN_COUNT 0
#define FIELD_COUNT 42
#define MAX_ALIAS_SEQUENCE_LENGTH 16
#define PRODUCTION_ID_COUNT 190

970b548
1,6M target/parser.so
#define LANGUAGE_VERSION 14
#define STATE_COUNT 4590
#define LARGE_STATE_COUNT 787
#define SYMBOL_COUNT 670
#define ALIAS_COUNT 0
#define TOKEN_COUNT 386
#define EXTERNAL_TOKEN_COUNT 0
#define FIELD_COUNT 42
#define MAX_ALIAS_SEQUENCE_LENGTH 16
#define PRODUCTION_ID_COUNT 190

385aff4 (main)
1,5M target/parser.so
#define LANGUAGE_VERSION 14
#define STATE_COUNT 4536
#define LARGE_STATE_COUNT 775
#define SYMBOL_COUNT 670
#define ALIAS_COUNT 0
#define TOKEN_COUNT 386
#define EXTERNAL_TOKEN_COUNT 0
#define FIELD_COUNT 42
#define MAX_ALIAS_SEQUENCE_LENGTH 16
#define PRODUCTION_ID_COUNT 190

Copy link
Collaborator

@matthias-Q matthias-Q left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, thanks for you PR. I have made some remarks. Would be nice If you could address them.

For future PRs, I would be nice if you could limit the scope of the PR to one topic and don't let the PR get too large. I makes it hard to review. If I am not mistaken, most of the suggested changes have nothing to do with the title of the PR either. A (very short) description of what you want to address/change/implement is also welcome.

grammar.js Outdated
keyword_session: _ => make_keyword("session"),
keyword_isolation: _ => make_keyword("isolation"),
keyword_level: _ => make_keyword("level"),
keyword_serializable: _ => make_keyword("seria"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this called seria? I have search pg and mariadb docs and was not able to find this. Can you give me an example?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a typo.

grammar.js Outdated
Comment on lines 277 to 278
keyword_repeatable: _ => make_keyword("repeatable: _ ="),
keyword_read: _ => make_keyword("read: _ =>"),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, I was not able to fin this structure in PG and MariaDB. Also separating tokens in the keyword statement is not the right way. In SQL there can be multiple spaces/tabs between tokens.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before a keyboard macro typo.

grammar.js Show resolved Hide resolved
@@ -735,6 +757,31 @@ module.exports = grammar({
),
),

_argmode: $ => choice(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you add one or two test cases for this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -904,6 +961,54 @@ module.exports = grammar({
),
),

reset_statement: $ => seq(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, can you add test cases here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

grammar.js Show resolved Hide resolved
test/corpus/insert.txt Show resolved Hide resolved
Add test to set/reset statement.
Correct keyword typos.
Add test on function arguments with default value and IN/OUT mode.
Copy link
Collaborator

@dmfay dmfay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@matthias-Q if you're alright with the current state feel free to land it, or let me know and I can later 🚀

@matthias-Q matthias-Q merged commit 2b782fd into DerekStride:main Oct 16, 2023
4 checks passed
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

Successfully merging this pull request may close these issues.

3 participants