dbTalk Databases Forums  

[BUGS] ECPG doesn't return the correct length for an empty

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss [BUGS] ECPG doesn't return the correct length for an empty in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Hebert, Caroline
 
Posts: n/a

Default [BUGS] ECPG doesn't return the correct length for an empty - 06-24-2004 , 09:11 AM






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 (AT) postgresql (DOT) org]
Envoye : lundi 21 juin 2004 11:13
A : Hebert, Caroline
Cc : 'pgsql-bugs (AT) postgresql (DOT) 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:
Quote:
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.

Quote:
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 (AT) jabber (DOT) org
Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!


---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings


Reply With Quote
  #2  
Old   
Michael Meskes
 
Posts: n/a

Default Re: [BUGS] ECPG doesn't return the correct length for an empty - 06-27-2004 , 07:41 AM






On Thu, Jun 24, 2004 at 02:56:04PM +0100, Hebert, Caroline wrote:
Quote:
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.
...
I still think that you are on a risky path by misusing this feature. On
the other hand I see no reason why setting the len to 0 in case of a
NULL could be a problem for ecpg. But please keep in mind that you are
getting NULLs from the DB, not empty varchars, even if they look that
way in C.

I will commit the patch in a few minutes.

Michael

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

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.