-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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: make ParseQualifiedTableName do what it's meant to do #22577
Conversation
d49b601
to
87c3bcd
Compare
Prior to this patch, ParseQualifiedTableName() was using ParseTableNameWithIndex and thus was overly generous in the syntax it accepted. Worse than that, it would even silently drop the index part, so one could e.g. compute `nextval('someseq@invalidindex')` without error. This patch corrects this oversight by ensuring the method only parses table names. Release note (bug fix): various primitives that expect table names as argument now properly reject invalid table names.
87c3bcd
to
e3eb829
Compare
pkg/sql/parser/parse.go, line 105 at r1 (raw file):
Comments from Reviewable |
Review status: 0 of 3 files reviewed at latest revision, 1 unresolved discussion, all commit checks successful. pkg/sql/parser/parse.go, line 105 at r1 (raw file): Previously, m-schneider (Masha Schneider) wrote…
The idea is that we're merely parsing that statement. since the SQL language (and thus its grammar) do not support using a table name at the top level, we need a well-known grammar rule that accepts table name in its syntax, and then after parsing extract that part. See Does this clarify? Comments from Reviewable |
pkg/sql/parser/parse.go, line 105 at r1 (raw file): Previously, knz (kena) wrote…
Yep makes sense! Comments from Reviewable |
Review status: 0 of 3 files reviewed at latest revision, 1 unresolved discussion, some commit checks pending. Comments from Reviewable |
Thanks! |
Review status: 0 of 3 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. pkg/sql/parser/parse.go, line 105 at r1 (raw file): Previously, m-schneider (Masha Schneider) wrote…
I know you've copied this from somewhere, but this obviously needed a comment :) Comments from Reviewable |
ALTER TABLE RENAME is the smallest syntax element that contains a table name. Every other rule involving a table name is much more complex to parse. I don't understand your concern? |
Review status: 0 of 3 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. pkg/sql/parser/parse.go, line 105 at r1 (raw file):
A qualified name is also a "syntax element"; perhaps not a top-level one. I'm asking if you think there's a way to ask the yacc-generated parser to parse using a smaller grammar - basically to tell it what rule we want it to use. Comments from Reviewable |
Review status: 0 of 3 files reviewed at latest revision, 1 unresolved discussion, some commit checks failed. pkg/sql/parser/parse.go, line 105 at r1 (raw file): Previously, andreimatei (Andrei Matei) wrote…
sent #24132 adding a small comment Comments from Reviewable |
Op 21-03-18 om 23:14 schreef Andrei Matei:
A qualified name is also a "syntax element"
No. "Qualified names" do not exist in the 2.0 grammar any more. For good
reason.
I'm asking if you think there's a way to ask the yacc-generated
parser to parse using a smaller grammar - basically to tell it what rule
we want it to use.
No this is not possible. The LALR generator underlying go-yacc is unable
to do this.
If you want a different grammar, you'd need to make a separate .y file
containing just the sub-rule that you want. There'd need to be Makefile
magic to ensure there's no duplication of code between the two .y files
(go-yacc does not support include directives). Ugly all around.
I don't have a particular "concern", but this code is clearly bizarre.
This is clearly common in the world of LALR parser generators. I have a
couple good books to refer you to if you're interested.
…--
Raphael 'kena' Poss
|
Prior to this patch, ParseQualifiedTableName() was using
ParseTableNameWithIndex and thus was overly generous in the syntax it
accepted. Worse than that, it would even silently drop the index part,
so one could e.g. compute
nextval('someseq@invalidindex')
withouterror.
This patch corrects this oversight by ensuring the method only parses
table names.
Release note (bug fix): various primitives that expect table names as
argument now properly reject invalid table names.