[freetds] ct_dynamic()/ct_param() support

ZIGLIO Frediano Frediano.Ziglio at vodafone.com
Mon Oct 13 12:00:58 EDT 2003


> > 
> > Problem is not MS-SQL or Sybase, problem is CTLib. Code for dynamic 
> > was in
> > FreeTDS since 0.61 (with some bugs..) however it still works! I did 
> > many updates for ODBC but CTLib is not my library (I don't 
> know even 
> > how to submit a dynamic query using CTLib...). Looking at 
> code I saw a
> > lot of TODO. No tds_submit_prepare/tds_submit_execute are called 
> > however code for parameters seem present (for RPC). Bill is 
> preparing 
> > a patch for CTLib but I don't know is this patch include dynamic
> > implementation.
> 
> Thanks - I looked at the code a little, and it *appears* that 
> RPCs are supported. After two small patches (one to support 
> CS_NULLTERM as the datalen parameter) I got the code to 
> "work" - but it crashes the MSSQL 2k server that I've got 
> running here (the server crashes *hard*!).
> 
> I've attached the tdsdump file, in case anyone can see what 
> is missing.
> 
> Michael
> 

0000 03 01 00 38 00 00 01 00-0c 00 73 00 70 00 5f 00 |...8.... ..s.p._.|
0010 68 00 65 00 6c 00 70 00-69 00 6e 00 64 00 65 00 |h.e.l.p. i.n.d.e.|
0020 78 00 00 00 00 00 af 00-00 09 04 d0 00 34 08 00 |x.....¯. ...Ð.4..|
0030 73 79 73 75 73 65 72 73-                        |sysusers|

Why column_size is not initialized? This seem the problem. Packet should be 

0000 03 01 00 38 00 00 01 00-0c 00 73 00 70 00 5f 00 |...8.... ..s.p._.|
0010 68 00 65 00 6c 00 70 00-69 00 6e 00 64 00 65 00 |h.e.l.p. i.n.d.e.|
0020 78 00 00 00 00 00 af 08-00 09 04 d0 00 34 08 00 |x.....¯. ...Ð.4..|
                          ^^ ^^ column_size
0030 73 79 73 75 73 65 72 73-                        |sysusers|

>From documentation (src/doc/tds.html)

Data info structure 
  INT8          XCHAR[n]     INT8    INT32
+-------------+------------+-------+------------------+
| name length | param name | flags | usertype (TDS7+) |
+-------------+------------+-------+------------------+
  INT8   varies  varies     INT8[5]      INT8
+------+-------+----------+------------+---------------+
| type | size  | optional | collate    | locale        |
|      | (opt) | (opt)    | info(TDS8) | length (TDS5) |
+------+-------+----------+------------+---------------+

usertype is valid in TDS5, not in TDS7+, code is correct (it works).

freddy77


More information about the FreeTDS mailing list