postgresql-interfaces/psqlodbc GitHub issues and pull requests (mirror)  
help / color / mirror / Atom feed
From: r33s3n6 (@r33s3n6) <[email protected]>
To: postgresql-interfaces/psqlodbc <[email protected]>
Subject: [postgresql-interfaces/psqlodbc] PR #70: Fix PG_ErrorInfo and ER_ReturnError when error message is larger than 65535 bytes
Date: Sat, 02 Nov 2024 08:39:39 +0000
Message-ID: <[email protected]> (raw)

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;
```


view thread (3+ 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] PR #70: Fix PG_ErrorInfo and ER_ReturnError when error message is larger than 65535 bytes
  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