Skip to content

Commit

Permalink
Set value to '' if value within composite primary keys not defined (#…
Browse files Browse the repository at this point in the history
…2045)

As history reasons, null value is always set within the composite primary
keys, this patch is just a work aroud for the issue encountered on postgres.
Correct fix is to report error to the client side, but too much error handler
is missing in xcat code

close-issue: #2037
close-issue: #2007
  • Loading branch information
chenglch authored and immarvin committed Nov 1, 2016
1 parent f2eeaa3 commit 331d786
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions perl-xCAT/xCAT/Table.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,16 @@ sub setAttribs
@bind = ();
$cols = "";
my %newpairs;
# NOTE(chenglch): Just work around, set the default value to '' due to
# null value can not be allowed in composite primary keys in standard
# SQL rules.
my $descr = $xCAT::Schema::tabspec{ $self->{tabname} };
my @pkeys = @{$descr->{keys}};
for my $p (@pkeys) {
if(!defined($elems->{$p}) && !defined($pKeypairs->{$p})) {
$elems->{$p}= '';
}
}

#first, merge the two structures to a single hash
foreach (keys %keypairs)
Expand Down

0 comments on commit 331d786

Please sign in to comment.