[interchange-cvs] interchange - pajamian modified 2 files

interchange-cvs at icdevgroup.org interchange-cvs at icdevgroup.org
Wed Apr 11 07:16:30 EDT 2007


User:      pajamian
Date:      2007-04-11 11:16:25 GMT
Modified:  .        WHATSNEW-5.5
Modified:  lib/Vend/Table DBI.pm
Log:
We don't need to check last_sequence_value for the key if we already know it, especially on an UPDATE.

Revision  Changes    Path
1.31      +4 -0      interchange/WHATSNEW-5.5


rev 1.31, prev_rev 1.30
Index: WHATSNEW-5.5
===================================================================
RCS file: /var/cvs/interchange/WHATSNEW-5.5,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- WHATSNEW-5.5	27 Feb 2007 11:32:08 -0000	1.30
+++ WHATSNEW-5.5	11 Apr 2007 11:16:24 -0000	1.31
@@ -56,6 +56,10 @@
 * Fix [on-match]/[no-match] for loop lists without matchlimit generated from
   embedded Perl objects
     
+* Fixed problem where both set_row() and set_slice would try to get the key
+  from last_sequence_value() for returning even if we already know the key and
+  even on an UPDATE which can cause problems.
+
 UserDB
 ------
 



2.75      +16 -10    interchange/lib/Vend/Table/DBI.pm


rev 2.75, prev_rev 2.74
Index: DBI.pm
===================================================================
RCS file: /var/cvs/interchange/lib/Vend/Table/DBI.pm,v
retrieving revision 2.74
retrieving revision 2.75
diff -u -r2.74 -r2.75
--- DBI.pm	30 Mar 2007 11:39:54 -0000	2.74
+++ DBI.pm	11 Apr 2007 11:16:25 -0000	2.75
@@ -1,6 +1,6 @@
 # Vend::Table::DBI - Access a table stored in an DBI/DBD database
 #
-# $Id: DBI.pm,v 2.74 2007/03/30 11:39:54 pajamian Exp $
+# $Id: DBI.pm,v 2.75 2007/04/11 11:16:25 pajamian Exp $
 #
 # Copyright (C) 2002-2006 Interchange Development Group
 # Copyright (C) 1996-2002 Red Hat, Inc.
@@ -21,7 +21,7 @@
 # MA  02110-1301  USA.
 
 package Vend::Table::DBI;
-$VERSION = substr(q$Revision: 2.74 $, 10);
+$VERSION = substr(q$Revision: 2.75 $, 10);
 
 use strict;
 no warnings qw(uninitialized numeric);
@@ -1261,9 +1261,12 @@
 		my $rc = $sth->execute(@$vary)
 			or die ::errmsg("execute %s: %s", $sql, $DBI::errstr);
 
-		$val	= $s->[$CONFIG]->{AUTO_SEQUENCE}
-				? $s->last_sequence_value($key)
-				: $key;
+		if (length $key) {
+		    $val = $key;
+		}
+		else {
+		    $val = $s->last_sequence_value;
+		}
 	};
 
 #::logDebug("set_slice key: $val");
@@ -1393,12 +1396,15 @@
 #::logDebug("set_row fields='" . join(',', @fields) . "'" );
     $s->bind_entire_row($cfg->{_Insert_h}, @fields);
 
-	my $rc = $cfg->{_Insert_h}->execute()
-		or die $s->log_error("%s error on key '%s': $DBI::errstr", 'set_row', $fields[$ki], $DBI::errstr);
+    my $rc = $cfg->{_Insert_h}->execute()
+	or die $s->log_error("%s error on key '%s': $DBI::errstr", 'set_row', $fields[$ki], $DBI::errstr);
 
-	$val	= $cfg->{AUTO_SEQUENCE}
-			?  $s->last_sequence_value($fields[$ki])
-			: $fields[$ki];
+    if (length $fields[$ki]) {
+	$val = $fields[$ki];
+    }
+    else {
+	$val = $s->last_sequence_value;
+    }
 
 #::logDebug("set_row rc=$rc key=$val");
 	return $val;








More information about the interchange-cvs mailing list