More on using FreeTDS on a server (was Re: [freetds] Serverdumpscore...)
ZIGLIO, Frediano, VF-IT
Frediano.Ziglio at vodafone.com
Fri Apr 23 07:12:13 EDT 2004
> "James K. Lowden" <jklowden at schemamania.org> wrote on
> Thursday, Apr 22, 2004:
> > On Tue, 20 Apr 2004, Steve Kirkendall
> <skirkendall at dsl-only.net> wrote:
> > > There's no way for high-level functions to know what type
> of packet is
> > > received, because the tds_read_packet() function
> discards that byte.
> > > I added an in_flag field to the TDSSOCKET structure,
> > Perhaps "in_flag" would be better named "token" or "packet_type"?
> I chose the name "in_flag" because TDSSOCKET already contains a field
> named "out_flag" which seems to control the packet type for
> any outgoing
> packets. There are a lot of "in_XXX" and "out_XXX" field names, so I
> was trying to continue that symmetry.
> But now I wonder if it really matters. The received packet type seems
> to be superfluous. I originally wanted to know the packet
> type partly so
> my server could automatically distinguish between TDS7.0 and
> logins (in 0x10 and 0x02 packets, respectively), and partly
> so it could
> treat the entire content of a 0x01 query packet as the text
> of a query,
> while still allowing RPC calls in 0x04 packets.
> But Mike C. points out that 7.0 uses a prelogin packet, so my server
> should be able to detect the login type that way.
I don't understand why you want to use mssql2k syntax... if the reason
is to use default ms sql odbc drivers (or ADODB or other proprietary
libraries) I discourage you. The reason is that you MUST implement:
- advanced types (unicode, guid, variant)
- system tables (syscomments and others)
- prepared statement (server side)
- some internal store procedure (sp_prepare, sp_tables, sp_typeinfo...)
Version 4.2 is easier to implement (no prepared, no guid, variant, fewer
> I thought the entire content of a 0x01 packet was a query because the
> tsql program seems to send them that way. The
> tds_get_query() function
> expects a 6-byte header at the start of each query, so it doesn't work
> correctly with tsql. But it looks like the tds_get_query()
> function is
> right, and tsql is wrong. Maybe. I'm not 100% confident of
> that; I'll
> look into it tomorrow.
I don't think tsql is wrong... Language query are just the payload
(without packet header) content, packet type 1.
> If both of those things are right (prelogin to detect 7.0 logins, and
> token header for queries) then the server doesn't need to know the
> received packet type anymore than the client does. My "in_flag"
> modification wouldn't be necessary.
prelogin detect 8.0 login, not 7.0. 7.0 are detected with tds 7 type
More information about the FreeTDS