@@ -570,7 +570,8 @@ def __init__(self, host, port,
570
570
ssl_ca_file = DEFAULT_SSL_CA_FILE ,
571
571
ssl_ciphers = DEFAULT_SSL_CIPHERS ,
572
572
packer_factory = default_packer_factory ,
573
- unpacker_factory = default_unpacker_factory ):
573
+ unpacker_factory = default_unpacker_factory ,
574
+ fetch_schema = True ):
574
575
"""
575
576
:param host: Server hostname or IP address. Use ``None`` for
576
577
Unix sockets.
@@ -710,6 +711,18 @@ def __init__(self, host, port,
710
711
callable[[:obj:`~tarantool.Connection`], :obj:`~msgpack.Unpacker`],
711
712
optional
712
713
714
+ :param bool fetch_schema: If ``False``, allows to ignore schema
715
+ changes on the server, schema updates are not automatically
716
+ loaded. As a result, these methods become unavailable:
717
+ :meth:`~tarantool.Connection.replace`,
718
+ :meth:`~tarantool.Connection.insert`,
719
+ :meth:`~tarantool.Connection.delete`,
720
+ :meth:`~tarantool.Connection.upsert`,
721
+ :meth:`~tarantool.Connection.update`,
722
+ :meth:`~tarantool.Connection.select`,
723
+ :meth:`~tarantool.Connection.space`.
724
+ :type fetch_schema: :obj:`bool`, optional
725
+
713
726
:raise: :exc:`~tarantool.error.ConfigurationError`,
714
727
:meth:`~tarantool.Connection.connect` exceptions
715
728
@@ -740,6 +753,7 @@ def __init__(self, host, port,
740
753
self .socket_timeout = socket_timeout
741
754
self .reconnect_delay = reconnect_delay
742
755
self .reconnect_max_attempts = reconnect_max_attempts
756
+ self .fetch_schema = fetch_schema
743
757
self .schema = Schema (self )
744
758
self .schema_version = 1
745
759
self ._socket = None
@@ -952,7 +966,8 @@ def connect(self):
952
966
if self .transport == SSL_TRANSPORT :
953
967
self .wrap_socket_ssl ()
954
968
self .handshake ()
955
- self .load_schema ()
969
+ if self .fetch_schema :
970
+ self .load_schema ()
956
971
self ._check_features ()
957
972
except SslError as e :
958
973
raise e
@@ -1048,7 +1063,8 @@ def _send_request_wo_reconnect(self, request, on_push=None, on_push_ctx=None):
1048
1063
response = request .response_class (self , self ._read_response ())
1049
1064
break
1050
1065
except SchemaReloadException as e :
1051
- self .update_schema (e .schema_version )
1066
+ if self .fetch_schema :
1067
+ self .update_schema (e .schema_version )
1052
1068
continue
1053
1069
1054
1070
while response ._code == IPROTO_CHUNK :
@@ -1199,6 +1215,18 @@ def flush_schema(self):
1199
1215
self .schema .flush ()
1200
1216
self .load_schema ()
1201
1217
1218
+ def _fetch_schema_support_check (self ):
1219
+ """
1220
+ Checks the fetch_schema opt of the connection is enabled.
1221
+ If the opt is disabled, an exception will be thrown
1222
+ about unsupporting the method with fetch_schema=False.
1223
+
1224
+ :raise: :exc:`~tarantool.error.NotSupportedError`
1225
+ """
1226
+ if not self .fetch_schema :
1227
+ raise NotSupportedError ('This method is not available in ' +
1228
+ 'connection opened with fetch_schema=False' )
1229
+
1202
1230
def call (self , func_name , * args , on_push = None , on_push_ctx = None ):
1203
1231
"""
1204
1232
Execute a CALL request: call a stored Lua function.
@@ -1296,11 +1324,14 @@ def replace(self, space_name, values, on_push=None, on_push_ctx=None):
1296
1324
:exc:`~tarantool.error.DatabaseError`,
1297
1325
:exc:`~tarantool.error.SchemaError`,
1298
1326
:exc:`~tarantool.error.NetworkError`,
1299
- :exc:`~tarantool.error.SslError`
1327
+ :exc:`~tarantool.error.SslError`,
1328
+ :exc:`~tarantool.error.NotSupportedError`
1300
1329
1301
1330
.. _replace: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/replace/
1302
1331
"""
1303
1332
1333
+ self ._fetch_schema_support_check ()
1334
+
1304
1335
if isinstance (space_name , str ):
1305
1336
space_name = self .schema .get_space (space_name ).sid
1306
1337
if on_push is not None and not callable (on_push ):
@@ -1338,7 +1369,7 @@ def authenticate(self, user, password):
1338
1369
request = RequestAuthenticate (self , self ._salt , self .user ,
1339
1370
self .password )
1340
1371
auth_response = self ._send_request_wo_reconnect (request )
1341
- if auth_response .return_code == 0 :
1372
+ if auth_response .return_code == 0 and self . fetch_schema :
1342
1373
self .flush_schema ()
1343
1374
return auth_response
1344
1375
@@ -1483,11 +1514,14 @@ def insert(self, space_name, values, on_push=None, on_push_ctx=None):
1483
1514
:exc:`~tarantool.error.DatabaseError`,
1484
1515
:exc:`~tarantool.error.SchemaError`,
1485
1516
:exc:`~tarantool.error.NetworkError`,
1486
- :exc:`~tarantool.error.SslError`
1517
+ :exc:`~tarantool.error.SslError`,
1518
+ :exc:`~tarantool.error.NotSupportedError`
1487
1519
1488
1520
.. _insert: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/insert/
1489
1521
"""
1490
1522
1523
+ self ._fetch_schema_support_check ()
1524
+
1491
1525
if isinstance (space_name , str ):
1492
1526
space_name = self .schema .get_space (space_name ).sid
1493
1527
if on_push is not None and not callable (on_push ):
@@ -1522,11 +1556,14 @@ def delete(self, space_name, key, *, index=0, on_push=None, on_push_ctx=None):
1522
1556
:exc:`~tarantool.error.DatabaseError`,
1523
1557
:exc:`~tarantool.error.SchemaError`,
1524
1558
:exc:`~tarantool.error.NetworkError`,
1525
- :exc:`~tarantool.error.SslError`
1559
+ :exc:`~tarantool.error.SslError`,
1560
+ :exc:`~tarantool.error.NotSupportedError`
1526
1561
1527
1562
.. _delete: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/delete/
1528
1563
"""
1529
1564
1565
+ self ._fetch_schema_support_check ()
1566
+
1530
1567
key = wrap_key (key )
1531
1568
if isinstance (space_name , str ):
1532
1569
space_name = self .schema .get_space (space_name ).sid
@@ -1581,11 +1618,14 @@ def upsert(self, space_name, tuple_value, op_list, *, index=0, on_push=None, on_
1581
1618
:exc:`~tarantool.error.DatabaseError`,
1582
1619
:exc:`~tarantool.error.SchemaError`,
1583
1620
:exc:`~tarantool.error.NetworkError`,
1584
- :exc:`~tarantool.error.SslError`
1621
+ :exc:`~tarantool.error.SslError`,
1622
+ :exc:`~tarantool.error.NotSupportedError`
1585
1623
1586
1624
.. _upsert: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/upsert/
1587
1625
"""
1588
1626
1627
+ self ._fetch_schema_support_check ()
1628
+
1589
1629
if isinstance (space_name , str ):
1590
1630
space_name = self .schema .get_space (space_name ).sid
1591
1631
if isinstance (index , str ):
@@ -1669,11 +1709,14 @@ def update(self, space_name, key, op_list, *, index=0, on_push=None, on_push_ctx
1669
1709
:exc:`~tarantool.error.DatabaseError`,
1670
1710
:exc:`~tarantool.error.SchemaError`,
1671
1711
:exc:`~tarantool.error.NetworkError`,
1672
- :exc:`~tarantool.error.SslError`
1712
+ :exc:`~tarantool.error.SslError`,
1713
+ :exc:`~tarantool.error.NotSupportedError`
1673
1714
1674
1715
.. _update: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/update/
1675
1716
"""
1676
1717
1718
+ self ._fetch_schema_support_check ()
1719
+
1677
1720
key = wrap_key (key )
1678
1721
if isinstance (space_name , str ):
1679
1722
space_name = self .schema .get_space (space_name ).sid
@@ -1855,11 +1898,14 @@ def select(self, space_name, key=None, *, offset=0, limit=0xffffffff, index=0, i
1855
1898
:exc:`~tarantool.error.DatabaseError`,
1856
1899
:exc:`~tarantool.error.SchemaError`,
1857
1900
:exc:`~tarantool.error.NetworkError`,
1858
- :exc:`~tarantool.error.SslError`
1901
+ :exc:`~tarantool.error.SslError`,
1902
+ :exc:`~tarantool.error.NotSupportedError`
1859
1903
1860
1904
.. _select: https://www.tarantool.io/en/doc/latest/reference/reference_lua/box_space/select/
1861
1905
"""
1862
1906
1907
+ self ._fetch_schema_support_check ()
1908
+
1863
1909
if iterator is None :
1864
1910
iterator = ITERATOR_EQ
1865
1911
if key is None or (isinstance (key , (list , tuple )) and
@@ -1895,6 +1941,8 @@ def space(self, space_name):
1895
1941
:raise: :exc:`~tarantool.error.SchemaError`
1896
1942
"""
1897
1943
1944
+ self ._fetch_schema_support_check ()
1945
+
1898
1946
return Space (self , space_name )
1899
1947
1900
1948
def generate_sync (self ):
0 commit comments