Commit d149ca13 authored by Leigh Stoller's avatar Leigh Stoller

Another fix for the eventlist table; this one is annoying. Does

not quite fit the model like all the other tables.
parent b119fd03
...@@ -65,7 +65,7 @@ my $debug = 0; ...@@ -65,7 +65,7 @@ my $debug = 0;
"virt_programs" => [ "vname", "vnode" ], "virt_programs" => [ "vname", "vnode" ],
"virt_user_environment" => [ "name", "value" ], "virt_user_environment" => [ "name", "value" ],
"nseconfigs" => [ "vname" ], "nseconfigs" => [ "vname" ],
"eventlist" => [ "vnode", "vname"], "eventlist" => [ "idx" ],
"event_groups" => [ "group_name", "agent_name" ], "event_groups" => [ "group_name", "agent_name" ],
"virt_firewalls" => [ "fwname", "type", "style" ], "virt_firewalls" => [ "fwname", "type", "style" ],
"firewall_rules" => [ "fwname", "ruleno", "rule" ], "firewall_rules" => [ "fwname", "ruleno", "rule" ],
...@@ -545,6 +545,7 @@ sub Create($$$) ...@@ -545,6 +545,7 @@ sub Create($$$)
$self->{'SLOTNAMES'} = $slotnames; $self->{'SLOTNAMES'} = $slotnames;
$self->{'TABLEHASH'} = {}; $self->{'TABLEHASH'} = {};
$self->{'TABLELIST'} = []; $self->{'TABLELIST'} = [];
$self->{'COUNTER'} = 1;
bless($self, $class); bless($self, $class);
return $self; return $self;
...@@ -566,6 +567,7 @@ sub DESTROY { ...@@ -566,6 +567,7 @@ sub DESTROY {
$self->{'SLOTNAMES'} = undef; $self->{'SLOTNAMES'} = undef;
$self->{'TABLEHASH'} = undef; $self->{'TABLEHASH'} = undef;
$self->{'TABLELIST'} = undef; $self->{'TABLELIST'} = undef;
$self->{'COUNTER'} = undef;
} }
# #
...@@ -621,9 +623,14 @@ sub NewRow($$) ...@@ -621,9 +623,14 @@ sub NewRow($$)
my @pvals = (); my @pvals = ();
foreach my $key (@pkeys) { foreach my $key (@pkeys) {
if (!exists($argref->{$key})) { if (!exists($argref->{$key})) {
if ($tablename eq "eventlist" && $key eq "idx") {
$argref->{$key} = $self->{'COUNTER'}++;
}
else {
carp("Missing table key for new table in $tablename"); carp("Missing table key for new table in $tablename");
return undef; return undef;
} }
}
push(@pvals, $argref->{$key}); push(@pvals, $argref->{$key});
} }
# This is the full key. Make sure it does not already exist. # This is the full key. Make sure it does not already exist.
...@@ -918,8 +925,11 @@ sub Store($;$) ...@@ -918,8 +925,11 @@ sub Store($;$)
if ($key eq "pid" ||$key eq "eid" || $key eq "exptidx"); if ($key eq "pid" ||$key eq "eid" || $key eq "exptidx");
if ($key eq "idx") { if ($key eq "idx") {
# XXX # This test for eventlist.
if ($val =~ /^\d*$/) { if ($tablename eq "eventlist") {
push(@values, "NULL");
}
elsif ($val =~ /^\d*$/) {
push(@values, DBQuoteSpecial($val)); push(@values, DBQuoteSpecial($val));
} }
else { else {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment