@@ -579,7 +579,8 @@ def __init__(self, host, port,
579
579
ssl_password_file = DEFAULT_SSL_PASSWORD_FILE ,
580
580
packer_factory = default_packer_factory ,
581
581
unpacker_factory = default_unpacker_factory ,
582
- auth_type = None ):
582
+ auth_type = None ,
583
+ fetch_schema = True ):
583
584
"""
584
585
:param host: Server hostname or IP address. Use ``None`` for
585
586
Unix sockets.
@@ -736,6 +737,18 @@ def __init__(self, host, port,
736
737
``"chap-sha1"``.
737
738
:type auth_type: :obj:`None` or :obj:`str`, optional
738
739
740
+ :param bool fetch_schema: If ``False``, allows to ignore schema
741
+ changes on the server, schema updates are not automatically
742
+ loaded. As a result, these methods become unavailable:
743
+ :meth:`~tarantool.Connection.replace`,
744
+ :meth:`~tarantool.Connection.insert`,
745
+ :meth:`~tarantool.Connection.delete`,
746
+ :meth:`~tarantool.Connection.upsert`,
747
+ :meth:`~tarantool.Connection.update`,
748
+ :meth:`~tarantool.Connection.select`,
749
+ :meth:`~tarantool.Connection.space`.
750
+ :type fetch_schema: :obj:`bool`, optional
751
+
739
752
:raise: :exc:`~tarantool.error.ConfigurationError`,
740
753
:meth:`~tarantool.Connection.connect` exceptions
741
754
@@ -766,6 +779,7 @@ def __init__(self, host, port,
766
779
self .socket_timeout = socket_timeout
767
780
self .reconnect_delay = reconnect_delay
768
781
self .reconnect_max_attempts = reconnect_max_attempts
782
+ self .fetch_schema = fetch_schema
769
783
self .schema = Schema (self )
770
784
self .schema_version = 1
771
785
self ._socket = None
@@ -1023,7 +1037,9 @@ def connect(self):
1023
1037
if self .transport == SSL_TRANSPORT :
1024
1038
self .wrap_socket_ssl ()
1025
1039
self .handshake ()
1026
- self .load_schema ()
1040
+ if self .fetch_schema :
1041
+ self .load_schema ()
1042
+ self ._check_features ()
1027
1043
except SslError as e :
1028
1044
raise e
1029
1045
except Exception as e :
@@ -1118,7 +1134,8 @@ def _send_request_wo_reconnect(self, request, on_push=None, on_push_ctx=None):
1118
1134
response = request .response_class (self , self ._read_response ())
1119
1135
break
1120
1136
except SchemaReloadException as e :
1121
- self .update_schema (e .schema_version )
1137
+ if self .fetch_schema :
1138
+ self .update_schema (e .schema_version )
1122
1139
continue
1123
1140
1124
1141
while response ._code == IPROTO_CHUNK :
@@ -1269,6 +1286,18 @@ def flush_schema(self):
1269
1286
self .schema .flush ()
1270
1287
self .load_schema ()
1271
1288
1289
+ def _fetch_schema_support_check (self ):
1290
+ """
1291
+ Checks the fetch_schema opt of the connection is enabled.
1292
+ If the opt is disabled, an exception will be thrown
1293
+ about unsupporting the method with fetch_schema=False.
1294
+
1295
+ :raise: :exc:`~tarantool.error.NotSupportedError`
1296
+ """
1297
+ if not self .fetch_schema :
1298
+ raise NotSupportedError ('This method is not available in ' +
1299
+ 'connection opened with fetch_schema=False' )
1300
+
1272
1301
def call (self , func_name , * args , on_push = None , on_push_ctx = None ):
1273
1302
"""
1274
1303
Execute a CALL request: call a stored Lua function.
@@ -1366,11 +1395,14 @@ def replace(self, space_name, values, on_push=None, on_push_ctx=None):
1366
1395
:exc:`~tarantool.error.DatabaseError`,
1367
1396
:exc:`~tarantool.error.SchemaError`,
1368
1397
:exc:`~tarantool.error.NetworkError`,
1369
- :exc:`~tarantool.error.SslError`
1398
+ :exc:`~tarantool.error.SslError`,
1399
+ :exc:`~tarantool.error.NotSupportedError`
1370
1400
1371
1401
.. _replace: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/replace/
1372
1402
"""
1373
1403
1404
+ self ._fetch_schema_support_check ()
1405
+
1374
1406
if isinstance (space_name , str ):
1375
1407
space_name = self .schema .get_space (space_name ).sid
1376
1408
if on_push is not None and not callable (on_push ):
@@ -1411,7 +1443,7 @@ def authenticate(self, user, password):
1411
1443
password = self .password ,
1412
1444
auth_type = self ._get_auth_type ())
1413
1445
auth_response = self ._send_request_wo_reconnect (request )
1414
- if auth_response .return_code == 0 :
1446
+ if auth_response .return_code == 0 and self . fetch_schema :
1415
1447
self .flush_schema ()
1416
1448
return auth_response
1417
1449
@@ -1584,11 +1616,14 @@ def insert(self, space_name, values, on_push=None, on_push_ctx=None):
1584
1616
:exc:`~tarantool.error.DatabaseError`,
1585
1617
:exc:`~tarantool.error.SchemaError`,
1586
1618
:exc:`~tarantool.error.NetworkError`,
1587
- :exc:`~tarantool.error.SslError`
1619
+ :exc:`~tarantool.error.SslError`,
1620
+ :exc:`~tarantool.error.NotSupportedError`
1588
1621
1589
1622
.. _insert: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/insert/
1590
1623
"""
1591
1624
1625
+ self ._fetch_schema_support_check ()
1626
+
1592
1627
if isinstance (space_name , str ):
1593
1628
space_name = self .schema .get_space (space_name ).sid
1594
1629
if on_push is not None and not callable (on_push ):
@@ -1623,11 +1658,14 @@ def delete(self, space_name, key, *, index=0, on_push=None, on_push_ctx=None):
1623
1658
:exc:`~tarantool.error.DatabaseError`,
1624
1659
:exc:`~tarantool.error.SchemaError`,
1625
1660
:exc:`~tarantool.error.NetworkError`,
1626
- :exc:`~tarantool.error.SslError`
1661
+ :exc:`~tarantool.error.SslError`,
1662
+ :exc:`~tarantool.error.NotSupportedError`
1627
1663
1628
1664
.. _delete: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/delete/
1629
1665
"""
1630
1666
1667
+ self ._fetch_schema_support_check ()
1668
+
1631
1669
key = wrap_key (key )
1632
1670
if isinstance (space_name , str ):
1633
1671
space_name = self .schema .get_space (space_name ).sid
@@ -1682,11 +1720,14 @@ def upsert(self, space_name, tuple_value, op_list, *, index=0, on_push=None, on_
1682
1720
:exc:`~tarantool.error.DatabaseError`,
1683
1721
:exc:`~tarantool.error.SchemaError`,
1684
1722
:exc:`~tarantool.error.NetworkError`,
1685
- :exc:`~tarantool.error.SslError`
1723
+ :exc:`~tarantool.error.SslError`,
1724
+ :exc:`~tarantool.error.NotSupportedError`
1686
1725
1687
1726
.. _upsert: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/upsert/
1688
1727
"""
1689
1728
1729
+ self ._fetch_schema_support_check ()
1730
+
1690
1731
if isinstance (space_name , str ):
1691
1732
space_name = self .schema .get_space (space_name ).sid
1692
1733
if isinstance (index , str ):
@@ -1770,11 +1811,14 @@ def update(self, space_name, key, op_list, *, index=0, on_push=None, on_push_ctx
1770
1811
:exc:`~tarantool.error.DatabaseError`,
1771
1812
:exc:`~tarantool.error.SchemaError`,
1772
1813
:exc:`~tarantool.error.NetworkError`,
1773
- :exc:`~tarantool.error.SslError`
1814
+ :exc:`~tarantool.error.SslError`,
1815
+ :exc:`~tarantool.error.NotSupportedError`
1774
1816
1775
1817
.. _update: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/update/
1776
1818
"""
1777
1819
1820
+ self ._fetch_schema_support_check ()
1821
+
1778
1822
key = wrap_key (key )
1779
1823
if isinstance (space_name , str ):
1780
1824
space_name = self .schema .get_space (space_name ).sid
@@ -1956,11 +2000,14 @@ def select(self, space_name, key=None, *, offset=0, limit=0xffffffff, index=0, i
1956
2000
:exc:`~tarantool.error.DatabaseError`,
1957
2001
:exc:`~tarantool.error.SchemaError`,
1958
2002
:exc:`~tarantool.error.NetworkError`,
1959
- :exc:`~tarantool.error.SslError`
2003
+ :exc:`~tarantool.error.SslError`,
2004
+ :exc:`~tarantool.error.NotSupportedError`
1960
2005
1961
2006
.. _select: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/select/
1962
2007
"""
1963
2008
2009
+ self ._fetch_schema_support_check ()
2010
+
1964
2011
if iterator is None :
1965
2012
iterator = ITERATOR_EQ
1966
2013
if key is None or (isinstance (key , (list , tuple )) and
@@ -1996,6 +2043,8 @@ def space(self, space_name):
1996
2043
:raise: :exc:`~tarantool.error.SchemaError`
1997
2044
"""
1998
2045
2046
+ self ._fetch_schema_support_check ()
2047
+
1999
2048
return Space (self , space_name )
2000
2049
2001
2050
def generate_sync (self ):
0 commit comments