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

Add support for substr for static strings. #4350

Merged
merged 1 commit into from
Nov 9, 2018
Merged

Add support for substr for static strings. #4350

merged 1 commit into from
Nov 9, 2018

Conversation

kuba--
Copy link
Collaborator

@kuba-- kuba-- commented Nov 8, 2018

Signed-off-by: kuba-- kuba@sourced.tech

So far vitess supports substring for columns_names. This PR adds support for static string values, so you can:

SELECT SUBSTRING("foo", 1, 2)

Copy link
Contributor

@sougou sougou left a comment

Choose a reason for hiding this comment

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

Change is good. One minor nit.

@@ -3000,18 +3000,25 @@ func (node *ValuesFuncExpr) replace(from, to Expr) bool {
// SubstrExpr represents a call to SubstrExpr(column, value_expression) or SubstrExpr(column, value_expression,value_expression)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: column->column/val

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I thought about it, but if I reuse ColName , e.g.:

SUBSTR openb STRING ',' value_expression closeb
  {
    $$ = &SubstrExpr{Name: &ColName{Name: NewColIdent($3)}, From: $5, To: nil}
  }

How could I figure out later if it's a static string or column name? How could I stop walkSubtree in this case?
Maybe instead of having extra StrVal *SQLVal, I'll add some boolean member (static/resolved/...) to mark it's a static string expression.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh. You misunderstood :). I just wanted the SubstrExpr comment to be updated to say that the input can be a column or a value, to reflect the code change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ok, how about now - take a look.

Signed-off-by: kuba-- <kuba@sourced.tech>
@sougou sougou merged commit 954b94c into vitessio:master Nov 9, 2018
@kuba-- kuba-- deleted the static-substring branch November 9, 2018 18:53
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.

2 participants