Skip to content

Add support for substr for static strings.#4350

Merged
sougou merged 1 commit intovitessio:masterfrom
kuba--:static-substring
Nov 9, 2018
Merged

Add support for substr for static strings.#4350
sougou merged 1 commit intovitessio:masterfrom
kuba--:static-substring

Conversation

@kuba--
Copy link
Copy Markdown
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
Copy Markdown
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.

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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