pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Darko Prenosil <darko.prenosil@finteh.hr>
To: pgsql-interfaces@postgresql.org
Subject: Re: libpq:Find Table Name
Date: Mon, 14 Jul 2003 14:30:20 +0200
Message-ID: <200307141430.20194.darko.prenosil@finteh.hr> (raw)
In-Reply-To: <3F12981B.CDE42A4A@rodos.fzk.de>
References: <3F12981B.CDE42A4A@rodos.fzk.de>

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 !




view thread (6+ messages)  latest in thread

Message-ID: <200307141430.20194.darko.prenosil@finteh.hr>
Permalink:  ../200307141430.20194.darko.prenosil@finteh.hr/
Also on:    postgresql.org/message-id/200307141430.20194.darko.prenosil@finteh.hr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: darko.prenosil@finteh.hr
  Subject: Re: libpq:Find Table Name
  In-Reply-To: <200307141430.20194.darko.prenosil@finteh.hr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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