Problems and workaround recreating implicit casts using 8.3+
There’s a very frequent issue when upgrading to version 8.3 and bellow: the
removal of some implicit casts from text types to time or numerical ones in
8.3. The only clean solution here is to fix the application itself, period.
However, for those that cannot afford quickly such a hard work, the popular
workaround is to recreate these implicit casts, but it suffer from a side
effect. About a year ago, I found another quick-n-dirty fix for a customer.
Here is the problem:
The very well known solution is to recreate some of these implicit casts that
were removed in 8.3. Peter Eisentraut blogged about that, you’ll find his SQL
script
here.
However, as some users noticed in the comments, there is a side effect bug with
this solution: it breaks the concatenation operator.
From here, the solution could be to cast one of the operand:
But then, we are back to the application fix where it might worth spending more
time fixing things in the good way.
There is another solution: creating missing operators instead of implicit
casts. You will find a sql file with a lot of those operators under the
following link: 8.3 operator workaround.sql.
Here is a sample for text to integer comparison:
Using this operator instead of implicit cast, the previous test shows:
Same advice from Peter here: if possible, only create the operators you need to
fix your application!
So far, I only had one positive feedback about this workaround about a year
ago, and I don’t consider this is enough to actually claim it is a safe
solution. So please, comments, tests and reports are welcome!
Again, keep in mind that the only clean way is fix your application if you hit
this problem!
Comments Leave a comment by email or Disqus
Note: I only publish your name/pseudo, mail subject and content. I will NOT publish your email address.
No comments yet.