Re: [HACKERS] Oid Questions

From: Zeev Suraski <bourbon(at)netvision(dot)net(dot)il>
To: Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>, mrogan(at)fpelectronics(dot)com
Cc: hackers(at)postgreSQL(dot)org, php-dev(at)php(dot)iquest(dot)net
Subject: Re: [HACKERS] Oid Questions
Date: 1998-01-22 23:55:35
Message-ID: 3.0.3.32.19980122235535.00cdc100@bourbon.netvision.net.il
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)php(dot)net>
Web programmer, System administrator, Netvision LTD
http://bourbon.netvision.net.il/ ICQ: 1450980
For a PGP public key, finger bourbon(at)netvision(dot)net(dot)il

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1998-01-23 00:09:05 LOCK command
Previous Message The Hermit Hacker 1998-01-22 23:48:06 Important Announcement