Re: version detection

Frediano Ziglio <[email protected]>
Newsgroups gmane.comp.db.tds.freetds
Message-ID <CAHt6W4c=y80PmoOmUKLzsuFTLRNra-hkuD0D9u3Auwzx3bOUxg@mail.gmail.com>
2016-06-21 22:45 GMT+01:00 Adam Baratz <[email protected]>:
> Following up on my pdo_dblib thread, I'd like to be able to detect which
> version of FreeTDS is installed. So I can know when the dbnextrow()
> workaround should be used instead of dbcanquery(). As far as I can tell,
> the version only gets exposed through dbversion(), which is a string I'd
> have to parse.
>
> Thanks,
> Adam

I don't see another way using dblib calls. You could use some packaging
method testing the version.
As dbversion just returns a constant string you could just use a function
caching the results, like

bool check_dbcanquery_works(void)
{
    static bool initialized = false;
    static bool ok = false;
    if (!initialized) {
       const char *version = dbversion();
       int maj, min, fix = 0;
       if (sscanf(version, "freetds v%d.%d.%d", &maj, &min, &fix) >= 2
&& ((maj << 24) | (min << 16) | fix) >= 0x01000006)
          ok = true;
       initialized = true;
    }
    return ok;
}

Frediano
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.