Message-ID: From: "KristianIvarsson (@KristianIvarsson)" To: "postgresql-interfaces/psqlodbc" Date: Sat, 21 Sep 2024 08:57:03 +0000 Subject: Re: [postgresql-interfaces/psqlodbc] issue #43: syntax error at or near "ROWS" In-Reply-To: References: List-Id: X-GitHub-Author-Login: KristianIvarsson X-GitHub-Comment-Id: 2365067640 X-GitHub-Comment-Type: issue_comment X-GitHub-Edited-At: 2024-09-21T11:43:15Z X-GitHub-Issue: 43 X-GitHub-Repo: postgresql-interfaces/psqlodbc X-GitHub-Type: comment X-GitHub-Url: https://github.com/postgresql-interfaces/psqlodbc/issues/43#issuecomment-2365067640 Content-Type: text/plain; charset=utf-8 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 #include #include #include #include #include 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(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; } ```