[ic] Shared Tables Not Always in %Sql
John Young
john_young at sonic.net
Fri Jan 16 01:31:38 EST 2004
Mike Heins wrote:
> Quoting John Young (john_young at sonic.net):
>
>>I'm chasing down an intermittent problem accessing database handles
>>using %Sql (sometimes the table is shared, and sometimes it isn't),
>>and am wondering if the following would be desirable:
>>
>>(I lengthened the diff in order to show the entire block)
>>
>>
>>--- Interpolate.pm.2.201 Wed Jan 14 03:05:29 2004
>>+++ Interpolate.pm Wed Jan 14 03:11:07 2004
>>@@ -1842,26 +1842,26 @@
>> if($tables) {
>> my (@tab) = grep /\S/, split /\s+/, $tables;
>> foreach my $tab (@tab) {
>>- next if $Db{$tab};
>>+ next if $Sql{$tab} && $Db{$tab};
>> my $db = database_exists_ref($tab);
>> next unless $db;
>> $db = $db->ref();
>> if($db->config('type') == 10) {
>> my @extra_tabs = $db->_shared_databases();
>> push (@tab, @extra_tabs);
>> }
>> if($hole) {
>> $Sql{$tab} = $hole->wrap($db->dbh())
>> if $db->can('dbh');
>> $Db{$tab} = $hole->wrap($db);
>> if($db->config('name') ne $tab) {
>> $Db{$db->config('name')} = $Db{$tab};
>> }
>> }
>> else {
>> $Sql{$tab} = $db->[$Vend::Table::DBI::DBI]
>> if $db =~ /::DBI/;
>> $Db{$tab} = $db;
>> }
>> }
>> }
>>
>
>
> Does this solve the "Cannot find object method st via package DBD::Pg"
> problem? If it does, then it assuredly would be desirable. 8-)
I don't know... perhaps if $Sql{tablename} is being deleted/undefined
while whomever is using it thinks it is still defined... Since I don't
have Postgres installed, I hope someone else can test for that. I don't
recall having seen that error with the DBD I use, nor do I see anything
for it in the archives or Usenet.
The problem I faced was *occasionally* having this scenario fail:
[perl tables="tablename"]
...
my $dbh = $Sql{tablename} or do ...
...
[/perl]
I speculated that sometimes $Db{tablename} was being defined or retained
while $Sql{tablename} was not... and the existing Interpolate.pm logic
seemed to avoid defining $Sql{tablename} if $Db{tablename} was currently
defined. To test by forcing the condition, at the beginning of a page
containing the scenario above, I added:
[perl tables="gift_certs"]
# This is a test to force existence of $Db and no $Sql.
my $db = $Db{tablename};
delete $Sql{tablename};
return;
[/perl]
... HTML, ITL, etc. ...
(then the [perl] shown above using my $dbh = $Sql{})
The minor patch above for Interpolate.pm seems to have fixed it in my
limited testing.
Thanks,
John Young
More information about the interchange-users
mailing list