-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
sql: refactor casts to be more like postgresql #55094
Comments
55095: tree: fix casts and parse to obey type limits r=rafiss a=otan Resolves #54844 A more general solution for this should be #55094. Release note (bug fix): Previously, casts and parsing of strings to types may allow an out-of-bounds value to be successfully used (e.g. SELECT -232321321312::int2 would work), but fail with an out-of-bounds message when it is inserted into the table. This has been rectified to instead be checked when the value is parsed or being casted to. Co-authored-by: Oliver Tan <otan@cockroachlabs.com>
@otan I'm considering making this refactor to make some upcoming changes to casting easier. I had a couple questions:
What's the reasoning behind using an
Can you explain more what you mean by this? |
Well, it doesn't if you have implicit/assignment casts :). OID -> OID is most
I phrased this badly, let me rephrase. This is in the context of string casts, which IIUC goes through ParseAndRequireString anyway. In PG, type I/O input/output functions depend on What I believe I meant was that the casts should re-use the |
I don't follow. OID -> OID would require a map that contains casting details for each OID pair. Family -> Family would by definition be a smaller map.
Sounds good, I'll give it a shot. |
smaller map, a lot more if conditions based on oids ;) |
We have marked this issue as stale because it has been inactive for |
Our current method of handling casts and operators are a bit of a mess.
Casts are defined in a massive switch statement, and their volatility in a separate map (validCasts).
In large parts, AdjustValueFor[Column]Type should be folded into here.
We should refactor casts and parse to be more like Postgres: there should be a map that roughly goes
map[fromType oid.Oid]map[toType oid.Oid]castOps
that defines casts from and to. They should be able to re-use the parse function -- strings should automatically be populated into these cast maps using the parse definitions. In postgres, this is handled by a<datatype>_in
command.Doing this will also greatly simplify adding new types.
Jira issue: CRDB-3696
The text was updated successfully, but these errors were encountered: