From b91b55891493c696e7740813bf61a003bb81c165 Mon Sep 17 00:00:00 2001 From: lissav Date: Wed, 12 Jan 2011 18:42:03 +0000 Subject: [PATCH] remove more database checkes git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@8633 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Table.pm | 48 +++++++++++------------------------------ 1 file changed, 12 insertions(+), 36 deletions(-) diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index df4f34150..7ae1d9b85 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -2740,7 +2740,6 @@ sub getAllNodeAttribs #Extract and substitute every node record, expanding groups and substituting as getNodeAttribs does my $self = shift; - my $xcatcfg =get_xcatcfg(); if ($dbworkerpid) { return dbc_call($self,'getAllNodeAttribs',@_); } @@ -2755,23 +2754,13 @@ sub getAllNodeAttribs if (defined $xCAT::Schema::tabspec{$self->{tabname}}->{nodecol}) { $nodekey = $xCAT::Schema::tabspec{$self->{tabname}}->{nodecol} }; - if ($xcatcfg =~ /^mysql:/) { #for mysql - $query = $self->{dbh}->prepare('SELECT '.$nodekey.' FROM ' - . $self->{tabname} - . " WHERE " . q(`disable`) . " is NULL or " . q(`disable`) . " in ('0','no','NO','No','nO')"); - } else { - if ($xcatcfg =~ /^DB2:/) { #for DB2 - my $qstring = "Select \"$nodekey\" FROM "; - $qstring .= $self->{tabname}; - $qstring .= " WHERE \"disable\" is NULL OR \"disable\" LIKE '0' OR \"disable\" LIKE 'no' OR \"disable\" LIKE 'NO' OR \"disable\" LIKE 'No' OR \"disable\" LIKE 'nO'"; - $query = $self->{dbh}->prepare($qstring); - } else { # for other dbs - $query = - $self->{dbh}->prepare('SELECT '.$nodekey.' FROM ' - . $self->{tabname} - . " WHERE \"disable\" is NULL or \"disable\" in ('','0','no','NO','no')"); - } - } + # delimit the disable column based on the DB + my $disable= &delimitcol("disable"); + my $dnodekey= &delimitcol($nodekey); + my $qstring= 'SELECT '.$dnodekey.' FROM ' + . $self->{tabname} + . " WHERE " . $disable . " is NULL or " . $disable . " in ('0','no','NO','No','nO')"; + $query = $self->{dbh}->prepare($qstring); $query->execute(); xCAT::NodeRange::retain_cache(1); $self->{_use_cache} = 0; @@ -2869,7 +2858,6 @@ sub getAllAttribs #Takes a list of attributes, returns all records in the table. my $self = shift; - my $xcatcfg =get_xcatcfg(); if ($dbworkerpid) { return dbc_call($self,'getAllAttribs',@_); } @@ -2900,24 +2888,12 @@ sub getAllAttribs } return undef; } + # delimit the disable column based on the DB + my $disable= &delimitcol("disable"); my $query; - if ($xcatcfg =~ /^mysql:/) { #for mysql - $query = $self->{dbh}->prepare('SELECT * FROM ' - . $self->{tabname} - . " WHERE " . q(`disable`) . " is NULL or " . q(`disable`) . " in ('0','no','NO','No','nO')"); - } else { - if ($xcatcfg =~ /^DB2:/) { #for DB2 - my $qstring = - "SELECT * FROM " - . $self->{tabname} - . " WHERE \"disable\" is NULL OR \"disable\" LIKE '0' OR \"disable\" LIKE 'no' OR \"disable\" LIKE 'NO' OR \"disable\" LIKE 'nO' "; - $query = $self->{dbh}->prepare($qstring); - } else { # for other dbs - $query = $self->{dbh}->prepare('SELECT * FROM ' - . $self->{tabname} - . " WHERE \"disable\" is NULL or \"disable\" in ('','0','no','NO','nO')"); - } - } + my $qstring = "SELECT * FROM " . $self->{tabname} + . " WHERE " . $disable . " is NULL or " . $disable . " in ('0','no','NO','No','nO')"; + $query = $self->{dbh}->prepare($qstring); #print $query; $query->execute(); while (my $data = $query->fetchrow_hashref())