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 placeholder type resolution
When assignment casts for inserts were add in cockroachdb#70722, type resolution of placeholders in prepared statements was changed so that during the prepare phase the optimizer would only plan assignment casts when it could not be guaranteed that an insert column would be an identical type to the target column. Unfortunately, the change to placeholder type resolution change strays from Postgres's behavior and breaks some third-party tools. This commit reverts the type resolution changes, and as a result, assignment casts are always planned to convert each insert column to its target column type, even if the cast ends up being a no-op because the types are identical. I attempted to implement a solution that did not plan assignment casts in all cases, but it proved to be tedious and error prone, so I opted for this simpler solution for now. My attempt required annotating each placeholder expression in the memo with a context: a non-assignment context or an assignment context. This context would be used during the EXECUTE to determine whether a placeholder value should undergo a regular cast or an assignment cast: a critical decision due to their slightly different behaviors (see `PerformAssignmentCast`). The problem is that correctly annotating placeholders in complex mutations with expressions like subqueries or CTEs is difficult. Fixes cockroachdb#71576 There is no release note because this bug was never present in a release. Release note: None
- Loading branch information
Showing
54 changed files
with
6,851 additions
and
5,216 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
Oops, something went wrong.