X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id D23F4D1B19F for ; Mon, 2 Aug 2004 21:48:21 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 96159-10 for ; Tue, 3 Aug 2004 00:48:16 +0000 (GMT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 0338AD1B16E for ; Mon, 2 Aug 2004 21:48:12 -0300 (ADT) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i730mCqb088397 for ; Tue, 3 Aug 2004 00:48:12 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i730UxUJ086473 for pgsql-jdbc@postgresql.org; Tue, 3 Aug 2004 00:30:59 GMT From: "Mike Martin" X-Newsgroups: comp.databases.postgresql.interfaces.jdbc Subject: Re: Wrong column names in ResultSetMetaData Date: Mon, 2 Aug 2004 19:32:09 -0500 Organization: Vieo, Inc. Lines: 38 Message-ID: References: <41086EF8.7010101@opencloud.com> <410ED4E6.8020806@opencloud.com> X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 To: pgsql-jdbc@postgresql.org X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.8 tagged_above=0.0 required=5.0 tests=PRIORITY_NO_NAME X-Spam-Level: X-Archive-Number: 200408/21 X-Sequence-Number: 10743 Oliver wrote: > RSMD.getColumnName() returns the column alias > RSMD.getColumnLabel() returns the column alias, or maybe something > like the column's comment (can you COMMENT ON columns?) later. > PGResultSetMetadata.getSourceColumnName() returns the underlying > table column name. The driver's updateable resultset code can use this > when constructing update SQL. I like that, not just because I think it jives with the spec but because a new method can explicitly document that the source column name is not available if the result column has multiple sources. > On a related note, if I execute this query: > > SELECT * FROM footable f > > should RSMD.getTableName() return "footable" or "f"? By analogy to > RSMD.getColumnName() it should return "f", but it seems more useful to > return "footable". According to SQL "f" is the right answer. One way convince yourself is to observe the difference between: SELECT f.col FROM footable f SELECT footable.col FROM footable f The former works as you might expect. The latter fails on some DBMS's and I'm pretty sure it's invalid SQL. Interestingly, on PG the latter is evaluated as though it were: SELECT f2.col FROM footable f1 CROSS JOIN footable f2 which for a footable of N rows returns N*N rows! Mike