ECPG doesn't return the correct length for an empty - Mailing list pgsql-bugs

From Hebert, Caroline
Subject ECPG doesn't return the correct length for an empty
Date
Msg-id 43971E314F29D511B45C00508BCFF22408BAEDCF@frnam201.exfr01.exch.eds.com
Whole thread Raw
Responses Re: ECPG doesn't return the correct length for an empty
List pgsql-bugs
I understand very well your answer, however, I would like to introduce
briefly our needs and why we decided to use the "-r no_indicator" with ECPG.

We are porting a Pro*C/Oracle 7.3.4 based application (about 4000 SQL
requests) to ECPG/PostGreSQL 7.4.2.
This application mostly uses VARCHAR variables, considering (with Oracle)
any
uninitialised varchar (NULL value) as an empty string.
If we don't use the "-r no_indicator" option with ECPG, requests containing
at least one NULL value return an "ECPG_MISSING_INDICATOR" error code.
This is normal as they don't contain "null indicator" variables in their
Oracle version.

The "-r no_indicator" option, which considers NULL VARCHARs as empty
VARCHARs, seems to corresponds to the application needs.
However, if this mechanism doesn't guarantee the length field to be coherent

with the returned strings, we'll have to test the string length with :
    strlen(myVarchar.arr)
instead of simply reading
    myVarchar.len

Is there another way to get "real" empty varchars (with a correct length
associated !) instead of NULL VARCHAR values ?

However, having a positive length associated with an empty VARCHAR still
seems incoherent to me...

Thanks a lot

Regards

Caroline Hebert

-----Message d'origine-----
De : Michael Meskes [mailto:meskes@postgresql.org]
Envoye : lundi 21 juin 2004 11:13
A : Hebert, Caroline
Cc : 'pgsql-bugs@postgresql.org'
Objet : Re: [BUGS] ECPG doesn't return the correct length for an empty


On Mon, Jun 21, 2004 at 08:18:07AM +0100, Hebert, Caroline wrote:
>   Short Description : ECPG doesn't return the correct length for an empty
> VARCHAR

I'm sorry, but this is not a bug but an incorrectly used feature.

> I compiled with :
> * /usr/local/pgsql/bin/ecpg -r no_indicator pg_empty_varchar.pgc

When using "-r no_indicator" an empty string in a varchar is considered
a NULL value.  So you essantially put a NULL value in the database and
then read it and try to use it as if it was not NULL.

If you remove this option it works fine.

As an explanation, this option came in as a compatibility option to
Informix. But it can also be used without Informix as you see. I wonder
if I should make this option only callable in compatibility mode.

Michael
--
Michael Meskes
Email: Michael at Fam-Meskes dot De
ICQ: 179140304, AIM/Yahoo: michaelmeskes, Jabber: meskes@jabber.org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!

pgsql-bugs by date:

Previous
From: Theo Kramer
Date:
Subject: Re: BUG #1178: PQexecPrepared - PostgreSQL 7.4.1
Next
From: Tom Lane
Date:
Subject: Re: Dump/Restore of cvs regression database gives invalid timestamp syntax error