Re: pgsql.tcl: Bug concerning joins

Поиск
Список
Период
Сортировка
От Valentin Iliev
Тема Re: pgsql.tcl: Bug concerning joins
Дата
Msg-id Pine.LNX.3.93.980902114237.6107A-100000@aero.vmei.acad.bg
обсуждение исходный текст
Ответ на pgsql.tcl: Bug concerning joins  (Sebastian Meyer <meyer@mevis.de>)
Список pgsql-interfaces
From: JohnDz <John_dzilvelis@valpak.com>

John Dzilvelis wrote:
>
> Sebastian Meyer wrote:
> >
> > I found a bug processing a simple join like
> >    SELECT s1.b,s2.b FROM pgsqlbug1 s1, pgsqlbug2 s2 WHERE s1.a = s2.c;
> > This bug only occurs whern using pgsql.tcl.
> >
> >
> > Using pgsql.tcl from Tcl however I get:
> >
> > meyer> SELECT s1.b,s2.b FROM pgsqlbug1 s1, pgsqlbug2 s2 WHERE s1.a =
s2.c;
> >
> > attributes: b b
> > lAttributes: {b 1042 -1} {b 1042 -1}
> > Tuple 0: {from table 2} {from table 2}
> >
> > ... what is wrong, obviously.
> >
>
> I can't figure out why this happens, but I did find a work around. Try:
>
> SELECT s1.b AS b1, s2.b AS b2 FROM pgsqlbug1 s1, pgsqlbug2 s2 WHERE s1.a
> = s2.c ;
>
> This worked fine with pgsql.tcl .
>
> By the way, I was able to duplicate your error using pgsql.tcl. I think
> it has to do with how proc pg_exec or pg_result processes columns with
> the same name ( .b ).

The problem is that pg_exec uses the names of the columns to store
results.

When you make connection pgsql create global array with unique name that
holds parameters for this connection, e.g. pgp0, and returns the name of the
array as result (see pgsql.doc).

When you exec sql command with pq_exec that returns result, then pg_exec
creats new global array, e.g. pgp0_res, that holds information for results
(see pgsql.doc). pg_exec saves the name of the array in pgp0(resName). It also
creates global array, e.g. pgp0_tup, that holds tuples. The name of this
array is saved to pgp0_res(tuples).

pgp0_tup(3,b) will contain data from row 4 and column b, so you MUST use
different names for the columns.


-------------------------------------------------------
   Valentin Iliev     e-mail: vale@aero.vmei.acad.bg
      Dept. of Aeronautics, Tech. univ. of Sofia
-------------------------------------------------------


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

Предыдущее
От: leif@danmos.dk
Дата:
Сообщение: Postgres ODBC and SQL_BIT
Следующее
От: David Hartwig
Дата:
Сообщение: Re: [INTERFACES] Postgres ODBC and SQL_BIT