[TD-785]check the caller and creater, if not match, return none

This commit is contained in:
liu0x54 2020-06-30 01:32:38 +00:00
parent 6cb97b3730
commit 496932f0cc
1 changed files with 16 additions and 0 deletions

View File

@ -1,6 +1,7 @@
from .cinterface import CTaosInterface
from .error import *
from .constants import FieldType
import threading
# querySeqNum = 0
@ -37,6 +38,7 @@ class TDengineCursor(object):
self._block_iter = 0
self._affected_rows = 0
self._logfile = ""
self._threadId = threading.get_ident()
if connection is not None:
self._connection = connection
@ -103,6 +105,11 @@ class TDengineCursor(object):
def execute(self, operation, params=None):
"""Prepare and execute a database operation (query or command).
"""
if threading.get_ident() != self._threadId:
info ="Cursor execute:Thread ID not match,creater:"+str(self._threadId)+" caller:"+str(threading.get_ident())
print(info)
return None
if not operation:
return None
@ -188,6 +195,10 @@ class TDengineCursor(object):
def fetchall(self):
"""Fetch all (remaining) rows of a query result, returning them as a sequence of sequences (e.g. a list of tuples). Note that the cursor's arraysize attribute can affect the performance of this operation.
"""
if threading.get_ident() != self._threadId:
info ="Cursor fetchall:Thread ID not match,creater:"+str(self._threadId)+" caller:"+str(threading.get_ident())
print(info)
return None
if self._result is None or self._fields is None:
raise OperationalError("Invalid use of fetchall")
@ -232,6 +243,11 @@ class TDengineCursor(object):
def _handle_result(self):
"""Handle the return result from query.
"""
if threading.get_ident() != self._threadId:
info = "Cursor handleresult:Thread ID not match,creater:"+str(self._threadId)+" caller:"+str(threading.get_ident())
print(info)
return None
self._description = []
for ele in self._fields:
self._description.append(