Author: REHSACK
Date: Tue Oct 2 02:24:10 2012
New Revision: 15408
Modified:
dbi/branches/sqlengine/lib/DBD/File.pm
dbi/branches/sqlengine/lib/DBI/DBD/SqlEngine.pm
Log:
- fix table meta initialization
- fix drh::data_sources() sub
Modified: dbi/branches/sqlengine/lib/DBD/File.pm
==============================================================================
--- dbi/branches/sqlengine/lib/DBD/File.pm (original)
+++ dbi/branches/sqlengine/lib/DBD/File.pm Tue Oct 2 02:24:10 2012
@@ -338,7 +338,7 @@
my %attrs;
$attr and %attrs = %$attr;
delete $attrs{f_dir};
- my $dsn_quote = $drh->can("dsn_quote");
+ my $dsn_quote = $drh->{ImplementorClass}->can("dsn_quote");
my $dsnextra = join ";", map { $_ . "=" . &{$dsn_quote} ($attrs{$_}) }
keys %attrs;
my $dirh = IO::Dir->new($dir);
unless (defined $dirh) {
@@ -353,7 +353,7 @@
my $d = File::Spec->catdir ($dir, $file);
# allow current dir ... it can be a data_source too
$file ne File::Spec->updir () && -d $d and
- push @dsns, "DBI:$driver:f_dir=" . dsn_quote ($d) . ($dsnextra ?
";$dsnextra" : "");
+ push @dsns, "DBI:$driver:f_dir=" . &{$dsn_quote} ($d) . ($dsnextra
? ";$dsnextra" : "");
}
return @dsns;
} # data_sources
@@ -591,6 +591,7 @@
my ($fh, $fn);
unless ($meta->{f_dontopen}) {
+ $meta->{fh} and return; # called twice
$fn = $meta->{f_fqfn};
if ($flags->{createMode}) {
-f $meta->{f_fqfn} and
@@ -614,10 +615,11 @@
}
}
if ($meta->{f_fqln}) {
+ $meta->{lockfh} and return; # called twice
$fn = $meta->{f_fqln};
if ($flags->{createMode}) {
-f $fn and
- croak "Cannot create table lock for $attrs->{table}: Already
exists";
+ croak "Cannot create table lock at '$fn' for $attrs->{table}:
Already exists";
$fh = IO::File->new ($fn, "a+") or
croak "Cannot open $fn for writing: $! (" . ($!+0) . ")";
}
@@ -777,8 +779,6 @@
{
my ($self, $meta, $attrs, $flags) = @_;
- $meta->{fh} and return;
-
$meta->{sql_data_source} or
croak "Table " . $meta->{table_name} . " not completely initialized";
$meta->{sql_data_source}->open_data ($meta, $attrs, $flags);
@@ -815,8 +815,8 @@
$meta->{lockfh} and $meta->{lockfh}->close ();
undef $meta->{fh};
undef $meta->{lockfh};
- $meta->{f_fqfn} and unlink $meta->{f_fqfn};
- $meta->{f_fqln} and unlink $meta->{f_fqln};
+ $meta->{f_fqfn} and unlink $meta->{f_fqfn}; # XXX ==> sql_data_source
+ $meta->{f_fqln} and unlink $meta->{f_fqln}; # XXX ==> sql_data_source
delete $data->{Database}{sql_meta}{$self->{table}};
return 1;
} # drop
Modified: dbi/branches/sqlengine/lib/DBI/DBD/SqlEngine.pm
==============================================================================
--- dbi/branches/sqlengine/lib/DBI/DBD/SqlEngine.pm (original)
+++ dbi/branches/sqlengine/lib/DBI/DBD/SqlEngine.pm Tue Oct 2 02:24:10 2012
@@ -217,8 +217,8 @@
and $tbl_src = $attr->{sql_table_source};
!defined($tbl_src)
- and $drh->can('default_table_source')
- and $tbl_src = $drh->default_table_source();
+ and $drh->{ImplementorClass}->can('default_table_source')
+ and $tbl_src = $drh->{ImplementorClass}->default_table_source();
defined($tbl_src) or return;
$tbl_src->data_sources( $drh, $attr );
@@ -1443,6 +1443,7 @@
my $meta = {};
defined $dbh->{sql_meta}{$table} and $meta = $dbh->{sql_meta}{$table};
+do_initialize:
unless ( $meta->{initialized} )
{
$self->bootstrap_table_meta( $dbh, $meta, $table, @other );
@@ -1457,12 +1458,13 @@
# now we know a bit more - let's check if user can't use consequent
spelling
# XXX add know issue about reset sql_identifier_case here ...
- if ( defined $dbh->{sql_meta}{$table} && defined
$dbh->{sql_meta}{$table}{initialized} )
+ if ( defined $dbh->{sql_meta}{$table} )
{
- $meta = $dbh->{sql_meta}{$table};
- $dbh->{sql_meta}{$table}{initialized}
- or $meta->{sql_data_source}->complete_table_name( $meta, $table,
$respect_case, @other )
- or return;
+ $meta = delete $dbh->{sql_meta}{$table}; # avoid endless loop
+ $meta->{initialized}
+ or goto do_initialize;
+ #or $meta->{sql_data_source}->complete_table_name( $meta, $table,
$respect_case, @other )
+ #or return;
}
unless ( $dbh->{sql_meta}{$table}{initialized} )