CaselIT commented on issue #3878:
URL: https://github.com/apache/arrow-adbc/issues/3878#issuecomment-3738999923
It seems there was a typo in the refactoring done here a48ccec
It went from
```c
const char* sqlstate = PQresultErrorField(result, PG_DIAG_SQLSTATE);
if (sqlstate) {
// https://www.postgresql.org/docs/current/errcodes-appendix.html
// This can be extended in the future
if (std::strcmp(sqlstate, "57014") == 0) {
code = ADBC_STATUS_CANCELLED;
} else if (std::strcmp(sqlstate, "42P01") == 0 ||
std::strcmp(sqlstate, "42602") == 0) {
code = ADBC_STATUS_NOT_FOUND;
} else if (std::strncmp(sqlstate, "42", 0) == 0) {
// Class 42 — Syntax Error or Access Rule Violation
code = ADBC_STATUS_INVALID_ARGUMENT;
}
static_assert(sizeof(error->sqlstate) == 5, "");
// N.B. strncpy generates warnings when used for this purpose
int i = 0;
for (; sqlstate[i] != '\0' && i < 5; i++) {
error->sqlstate[i] = sqlstate[i];
}
for (; i < 5; i++) {
error->sqlstate[i] = '\0';
}
}
```
to
```c
if (sqlstate) {
// https://www.postgresql.org/docs/current/errcodes-appendix.html
// This can be extended in the future
if (std::strcmp(sqlstate, "57014") == 0) {
code = ADBC_STATUS_CANCELLED;
} else if (std::strcmp(sqlstate, "42P01") == 0 ||
std::strcmp(sqlstate, "42602") == 0) {
code = ADBC_STATUS_NOT_FOUND;
} else if (std::strncmp(sqlstate, "42", 0) == 0) {
// Class 42 — Syntax Error or Access Rule Violation
code = ADBC_STATUS_INVALID_ARGUMENT;
}
}
Status status(code, message);
status.SetSqlState(sqlstate);
```
setstatus should be called only inside the `if (sqlstate) {` not outside
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]