]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
Fixes: #4914 Amend BufferedRowResultProxy to handle max_row_buffer > 1000
authorsumau <soumaya.mauthoor@gmail.com>
Sat, 19 Oct 2019 22:03:31 +0000 (23:03 +0100)
committersumau <soumaya.mauthoor@gmail.com>
Sat, 19 Oct 2019 22:14:06 +0000 (23:14 +0100)
lib/sqlalchemy/engine/result.py

index 733bd6f6ab701d1aeda17b27346ff5c93f180dea..100004c1676ddec7333fb3fbac4770ee8072ea18 100644 (file)
@@ -1486,9 +1486,8 @@ class BufferedRowResultProxy(ResultProxy):
 
     The pre-fetching behavior fetches only one row initially, and then
     grows its buffer size by a fixed amount with each successive need
-    for additional rows up to a size of 1000.
-
-    The size argument is configurable using the ``max_row_buffer``
+    for additional rows up to a size of 1000, after which the buffer
+    size increases to the value configured using the ``max_row_buffer``
     execution option::
 
         with psycopg2_engine.connect() as conn:
@@ -1508,13 +1507,14 @@ class BufferedRowResultProxy(ResultProxy):
         self._max_row_buffer = self.context.execution_options.get(
             "max_row_buffer", None
         )
+        self.__update_size_growth()
         self.__buffer_rows()
         super(BufferedRowResultProxy, self)._init_metadata()
 
     # this is a "growth chart" for the buffering of rows.
     # each successive __buffer_rows call will use the next
     # value in the list for the buffer size until the max
-    # is reached
+    # or 1000 is reached
     size_growth = {
         1: 5,
         5: 10,
@@ -1526,6 +1526,12 @@ class BufferedRowResultProxy(ResultProxy):
         500: 1000,
     }
 
+    # this increases size_growth if the max buffer size > 1000
+    def __update_size_growth(self):
+        if self._max_row_buffer is not None:
+            if self._max_row_buffer >1000:
+                self.size_growth.update({1000:self._max_row_buffer})
+
     def __buffer_rows(self):
         if self.cursor is None:
             return