A cast from INTERVAL to STRING is labelled as composite insensitive. You can see this by adding this test to pkg/sql/opt/memo/testdata/composite_sensitive:
composite-sensitive vars=(i interval)
i::string
----
false
I believe this is incorrect because INTERVAL is a composite type, even though we don't mark it as such:
|
case types.BoolFamily, |
|
types.IntFamily, |
|
types.DateFamily, |
|
types.TimestampFamily, |
|
types.IntervalFamily, |
|
types.StringFamily, |
|
types.BytesFamily, |
|
types.TimestampTZFamily, |
|
types.OidFamily, |
|
types.UuidFamily, |
|
types.INetFamily, |
|
types.TimeFamily, |
|
types.JsonFamily, |
|
types.TimeTZFamily, |
|
types.BitFamily, |
|
types.GeometryFamily, |
|
types.GeographyFamily, |
|
types.EnumFamily, |
|
types.Box2DFamily: |
|
return false |
Notice that an equal interval can present itself in different ways, making it composite:
SELECT i1, i2, i1 = i2 FROM t;
i1 | i2 | ?column?
-----------+-------+-----------
24:00:00 | 1 day | true
Marking an expression as composite insensitive when it is not actually composite insensitive can cause correctness bugs. I don't have an example of a correctness bug caused by this at the moment, but I have a strong feeling that one exists.
Jira issue: CRDB-15403
Epic: CRDB-20062
A cast from
INTERVALtoSTRINGis labelled as composite insensitive. You can see this by adding this test topkg/sql/opt/memo/testdata/composite_sensitive:I believe this is incorrect because
INTERVALis a composite type, even though we don't mark it as such:cockroach/pkg/sql/catalog/colinfo/column_type_properties.go
Lines 65 to 84 in c1754fb
Notice that an equal interval can present itself in different ways, making it composite:
Marking an expression as composite insensitive when it is not actually composite insensitive can cause correctness bugs. I don't have an example of a correctness bug caused by this at the moment, but I have a strong feeling that one exists.
Jira issue: CRDB-15403
Epic: CRDB-20062