forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: fix serialization of datums and prefix casts
This change addresses a few related problems (described in more detail in cockroachdb#12532): - ambiguous datum types after serialization - invalid prefix casts after expression processing (like `INTERVAL INTERVAL `1.5s`'). Changes: - a new FmtFlag adds type annotations to datums and placeholders. This ensures that expressions that contain `DDInterval`, `DDate` can be formatted and re-parsed correctly. This replaces ad-hoc type prepending like `INTERVAL '..'` or `DATE '..'`. - `CastExpr.TypeCheck` now returns the underlying type-checked expression directly when it is a Datum that we know for sore is of identical type. - `castPrefix` (renamed to `castPrepend`) now only functions if the underlying expression is a string literal (preventing incorrect expressions like `DECIMAL '1.0':::string`). `castPrefixParens` is removed (it was incorrect). - `AnnotateTypeExpr.TypeCheck` now returns the underlying type-checked expression rather than changing the `AnnotateTypeExpr` in-place and returning it (which could result in double annotations with the new `FmtFlag`). `AnnotateTypeExpr` is no longer a `TypedExpr` so it is never part of a type-checked expression (which makes sense). - type checking tests are extended to verify the serliazed type-checked expression, which verifies both serialization and type resolution. Note that changing the prepend syntax to a `AnnotateTypeExpr` was considered but that doesn't work for things like `DECIMAL '2.0'`. Fixes cockroachdb#12532. Resolves some of the concerns in cockroachdb#12611.
- Loading branch information
1 parent
62f24f8
commit 5f87a27
Showing
17 changed files
with
271 additions
and
202 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.