On 2019-11-12 17:25:05 -0500, Dave Lambley via RT wrote:
Show quoted text> <URL:
https://rt.cpan.org/Ticket/Display.html?id=24539 >
> On Sun Nov 10 14:12:18 2019, hjp@hjp.at wrote:
> > On 2019-11-10 09:28:13 -0500, Dave Lambley via RT wrote:
> > > On Wed Jan 24 04:59:26 2007, hjp@hjp.at wrote:
> > > > On Mi. 24. Jan. 2007, 04:24:11, hjp@hjp.at wrote:
> > > > > The /describe command always returns an empty result set [0
> > > > > rows of 9 fields returned] regardless of whether the table
> > > > > exists or not.
> > > >
> > > > Actually, it does work - you just need to give the table name in
> > > > upper case.
[...]
Show quoted text> Perhaps the thing to do would be to make DBI::Shell emit a warning if
> you're using DBD::Oracle and you give a table name that's not upper
> case? That seems preferable to magically fixing the case, which could
> be misleading.
Databases like Oracle or PostgreSQL actually convert the case of
unquoted identifiers (so «select * from Foo» is treated like
«select * from "FOO"» or «select * from "foo"» respectively) and one
could expect that /describe does the same. However, I don't think there
is any way to get this information out of DBI, so I guess you are right:
Printing a warning (probably only if the table isn't found) is better.
There should be a better way than hardcoding a check for DBD::Oracle,
though.
One idea I had was to compute stats over the result of
$dbh->table_info("%", "%", "%", "TABLE")
If 90+ % are upper case the database probably defaults to upper case, if
90+% are lower case, it's lower case and between those we don't know.
However, while writing this, I had a different idea: Instead of trying
to determine this globally, try to find a matching table if the table
requested by the user doesn't exist. So if the user types «/describe Foo»
and "Foo" doesn't exist, but "FOO" or "foo" does, print an error message
and the hint «Did you mean "FOO"?» (or "foo"). This could check for other
typos, too («/describe eaxmple» -> «Did you mean "example"?»).
I just noticed that /describe isn't described in the current man-page.
Is/was this even part of the core or in a plugin?
I have to admit I haven't used DBI::Shell in several years. I'm mostly
using PostgreSQL now, and psql is a fine sql shell (unlike Oracle's
sqlplus, which is quite horrible).
Show quoted text> I would get stuck in and do this, but have no means to
> test (and nor am I likely to use Oracle in the near future!)
I still have one Oracle database, so I can test.
hp
--
_ | Peter J. Holzer | Story must make more sense than reality.
|_|_) | |
| | | hjp@hjp.at | -- Charles Stross, "Creative writing
__/ |
http://www.hjp.at/ | challenge!"