Skip site navigation (1) Skip section navigation (2)

Cast null to int4 upgrading from Version 7.2

From: "Dwight Emmons" <demmons(at)instantbenefits(dot)com>
To: <pgsql-patches(at)postgresql(dot)org>
Cc: "'Jason Rutherford'" <jasonr(at)instantbenefits(dot)com>,"Dave Horn" <dhorn(at)instantbenefits(dot)com>
Subject: Cast null to int4 upgrading from Version 7.2
Date: 2006-11-16 21:47:01
Message-ID: 20061116215335.374B49F93C9@postgresql.org (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
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

 

Responses

pgsql-hackers by date

Next:From: Bruce MomjianDate: 2006-11-16 21:50:31
Subject: Re: replication docs: split single vs. multi-master
Previous:From: Gurjeet SinghDate: 2006-11-16 21:07:35
Subject: Re: [HACKERS] Not your father's question about deadlocks

pgsql-patches by date

Next:From: Bruce MomjianDate: 2006-11-16 21:50:31
Subject: Re: replication docs: split single vs. multi-master
Previous:From: Markus SchiltknechtDate: 2006-11-16 20:46:51
Subject: Re: replication docs: split single vs. multi-master

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group