From 9d7014c2cac7ac17ff0e046a76cbee10bad08ca9 Mon Sep 17 00:00:00 2001 From: lissav Date: Tue, 3 Aug 2010 14:12:05 +0000 Subject: [PATCH] fix mysql calls in setNodesAtt git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@6954 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Table.pm | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index 81843e117..90850b088 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -1800,10 +1800,14 @@ sub setNodesAttribs { my %insertnodes=(); my $qstring; #sort nodes into inserts and updates - if ($xcatcfg =~ /^DB2:/){ - $qstring = "SELECT * FROM " . $self->{tabname} . " WHERE \"$nodekey\" LIKE ("; + if ($xcatcfg =~ /^mysql:/) { #for mysql + $qstring = "SELECT * FROM " . $self->{tabname} . " WHERE \`$nodekey\` in ("; } else { - $qstring = "SELECT * FROM " . $self->{tabname} . " WHERE $nodekey in ("; + if ($xcatcfg =~ /^DB2:/){ + $qstring = "SELECT * FROM " . $self->{tabname} . " WHERE \"$nodekey\" LIKE ("; + } else { + $qstring = "SELECT * FROM " . $self->{tabname} . " WHERE $nodekey in ("; + } } $qstring .= '?, ' x scalar(@currnodes); $qstring =~ s/, $/)/; @@ -1850,19 +1854,27 @@ sub setNodesAttribs { if (not $upsth and keys %updatenodes) { #prepare an insert statement since one will be needed my $upstring = "UPDATE ".$self->{tabname}." set "; foreach my $col (@orderedcols) { #try aggregating requests. Could also see about single prepare, multiple executes instead - if ($xcatcfg =~ /^DB2:/){ - $upstring .= "\"$col\" = ?, "; + if ($xcatcfg =~ /^mysql:/) { #for mysql + $upstring .= "\`$col\` = ?, "; } else { - $upstring .= "$col = ?, "; + if ($xcatcfg =~ /^DB2:/){ + $upstring .= "\"$col\" = ?, "; + } else { + $upstring .= "$col = ?, "; + } } } if (grep { $_ eq $nodekey } @orderedcols) { $upstring =~ s/, \z//; } else { - if ($xcatcfg =~ /^DB2:/){ - $upstring =~ s/, \z/ where \"$nodekey\" = ?/; + if ($xcatcfg =~ /^mysql:/) { #for mysql + $upstring =~ s/, \z/ where \`$nodekey\` = ?/; } else { - $upstring =~ s/, \z/ where $nodekey = ?/; + if ($xcatcfg =~ /^DB2:/){ + $upstring =~ s/, \z/ where \"$nodekey\" = ?/; + } else { + $upstring =~ s/, \z/ where $nodekey = ?/; + } } } $upsth = $self->{dbh}->prepare($upstring);