Message-ID: From: "vadz (@vadz)" To: "postgresql-interfaces/psqlodbc" Date: Tue, 28 Jan 2025 17:03:53 +0000 Subject: [postgresql-interfaces/psqlodbc] issue #89: Batch update with some invalid values fails for all rows List-Id: X-GitHub-Author-Id: 146917 X-GitHub-Author-Login: vadz X-GitHub-Issue: 89 X-GitHub-Repo: postgresql-interfaces/psqlodbc X-GitHub-State: open X-GitHub-Type: issue X-GitHub-Url: https://github.com/postgresql-interfaces/psqlodbc/issues/89 Content-Type: text/plain; charset=utf-8 Suppose there is the following table in the database: ```sql create table t(x integer check (x<100)); ``` and consider a program which does something like the following (simplified): ```cpp constexpr int ARRAY_SIZE = 2; SQLSetStmtAttr(h, SQL_ATTR_PARAMSET_SIZE, (void *)ARRAY_SIZE, 0); SQLINTEGER values[ARRAY_SIZE] = { 1, 101 }; // First value is valid, second one is not. SQLLEN inds[ARRAY_SIZE]; SQLBindParameter(h, 1, SQL_PARAM_INPUT, SQL_C_INTEGER, SQL_INTEGER, 0, 0, values, 0, inds); SQLUSMALLINT status[ARRAY_SIZE]; SQLSetStmtAttr(h, SQL_ATTR_PARAM_STATUS_PTR, status, 0); SQLPrepare(h, "insert into t(x) values(?)", SQL_NTS); SQLRETURN rc = SQLExecute(h); ``` When using SQL Server with either Microsoft ODBC driver or FreeTDS, `rc` is `SQL_SUCCESS_WITH_INFO` and `status` array is filled with `{ SQL_PARAM_SUCCESS, SQL_PARAM_ERROR }` which is nice because it allows the application to determine which row(s) contained values that resulted in an error. When using PostgreSQL ODBC driver (v13.02, but from examining Git history it doesn't look like there have been any changes here even in the latest version), `rc` is `SQL_ERROR` and `status` contains `SQL_PARAM_ERROR` for both elements, which doesn't provide any useful information. Is this behaviour intentional and, if not, would it be possible to change it to be more consistent with other ODBC drivers and, also, more useful?