Re: 'compute' deprecated (Re: rc3 looks good on OpenVMS)
Frediano Ziglio <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <CAHt6W4c52xU6Xwv9oD5nN+2doxNiBxG3Tx+E-4PBonDpMExR4Q@mail.gmail.com> |
2016-04-29 14:41 GMT+01:00 Craig A. Berry <[email protected]>: > >> On May 28, 2015, at 5:16 PM, Frediano Ziglio <[email protected]> wrote: >> >> Il 28/Mag/2015 09:58, "Craig A. Berry" <[email protected]> ha scritto: >>> With SQL 2012 this test below fails, but I >>> think it's just because "compute" has been removed in SQL 2012: > >> Yes, that test check how compute queries reply so cannot work but is not a >> Freetds issue > > I’m reviving this year-old thread because this is still a problem and getting to be a bigger one, and while it isn’t FreeTDS’s fault, it is FreeTDS’s problem if its test suite can’t even run to completion on 3 of the 4 currently-supported versions of Microsoft’s server (SQL 2005 went out of support a week or two ago, so SQL 2008 is the only one that can run the test suite). > I though AppVeyor was running check against mssql 2012 !! > The following tests are the ones affected: > > src/ctlib/unittests/t0009 > src/dblib/unittests/t0023 > src/dblib/unittests/dbmorecmds > > I tried (unsuccessfully) to come up with a way to skip the tests when running on SQL 2012 or greater. The following check tells you what you’ve got, but only at run time, which is too late. The ‘compute’ keyword will still be seen at parse time so the script will already fail before this check runs. Plus it uses Microsoft-specific functions that will probably not parse on Sybase. > > IF CHARINDEX('Microsoft', @@VERSION) <> 0 > BEGIN > IF CAST(PARSENAME(CAST(SERVERPROPERTY('PRODUCTVERSION') AS VARCHAR), 4) AS INT) >= 11 > BEGIN > PRINT 'SKIP - SQL 2012 or greater' > END > END > > Not sure what to suggest. Anybody have a good way forward? > Could this be a solution for t0009 ? diff --git a/src/ctlib/unittests/t0009.c b/src/ctlib/unittests/t0009.c index a033ffe..d7efbde 100644 --- a/src/ctlib/unittests/t0009.c +++ b/src/ctlib/unittests/t0009.c @@ -8,8 +8,8 @@ #include <ctpublic.h> #include "common.h" -static char software_version[] = "$Id: t0009.c,v 1.13 2011-05-16 08:51:40 freddy77 Exp $"; -static void *no_unused_var_warn[] = { software_version, no_unused_var_warn }; +static CS_RETCODE ex_servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * errmsg); +static int compute_supported = 1; /* Testing: Retrieve compute results */ int @@ -91,6 +91,7 @@ main(int argc, char *argv[]) return 1; } + ct_callback(ctx, NULL, CS_SET, CS_SERVERMSG_CB, (CS_VOID *) ex_servermsg_cb); while ((results_ret = ct_results(cmd, &result_type)) == CS_SUCCEED) { switch ((int) result_type) { case CS_CMD_SUCCEED: @@ -98,6 +99,10 @@ main(int argc, char *argv[]) case CS_CMD_DONE: break; case CS_CMD_FAIL: + if (!compute_supported) { + try_ctlogout(ctx, conn, cmd, verbose); + return 0; + } fprintf(stderr, "ct_results() result_type CS_CMD_FAIL.\n"); return 1; case CS_ROW_RESULT: @@ -320,3 +325,14 @@ main(int argc, char *argv[]) return 0; } + +static CS_RETCODE +ex_servermsg_cb(CS_CONTEXT * context, CS_CONNECTION * connection, CS_SERVERMSG * srvmsg) +{ + if (strstr(srvmsg->text, "compute")) { + compute_supported = 0; + printf("Server does not support compute\n"); + return CS_SUCCEED; + } + return servermsg_cb(context, connection, srvmsg); +} >> SQL text will be read from ../../../src/dblib/unittests/t0023.sql >>> Starting dsa0:[craig.freetds-0^.95rc3.src.dblib.unittests]t0023.exe >>> About to logon >>> About to open >>> creating table >>> 1: create table #dblib0023 (col1 int not null, col2 char(1) not >>> null, col3 datetime not null) >>> insert >>> 1: insert into #dblib0023 values (1, 'A', 'Jan 1 2002 >>> 10:00:00AM') >>> 1: insert into #dblib0023 values (2, 'A', 'Jan 2 2002 >>> 10:00:00AM') >>> 1: insert into #dblib0023 values (3, 'A', 'Jan 3 2002 >>> 10:00:00AM') >>> 1: insert into #dblib0023 values (8, 'B', 'Jan 4 2002 >>> 10:00:00AM') >>> 1: insert into #dblib0023 values (9, 'B', 'Jan 5 2002 >>> 10:00:00AM') >>> select >>> 1: select col1, col2, col3 from #dblib0023 order by col2 compute >>> sum(col1) by col2 compute max(col3) >>> Msg 156, Level 15, State 1 >>> Server 'ABC0012312' >>> , Line 1 >>> >>> Incorrect syntax near the keyword 'compute'. >>> exit: no unanticipated messages allowed in unit tests > > I did a test with AppVeyor and only these 3 tests are failing. Good! Frediano _______________________________________________ FreeTDS mailing list [email protected] http://lists.ibiblio.org/mailman/listinfo/freetds