-
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: allow strpos() builtin function to support bit and bytes array #46875
sql: allow strpos() builtin function to support bit and bytes array #46875
Conversation
Fixes cockroachdb#45849 This commit modified strpos builtin function to allow it to support bit and byte array and add their respective testcases. This PR creates separate overloads for both bit and bytes as: strpos(varbit, varbit) strpos(bytes, bytes) since POSITION is an alias for strpos, at the parser level. Therefore this PR affect POSITION too. Release justification: low-risk change to existing functionality. Release note (sql change): This PR modified strpos() function to allow it support bit and byte array.
small overview
for that, we have to implement a separate function like |
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.
LGTM!
leaving this here as a comment to myself, but if you want to nerd it out you can have a squiz!
it looks like postgres handles POSITION as a position
C function (which is not available as a builtin)
whereas we use strpos
cockroach/pkg/sql/parser/sql.y
Line 8714 in 7dc8cc4
$$.val = &tree.FuncExpr{Func: tree.WrapFunction("strpos"), Exprs: $3.exprs()} |
one could argue strpos should only be strings, not bits and bytes. but doing a position builtin
will make parsing angry as it will fight with the line mentioned above. so whatever /shrug
bors r+ |
bors r- bors is stick due to github issue |
bors r+ |
TF[YT]R Hi @otan, |
Build failed |
flakes
bors r+
…On Mon, 6 Apr 2020, 9:29 pm craig[bot], ***@***.***> wrote:
Build failed
- GitHub CI (Cockroach)
<https://teamcity.cockroachdb.com/viewLog.html?buildId=1857029&buildTypeId=Cockroach_UnitTests>
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#46875 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AA32FQ6QCYSQUZ6G3XEZ65DRLKT23ANCNFSM4LZP4OAA>
.
|
Build succeeded |
Fixes #45849
This commit modified strpos builtin function to allow it to
support bit and byte array and add their respective testcases.
This PR creates separate overloads for both bit and bytes as:
strpos(varbit, varbit)
strpos(bytes, bytes)
since POSITION is an alias for strpos, at the parser level.
Therefore this PR affect POSITION too.
Release justification: low-risk change to existing functionality.
Release note (sql change): This PR modified strpos() function
to allow it support bit and byte array.