And the following (with %newobject added to
dbFactory::createNdbClusterConnection and
Ndb_cluster_connection::getNdb) fixes the lifetime of the cluster object:
%feature("shadow") getNdb(const char* aCatalogName="", const char*
aSchemaName="def")
%{
sub getNdb {
my $self=$_[0];
my $ndb=mysql::cluster::ndbapic::NdbClusterConnection_getNdb(@_);
my $t=tied(%{$ndb});
$mysql::cluster::ndbapi::ndb_connectors_owned{$t}=$self;
return $ndb;
}
%}
%feature("shadow") ~Ndb
%{
sub DESTROY {
return unless $_[0]->isa('HASH');
my $self = tied(%{$_[0]});
return unless defined $self;
delete $ITERATORS{$self};
if (exists $OWNER{$self}) {
mysql::cluster::ndbapic::delete_Ndb($self);
delete $OWNER{$self};
}
delete $mysql::cluster::ndbapi::ndb_connectors_owned{$self};
}
%}
Something similar should be easies to write for the other languages?
I'm not doing patches since so much of what my code relies on is not in
bazaar. I can do the patches when the rest of the stuff is merged.
Incrementing the refcount of the Ndb object when a transaction is
created doesn't seem necessary, as nothing ever happens with the
transaction unless you call methods on Ndb (execute...).
Mika
Mika