pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedTables names from query
6+ messages / 4 participants
[nested] [flat]
* Tables names from query
@ 1999-02-22 10:24 Philip Shiels <philip.shiels@jrc.it>
0 siblings, 0 replies; 6+ messages in thread
From: Philip Shiels @ 1999-02-22 10:24 UTC (permalink / raw)
To: pgsql-interfaces
I'm currently developing a postgres DB backend to my current project and have
the following problem. If I execute a query I need to know the table the
returning fields belong to. For example :
SELECT x.y, z.y from x, y where x.key = z.key
The problem with the above is that I get back 2 fields called 'y' and have no
way of knowing from which tables they've come from. The query is arbitrary so I
cannot assume table order in the SQL statement (Icannot assume anything about
the query except that it's a SELECT).
What information from the 'C' or 'C++' APIs can help ?
Is there is a way of identifying the originating tables ?
Thanks
Philip
--------------------------------------------------------------------------
Philip Shiels E-Mail:Philip.Shiels@jrc.it JRC Ispra, Italy, TP270
GIST:http://gist.jrc.it
^ permalink raw reply [nested|flat] 6+ messages in thread
* Tables names from query
@ 1999-02-22 10:36 Philip Shiels <philip.shiels@jrc.it>
0 siblings, 0 replies; 6+ messages in thread
From: Philip Shiels @ 1999-02-22 10:36 UTC (permalink / raw)
To: pgsql-hackers@postgresql.org; pgsql-interfaces
I'm currently developing a postgres DB backend to my current project and have
the following problem. If I execute a query I need to know the table the
returning fields belong to. For example :
SELECT x.y, z.y from x, y where x.key = z.key
The problem with the above is that I get back 2 fields called 'y' and have no
way of knowing from which tables they've come from. The query is arbitrary so I
cannot assume table order in the SQL statement.
What information from the 'C' or 'C++' APIs can help ?
Is there is a way of identifying the originating tables ?
Thanks
Philip
--------------------------------------------------------------------------
Philip Shiels E-Mail:Philip.Shiels@jrc.it JRC Ispra, Italy, TP270
GIST:http://gist.jrc.it CEO:http://www.ceo.org GEM:http://gem.jrc.it
^ permalink raw reply [nested|flat] 6+ messages in thread
* Tables names from query
@ 1999-02-22 13:26 Philip Shiels <philip.shiels@jrc.it>
1999-02-22 11:53 ` Re: [INTERFACES] Tables names from query Anatoly K. Lasareff <tolik@icomm.ru>
1999-02-22 15:47 ` Re: [INTERFACES] Tables names from query Bob VonMoss <bvonmoss@idm.com>
1999-02-22 15:49 ` Re: [INTERFACES] Tables names from query Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 3 replies; 6+ messages in thread
From: Philip Shiels @ 1999-02-22 13:26 UTC (permalink / raw)
To: pgsql-interfaces
I'm currently developing a postgres DB backend to my current project and have
the following problem. If I execute a query I need to know the table the
returning fields belong to. For example :
SELECT x.y, z.y from x, y where x.key = z.key
The problem with the above is that I get back 2 fields called 'y' and have no
way of knowing from which tables they've come from. The query is arbitrary so I
cannot assume table order in the SQL statement (Icannot assume anything about
the query except that it's a SELECT).
What information from the 'C' or 'C++' APIs can help ?
Is there is a way of identifying the originating tables ?
Thanks
Philip
--------------------------------------------------------------------------
Philip Shiels E-Mail:Philip.Shiels@jrc.it JRC Ispra, Italy, TP270
GIST:http://gist.jrc.it CEO:http://www.ceo.org GEM:http://gem.jrc.it
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [INTERFACES] Tables names from query
1999-02-22 13:26 Tables names from query Philip Shiels <philip.shiels@jrc.it>
@ 1999-02-22 11:53 ` Anatoly K. Lasareff <tolik@icomm.ru>
2 siblings, 0 replies; 6+ messages in thread
From: tolik@icomm.ru @ 1999-02-22 11:53 UTC (permalink / raw)
To: philip.shiels@jrc.it; +Cc: pgsql-interfaces
>>>>> "PS" == Philip Shiels <philip.shiels@jrc.it> writes:
PS> I'm currently developing a postgres DB backend to my current project and have
PS> the following problem. If I execute a query I need to know the table the
PS> returning fields belong to. For example :
PS> SELECT x.y, z.y from x, y where x.key = z.key
select x.y as xy, z.y as zy from x, y where x.key = z.key
^^^^^ ^^^^^
????
--
Anatoly K. Lasareff Email: tolik@icomm.ru
Senior programmer
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [INTERFACES] Tables names from query
1999-02-22 13:26 Tables names from query Philip Shiels <philip.shiels@jrc.it>
@ 1999-02-22 15:47 ` Bob VonMoss <bvonmoss@idm.com>
2 siblings, 0 replies; 6+ messages in thread
From: Bob VonMoss @ 1999-02-22 15:47 UTC (permalink / raw)
To: philip.shiels@jrc.it; +Cc: pgsql-interfaces
Philip Shiels wrote:
> SELECT x.y, z.y from x, y where x.key = z.key
>
> The problem with the above is that I get back 2 fields called 'y' and have no
> way of knowing from which tables they've come from.
Do something like this:
SELECT x.y, z.y AS z_y from x, z where x.key = z.key;
> Is there is a way of identifying the originating tables ?
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: [INTERFACES] Tables names from query
1999-02-22 13:26 Tables names from query Philip Shiels <philip.shiels@jrc.it>
@ 1999-02-22 15:49 ` Tom Lane <tgl@sss.pgh.pa.us>
2 siblings, 0 replies; 6+ messages in thread
From: Tom Lane @ 1999-02-22 15:49 UTC (permalink / raw)
To: philip.shiels@jrc.it; +Cc: pgsql-interfaces
Philip Shiels <philip.shiels@jrc.it> writes:
> I'm currently developing a postgres DB backend to my current project and have
> the following problem. If I execute a query I need to know the table the
> returning fields belong to. For example :
> SELECT x.y, z.y from x, y where x.key = z.key
Can you use "SELECT AS"? For instance
SELECT x.y AS x_y, z.y AS z_y WHERE ...
A bit grotty, but there's no hope of changing the column-labeling
behavior without modifying the innards of the backend; the column names
you see in psql are all the info there is on the client side.
I dunno whether it would be a good idea to change the backend's column
labeling rules for this case or not. I'd be worried about breaking
existing applications that depend on the current labeling rules...
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~1999-02-22 15:49 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-02-22 10:24 Tables names from query Philip Shiels <philip.shiels@jrc.it>
1999-02-22 10:36 Tables names from query Philip Shiels <philip.shiels@jrc.it>
1999-02-22 13:26 Tables names from query Philip Shiels <philip.shiels@jrc.it>
1999-02-22 11:53 ` Anatoly K. Lasareff <tolik@icomm.ru>
1999-02-22 15:47 ` Bob VonMoss <bvonmoss@idm.com>
1999-02-22 15:49 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox