Skip to Content.
Sympa Menu

freetds - [freetds] Proposed Patch: FreeTDS ODBC without an ODBC driver manager

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "David Fraser" <david AT abelon.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: [freetds] Proposed Patch: FreeTDS ODBC without an ODBC driver manager
  • Date: Fri, 24 Oct 2003 16:26:05 +0100

Ok folks.

As promised here are details of what needs done to get FreeTDS ODBC
working without a driver manager.

I leave it to the core-developers to review/critique/complain/modify
and/or perhaps accept the patch.

What it provides is mainly the following:
* Ability to make an ODBC driver standalone (i.e. with no driver
manager).
* Provides configure script option for this, which also defines the
existing TDS_NO_DM define, thus providing a means to enable this
existing code (put together by Freddy & Steve Murphree) via
configure.
* Allows unittests to build for this standalone driver environment.
* Minor fixes to buglets that got in the way of the above.

Pre-requisites
* The files sql.h, sqlext.h and sqltypes.h need to be available. These can
be taken from either the iODBC or UnixODBC distributions. Either set
of files work equally well. I copy them into /usr/local/include, in my
setup. This directory is configurable - see next.

Code changes - the patch for this is attached and is relatively trivial:
1) I changed configure.in, adding in a clause which defines a
"--with-odbc-nodm" option, much like "--with-iodbc" or
"--with-unixodbc". Indeed it rips of the configure.in settings
for these options, since I'm not that familiar with configure
scripts. As with these options a directory is supplied as a
parameter - such as /usr/local. The include files (sql.h, sqlext.h
etc) are looked for in the "include" subdirectory below this
point (as with the iodbc and unixodbc options).

I'm open to renaming the option for aesthetic reasons, and
if anyone wants to alter my patch to the configure script to
allow the supplied parameter to be the full include directory
- i.e. /usr/local/include and not just /usr/local, then that's fine
with me. On the other hand it would be consistent with the
--with-unixodbc and --with-iodbc setup to leave it as I
propose.

This new clause also defines TDS_NO_DM, when
--with-odbc-nodm is set. This is the define that Freddy mailed
me about, that adds extra driver manager functionality in a DM-less
scenario.

2) A complimentary change is required to src/odbc/unittests/Makefile.am,
to ensure the right files are linked with the unittests.
This fix also allows iODBC to be built with the unittests (if so
configured): previously, -lodbc was hard-wired into the makefile,
whereas -liodbc is required for iODBC.

3) Changes are required to several include files to ensure sql.h and
sqlext.h are included for the DM-less case (ifdef'd on TDS_NO_DM).
These files are include/tdsodbc.h, src/odbc/prepare_query.h and
src/odbc/odbc_util.h

4) There was an outstanding buglet in the code in odbc.c at line
4601. Extra {}s were required around the if body in order to get
the code to compile.

5) I added an implementation of SQLCloseCursor ifdef'd for
TDS_NO_DM, to give the unittests a chance of linking for this
case. My one question here was whether or not it is appropriate
to change the hstmt->cursor_state to closed. Not that I noticed
any problems with the code as it is.

So with these changes in place, the procedure to install this is:

1) Ensure the sql header files are in place (see pre-requisites above)
2) Get the FreeTDS code with patch applied.
3) Run autogen.sh --with-odbc-nodm=/usr/local [--with-tdsver=7.0] (etc)
4) make
5) make install.

I also verified that the code still works when configured with the iODBC
and unixODBC driver managers, using "configure" which was generated by
the above invocation of autogen.sh.

Unittest failure results are as follows for builds configured with each
of the given driver managers (in my libiconv-less environment):
(x/y) indicates x failed out of y tests - so (0/y) is ideal.

TDS CTLIB DBLIB ODBC
unixODBC: 0/21 1/21 0/25 5/20* (3/20)
iODBC: 0/21 1/21 0/25 14/20
NO-DM: 0/21 1/21 0/25 7/20

Yes - it was probably pretty pointless testing TDS,
CTLIB and DBLIB multiple times, but I wanted to prove
that my configure.in/automake changes hadn't broken
these somehow.

The unixODBC ODBC figure drops to 3/20 when ENABLE_DEVELOPING is
defined. This trick can't be tried with the no-DM code as there is a
bug in the ODBC code in this case which I reported earlier today).
The failures for unixODBC are what Freddy sees, so that's the baseline
I'm working to.

I'm not sure what's up with iODBC, but that I got those results
on a clean build as well, so I'm not taking the rap for that. :-)
It's possibly down to my environment, though the unittests had
unixODBC specifics in the makefile.

Ok - there are some failures for NO-DM over and above unixODBC,
but that's hardly surprising. Two-thirds of the tests work,
i.e. basic useful functionality does work for the No DM case.
It's a good start.

In case I didn't mention it the patch is attached.
I used 'cvs diff -u' - let me know if another format is preferred.
I cvs updated and re-ran the tests around an hour ago, so the patches
should be up-to-date.

Enjoy!

Cheers,

David
--
David Fraser, Consultant, Abelon Systems Ltd, UK
http://www.abelon.com


----- Original Message -----
From: "ZIGLIO Frediano" <Frediano.Ziglio AT vodafone.com>
To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
Sent: Monday, October 20, 2003 10:55 AM
Subject: RE: [freetds] FreeTDS ODBC works without an ODBC driver manager


> >
> > I tried removing the iODBC driver manager,
> > and got my ODBC app to link with the FreeTDS ODBC library
> (libtdsodbc)
> > pretty easily.
>
> Good to hear.
>

Well, Steve Murphree and others add a lot of code for DM removing. DM do
some things very good:
- emulate some functions missed (it can provide ODBC2 while your driver
is ODBC3 and viceversa)
- check many parameters.

You can define TDS_NO_DM in include/config.h to enable some extra checks
that DM do.
Someone (perhaps me) should add an option to enable these checks from
configure...

> > You might
> > argue, why use ODBC then if you are not going to use the Driver
> > Manager
> > - well think of it as insurance/future-proofing - future
> systems might
> > have more memory and might talk to another database - so a Driver
> > Manager can be slotted back in if needed.
>
> True. I'm curious, though, as far as future flexibility is
> concerned, What does ODBC buy you that DBI doesn't?
>

Mainly you can use ODBC to access many DB types. Also some firm have
ODBC applications to port on Unix..

> > However, there are a few pretty easy steps to getting this
> to work on
> > a clean system, which would need incorporated into the source
> > code/Makefile/configure script. (I'm assuming there aren't already
> > options to run FreeTDS ODBC standalone - correct me if I'm
> wrong, but
> > I couldn't find them).
>
> http://www.freetds.org/userguide/x1853.htm
>
> We have some terse instructions, but more would be better. We
certainly don't have any support in "configure" for it.
>
> > Is this of interest to the FreeTDS developers?
>
> Yes!
>
> The place to change anything like this (except for documentation,
which really needs redoing) is in configure.in, which is used by
autoconf to > generate the configure script. We can't use patches to
Makefiles and configure, except as guidance for changes to upstream
files.
>
> > or have I offended everyone's sensibilities by even suggesting such
> > an outrageous idea which violates the very foundations of the ODBC
> > architecture and threatens the moral fabric of our society?
>
> Er, no. To do that, I think you have to win -- or, at least, steal --
an election. ;-)
>

As you can see we are interested and not offended :)

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

Attachment: nodm.diffs.gz
Description: Binary data




Archive powered by MHonArc 2.6.24.

Top of Page