-
Notifications
You must be signed in to change notification settings - Fork 128
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
handle casted placeholders [T1075] #328
handle casted placeholders [T1075] #328
Conversation
@@ -618,572 +619,521 @@ var yyExca = [...]int{ | |||
153, 272, | |||
-2, 262, | |||
-1, 248, | |||
111, 616, | |||
111, 617, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
o.o
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this code is fully generated, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sql.go is auto-generated from sql.y via goyacc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow, an actual yacc parser for SQL!
@@ -1577,6 +1577,8 @@ func TestConvert(t *testing.T) { | |||
input: "select convert('abc', json) from t", | |||
}, { | |||
input: "select convert('abc' using ascii) from t", | |||
}, { | |||
input: "select $1::integer::bytea from dual where test = $2::varchar::bytea", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$1::integer::bytea
- this is valid only in postgres, right? Is it possible to cast into bytea right away?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, only postgres
*support type cast for placeholders:
select $1::type1::type2 from table1 where column1=$2::type3::type4
before placeholders were as the separate expression and worked only with placeholders without any casts.
to add cast support it needed to duplicate same logic as it was done for SQLVal with extra field for expression struct that will contain type info as bytes and extend
format
method. But this way has one disadvantage that we can't handle such expressions assqlval
in our censor rules and encryptor's logic.So, to handle it better, it to work with placeholders as with
sqlval
's and extend rule fortypecast
to support more than one type.