PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: Michael Peppler <mpeppler at peppler dot org>
Subject: Re: A patch proposal to the NULL-value problem on blk_rowxfer
Date: Jun 19 2002 5:38PM

On Wed, 2002-06-19 at 08:05, Masatsuyo Takahashi wrote:
> I'd like to propose a patch to fix the NULL-value problem on blk_rowxfer
> recently posted by Hiroshi Yamada and answered by Martin Rieder.
> 
> I'll clarify the situation first, discuss what to fix, and then show the
> patch.
> 
> THE CAUSE OF TROUBLE
> 
> The problem comes from the three silmilar but different states
> of an array element, namely,
> 
>     (NA) where nothing is assigned yet
>     (UD) where 'undef' has been assigned
>     (NS) where null string '' ha been assigned.

> Thus, I think, in a Perl-like way, it is fair for CTlib.xs to conform to
> Perl.
> That is, all the three states in Perl should be converted within CTlib.xs
> into NULLs in Sybase.
> 
>     Perl(XS)    Sybase
>     -----------------
>     NA    =>    NULL
>     UD    =>    NULL
>     NS    =>    NULL

I agree on the first two. For the last one I have a bit of a problem -
and that is related to the never ending argument about empty strings in
varchar() columns which end up having a single space (i.e. insert "" to
a varchar column will produce " " in the database).

Scott's comment that an empty string and a NULL value are different is,
in my opinion, relevant.

So the question is - should blk_rowxfer() be modified to coerce the
empty string to NULL, or should it be the caller's responsibility to
make sure that any values where NULL is expected actually have undef,
and not the empty string?

Personally I tend towards the latter (and maybe Sybase::BLK needs to be
modified to properly address this issue?).

Anyone else care to comment?

(to make things really confusing the behavior could be made
configurable...)

> Especially, without the "!svp" condition, it may cause memory faults
> for 'NA(not assigned)' cases.

Yes - absolutely - thanks for catching that!

Michael
-- 
Michael Peppler / mpeppler@peppler.org / http://www.mbay.net/~mpeppler
mpeppler@zetatools.com / ZetaTools, Inc / http://www.zetatools.com
ZetaTools: Call perl functions as Sybase stored procedures!