Re: [HACKERS] Oid Questions

Поиск
Список
Период
Сортировка
От Zeev Suraski
Тема Re: [HACKERS] Oid Questions
Дата
Msg-id 3.0.3.32.19980122235535.00cdc100@bourbon.netvision.net.il
обсуждение исходный текст
Ответ на Re: [HACKERS] Oid Questions  (Bruce Momjian <maillist@candle.pha.pa.us>)
Ответы Re: [HACKERS] Oid Questions  (Bruce Momjian <maillist@candle.pha.pa.us>)
Список pgsql-hackers
At 16:25 22/01/98 -0500, Bruce Momjian wrote:
>A zero value for OID is reserved for an Invalid OID.  If it returns a
>zero, I would pass it back to the application.  You may want to call
>libpq's PQoidStatus() to get this information.  That is a new function
>for 6.2.1.

Ok, please tell me if this logic is correct.  It describes the logic behind
the implementation of pg_exec() in PHP.

First, the query is executed.  If the status is PGRES_EMPTY_QUERY or
PGRES_BAD_RESPONSE or PGRES_NONFATAL_ERROR or PGRES_FATAL_ERROR, return
FALSE (failure).
If it returns PGRES_COMMAND_OK (which is, from what I understand, a
successful query that is, by definition, not supposed to return rows) -
check PQoidStatus().  If it's not null, atoi() of it is not 0, return its
return value as a numeric integer.  If it is zero, assume that this was a
successful query that didn't cause the oid to be updated, and return TRUE
(successful query that does not return rows or oid).
Otherwise, assume that that was a succesful query that returned rows -
return a PostgresSQL result identifier.

I guess that my key question is, whether or not it's correct to assume
PGRES_COMMAND_OK + PQoidStatus() == 0 or "0"   => successful query that did
not return rows and did not update the oid, OR, is it possible that
PQoidStatus() of zero reflects some error, even though the return value was
PGRES_COMMAND_OK?

PHP can return different datatypes from the same function, in case you were
wondering :)

Zeev
---
Zeev Suraski  <zeev@php.net>
Web programmer, System administrator, Netvision LTD
http://bourbon.netvision.net.il/   ICQ: 1450980
For a PGP public key, finger bourbon@netvision.net.il

В списке pgsql-hackers по дате отправления:

Предыдущее
От: The Hermit Hacker
Дата:
Сообщение: Re: [HACKERS] Current open 6.3 issues
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: [HACKERS] Oid Questions