Обсуждение: [GENERAL] PQerrorMessage documentation

Поиск
Список
Период
Сортировка

[GENERAL] PQerrorMessage documentation

От
Igor Korot
Дата:
Hi, ALL,
[quote]
Nearly all libpq functions will set a message for PQerrorMessage if
they fail. Note that by libpq convention, a nonempty PQerrorMessage
result can consist of multiple lines, and will include a trailing
newline. The caller should not free the result directly. It will be
freed when the associated PGconn handle is passed to PQfinish. The
result string should not be expected to remain the same across
operations on the PGconn structure.
[/quote]

Since there may be multiple errors, I presume that in this case the string
will end with just \0, correct? It's not going to be \0\0 like with MSVC.

Thank you.


Re: [GENERAL] PQerrorMessage documentation

От
Peter Eisentraut
Дата:
On 5/3/17 21:23, Igor Korot wrote:
> Hi, ALL,
> [quote]
> Nearly all libpq functions will set a message for PQerrorMessage if
> they fail. Note that by libpq convention, a nonempty PQerrorMessage
> result can consist of multiple lines, and will include a trailing
> newline. The caller should not free the result directly. It will be
> freed when the associated PGconn handle is passed to PQfinish. The
> result string should not be expected to remain the same across
> operations on the PGconn structure.
> [/quote]
>
> Since there may be multiple errors, I presume that in this case the string
> will end with just \0, correct? It's not going to be \0\0 like with MSVC.

I don't know what you mean by \0\0 with MSVC, but it is correct that the
error message string will end with \0, like any C string.

--
Peter Eisentraut              http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services


Re: [GENERAL] PQerrorMessage documentation

От
Igor Korot
Дата:
Hi,

On Thu, May 4, 2017 at 9:57 PM, Peter Eisentraut
<peter.eisentraut@2ndquadrant.com> wrote:
> On 5/3/17 21:23, Igor Korot wrote:
>> Hi, ALL,
>> [quote]
>> Nearly all libpq functions will set a message for PQerrorMessage if
>> they fail. Note that by libpq convention, a nonempty PQerrorMessage
>> result can consist of multiple lines, and will include a trailing
>> newline. The caller should not free the result directly. It will be
>> freed when the associated PGconn handle is passed to PQfinish. The
>> result string should not be expected to remain the same across
>> operations on the PGconn structure.
>> [/quote]
>>
>> Since there may be multiple errors, I presume that in this case the string
>> will end with just \0, correct? It's not going to be \0\0 like with MSVC.
>
> I don't know what you mean by \0\0 with MSVC, but it is correct that the
> error message string will end with \0, like any C string.

Sorry about the confusion - I actually meant MS SQL Server.

Anyway, thank you for the confirmation.

>
> --
> Peter Eisentraut              http://www.2ndQuadrant.com/
> PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services