[freetds] [0.95rc2] Preliminary test results

Frediano Ziglio freddy77 at gmail.com
Tue May 12 18:10:55 EDT 2015


2015-05-12 21:07 GMT+01:00 Sergio NNX <sfhacker at hotmail.com>:
>> I start to suspect this (and the other rpc test) could be due to some changes in the protocol for mssql 2008 r2.
>> I'll need a dump to confirm it.
>
> dblib/rpc test dump
>
> About to logon
> expected error 20201: "Packet size of -1 not supported -- size of 0 used instead!"
> About to open localhost.tempdb
> Check if server support long identifiers
>       1: SELECT 'x' AS this_is_a_really_really_long_identifier
> trying to create a temporary stored procedure
> Creating procedure #t0022
>       1:
>       2: CREATE PROCEDURE #t0022
>       3:   @null_input varchar(30) OUTPUT
>       4: , @first_type varchar(30) OUTPUT
>       5: , @nullout int OUTPUT
>       6: , @varchar_tds7_out varchar(8000) OUTPUT
>       7: , @nvarchar_tds7_out nvarchar(4000) OUTPUT
>       8: , @nrows int OUTPUT
>       9: , @c_this_name_is_way_more_than_thirty_characters_charlie varchar(20)
>      10: , @nv nvarchar(20) = N'hello'
>      11: AS
>      12: BEGIN
>      13: if @null_input is not NULL begin
>      14:     select 'error: should be NULL' as status, @null_input as 'null_input'
>      15:     return -42
>      16: end else begin
>      17:     print 'Good: @null_input is NULL'
>      18: end
>      19: if @c_this_name_is_way_more_than_thirty_characters_charlie is not NULL begin
>      20:     select 'error: should be NULL' as status, @c_this_name_is_way_more_than_thirty_characters_charlie as '@c_this_name_is_way_more_than_thirty_characters_charlie'
>      21:     return -42
>      22: end else begin
>      23:     print 'Good: @c_this_name_is_way_more_than_thirty_characters_charlie is NULL'
>      24: end
>      25: select @null_input = max(convert(varchar(30), name)) from systypes
>      26: select @first_type = min(convert(varchar(30), name)) from systypes
>      27: select name from sysobjects where 0=1
>      28: select distinct convert(varchar(30), name) as 'type'  from systypes
>      29: where name in ('int', 'char', 'text')
>      30: select @nrows = @@rowcount
>      31: set @varchar_tds7_out = replicate(char(247), 8000)
>      32: set @nvarchar_tds7_out = replicate(nchar(246), 4000)
>      33: select distinct @nv as '@nv', convert(varchar(30), name) as name  from sysobjects where type = 'S'
>      34: select      @null_input as 'null_input'
>      35:     , @first_type as 'first_type'
>      36:     , @nullout as 'nullout'
>      37:     , @nrows as 'nrows'
>      38:     , @c_this_name_is_way_more_than_thirty_characters_charlie as 'c'
>      39:     , @nv as 'nv'
>      40:     into #parameters
>      41: select * from #parameters
>      42: return 42
>      43: END
>      44:
> Created procedure #t0022
> executing dbrpcinit
> executing dbrpcparam for @null_input
> executing dbrpcparam for @first_type
> executing dbrpcparam for @nullout
> executing dbrpcparam for @varchar_tds7_out
> executing dbrpcparam for @nvarchar_tds7_out
> executing dbrpcparam for @nrows
> executing dbrpcparam for @c_this_name_is_way_more_than_thirty_characters_charlie
> executing dbrpcparam for @nv
> executing dbrpcsend
> executing dbsqlok
> Good: @null_input is NULL
> Good: @c_this_name_is_way_more_than_thirty_characters_charlie is NULL
> fetching results
> fetched resultset 1 successfully:
> column 1 (name) is 1 wide, buffer initialized to 'one'
> name
> row count 0
> fetched resultset 2 successfully:
> column 1 (type) is 1 wide, buffer initialized to 'one'
> type
> char
> int
> text
> row count 3
> fetched resultset 3 successfully:
> column 1 (@nv) is 1 wide, buffer initialized to 'one'
> column 2 (name) is 1 wide, buffer initialized to 'two'
> @nv name
> row count 0
> fetched resultset 4 successfully:
> column 1 (null_input) is 1 wide, buffer initialized to 'one'
> column 2 (first_type) is 1 wide, buffer initialized to 'two'
> column 3 (nullout) is 1 wide, buffer initialized to 'three'
> column 4 (nrows) is 1 wide, buffer initialized to 'four'
> column 5 (c) is 1 wide, buffer initialized to 'five'
> null_input first_type nullout nrows c
> xml bigint   3
> row count 1
> retrieving return status...
> 42
> retrieving output parameters...
> param name                  type length  data
> ----  -------------------   ----  ----- ------------------------------
> 1     @null_input             39      3  xml
> 2     @first_type             39      6  bigint
> 3     @nullout                56      0
> 4     @varchar_tds7_out       39   8000  ÷÷÷÷÷÷÷÷÷÷...
> 5     @nvarchar_tds7_out      39   4000  öööööööööö...
> 6     @nrows                  56      4  3
> Good: Got 6 output parameters and 1 return status of 42.
> Expected an empty resultset got 2.
> FAIL rpc.exe (exit status: 1)
>

This is the output, to get the dump define TDSDUMP to a filename and
send the file, under cmd.exe is something like

set TDSDUMP=dump.txt

while in bash (if you use mingw or cygwin or Linux) is

export TDSDUMP=dump.txt

>
>>> freeclose test output
>>>
>>> [...]
>>> Error finding last socket opened
>>> FAIL freeclose.exe (exit status: 1)
>>>
>
>> Can you try the attached version?
>
> It didn't work. Same error message as before.
> I'd like to understand that test. What's a typical result for this function: odbc_find_last_socket(void)?
> What's a common (or default) value for ip remote addr and remote port? Show me an example.
>
> Thanks for your time.
>
> Sergio.
>

This function is quite an hack function. It try to discover the last
socket connection opened. So it try to scan a lot of possible handles
(numerically 4096 starting from 4, so 4, 8, 12, 16 ... etc) and call
some function to check if they are really sockets (getpeername and
getsockname). I also recently changed to discard pair of socketpair
(two sockets attached together).

I attached a new version, should handle IPv6 addresses (unfortunately
sizeof(struct sockaddr) < sizeof(struct sockaddr_in6) on Windows).

Frediano
-------------- next part --------------
A non-text attachment was scrubbed...
Name: freeclose.c
Type: text/x-csrc
Size: 11435 bytes
Desc: not available
URL: <http://lists.ibiblio.org/pipermail/freetds/attachments/20150512/3b980749/attachment-0001.bin>


More information about the FreeTDS mailing list