[freetds] SQLFetch broken in HEAD?

Frediano Ziglio freddyz77 at tin.it
Tue Jul 4 16:25:01 EDT 2006


Il giorno mar, 04/07/2006 alle 11.46 -0400, James K. Lowden ha scritto: 
> ZIGLIO, Frediano, VF-IT wrote:
> > > 
> > > > > > > I added a new unit test, src/odbc/unittests/rpc.c.  
> > > 
> > > I'm interested to know if it's right and if it works for you.  :-)
> > 
> > Well... it depends on what is the expected behavior... written as it's
> > written currently it write
> > 
> >   error: expected at least 15 rows to be returned, found 0
> > 
> > and it exit with 1. Well, this is the correct behavior for ODBC, but I
> > think that intention for any tests should be return 0 for expected
> > behavior...
> 
> It returns 1 because that's *not* expected.  Not by me, anyway.  
> 
> The SELECT statement is "SELECT name from systypes".  I use the same query
> in src/dblib/unittests/rpc.c.  It should return at least 15 rows (24 on a
> Microsoft server).  
> 
> I don't understand why SQLFetch returns SQL_NO_DATA_FOUND the first time
> it's called.  How is that "correct behavior for ODBC"?  What else am I
> supposed to do to get the data?  
> 

This is procedure body

select @null_input = max(convert(varchar(30), name)) from systypes 
select @first_type = min(convert(varchar(30), name)) from systypes
select name from sysobjects where 0=1
select distinct convert(varchar(30), name) as 'type'  from systypes
  where name in ('int', 'char', 'text')
select @nrows = @@rowcount
select distinct convert(varchar(30), name) as name  from sysobjects where type = 'S'
return 42

first select return nothing (just an ignored DONEINPROC)
second select return nothing
third select (select name from sysobjects where 0=1) returns no row so
SQLFetch return NO_DATA

dblib rpc test returns more rows cause the external loop (dbresults)
read multiple recordsets while inner one (dbnextrow) read multiple rows,
perhaps you forgot the external loop. Note also that there isn't a
"SELECT name from systypes" query. 

dblib rpc returns

found local.tempdb for sa in "../../../PWD"
Start
About to logon
About to open local.tempdb
Creating procedure #t0022
Msg 177, Level 15, State 6
Server '', Line 1
CREATE PROCEDURE cannot create a temporary object (with '#' as the first
character name.

Msg 137, Level 15, State 1
Server '', Line 9
Must declare variable '@null_input'.

Msg 137, Level 15, State 1
Server '', Line 10
Must declare variable '@first_type'.

Msg 137, Level 15, State 1
Server '', Line 14
Must declare variable '@nrows'.

Failed to create procedure #t0022. Wrong permission or not MSSQL.
Dropping procedure t0022
Msg 3701, Level 11, State 1
Server '', Line 1
Cannot drop the procedure 't0022', because it doesn't exist in the
system catalogs.

Creating procedure t0022
executing dbrpcinit
executing dbrpcparam
executing dbrpcparam
executing dbrpcparam
executing dbrpcparam
executing dbrpcparam
executing dbrpcsend
executing dbsqlok
bound 1 of 1 columns ('name') in result 1.
        name
        -----------
retrieving return status...
none
retrieving output parameters...
param name             type length  data
----- --------------- ----- ------ ------------------------------
bound 1 of 1 columns ('type') in result 2.
        type
        -----------
        int
        char
        text
retrieving return status...
none
retrieving output parameters...
param name             type length  data
----- --------------- ----- ------ ------------------------------
bound 1 of 1 columns ('name') in result 3.
        name
        -----------
        sysgams
        syskeys
        syslogs
        sysroles
        systypes
        sysusers
        syscolumns
        sysdepends
        sysindexes
        sysobjects
        syscomments
        sysprotects
        syssegments
        systabstats
        sysalternates
        sysattributes
        syspartitions
        sysprocedures
        sysreferences
        sysstatistics
        systhresholds
        sysconstraints
        sysusermessages
retrieving return status...
42
retrieving output parameters...
param name             type length  data
----- --------------- ----- ------ ------------------------------
1     @null_input        39      7  varchar
2     @first_type        39      6  binary
3     @nullout           56      0
4     @nrows             56      4  3
Good: Got 4 output parameters and 1 return status of 42.
Good: Got 3 resultsets and 1 empty resultset.
Dropping procedure
dblib okay on rpc.c

freddy77





More information about the FreeTDS mailing list