summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/engine/default.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2020-09-13 10:36:16 -0400
committerMike Bayer <mike_mp@zzzcomputing.com>2020-09-13 13:06:02 -0400
commit25b8e89d3d425656e51438b5cac7e6e1f2592817 (patch)
tree66d2b0c07245f084ad4058c35c502d51332fd192 /lib/sqlalchemy/engine/default.py
parenta4bfde4a18e50d93e44aec5c6216be8a6f9fbacb (diff)
downloadsqlalchemy-25b8e89d3d425656e51438b5cac7e6e1f2592817.tar.gz
Deprecate engine-wise ss cursors; repair mariadbconnector
The server_side_cursors engine-wide feature relies upon regexp parsing of statements a well as general guessing as to when the feature should be used. This is not within the 2.0 way of doing things and should be removed. Additionally, mariadbconnector defaults to unbuffered cursors; add new cursor hooks so that mariadbconnector can specify buffered or unbuffered cursors without too much difficulty. This will also correctly default mariadbconnector to buffered cursors which should repair the segfaults we've been getting. Try to restore the assert_raises that was removed in 5b6dfc0c38bf1f01da4b8 to see if mariadbconnector segfaults are resolved. Change-Id: I77f1c972c742e40694972f578140bb0cac8c39eb
Diffstat (limited to 'lib/sqlalchemy/engine/default.py')
-rw-r--r--lib/sqlalchemy/engine/default.py25
1 files changed, 24 insertions, 1 deletions
diff --git a/lib/sqlalchemy/engine/default.py b/lib/sqlalchemy/engine/default.py
index 9d2eaf606..ff29c3b9d 100644
--- a/lib/sqlalchemy/engine/default.py
+++ b/lib/sqlalchemy/engine/default.py
@@ -144,6 +144,8 @@ class DefaultDialect(interfaces.Dialect):
supports_server_side_cursors = False
+ server_side_cursors = False
+
# extra record-level locking features (#4860)
supports_for_update_of = False
@@ -235,6 +237,14 @@ class DefaultDialect(interfaces.Dialect):
"Applications should work with result column names in a case "
"sensitive fashion.",
),
+ server_side_cursors=(
+ "1.4",
+ "The :paramref:`_sa.create_engine.server_side_cursors` parameter "
+ "is deprecated and will be removed in a future release. Please "
+ "use the "
+ ":paramref:`_engine.Connection.execution_options.stream_results` "
+ "parameter.",
+ ),
)
def __init__(
self,
@@ -250,6 +260,7 @@ class DefaultDialect(interfaces.Dialect):
# int() is because the @deprecated_params decorator cannot accommodate
# the direct reference to the "NO_LINTING" object
compiler_linting=int(compiler.NO_LINTING),
+ server_side_cursors=False,
**kwargs
):
@@ -259,6 +270,14 @@ class DefaultDialect(interfaces.Dialect):
% self.name
)
+ if server_side_cursors:
+ if not self.supports_server_side_cursors:
+ raise exc.ArgumentError(
+ "Dialect %s does not support server side cursors" % self
+ )
+ else:
+ self.server_side_cursors = True
+
self.convert_unicode = convert_unicode
self.encoding = encoding
self.positional = False
@@ -1189,6 +1208,7 @@ class DefaultExecutionContext(interfaces.ExecutionContext):
return False
if self.dialect.server_side_cursors:
+ # this is deprecated
use_server_side = self.execution_options.get(
"stream_results", True
) and (
@@ -1232,7 +1252,10 @@ class DefaultExecutionContext(interfaces.ExecutionContext):
return self.create_server_side_cursor()
else:
self._is_server_side = False
- return self._dbapi_connection.cursor()
+ return self.create_default_cursor()
+
+ def create_default_cursor(self):
+ return self._dbapi_connection.cursor()
def create_server_side_cursor(self):
raise NotImplementedError()