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

handle casted placeholders [T1075] #328

Merged
merged 2 commits into from
Mar 12, 2019
Merged

handle casted placeholders [T1075] #328

merged 2 commits into from
Mar 12, 2019

Conversation

Lagovas
Copy link
Collaborator

@Lagovas Lagovas commented Mar 11, 2019

*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 as sqlval 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 for typecast to support more than one type.

@@ -618,572 +619,521 @@ var yyExca = [...]int{
153, 272,
-2, 262,
-1, 248,
111, 616,
111, 617,
Copy link
Collaborator

Choose a reason for hiding this comment

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

o.o

Copy link
Collaborator

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?

Copy link
Collaborator Author

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

Copy link
Contributor

@ilammy ilammy left a 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",
Copy link
Contributor

@storojs72 storojs72 Mar 12, 2019

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, only postgres

@Lagovas Lagovas merged commit 92dc016 into cossacklabs:master Mar 12, 2019
@Lagovas Lagovas deleted the lagovas/T1075-handle-casted-placeholders branch March 18, 2020 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants