-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
release-23.1: opt: fix BPCHAR type and CASE typing #130899
Conversation
Thanks for opening a backport. Please check the backport criteria before merging:
If your backport adds new functionality, please ensure that the following additional criteria are satisfied:
Also, please add a brief release justification to the body of your PR to justify this |
Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
7aa89da
to
bf72a4d
Compare
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.
once the merge conflicts / extra file are resolved.
Reviewed 8 of 28 files at r1.
Reviewable status: complete! 1 of 0 LGTMs obtained (waiting on @kev-cao, @mgartner, and @rytaft)
pkg/sql/logictest/testdata/logic_test/grant_table
line 595 at r2 (raw file):
test public NULL schema public USAGE false test public NULL schema root ALL true =======
Merge conflict here.
pkg/sql/opt/xform/testdata/external/tpcc-later-stats
line 638 at r2 (raw file):
<<<<<<< HEAD │ │ └── CASE c_credit:37 WHEN 'BC' THEN left((((((c_id:24::STRING || c_d_id:25::STRING) || c_w_id:26::STRING) || '5') || '10') || '3860.61') || c_data:44, 500) ELSE c_data:44::STRING END =======
Looks like the optimizer tests need to be rewritten as well.
pkg/sql/opt/xform/testdata/external/tpcc-read-committed
line 1 at r2 (raw file):
import file=tpcc_schema
This file should be removed.
f645fba
to
37f4321
Compare
This commit addresses inconsistencies from Postgres' behavior. First, it makes the `BPCHAR` type distinct from `CHAR`. The former is a blank-padded character type with no type width, meaning that it could have any length. The latter is a blank-padded character type with a type width of exactly 1 - it is essentially an alias of `CHAR(1)`. Previously, a column of type `BPCHAR` behaved the same as a column of type `CHAR(1)` - it enforced a length limit of 1. Second, the typing of `CASE` and `CASE`-like expressions has been fixed. The branches of these conditionals is no longer forced to have the same type-width. Fixes cockroachdb#127889 Fixes cockroachdb#108360 Release note (bug fix): A bug has been fixed that caused incorrect evaluation of `CASE`, `COALESCE`, and `IF` expressions with branches producing fixed-width string-like types, such as `CHAR`. In addition, the `BPCHAR` type has been fixed so that it no longer incorrectly imposes a length limit of 1.
37f4321
to
30ad44f
Compare
I think this backport would require #108387 too, which has not been backported to 23.1. I'm going to close this backport for now - I don't think there's a strong reason to backport it. |
Backport 1/1 commits from #129007.
/cc @cockroachdb/release
This commit addresses inconsistencies from Postgres' behavior. First, it
makes the
BPCHAR
type distinct fromCHAR
. The former is ablank-padded character type with no type width, meaning that it could
have any length. The latter is a blank-padded character type with a type
width of exactly 1 - it is essentially an alias of
CHAR(1)
.Previously, a column of type
BPCHAR
behaved the same as a column oftype
CHAR(1)
- it enforced a length limit of 1.Second, the typing of
CASE
andCASE
-like expressions has been fixed.The branches of these conditionals is no longer forced to have the same
type-width.
Fixes #127889
Fixes #108360
Release note (bug fix): A bug has been fixed that caused incorrect
evaluation of
CASE
,COALESCE
, andIF
expressions with branchesproducing fixed-width string-like types, such as
CHAR
. In addition,the
BPCHAR
type has been fixed so that it no longer incorrectlyimposes a length limit of 1.
Release justification: Low-risk bug fix.