Change to DBI $dbh->tables() API

[email protected] (Tim Bunce)
Newsgroups perl.dbi.dev,perl.dbi.users,perl.dbi.announce
Message-ID <[email protected]>
DBI 1.201 (and soon 1.21) have a new quote_identifier method.
The tables method should use this to quote the identifiers it returns.
The DBI now provides a default quote_identifier method that does
standard SQL quote_identifier quoting (using double quotes).
Great.

But there's a problem for databases that require non-standard
quoting (DBD::mysql being the most widely used).

If I add calling quote_identifier into the default tables method
(that most drivers use) then any existing driver will get the
DBI's default quote_identifier method. For DBD::mysql, and some
others, tables() will now return names that are incorrectly quoted
and applications that try to use them will fail.

Here's how I'm currently thinking of handling the issue:

    =item C<tables> I<NEW>
     
    B<Warning:> This method is experimental and may change.
     
      @names = $dbh->tables( $catalog, $schema, $table, $type );
      @names = $dbh->tables;        # deprecated
     
    Simple interface to table_info(). Returns a list of matching
    table names, possibly including a catalog/schema prefix.
     
    See L</table_info> for a description of the parameters.
     
    If arguments are supplied then the table names are constructed and
    quoted by L</quote_identifier> to ensure they are usable even if
    they contain whitespace or reserved words etc. This is recommended
    (the "no-args means no-quoting" hack is only for historical reasons
    and will be changed in a later version).

The principle being that very few applications would be passing
parameters to tables() since that was only added in DBI 1.19
and very few drivers support it yet.

I really don't want to add an option to tables() to enable quoting
since that _really_ ought to be the default behaviour.

Comments welcome.

Tim.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.