Tim Bunce <[EMAIL PROTECTED]> wrote:
> > sub execute {
> >     my $self = shift;
> >     my $rv = eval { DBI::st::execute($self, @_); };
> 
> I'd probably say:
> 
>       my $rv = eval { $self->SUPER::execute(@_) };

        Yeah, maybe... I adopted that idiom because this doesn't work:

--snip--

  sub close_transaction {
      my $self = shift;
      my $method = shift;
      my $code = $self->SUPER::can($method);

      $self->{private_DBIx_Transaction_Level} = 0;
      $self->clear_transaction_error;
      $self->transaction_trace($method);
      my $rv = $code->($self, @_);
      return $rv;
  }

--snip--

        My commit() method would end up calling
$self->close_transaction('commit'), with would then call my commit() method
again, instead of DBI::db's... so I changed it to read

      my $code = DBI::db->can($method);

        And everything's happy again.

> Very few databases support information_schema.

        *grumble*

> The generic portable fallback is "select 1 from $table where 1=0" - if that
> statement can be executed without error then the table exists.

        ... but only if you're not already in the middle of a transaction,
which means setting up state counters and having to refresh them constantly
if this is the sort of table that can come and go as it pleases... I suppose
I could do that in this particular application since it's *very* unlikely
that multiple people/apps will be engaging in schema management on the same
database in paralell, but:

> This is something I've been meaning to address for a while. I was
> thinking of something like:
> 
>       $schema_name = $dbh->current_schema

        I really like this. I read your exchange with Steffen Goeldner and
that prompted me to take a look at the get_info method. I expected either
SQL_DATABASE_NAME (16) or SQL_CATALOG_NAME (10003) to tell me the current
database name, but I guess I was wrong; on both MySQL and Pg,
SQL_DATABASE_NAME returns nothing; under MySQL, SQL_CATALOG_NAME returns
'Y', under Pg, 'N'.

> Why not help save the world and help me add current_schema() to the DBI
> and send implementations to the authors of drivers you're using?

        SQL_DATABASE_NAME is such a self-explanitory label that I have to
believe this is the right place to put the information we're after, but I
could be way off-base. I'd be willing to task myself with producing patches
for the Pg, MySQL, and SQLite2 drivers to either make use of that attribute,
or provide a current_schema (or maybe current_database? under Pg at least,
schemas and db's are different) method. Which way is the right way to go
here?

        I also noticed that the SQLite2 DBD driver doesn't even return
SQL_DBMS_VERSION... hmmm, might have to add that too...

                - Tyler

Reply via email to