Re: Cast null to int4 upgrading from Version 7.2

From: Mario Weilguni <mweilguni(at)sime(dot)com>
To: pgsql-patches(at)postgresql(dot)org, demmons(at)instantbenefits(dot)com
Cc: "'Jason Rutherford'" <jasonr(at)instantbenefits(dot)com>, "Dave Horn" <dhorn(at)instantbenefits(dot)com>
Subject: Re: Cast null to int4 upgrading from Version 7.2
Date: 2006-11-17 08:50:33
Message-ID: 200611170950.33255.mweilguni@sime.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

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 (having 60000 lines old application
code using this)

Am Donnerstag, 16. November 2006 22:47 schrieb Dwight Emmons:
> 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 * from employee_table where employee_id = '';
>
>
>
> When executing this select statement in version 7.2 the null will be
> converted to an int zero and not fail. In version 8.2 it fails. We have
> over 20,000 lines of code and do not want to modify and test all of it.
> Has anyone come across this problem? (I am not interested in debating the
> theory of nulls versus zero. I am just trying to avoid unnecessary costs).
>
>
>
> I am not a DBA, and am looking for explicit instructions to solve this
> problem. Is it possible to create a CAST after upgrading to version 8.2?
> My research tells me the following cast was no longer implemented after
> version 7.2. Will executing the following CAST solve my problem?
>
>
>
> CREATE CAST (text AS int4) WITH FUNCTION int4(text);
>
>
>
> If so, can someone give me instructions as to executing this statement?
>
>
>
> Any help is appreciated..
>
>
>
> Dwight

Attachment Content-Type Size
postgresql-8.1.0-empty_equals_0.patch text/x-diff 1.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Simon Riggs 2006-11-17 09:40:12 Re: [HACKERS] Extended protocol logging
Previous Message Markus Schiltknecht 2006-11-17 08:06:35 Re: [PATCHES] replication docs: split single vs. multi-master

Browse pgsql-patches by date

  From Date Subject
Next Message Gleb Kouzmenko 2006-11-17 08:58:56 SSL cert client authentication
Previous Message Markus Schiltknecht 2006-11-17 08:06:35 Re: [PATCHES] replication docs: split single vs. multi-master