sql: match Postgres type conversion behavior #75101
Labels
C-enhancement
Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
O-support
Would prevent or help troubleshoot a customer escalation - bugs, missing observability/tooling, docs
P-3
Issues/test failures with no fix SLA
T-sql-queries
SQL Queries Team
Projects
The behavior of type conversions in CockroachDB behaves differently than Postgres in a handful of cases. The Postgres docs on type conversion are an excellent starting place for understanding how Postgres makes type conversion decisions.
Implicit Casts
Implicit casts are casts that are automatically added so that expressions can be strongly typed. For example, implicit casts allow expressions like
1::INT4 = 1::INT2
to be typed.From the Postgres docs on type conversion:
We currently have logic scattered throughout the code base that loosely mimics implicit casts, but has some rough edges. This is a meta issue to track all the work required in order to fully implement implicit casts to behave as they do in Postgres.
Another Example with Collated Strings
We also need to support implicit casts for collated strings. For example, the SQL below executes successfully in PG, but not in CRDB v22.1.
Function overload resolution
The logic for determining the overload of a function is documented here. We currently differ from this behavior in several ways.
TODO
unknown
initially #94718Placeholder.Eval
instead of casts to equivalent types (or perhaps don't create casts at all here if not necessary).@@
operator type-checking #100704.Epic CRDB-2474
Jira issue: CRDB-12461
The text was updated successfully, but these errors were encountered: