changeset 328:b2fbb9de8845

avoid infinite loop when r[-1] > rows_remembered
author Catherine Devlin <catherine.devlin@gmail.com>
date Sun, 05 Apr 2009 00:08:42 -0400
parents 7cc5cc19891f
children 8dd71d47f3cb
files sqlpython/sqlpyPlus.py
diffstat 1 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/sqlpython/sqlpyPlus.py	Sat Apr 04 22:10:47 2009 -0400
+++ b/sqlpython/sqlpyPlus.py	Sun Apr 05 00:08:42 2009 -0400
@@ -316,7 +316,7 @@
     def __init__(self):
         sqlpython.sqlpython.__init__(self)
         self.binds = CaselessDict()
-        self.settable += 'autobind commit_on_exit maxfetch maxtselctrows rows_remembered scan serveroutput sql_echo store_results timeout heading wildsql'.split()
+        self.settable += 'autobind commit_on_exit maxfetch maxtselctrows rows_remembered scan serveroutput sql_echo timeout heading wildsql'.split()
         self.settable.remove('case_insensitive')
         self.settable.sort()
         self.stdoutBeforeSpool = sys.stdout
@@ -330,7 +330,6 @@
         self.nonpythoncommand = 'sql'
         self.substvars = {}
         self.result_history = []
-        self.store_results = True
         self.rows_remembered = 10
         
         self.pystate = {'r': [], 'binds': self.binds, 'substs': self.substvars}
@@ -666,12 +665,12 @@
         
     def age_out_resultsets(self):
         total_len = sum(len(rs) for rs in self.pystate['r'])
-        while (self.rows_remembered and (total_len >= self.rows_remembered)):
-            for (i, rset) in enumerate(self.pystate['r'][:-1]):
-                if rset:
-                    self.pystate['r'][i] = []
-                    break
-            total_len = sum(len(rs) for rs in self.pystate['r'])
+        for (i, rset) in enumerate(self.pystate['r'][:-1]):
+            if total_len <= self.rows_remembered:
+                return
+            total_len -= len(rset)
+            self.pystate['r'][i] = []
+            
     def do_select(self, arg, bindVarsIn=None, terminator=None):
         """Fetch rows from a table.