postgresql-interfaces/psqlodbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: KristianIvarsson (@KristianIvarsson) <[email protected]>
To: postgresql-interfaces/psqlodbc <[email protected]>
Subject: Re: [postgresql-interfaces/psqlodbc] issue #43: syntax error at or near "ROWS"
Date: Sat, 21 Sep 2024 08:57:03 +0000
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <[email protected]>
Okey, I now read your comment more thoroughly @davecramer and the "Slightly different table works fine"
Do you mean that you can reproduce the error with our table design but not with your table design ? If so, that is not a proper hotfix for us and this error occurs occationally for other tables with other layout as well. It ends up with this error even if you're doing a SELECT with a non existing table.
However, here's some code that reproduces the error. Compiled with Visual Studio 17.12.0 Preview 2.0 and /std:c++latest (in case the `std::println()` function doesn't work)
```cpp
#ifdef UNICODE
#undef UNICODE
#endif
#include <windows.h>
#include <sqltypes.h>
#include <sqlext.h>
#include <sql.h>
#include <cassert>
#include <print>
void evaluate(const SQLUSMALLINT type, const SQLHANDLE handle, const SQLRETURN result)
{
switch(result)
{
case SQL_SUCCESS:
case SQL_SUCCESS_WITH_INFO:
break;
default:
SQLCHAR state[5 + 1] = {0};
SQLCHAR message[SQL_MAX_MESSAGE_LENGTH + 1] = {0};
SQLSMALLINT length = sizeof(message);
SQLGetDiagRec(type, handle, 1, state, nullptr, message, length, &length);
std::println("{} [state={}] [result={}]", (const char*)message, (const char*)state, result);
assert(false);
}
}
int main()
{
SQLHANDLE environment;
evaluate(SQL_HANDLE_ENV, environment, SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &environment));
evaluate(SQL_HANDLE_ENV, environment, SQLSetEnvAttr(environment, SQL_ATTR_ODBC_VERSION, reinterpret_cast<void*>(SQL_OV_ODBC3), 0));
SQLHANDLE connection;
evaluate(SQL_HANDLE_DBC, connection, SQLAllocHandle(SQL_HANDLE_DBC, environment, &connection));
evaluate(SQL_HANDLE_DBC, connection, SQLDriverConnect(connection, NULL, (SQLCHAR*)"DSN=TestPG", SQL_NTS, NULL, 0, NULL, SQL_DRIVER_NOPROMPT));
SQLHANDLE statement;
evaluate(SQL_HANDLE_STMT, statement, SQLAllocHandle(SQL_HANDLE_STMT, connection, &statement));
SQLSMALLINT number = 0;
long page = 25;
evaluate(SQL_HANDLE_STMT, statement, SQLBindParameter(statement, ++number, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &page, sizeof(page), NULL));
long size = 25;
evaluate(SQL_HANDLE_STMT, statement, SQLBindParameter(statement, ++number, SQL_PARAM_INPUT, SQL_C_SLONG, SQL_INTEGER, 0, 0, &size, sizeof(size), NULL));
SQLCHAR sql[] = R"(SELECT "Id" FROM "ServerSession" ORDER BY "Begin" ASC OFFSET ? ROWS FETCH FIRST ? ROWS ONLY)";
evaluate(SQL_HANDLE_STMT, statement, SQLExecDirect(statement, sql, sizeof(sql)));
return 0;
}
```
view thread (14+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: github://postgresql-interfaces/psqlodbc
Cc: [email protected], [email protected]
Subject: Re: [postgresql-interfaces/psqlodbc] issue #43: syntax error at or near "ROWS"
In-Reply-To: <<[email protected]>>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox