ResultSetMetaData.getTableName()
ResultSetMetaData.getTableName()
От:
Jason Davies <jason@netspade.com>
Дата:
Is there any chance ResultSetMetaData.getTableName(int column) could be implemented somehow? It seems that the backend doesn't provide any info about the table name of a column, is this correct? Obviously not all columns returned have a specific table associated with them, but for simple SELECT statements it is possible. I think this needs to be added to the TODO list to be implemented in the backend. This is another of those features which generic database admin tools would find useful. -- Jason Davies jason@netspade.com
Re: ResultSetMetaData.getTableName()
От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
Jason Davies writes: > Is there any chance ResultSetMetaData.getTableName(int column) could > be implemented somehow? The entire concept seems faulty. Select results don't come from any particular table in the general case, and any tool that expects the special case to apply to general queries is broken by design. You do, of course, know which table the columns came from if you issue a query like SELECT * FROM foo but you hardly need the backend to tell you so. ISTM that no frontend tool should expect to associate particular table names with SELECT results except when it knows the query is of such a simple form as this. regards, tom lane
Re: ResultSetMetaData.getTableName()
От:
Jason Davies <jason@netspade.com>
Дата:
On Sat, Nov 24, 2001 at 01:00:07PM -0500, Tom Lane wrote: > Jason Davies writes: > > Is there any chance ResultSetMetaData.getTableName(int column) could > > be implemented somehow? > > The entire concept seems faulty. Select results don't come from any > particular table in the general case, and any tool that expects the > special case to apply to general queries is broken by design. True, but the only time a tool would need to know the particular table name is if was going to UPDATE data in one of the columns returned. And this would only be possible for the special cases. > You do, of course, know which table the columns came from if you issue a > query like > SELECT * FROM foo > but you hardly need the backend to tell you so. Yes, I agree. I guess it would better design to parse the query and check if it is of the "simple" type. > ISTM that no frontend > tool should expect to associate particular table names with SELECT > results except when it knows the query is of such a simple form as this. Agreed. Thanks for your insight :) It seems there shouldn't be a getTableName at all in the spec because it wouldn't be useful most of the time. Should we put some code into the driver itself to parse the SQL query and check if it is a simple SELECT? Also should this be reflected in isWritable() too? -- Jason Davies jason@netspade.com