about [freetds] select bug...

Raven Gate vipera_r at yahoo.com
Tue May 6 15:49:27 EDT 2003


Thank you very much for support.I using:Platform : Red Hat v8.0ODBC driver : libtdsodbc.soProgram language: PHPmy php example: <?php
// v1.0
// (c) 2003 <vipera_r at yahoo.com>
// example.php$MSSQL_SERVER = mssql  // This is label in /etc/odbc.ini
$MSSQL_USER   = adm
$MSSQL_PASS   = testfunction __odbc_fetch_object($res)
   {
    if( function_exists("odbc_fetch_object") )
       return odbc_fetch_object($res);       $rs = array();
       $rs_obj = false;
       if( odbc_fetch_into($res, &$rs) )
       {
          foreach( $rs as $key=>$value )
           {
             $fkey = odbc_field_name($res, $key+1);
              $rs_obj->$fkey = trim($value);
           }
       }
      return $rs_obj;
  }
    echo("<HTML>\n"); 
    echo("<BODY>\n");
    putenv("ODBCINI=/etc/odbc.ini");
    // Suppress errors and handle them internally
    $DBLink = @odbc_connect($MSSQL_SERVER, $MSSQL_USER, $MSSQL_PASS );
    echo("<BR\n>");
    echo("Connecting to database ...");
    echo("<BR>\n");
    if ( !empty( $DBLink ) )
    {
        echo("<BR\n>");
        echo("Preparing query ...");
        echo("<BR>\n"); $SQL = "select * from clt_pc_inventory";
        $QResult = @odbc_exec( $DBLink, $SQL );
        if ( $QResult == True )
        {     $sql_fields = odbc_num_fields($QResult);
     echo("<BR\n>");
     echo("<FONT COLOR=\"#0000FF\">\n");
            echo("Count field are:</FONT>".$sql_fields);
            echo("<BR>\n");
            odbc_free_result( $QResult );
        }     
 else
        {
            print( "Query failed<BR>" );
        }
 $SQL = "select count(*) count from clt_pc_inventory";
        $QResult = @odbc_exec( $DBLink, $SQL );
        if ( $QResult == True )
        {     $row = __odbc_fetch_object($QResult);
     $sql_rows = $row->count;
     echo("<BR\n>");
     echo("<FONT COLOR=\"#0000FF\">\n");
            echo("Count rows are:</FONT>".$sql_rows);
            echo("<BR>\n");
            odbc_free_result( $QResult );
        }     
 else
        {
            print( "Query failed<BR>" );
        }
  
 
    }
    else
    {
        print( "Unable to connect to DB<br>" );
    }
       
    echo("</BODY>\n");
    echo("</HTML>\n");
?>
/etc/odbc.ini :[mssql]
Description = Microsoft SQL Server
Trace  = No
TraceFile = stderr
Driver  = FreeTDS
DSN  =  test
SERVER  = 10.0.0.3
PORT            = 1433 /etc/odbcinst.ini[FreeTDS]
Description = FreeTDS unixODBC Driver for MS SQL Server
Driver  = /usr/lib/libtdsodbc.so
FileUsage = 1 Sincerely   R.G.
Frediano Ziglio <freddyz77 at tin.it> wrote:Il mar, 2003-05-06 alle 15:06, Spyros Ioakim ha scritto:
> Yes Enterprise manager does reply correctly...
> 2 results for compid 186 and 1 result for 258 with the new date format.
> 
> Unfortunately freetds has the same behaviour (1 and 0 results)
> 
> I have attached the new log file.
> 
> Thanks,
> Spyros
> 

This is very strange...
>From dump
2003-05-06 16:03:35.380833 inside tds_process_result_tokens() state is
COMPLETED
2003-05-06 16:03:48.320304 tds_put_string converting 552 bytes of "use
office
SELECT Company.CompId FROM COMPANY, INSTALLS WHERE Company.CompId = 186
and (NoDownloads is null OR NoDownloads=0) AND Installs.CompID =
Company.CompID AND Installs.ProdId IN (SELECT ProdId FROM Products WHERE
Products.Code LIKE 'N%3%') AND ( (Installs.InstDate >= '2002-11-06') OR
(Installs.CompId IN (SELECT Installs.CompId FROM Installs, Products
WHERE Installs.ProdId = Products.ProdId AND ( (Products.Code LIKE
'N%3%') ) AND Installs.InstlId IN (SELECT InstlId FROM Cntrcts WHERE
CntrctType LIKE 'ðÓ%' AND ToDate >= '2003-05-06') ) ) )
"
^^ where came this buffer corruption ??

It seem near byte 512... 

Below

2003-05-06 16:03:48.321326 tds_put_string wrote 80 bytes
Sending packet @ 2003-05-06 16:03:48.321342
0000 01 01 00 68 00 00 01 00-70 00 65 00 20 00 4c 00 |...h.... p.e. .L.|
0010 49 00 4b 00 45 00 20 00-27 00 f0 00 d3 00 25 00 |I.K.E. . '.ð.Ó.%.|
^^^ ^^^ same ...
0020 27 00 20 00 41 00 4e 00-44 00 20 00 54 00 6f 00 |'. .A.N. D. .T.o.|
0030 44 00 61 00 74 00 65 00-20 00 3e 00 3d 00 20 00 |D.a.t.e. .>.=. .|
0040 27 00 32 00 30 00 30 00-33 00 2d 00 30 00 35 00 |'.2.0.0. 3.-.0.5.|
0050 2d 00 30 00 36 00 27 00-29 00 20 00 29 00 20 00 |-.0.6.'. ). .). .|
0060 29 00 20 00 29 00 0a 00- |). .)...|

Somewhere a buffer corruption occur...
What library are you using ? dblib ctlib or odbc ? What client ? PHP,
other ?

What platform are you using ?

freddy77


_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds

---------------------------------
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.



More information about the FreeTDS mailing list