Discussion:
[freetds] Best way to get FreeTDS version?
Marc Abramowitz
2013-03-01 15:55:47 UTC
Permalink
I thought it would be nice to have a function in pymssql that prints out the version of FreeTDS in use. This could be useful for troubleshooting as well as skipping tests that are known to fail with older versions of FreeTDS (e.g.: the problem with dbrpcparam with wide strings that I posted about in another thread -- http://lists.ibiblio.org/pipermail/freetds/2013q1/028272.html).

My first attempt was to use the function tds_get_compiletime_settings. That didn't work because that symbol is private in libsybdb. I wonder if it makes sense to make it global?

What I ended up doing was using the ct_config function ? unfortunately, this requiring adding a link with libct (pymssql only linked with libsybdb before)

Is there a better way?

Marc
James K. Lowden
2013-03-02 01:43:43 UTC
Permalink
On Fri, 1 Mar 2013 15:55:47 +0000
Post by Marc Abramowitz
I thought it would be nice to have a function in pymssql that prints
out the version of FreeTDS in use.
$ grep dbver api_status.txt
dblib core n/a dbversion
OK

Is dbversion what you want?

--jkl
Marc Abramowitz
2013-03-02 01:55:12 UTC
Permalink
Post by James K. Lowden
On Fri, 1 Mar 2013 15:55:47 +0000
Post by Marc Abramowitz
I thought it would be nice to have a function in pymssql that prints
out the version of FreeTDS in use.
$ grep dbver api_status.txt
dblib core n/a dbversion
OK
Is dbversion what you want?
Post by Marc Abramowitz
pymssql.get_dbversion()
'$Id: dblib.c,v 1.407 2012-03-11 15:52:22 freddy77 Exp $'


I wanted the version of FreeTDS rather than the version of a
particular source file.

Marc
James K. Lowden
2013-03-02 03:56:39 UTC
Permalink
On Sat, 2 Mar 2013 01:55:12 +0000
Post by Marc Abramowitz
Post by James K. Lowden
On Fri, 1 Mar 2013 15:55:47 +0000
Post by Marc Abramowitz
I thought it would be nice to have a function in pymssql that
prints out the version of FreeTDS in use.
$ grep dbver api_status.txt
dblib core n/a dbversion
OK
Is dbversion what you want?
Post by Marc Abramowitz
pymssql.get_dbversion()
'$Id: dblib.c,v 1.407 2012-03-11 15:52:22 freddy77 Exp $'
Ah. Well, you know, the way dbversion() is defined predates the
compile-time version manifest constant.

0 tdsver.h <global> 25 #define TDS_VERSION_NO
"freetds v0.92.dev.20120915"

Just change dbversion to refer to TDS_VERSION_NO instead. I see no
great value in using the CVS keyword expansion, especially now that
we're not using CVS. ;-)

That's the right fix IMO. If you supply a patch, I'd gladly apply it.

--jkl
Post by Marc Abramowitz
I wanted the version of FreeTDS rather than the version of a
particular source file.
Marc
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
Marc Abramowitz
2013-03-02 17:56:29 UTC
Permalink
Post by James K. Lowden
Just change dbversion to refer to TDS_VERSION_NO instead. I see no
great value in using the CVS keyword expansion, especially now that
we're not using CVS. ;-)
That's the right fix IMO. If you supply a patch, I'd gladly apply it.
OK, here you go:

diff --git a/src/dblib/dblib.c b/src/dblib/dblib.c
index 21ba37a..2a9978c 100644
--- a/src/dblib/dblib.c
+++ b/src/dblib/dblib.c
@@ -6598,7 +6598,7 @@ const char *
dbversion()
{
tdsdump_log(TDS_DBG_FUNC, "dbversion(void)\n");
- return rcsid_var;
+ return TDS_VERSION_NO;
}

#if defined(DBLIB_UNIMPLEMENTED)
James K. Lowden
2013-03-03 03:30:56 UTC
Permalink
On Sat, 2 Mar 2013 17:56:29 +0000
Post by Marc Abramowitz
Post by James K. Lowden
That's the right fix IMO. If you supply a patch, I'd gladly apply it.
diff --git a/src/dblib/dblib.c b/src/dblib/dblib.c
index 21ba37a..2a9978c 100644
--- a/src/dblib/dblib.c
+++ b/src/dblib/dblib.c
@@ -6598,7 +6598,7 @@ const char *
dbversion()
{
tdsdump_log(TDS_DBG_FUNC, "dbversion(void)\n");
- return rcsid_var;
+ return TDS_VERSION_NO;
}
#if defined(DBLIB_UNIMPLEMENTED)
Thanks. Although a one-liner like that seems trivial, it's not. It
saves me the time to investigate and test. You're presumably already
using it, and it solves a problem for you. We make your change part of
the next version, and everyone wins.

Regards,

--jkl
Marc Abramowitz
2013-03-03 19:26:03 UTC
Permalink
Post by James K. Lowden
Thanks. Although a one-liner like that seems trivial, it's not. It
saves me the time to investigate and test. You're presumably already
using it, and it solves a problem for you. We make your change part of
the next version, and everyone wins.
Glad I could help (if even in a very small way).

Marc
Frediano Ziglio
2013-03-09 15:20:13 UTC
Permalink
Applied to master branch

Frediano
Post by Marc Abramowitz
Post by James K. Lowden
Thanks. Although a one-liner like that seems trivial, it's not. It
saves me the time to investigate and test. You're presumably already
using it, and it solves a problem for you. We make your change part of
the next version, and everyone wins.
Glad I could help (if even in a very small way).
Marc
_______________________________________________
FreeTDS mailing list
FreeTDS at lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
Loading...