pg.ddx.io pgsql-interfaces@postgresql.org mailing list archive
help / color / mirror / Atom feedlibpq:Find Table Name
6+ messages / 5 participants
[nested] [flat]
* libpq:Find Table Name
@ 2003-07-09 20:30 Adam Pigg <adam@piggz.fsnet.co.uk>
0 siblings, 0 replies; 6+ messages in thread
From: Adam Pigg @ 2003-07-09 20:30 UTC (permalink / raw)
To: pgsql-interfaces
Hi
Am currently writing (or trying to at least) a postgresql driver for the
koffice app kexi.
The driver requires that i subclass some kexi classes, one being a class that
represents a field.
I know the SQL statement used to generate the result and for each field inthe
result i create an object. However, one property of the object is the table
name for the field. Other properties require that i know the table name, eg
given the table and field names i can query the system catalogs to get things
like contraints.
In the my_sql c library, the result (tuble) structure contains a filed
structure that contains the table name that the particular field originated
in, but libpq doesnt seem to have any similar kind of functionality (and i
have looked a lot i think)
Has anyone any suggestions on how i can achieve getting the table name for a
filed in a result without having to parse the sql statement (which i dont
think wold be easy).
Regards
--
adampigg.9p.org.uk
adam@piggz.fsnet.co.uk
adam@adampigg.9p.org.uk
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: libpq:Find Table Name
@ 2003-07-14 11:46 Christoph Haller <ch@rodos.fzk.de>
2003-07-14 12:30 ` Re: libpq:Find Table Name Darko Prenosil <darko.prenosil@finteh.hr>
2003-07-14 14:48 ` Re: libpq:Find Table Name Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 6+ messages in thread
From: Christoph Haller @ 2003-07-14 11:46 UTC (permalink / raw)
To: pgsql-interfaces; adam@piggz.fsnet.co.uk
>
> Am currently writing (or trying to at least) a postgresql driver for
the
> koffice app kexi.
>
> The driver requires that i subclass some kexi classes, one being a
class that
> represents a field.
>
> I know the SQL statement used to generate the result and for each
field inthe
> result i create an object. However, one property of the object is the
table
> name for the field. Other properties require that i know the table
name, eg
> given the table and field names i can query the system catalogs to get
things
> like contraints.
>
> In the my_sql c library, the result (tuble) structure contains a filed
> structure that contains the table name that the particular field
originated
> in, but libpq doesnt seem to have any similar kind of functionality
(and i
> have looked a lot i think)
>
> Has anyone any suggestions on how i can achieve getting the table name
for a
> filed in a result without having to parse the sql statement (which i
dont
> think wold be easy).
>
I very much doubt there is such thing, because the result may come from
a complex join or a function. What does MySQL do when it cames to this?
I have no idea, but am pretty sure that's why there is no similar field
in libpq. And even parsing the query would win you nothing, because of
the reason above.
Regards, Christoph
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: libpq:Find Table Name
2003-07-14 11:46 Re: libpq:Find Table Name Christoph Haller <ch@rodos.fzk.de>
@ 2003-07-14 12:30 ` Darko Prenosil <darko.prenosil@finteh.hr>
1 sibling, 0 replies; 6+ messages in thread
From: Darko Prenosil @ 2003-07-14 12:30 UTC (permalink / raw)
To: pgsql-interfaces
On Monday 14 July 2003 13:46, Christoph Haller wrote:
> > Am currently writing (or trying to at least) a postgresql driver for
>
> the
>
> > koffice app kexi.
> >
> > The driver requires that i subclass some kexi classes, one being a
>
> class that
>
> > represents a field.
> >
> > I know the SQL statement used to generate the result and for each
>
> field inthe
>
> > result i create an object. However, one property of the object is the
>
> table
>
> > name for the field. Other properties require that i know the table
>
> name, eg
>
> > given the table and field names i can query the system catalogs to get
>
> things
>
> > like contraints.
> >
> > In the my_sql c library, the result (tuble) structure contains a filed
> >
> > structure that contains the table name that the particular field
>
> originated
>
> > in, but libpq doesnt seem to have any similar kind of functionality
>
> (and i
>
> > have looked a lot i think)
> >
> > Has anyone any suggestions on how i can achieve getting the table name
>
> for a
>
> > filed in a result without having to parse the sql statement (which i
>
> dont
>
> > think wold be easy).
>
> I very much doubt there is such thing, because the result may come from
> a complex join or a function. What does MySQL do when it cames to this?
> I have no idea, but am pretty sure that's why there is no similar field
> in libpq. And even parsing the query would win you nothing, because of
> the reason above.
> Regards, Christoph
>
And this is not the only case when table name has no sense.
What if result column is "calculated", for example:
table1.field1 * 2
not to mention join:
table1.field1 * table2.field1
However, I think that parser has all this information, and the only way to do
this right would be to get this information from parser, and fill the libpq
result structure with needed data. Column names that have no sense could be
marked as "unknown".
Hackers would know better, but I think that such change is not trivial.
If I remember well, Interbase has such feature.
Regards !
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: libpq:Find Table Name
2003-07-14 11:46 Re: libpq:Find Table Name Christoph Haller <ch@rodos.fzk.de>
@ 2003-07-14 14:48 ` Tom Lane <tgl@sss.pgh.pa.us>
2003-07-13 19:06 ` Re: libpq:Find Table Name Darko Prenosil <Darko.Prenosil@finteh.hr>
2003-07-14 20:20 ` Re: libpq:Find Table Name Adam Pigg <adam@piggz.fsnet.co.uk>
1 sibling, 2 replies; 6+ messages in thread
From: Tom Lane @ 2003-07-14 14:48 UTC (permalink / raw)
To: Christoph Haller <ch@rodos.fzk.de>; +Cc: pgsql-interfaces; adam@piggz.fsnet.co.uk
Christoph Haller <ch@rodos.fzk.de> writes:
>> Has anyone any suggestions on how i can achieve getting the table name
>> for a
>> filed in a result without having to parse the sql statement (which i
>> dont
>> think wold be easy).
>>
> I very much doubt there is such thing, because the result may come from
> a complex join or a function.
There is support for this in PG 7.4, in the form of providing the table
OID for a column (when it's determinable).
regards, tom lane
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: libpq:Find Table Name
2003-07-14 11:46 Re: libpq:Find Table Name Christoph Haller <ch@rodos.fzk.de>
2003-07-14 14:48 ` Re: libpq:Find Table Name Tom Lane <tgl@sss.pgh.pa.us>
@ 2003-07-13 19:06 ` Darko Prenosil <Darko.Prenosil@finteh.hr>
1 sibling, 0 replies; 6+ messages in thread
From: Darko Prenosil @ 2003-07-13 19:06 UTC (permalink / raw)
To: pgsql-interfaces
----- Original Message -----
From: "Tom Lane" <tgl@sss.pgh.pa.us>
To: "Christoph Haller" <ch@rodos.fzk.de>
Cc: <pgsql-interfaces@postgresql.org>; <adam@piggz.fsnet.co.uk>
Sent: Monday, July 14, 2003 4:48 PM
Subject: Re: [INTERFACES] libpq:Find Table Name
> Christoph Haller <ch@rodos.fzk.de> writes:
> >> Has anyone any suggestions on how i can achieve getting the table name
> >> for a
> >> filed in a result without having to parse the sql statement (which i
> >> dont
> >> think wold be easy).
> >>
> > I very much doubt there is such thing, because the result may come from
> > a complex join or a function.
>
> There is support for this in PG 7.4, in the form of providing the table
> OID for a column (when it's determinable).
>
Wow !!!
I should read changelogs more often !
Regards !
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: libpq:Find Table Name
2003-07-14 11:46 Re: libpq:Find Table Name Christoph Haller <ch@rodos.fzk.de>
2003-07-14 14:48 ` Re: libpq:Find Table Name Tom Lane <tgl@sss.pgh.pa.us>
@ 2003-07-14 20:20 ` Adam Pigg <adam@piggz.fsnet.co.uk>
1 sibling, 0 replies; 6+ messages in thread
From: Adam Pigg @ 2003-07-14 20:20 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-interfaces
Excellent....can you point me to anymore info on this, i see that pg7.4 isnt
even in beta yet, is this function available in cvs?
cheers
Adam Pigg
On Monday 14 July 2003 15:48, Tom Lane wrote:
> Christoph Haller <ch@rodos.fzk.de> writes:
> >> Has anyone any suggestions on how i can achieve getting the table name
> >> for a
> >> filed in a result without having to parse the sql statement (which i
> >> dont
> >> think wold be easy).
> >
> > I very much doubt there is such thing, because the result may come from
> > a complex join or a function.
>
> There is support for this in PG 7.4, in the form of providing the table
> OID for a column (when it's determinable).
>
> regards, tom lane
>
> ---------------------------(end of broadcast)---------------------------
> TIP 3: if posting/reading through Usenet, please send an appropriate
> subscribe-nomail command to majordomo@postgresql.org so that your
> message can get through to the mailing list cleanly
--
adampigg.9p.org.uk
adam@piggz.fsnet.co.uk
adam@adampigg.9p.org.uk
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2003-07-14 20:20 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-07-09 20:30 libpq:Find Table Name Adam Pigg <adam@piggz.fsnet.co.uk>
2003-07-14 11:46 Re: libpq:Find Table Name Christoph Haller <ch@rodos.fzk.de>
2003-07-14 12:30 ` Darko Prenosil <darko.prenosil@finteh.hr>
2003-07-14 14:48 ` Tom Lane <tgl@sss.pgh.pa.us>
2003-07-13 19:06 ` Darko Prenosil <Darko.Prenosil@finteh.hr>
2003-07-14 20:20 ` Adam Pigg <adam@piggz.fsnet.co.uk>
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