Обсуждение: Strange pg_oid problem.

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

Strange pg_oid problem.

От
Andrew Hill
Дата:
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.

Re: Strange pg_oid problem.

От
Tom Lane
Дата:
Andrew Hill <andru@treshna.com> writes:
> 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.

I think you messed up in your code.  If you doubt it, try running the
postmaster with debug level 2, and look in the postmaster log to see
what query is actually being received by the backend.

            regards, tom lane