postgresql-interfaces/psqlodbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feed[postgresql-interfaces/psqlodbc] PR #70: Fix PG_ErrorInfo and ER_ReturnError when error message is larger than 65535 bytes
3+ messages / 2 participants
[nested] [flat]
* [postgresql-interfaces/psqlodbc] PR #70: Fix PG_ErrorInfo and ER_ReturnError when error message is larger than 65535 bytes
@ 2024-11-02 08:39 "r33s3n6 (@r33s3n6)" <[email protected]>
0 siblings, 0 replies; 3+ messages in thread
From: r33s3n6 (@r33s3n6) @ 2024-11-02 08:39 UTC (permalink / raw)
To: postgresql-interfaces/psqlodbc <[email protected]>
Old driver truncated the server error message incorrectly.
## old implementation
environ.c:147:
```c
error->errorsize = (Int2) errsize;
```
When `errsize` is larger than 32767, the errorsize is wrong.
environ.c:204:
```c
msglen = (SQLSMALLINT) strlen(msg);
```
`msglen` is truncated when msg is larger than 65535 bytes.
environ.c:224:
```c
RecNumber = 2 + (error->errorpos - 1) / error->recsize;
```
`errorpos` is used but never set.
## new implementaion
In `PG_ErrorInfo`, makes `errsize`, `errpos` UInt4.
```c
typedef struct
{
UInt4 status;
UInt4 errsize;
UInt4 errpos;
UInt2 recsize;
char sqlstate[6];
char __error_message[44];
} PG_ErrorInfo;
```
Fix `ER_Construct` and `ER_Dup` .
In `ER_ReturnError`, makes `msglen`, `wrtlen`, `pcblen` UInt4, and set `errpos` correctly.
```c
UInt4 stapos, msglen, wrtlen, pcblen;
```
```c
msglen = error->errsize;
```
```c
error->errpos = stapos + wrtlen;
```
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] PR #70: Fix PG_ErrorInfo and ER_ReturnError when error message is larger than 65535 bytes
@ 2024-11-02 10:11 ` "davecramer (@davecramer)" <[email protected]>
1 sibling, 0 replies; 3+ messages in thread
From: davecramer (@davecramer) @ 2024-11-02 10:11 UTC (permalink / raw)
To: postgresql-interfaces/psqlodbc <[email protected]>
Interesting. Did you run into this in a real situation ?
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [postgresql-interfaces/psqlodbc] PR #70: Fix PG_ErrorInfo and ER_ReturnError when error message is larger than 65535 bytes
@ 2024-11-02 10:26 ` "r33s3n6 (@r33s3n6)" <[email protected]>
1 sibling, 0 replies; 3+ messages in thread
From: r33s3n6 (@r33s3n6) @ 2024-11-02 10:26 UTC (permalink / raw)
To: postgresql-interfaces/psqlodbc <[email protected]>
Yes, but I was not connecting to Postgres, but another database that gives a very long error message.
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2024-11-02 10:26 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-11-02 08:39 [postgresql-interfaces/psqlodbc] PR #70: Fix PG_ErrorInfo and ER_ReturnError when error message is larger than 65535 bytes "r33s3n6 (@r33s3n6)" <[email protected]>
2024-11-02 10:11 ` "davecramer (@davecramer)" <[email protected]>
2024-11-02 10:26 ` "r33s3n6 (@r33s3n6)" <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox