[prev in list] [next in list] [prev in thread] [next in thread] 

List:       freetds
Subject:    Re: [freetds] version detection
From:       Frediano Ziglio <freddy77 () gmail ! com>
Date:       2016-06-22 15:41:19
Message-ID: CAHt6W4c=y80PmoOmUKLzsuFTLRNra-hkuD0D9u3Auwzx3bOUxg () mail ! gmail ! com
[Download RAW message or body]

2016-06-21 22:45 GMT+01:00 Adam Baratz <adam.baratz@gmail.com>:
> 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
_______________________________________________
FreeTDS mailing list
FreeTDS@lists.ibiblio.org
http://lists.ibiblio.org/mailman/listinfo/freetds
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic