Skip to Content.
Sympa Menu

freetds - Re: Hungry PHP

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Paul Schaap" <Paul.Schaap AT dingoblue.com.au>
  • To: freetds
  • Subject: Re: Hungry PHP
  • Date: Mon, 13 Sep 1999 3:54:22


Brian,

> Ok, looking at things, I may not need to be so drastic. PHP does something
> like this:
>
> res_length = dbdatlen(dbproc, offset);
> dbconvert(NULL,coltype(offset),dbdata(sybase_ptr->link,offset),
> res_length,SYBCHAR,res_buf,-1);
>
> So it should indeed null terminate them (the -1 means to null term the
> result), however dbdatlen() returns an incorrect value. I fixed that and
> also fixed it for the NULL case as well. I'm going to try all the test
> cases tommorow on a real dblib machine and then I think I should be able
> to fix the other cases. But try the latest CVS and let me know.
>
> Brian
>

For the VARCHARS this is now OK. Back onto the DATETIME issue, certain in
the knowledge that the library IS dynamically compiled, I have done a
little more testing to reveal that DATETIME data is also hungry ! Could
you
safely apply this patch to the DATETIME data types ?

As I mentioned before using sqsh worked perfectly but php did not.
Therefore I tried a full recompile apache and php against the working
freetds from scratch to no avail. I therefore think the next question is
if
datetimes are being treated differently, or, if the hungry issue is the
cause, or, if we should bother wasting any more time on it ?

>From php ...
ID Raw Converted
10001486 Feb 25 2003 03:50AM Sep 13 1999 4:15PM
10001485 Jan 29 2003 03:50AM Sep 13 1999 3:48PM
10001484 Jan 10 2003 03:50AM Sep 13 1999 3:29PM
10001483 Nov 24 2002 03:50AM Sep 13 1999 2:42PM
10001480 Jun 03 2002 03:50AM Sep 13 1999 11:48AM

>From sqsh ...
ID DateAdded
-------- ------------------- --------------------
10001486 Sep 13 1999 04:15PM Sep 13 1999 4:15PM
10001485 Sep 13 1999 03:48PM Sep 13 1999 3:48PM
10001484 Sep 13 1999 03:29PM Sep 13 1999 3:29PM
10001483 Sep 13 1999 02:42PM Sep 13 1999 2:42PM
10001480 Sep 13 1999 11:48AM Sep 13 1999 11:48AM

I'm also concerned any change to fix the php link may affect sqsh :-(

> On Sat, 11 Sep 1999, Paul Schaap wrote:
>
> > Brian,
> >
> > On 09/11/99, "Brian Bruns <camber AT umcc.ais.org>" wrote:
> > > Netscape browser by chance? Have you tried it under IE or lynx by chance
> >
> > I'm embarassed to say I dreamt I should have tried those last night,
> > please
> > forgive me ! Unfortunately my machine at home is largely a M$ free zone,
> > and my Linux side will dial into everything but work so I'll double check
> > tomorrow at work.
> >
> > > and did it work there? If so check the PHP FAQ, you have a null trailing
> > > 'Schaap' after which netscape kindly discards everthing (until a
> > > newline?)
> >
> > This is kinda what I thought may be going on !
> > More and more I'm finding Netscape less appealing for many such reasons
> > ...
> >
> > > Anyway, I'm going to guess the real problem is varchar handling in
> > > FreeTDS. Sybase's libs track the length of varchars in a structure
> > > something like:
> > >
> > > struct _cs_varchar {
> > > CS_CHAR array[CS_MAX_STRING];
> > > CS_INT length;
> > > } CS_VARCHAR
> > >
> > > and then the dblib structure is #define'd to this
> > >
> > > (This is off the top of my head, I don't remember exactly what the ctlib
> > > structure looks like, but close enough for this discussion). FreeTDS
> > > doesn't track the length as such, it just always null terms. So there
> > > are
> > > (under dblib) two basic ways to bind a string NTBSTRINGBIND (null
> > > term'd)
> > > and STRINGBIND. I believe what is happening is one of the cases is
> > > putting a null where it is not supposed to. It basically doesn't
> > > have enough information to do the right thing.
> > >
> > > So the short story is probably varchar has to be fixed, and that's going
> > > to break alot of things. PHP probably stopped working because of changes
> > > that were put to fix DBD::Sybase's behaviour.
> >
> > Ouch !
> >
> > >
> > > So, anybody mind if I really screw up things for a few days?
> >
> > What have I started .... :-0
> >
> > >
> > > brian
> > >
> > > On Sat, 11 Sep 1999, Paul Schaap wrote:
> > >
> > > > Brian,
> > > >
> > > > Following on from my previous MS SQL post here is some further
> > > > details on
> > > > the odd behaviour under php. Please note that under sqsh there is no
> > > > problem.
> > > >
> > > > Here is a phtml
> > > > ############################################################################
> > > > <HTML>
> > > > <HEAD>
> > > > <TITLE>freetds kicks butt</TITLE>
> > > > </HEAD>
> > > > <BODY>
> > > > <CENTER><H1><U>Hungry PHP</U></H1></CENTER>
> > > > <?
> > > > $cnn = sybase_pconnect("Your MS SQL Server","Login","Password")
> > > > or die("Connect");
> > > > $db = sybase_select_db("A Database",$cnn)
> > > > or die("Select");
> > > >
> > > > // Surname is a VARCHAR
> > > > $sql = "SELECT ID, Surname, ID
> > > > FROM Customer
> > > > WHERE ID = 10000696";
> > > > echo "$sql<BR>";
> > > > $qry = sybase_query($sql);
> > > > if($qry){
> > > > list($i1,$i2,$i3) = sybase_fetch_row($qry);
> > > > echo "$i1 $i2 eat me $i3<BR>\n";
> > > > echo "$i1 $i2 <B> eat me $i3</B><BR>\n";
> > > > }
> > > > sybase_free_result($qry);
> > > >
> > > > // WITH A CONVERT
> > > > $sql = "SELECT ID, CONVERT(CHAR(20),Surname), ID
> > > > FROM Customer
> > > > WHERE ID = 10000696";
> > > > echo "$sql<BR>";
> > > > $qry = sybase_query($sql);
> > > > if($qry){
> > > > list($i1,$i2,$i3) = sybase_fetch_row($qry);
> > > > echo "$i1 $i2 eat me $i3<BR>\n";
> > > > echo "$i1 $i2 <B> eat me $i3</B><BR>\n";
> > > > }
> > > > sybase_free_result($qry);
> > > > ?>
> > > > </BODY>
> > > > </HTML>
> > > > ############################################################################
> > > >
> > > > Heres a possible schema, I'm not 100% on the MS SQL DB syntax ...
> > > > ############################################################################
> > > > CREATE TABLE Customer (
> > > > ID INTEGER,
> > > > Surname VARCHAR(255)
> > > > );
> > > > ############################################################################
> > > >
> > > > Heres the output on the Browser
> > > > ############################################################################
> > > > Hungry PHP
> > > >
> > > > SELECT ID, Surname, ID FROM Customer WHERE ID = 10000696
> > > > 10000696 Schaap
> > > > 10000696 Schaap eat me 10000696
> > > > SELECT ID, CONVERT(CHAR(20),Surname), ID FROM Customer WHERE ID =
> > > > 10000696
> > > > 10000696 Schaap eat me 10000696
> > > > 10000696 Schaap eat me 10000696
> > > > ############################################################################
> > > > notice the first 'eat me 10000696' on the first query just doesnt
> > > > turn up.
> > > > But the second one does turn up ? The tag entered on the second one
> > > > somehow
> > > > saves the data from dissappearing. A view source on the page also
> > > > doesnt
> > > > reveal the missing info hidden in a tag or anything, it just vanished
> > > > !
> > > >
> > > > In the second query when I CONVERT all is well and as expected.
> > > >
> > > > REGARDS
> > > > Paul
> > > >
> >
> > REGARDS
> > Paul
> >
> > ---
> > You are currently subscribed to freetds as: camber AT ais.org
> > To unsubscribe, forward this message to $subst('Email.Unsub')
> >
> >

REGARDS
Paul




Archive powered by MHonArc 2.6.24.

Top of Page