From 331d7868fa5553d30daba3ec4be93279de7d6f84 Mon Sep 17 00:00:00 2001 From: chenglch Date: Tue, 1 Nov 2016 10:14:54 +0800 Subject: [PATCH] Set value to '' if value within composite primary keys not defined (#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 --- perl-xCAT/xCAT/Table.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index c45f1db6e..a97fbf7c0 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -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)