Re: Request for qualified column names

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Dave Cramer <dave(at)fastcrypt(dot)com>
Cc: PostgreSQL Hackers Mailing List <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Request for qualified column names
Date: 2003-01-27 01:38:38
Message-ID: 18781.1043631518@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Dave Cramer <dave(at)fastcrypt(dot)com> writes:
> So for a "select a, b, a+b as sum from c" returns c.a, c.b, ?table?.sum

This might be something to consider as part of the planned protocol
overhaul. We cannot simply change the returned column names --- at
least not without breaking a lot of application code. But if we
return table name (and schema name too!) as separate fields of the
'T' message, and make them accessible through new PQfoo accessor
functions, then no existing applications would break.

But there are more than a few definitional issues to be settled before
you'll convince me this idea is fully baked. Some things that come to
mind immediately:

What happens with views? Given
create view v as select col as vcol from tab;
select vcol from v;
are you expecting to get back "v.vcol"? Or "tab.col"?

What happens with FROM-clause aliases? Supposing tab really has a
column "col", what do you expect to see from
select * from tab AS a(t1), tab AS b(t2) WHERE ...
You could make a case for either "tab.col, tab.col" or "a.t1, b.t2"
(in the latter case, you can't realistically return a schema name).
But you will probably break existing code if you do the former, since
currently the output columns are labeled t1, t2.

What happens with join aliases (similar issues to above)?

Do you think
select col as foo from tab
should return "tab.foo", or just "foo"? I'd lean to the latter;
"tab.foo" seems awfully misleading. Or maybe you're wanting it
to ignore the AS and return "tab.col"? Don't think that will fly.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Clift 2003-01-27 02:37:38 Re: Have a PG 7.3.1 Windows (cygwin) easy installer... now
Previous Message Tatsuo Ishii 2003-01-27 01:12:49 Re: Sorting Chinese data in Postgresql 7.3.1