you might be interested using the patch attached, it introduces a new GUC
variable named empty_equals_0, allowing to set this per database:
alter database xyz set empty_equals_0 to true;
I've written and used this patch for internal purpose, and take no
responsibilty at all, but it's working
My company is currently using version 7.2 and would like to convert to the
latest version. Unfortunately, version 7.3 implicitly casts a null text to
an int4. For example:
Create table employee_table (
employee_id integer
employee_name text
employee_address text);
Select *
Dwight Emmons wrote:
[Why did you post this to pgsql-patches of all places? it should
properly have gone to pgsql-general, I think]
My company is currently using version 7.2 and would like to convert to
the latest version. Unfortunately, version 7.3 implicitly casts a null
text to an int4.
On Nov 16, 2006, at 3:10 PM, Neil Conway wrote:
Yes, this is a common problem for people upgrading from 7.2. I
think the
long-term fix is to change your queries: comparing an integer with
'' is
not sensible. That is:
SELECT * FROM employee_table WHERE employee_id = 0;
is the right way to
Jim Nasby wrote:
As a less invasive alternative, I *think* you could create an SQL
function for casting text to int that treated '' as 0, and then
replace the built-in CAST with that.
Won't work. You need to replace the data type input function.
--
Peter Eisentraut