Обсуждение: Does the psqlodbc driver support asynchronous queries?

Поиск
Список
Период
Сортировка

Does the psqlodbc driver support asynchronous queries?

От
Juan Tiritas
Дата:
Hello everyone,

I'm trying to run asynchronous queries with unixODBC + psqlodbcw.so in linux (RHEL5), but I can not do it.

The next code:

//-------
    // Get the Async state
 SQLINTEGER attrState;
    SQLGetConnectAttr(hstmt, SQL_ATTR_ASYNC_ENABLE, &attrState, 0, NULL);
    std::cout << "Async is set to: " << attrState << std::endl;
    // Enable Async Operation - if ASYNC is not allowed, SQLSetStmtAttr
    // will return an error
    retcode = SQLSetStmtAttr (hstmt, SQL_ATTR_ASYNC_ENABLE,
                              (SQLPOINTER) SQL_ASYNC_ENABLE_ON, SQL_IS_INTEGER);
    CHECK_ERROR(retcode, "SQLSetStmtAttr(SQL_ATTR_ASYNC_ENABLE)",
                hstmt, SQL_HANDLE_STMT);
    // Get the Async state again
    SQLGetConnectAttr(hstmt, SQL_ATTR_ASYNC_ENABLE, &attrState, 0, NULL);
    std::cout << "Async is set to: " << attrState << " now " << std::endl;
    // Execute SELECT whilst status SQL_STILL_EXECUTING
    //retcode = SQLExecDirect (hstmt, stmt, SQL_NTS);
 while (SQLExecDirect (hstmt, stmt, SQL_NTS) == SQL_STILL_EXECUTING) {
  printf ("\nStill executing ...");
  printf ("\nSnooze ..");
  sleep(1);
  printf ("\nAwake ..");
  retcode = SQLExecDirect (hstmt, stmt, SQL_NTS);
 }
//-------

Returns the next output:

Async is set to: -1074166952
Async is set to: -1074166952 now

and the select is not working in asynchronous mode.

Am I doing something wrong or the postgres odbc driver does not support asynchronous calls through unixODBC?

Thanks in advance.

Regards,
Juan Tiritas


Re: Does the psqlodbc driver support asynchronous queries?

От
Clemens Ladisch
Дата:
Juan Tiritas wrote:
> Am I doing something wrong

<https://docs.microsoft.com/en-us/sql/odbc/reference/develop-app/asynchronous-execution-polling-method>
says:
| To find out which one is supported, an application calls SQLGetInfo with an option
| of SQL_ASYNC_MODE. SQL_AM_CONNECTION is returned if connection-level asynchronous
| execution (for a statement handle) is supported; SQL_AM_STATEMENT if statement-
| level asynchronous execution is supported.

> or the postgres odbc driver does not support asynchronous calls through unixODBC?

It returns SQL_AM_NONE.


Regards,
Clemens


Re: Does the psqlodbc driver support asynchronous queries?

От
Juan Tiritas
Дата:
Thanks for your answer, Clemens.

You're right, I've tried SQLGetInfo and the function returns SQL_AM_NONE.

I will try libpq because my middleware needs asynchronous access.


Regards,
Juan Tiritas


El mar., 6 nov. 2018 a las 18:51, Clemens Ladisch (<clemens@ladisch.de>) escribió:
Juan Tiritas wrote:
> Am I doing something wrong

<https://docs.microsoft.com/en-us/sql/odbc/reference/develop-app/asynchronous-execution-polling-method>
says:
| To find out which one is supported, an application calls SQLGetInfo with an option
| of SQL_ASYNC_MODE. SQL_AM_CONNECTION is returned if connection-level asynchronous
| execution (for a statement handle) is supported; SQL_AM_STATEMENT if statement-
| level asynchronous execution is supported.

> or the postgres odbc driver does not support asynchronous calls through unixODBC?

It returns SQL_AM_NONE.


Regards,
Clemens