Skip to content

Commit 05adc7b

Browse files
committed
Merge pull request #7 from artyom-smirnov/fix-truncation-detection with local changes
2 parents 90c7da0 + 9b55d07 commit 05adc7b

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

firebird/driver/core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,6 +1069,7 @@ def get_server_version(self, con: Union[Connection, Server]) -> str:
10691069
else: # pragma: no cover
10701070
# Unknown version
10711071
result = '0.0.0.0'
1072+
self.response.rewind()
10721073
self.con = None
10731074
return result
10741075
def get_engine_version(self, con: Union[Connection, Server]) -> float:
@@ -1469,10 +1470,10 @@ def fetches(self) -> int:
14691470
"""
14701471
return self.get_info(DbInfoCode.FETCHES)
14711472
@property
1472-
def cache_hit_ratio(self) -> int:
1473+
def cache_hit_ratio(self) -> float:
14731474
"""Cache hit ratio = 1 - (reads / fetches).
14741475
"""
1475-
return 1 - (self.reads / self.fetches)
1476+
return (1 - (self.reads / self.fetches)) if self.fetches else 1.0
14761477
@property
14771478
def writes(self) -> int:
14781479
"""Current I/O statistics - Writes from page cache to disk.

firebird/driver/fbapi.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,22 @@
123123
blr_ex_time_tz = 30
124124
blr_ex_timestamp_tz = 31
125125

126+
# Masks for fb_shutdown_callback
127+
fb_shut_confirmation = 1
128+
fb_shut_preproviders = 2
129+
fb_shut_postproviders = 4
130+
fb_shut_finish = 8
131+
fb_shut_exit = 16
132+
133+
# Shutdown reasons, used by engine
134+
fb_shutrsn_svc_stopped = -1
135+
fb_shutrsn_no_connection = -2
136+
fb_shutrsn_app_stopped = -3
137+
fb_shutrsn_signal = -5
138+
fb_shutrsn_services = -6
139+
fb_shutrsn_exit_called = -7
140+
fb_shutrsn_emergency = -8
141+
126142
if platform.architecture() == ('64bit', 'WindowsPE'): # pragma: no cover
127143
intptr_t = c_longlong
128144
uintptr_t = c_ulonglong
@@ -238,6 +254,7 @@ class ISC_QUAD(Structure):
238254

239255
RESULT_VECTOR = ISC_ULONG * 15
240256
ISC_EVENT_CALLBACK = CFUNCTYPE(None, POINTER(ISC_UCHAR), c_ushort, POINTER(ISC_UCHAR))
257+
FB_SHUTDOWN_CALLBACK = CFUNCTYPE(c_int, c_int, c_int, c_void_p)
241258

242259
# >>> Firebird 4
243260
class ISC_TIME_TZ(Structure):
@@ -1951,6 +1968,13 @@ def __init__(self, filename: Path = None):
19511968
self.fb_sqlstate.restype = None
19521969
self.fb_sqlstate.argtypes = [STRING, ISC_STATUS_PTR]
19531970
#
1971+
self.fb_shutdown_callback = self.client_library.fb_shutdown_callback
1972+
self.fb_shutdown_callback.restype = ISC_STATUS
1973+
self.fb_shutdown_callback.argtypes = [ISC_STATUS_PTR,
1974+
FB_SHUTDOWN_CALLBACK,
1975+
c_int,
1976+
c_void_p]
1977+
#
19541978
self.isc_sqlcode = self.client_library.isc_sqlcode
19551979
self.isc_sqlcode.restype = ISC_LONG
19561980
self.isc_sqlcode.argtypes = [ISC_STATUS_PTR]

0 commit comments

Comments
 (0)