Strange pg_oid problem. - Mailing list pgsql-bugs

From Andrew Hill
Subject Strange pg_oid problem.
Date
Msg-id 1008640729.21088.6.camel@nikita
Whole thread Raw
Responses Re: Strange pg_oid problem.
List pgsql-bugs
Hello.

I'm using debian on i386 with postgresql 7.1.3.

I'm writing an interface libary to postgresql which uses libpq, and
I've stumbled across a weird problem and i'm having problems tracking
down.

Oh and sorry about bad code formating, evolution an't giving me as much
room as i want.

main()
{
gint err;
PGresult *res;
res = PQexec(globaldbconn->conn, "SELECT *,oid FROM programme WHERE
id='2131'");

err = PQresultStatus(res);
if (err == PGRES_BAD_RESPONSE || err == PGRES_NONFATAL_ERROR || err ==
PGRES_FATAL_ERROR)
    {
          printf("Result failed with %s\n", PQresultErrorMessage(res));
    }
printf("%s returned for oid",PQgetvalue(res, 0, 16));
}

oid is at position 16 in the result set, what i'm basically getting is
the oid for the record where id=2131.
The returned value is 3249697. If I run the sql statement into pgsql i
get:

SELECT *,oid FROM programme WHERE id='2131';
  id  | programmegroupid |         name          |  director   | amount
| enrollimit | waitinglistlimit | startdate  |  enddate   |
imembershiplength | membershiplengthtype | concession | programmetype |
history | quickadd | oneoff |   oid

------+------------------+-----------------------+-------------+--------+------------+------------------+------------+------------+-------------------+----------------------+------------+---------------+---------+----------+--------+---------
 2131 |                9 | L The Dream Team 9/99 | Ariana Sour |      0
|          0 |                0 | 1999-09-20 | 1999-11-01
|                 0 |                    1 |          0 |             2
| f       | f        | f      | 3249697
(1 row)
Which seems fine,


Now this is all what behave should be, but if i insert the exact same
code into my libary at a low level point, ie everytime i do a PQexec, i
get the result 2729675.  Everything else seems to work fine execpt this
which is why it took me ages to pick up.  Would having serveral
resultsets open at one time effect the oid values?. This could be
something in my libary screwing up, but i dont know. And if it is a bug
it could be hard to replicate, I'll keep working on it to see if i can
find something more definate that always causes it.

pgsql-bugs by date:

Previous
From: William Yu
Date:
Subject: Backend process termination + database corruption
Next
From: Paul Vixie
Date:
Subject: casting TEXT to CIDR (or to INET) has to be possible