3 |
# $Id$ |
# $Id$ |
4 |
# |
# |
5 |
# $Log$ |
# $Log$ |
6 |
|
# Revision 1.10 2002/12/15 02:02:22 joko |
7 |
|
# + fixed logging-message |
8 |
|
# |
9 |
|
# Revision 1.9 2002/12/05 07:58:20 joko |
10 |
|
# + now using Tie::SecureHash as a base for the COREHANDLE |
11 |
|
# + former public COREHANDLE becomes private _COREHANDLE now |
12 |
|
# |
13 |
# Revision 1.8 2002/12/01 22:20:43 joko |
# Revision 1.8 2002/12/01 22:20:43 joko |
14 |
# + sub createDb (from Storage.pm) |
# + sub createDb (from Storage.pm) |
15 |
# |
# |
81 |
#use Data::Dumper; print Dumper($self->{dbi}); |
#use Data::Dumper; print Dumper($self->{dbi}); |
82 |
|
|
83 |
eval { |
eval { |
84 |
$self->{COREHANDLE} = DBI->connect( $dsn, '', '', $self->{locator}->{dbi} ); |
$self->{_COREHANDLE} = DBI->connect( $dsn, '', '', $self->{locator}->{dbi} ); |
85 |
if (!$self->{COREHANDLE}) { |
if (!$self->{_COREHANDLE}) { |
86 |
$logger->warning( __PACKAGE__ . "->connect failed: " . DBI::errstr ); |
$logger->warning( __PACKAGE__ . "->connect failed: " . DBI::errstr ); |
87 |
return; |
return; |
88 |
} |
} |
104 |
|
|
105 |
$logger->debug( __PACKAGE__ . "->configureCOREHANDLE" ); |
$logger->debug( __PACKAGE__ . "->configureCOREHANDLE" ); |
106 |
|
|
107 |
return if !$self->{COREHANDLE}; |
return if !$self->{_COREHANDLE}; |
108 |
|
|
109 |
# apply configured modifications to DBI-handle |
# apply configured modifications to DBI-handle |
110 |
if (exists $self->{locator}->{dbi}->{trace_level} && exists $self->{locator}->{dbi}->{trace_file}) { |
if (exists $self->{locator}->{dbi}->{trace_level} && exists $self->{locator}->{dbi}->{trace_file}) { |
111 |
$self->{COREHANDLE}->trace($self->{locator}->{dbi}->{trace_level}, $self->{locator}->{dbi}->{trace_file}); |
$self->{_COREHANDLE}->trace($self->{locator}->{dbi}->{trace_level}, $self->{locator}->{dbi}->{trace_file}); |
112 |
} |
} |
113 |
if (exists $self->{locator}->{dbi}->{RaiseError}) { |
if (exists $self->{locator}->{dbi}->{RaiseError}) { |
114 |
$self->{COREHANDLE}->{RaiseError} = $self->{locator}->{dbi}->{RaiseError}; |
$self->{_COREHANDLE}->{RaiseError} = $self->{locator}->{dbi}->{RaiseError}; |
115 |
} |
} |
116 |
if (exists $self->{locator}->{dbi}->{PrintError}) { |
if (exists $self->{locator}->{dbi}->{PrintError}) { |
117 |
$self->{COREHANDLE}->{PrintError} = $self->{locator}->{dbi}->{PrintError}; |
$self->{_COREHANDLE}->{PrintError} = $self->{locator}->{dbi}->{PrintError}; |
118 |
} |
} |
119 |
if (exists $self->{locator}->{dbi}->{HandleError}) { |
if (exists $self->{locator}->{dbi}->{HandleError}) { |
120 |
$self->{COREHANDLE}->{HandleError} = $self->{locator}->{dbi}->{HandleError}; |
$self->{_COREHANDLE}->{HandleError} = $self->{locator}->{dbi}->{HandleError}; |
121 |
} |
} |
122 |
|
|
123 |
} |
} |
128 |
|
|
129 |
# two-level handling for implicit connect: |
# two-level handling for implicit connect: |
130 |
# if there's no corehandle ... |
# if there's no corehandle ... |
131 |
if (!$self->{COREHANDLE}) { |
if (!$self->{_COREHANDLE}) { |
132 |
# ... try to connect, but ... |
# ... try to connect, but ... |
133 |
$self->connect(); |
$self->connect(); |
134 |
# ... if this still fails, there's something wrong probably, so we won't continue |
# ... if this still fails, there's something wrong probably, so we won't continue |
135 |
if (!$self->{COREHANDLE}) { |
if (!$self->{_COREHANDLE}) { |
136 |
return; |
return; |
137 |
} |
} |
138 |
} |
} |
139 |
|
|
140 |
#print "prepare sql: $sql\n"; |
#print "prepare sql: $sql\n"; |
141 |
|
|
142 |
my $sth = $self->{COREHANDLE}->prepare($sql); |
my $sth = $self->{_COREHANDLE}->prepare($sql); |
143 |
$sth->execute(); |
$sth->execute(); |
144 |
return $sth; |
return $sth; |
145 |
} |
} |
158 |
my $self = shift; |
my $self = shift; |
159 |
my @nodes; |
my @nodes; |
160 |
$logger->debug( __PACKAGE__ . "->getChildNodes()" ); |
$logger->debug( __PACKAGE__ . "->getChildNodes()" ); |
161 |
|
my $locator = $self->{locator}; |
162 |
|
#print Dumper($locator); exit; |
163 |
if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { |
if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { |
164 |
my $dbname = getDbNameByDsn($self->{locator}->{dbi}->{dsn}); |
my $dbname = getDbNameByDsn($self->{locator}->{dbi}->{dsn}); |
165 |
my $key = "Tables_in_$dbname"; |
my $key = "Tables_in_$dbname"; |
186 |
sub sendQuery { |
sub sendQuery { |
187 |
my $self = shift; |
my $self = shift; |
188 |
my $query = shift; |
my $query = shift; |
189 |
|
|
190 |
|
$logger->debug( __PACKAGE__ . "->sendQuery" ); |
191 |
|
|
192 |
#my $sql = "SELECT cs FROM $self->{metainfo}->{$descent}->{node} WHERE $self->{metainfo}->{$descent}->{IdentProvider}->{arg}='$self->{entry}->{source}->{ident}';"; |
#my $sql = "SELECT cs FROM $self->{metainfo}->{$descent}->{node} WHERE $self->{metainfo}->{$descent}->{IdentProvider}->{arg}='$self->{entry}->{source}->{ident}';"; |
193 |
#my $result = $self->{metainfo}->{$descent}->{storage}->sendCommand($sql); |
#my $result = $self->{metainfo}->{$descent}->{storage}->sendCommand($sql); |
194 |
my @crits; |
my @crits; |
208 |
sub eraseAll { |
sub eraseAll { |
209 |
my $self = shift; |
my $self = shift; |
210 |
my $classname = shift; |
my $classname = shift; |
211 |
|
$logger->debug( __PACKAGE__ . "->eraseAll" ); |
212 |
my $sql = "DELETE FROM $classname"; |
my $sql = "DELETE FROM $classname"; |
213 |
$self->sendCommand($sql); |
$self->sendCommand($sql); |
214 |
} |
} |
257 |
|
|
258 |
} |
} |
259 |
|
|
260 |
|
sub getCOREHANDLE2 { |
261 |
|
my $self = shift; |
262 |
|
return $self->{_COREHANDLE}; |
263 |
|
} |
264 |
|
|
265 |
1; |
1; |