-
Notifications
You must be signed in to change notification settings - Fork 564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: add more TRACE calls for easier debugging #1317
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -325,7 +325,7 @@ static bool free_results(Cursor* self, int flags) | |
// this even when a query has not been executed. | ||
|
||
// If we ran out of memory, it is possible that we have a cursor but colinfos is zero. However, we should be | ||
// deleting this object, so the cursor will be freed when the HSTMT is destroyed. */ | ||
// deleting this object, so the cursor will be freed when the HSTMT is destroyed. | ||
|
||
assert((flags & STATEMENT_MASK) != 0); | ||
assert((flags & PREPARED_MASK) != 0); | ||
|
@@ -344,6 +344,8 @@ static bool free_results(Cursor* self, int flags) | |
|
||
if (StatementIsValid(self)) | ||
{ | ||
TRACE("free_results: %p\n", self); | ||
|
||
if ((flags & STATEMENT_MASK) == FREE_STATEMENT) | ||
{ | ||
Py_BEGIN_ALLOW_THREADS | ||
|
@@ -387,6 +389,8 @@ static bool free_results(Cursor* self, int flags) | |
|
||
self->rowcount = -1; | ||
|
||
TRACE("free_results: done\n"); | ||
|
||
return true; | ||
} | ||
|
||
|
@@ -407,6 +411,8 @@ static void closeimpl(Cursor* cur) | |
HSTMT hstmt = cur->hstmt; | ||
cur->hstmt = SQL_NULL_HANDLE; | ||
|
||
TRACE("SQLFreeHandle\n"); | ||
|
||
SQLRETURN ret; | ||
Py_BEGIN_ALLOW_THREADS | ||
ret = SQLFreeHandle(SQL_HANDLE_STMT, hstmt); | ||
|
@@ -415,6 +421,8 @@ static void closeimpl(Cursor* cur) | |
// If there is already an exception, don't overwrite it. | ||
if (!SQL_SUCCEEDED(ret) && !PyErr_Occurred()) | ||
RaiseErrorFromHandle(cur->cnxn, "SQLFreeHandle", cur->cnxn->hdbc, SQL_NULL_HANDLE); | ||
} else { | ||
TRACE("Invalid statement handle, skipping SQLFreeHandle\n"); | ||
} | ||
|
||
Py_XDECREF(cur->pPreparedSQL); | ||
|
@@ -750,12 +758,16 @@ static PyObject* execute(Cursor* cur, PyObject* pSql, PyObject* params, bool ski | |
const char* pch = PyBytes_AS_STRING(query.Get()); | ||
SQLINTEGER cch = (SQLINTEGER)(PyBytes_GET_SIZE(query.Get()) / (isWide ? sizeof(uint16_t) : 1)); | ||
|
||
TRACE("cursor.execute: isWide=%d query_len=%d\n", isWide, cch); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since we build on so many platforms with different pointer & integer widths, I think we should cast anything that is not a plain integer when using %d. Most likely everything is 64 bits nowdays, but it would't hurt. |
||
|
||
Py_BEGIN_ALLOW_THREADS | ||
if (isWide) | ||
ret = SQLExecDirectW(cur->hstmt, (SQLWCHAR*)pch, cch); | ||
else | ||
ret = SQLExecDirect(cur->hstmt, (SQLCHAR*)pch, cch); | ||
Py_END_ALLOW_THREADS | ||
|
||
TRACE("cursor.execute, finished\n"); | ||
} | ||
|
||
if (cur->cnxn->hdbc == SQL_NULL_HANDLE) | ||
|
@@ -1136,7 +1148,7 @@ static PyObject* Cursor_setinputsizes(PyObject* self, PyObject* sizes) | |
PyErr_SetString(ProgrammingError, "Invalid cursor object."); | ||
return 0; | ||
} | ||
|
||
Cursor *cur = (Cursor*)self; | ||
if (Py_None == sizes) | ||
{ | ||
|
@@ -2526,6 +2538,8 @@ Cursor_New(Connection* cnxn) | |
|
||
if (cnxn->timeout) | ||
{ | ||
TRACE("cursor.new: setting timeout to %d\n", cnxn->timeout); | ||
|
||
Py_BEGIN_ALLOW_THREADS | ||
ret = SQLSetStmtAttr(cur->hstmt, SQL_ATTR_QUERY_TIMEOUT, (SQLPOINTER)(uintptr_t)cnxn->timeout, 0); | ||
Py_END_ALLOW_THREADS | ||
|
@@ -2538,7 +2552,7 @@ Cursor_New(Connection* cnxn) | |
} | ||
} | ||
|
||
TRACE("cursor.new cnxn=%p hdbc=%d cursor=%p hstmt=%d\n", (Connection*)cur->cnxn, ((Connection*)cur->cnxn)->hdbc, cur, cur->hstmt); | ||
TRACE("cursor.new: cnxn=%p hdbc=%d cursor=%p hstmt=%d\n", (Connection*)cur->cnxn, ((Connection*)cur->cnxn)->hdbc, cur, cur->hstmt); | ||
} | ||
|
||
return cur; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1310,6 +1310,8 @@ void FreeParameterData(Cursor* cur) | |
{ | ||
// Unbinds the parameters and frees the parameter buffer. | ||
|
||
TRACE("FreeParameterData"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needs newline? |
||
|
||
if (cur->paramInfos) | ||
{ | ||
// MS ODBC will crash if we use an HSTMT after the HDBC has been freed. | ||
|
@@ -1330,6 +1332,8 @@ void FreeParameterInfo(Cursor* cur) | |
// Internal function to free just the cached parameter information. This is not used by the general cursor code | ||
// since this information is also freed in the less granular free_results function that clears everything. | ||
|
||
TRACE("FreeParameterInfo"); | ||
|
||
Py_XDECREF(cur->pPreparedSQL); | ||
PyMem_Free(cur->paramtypes); | ||
cur->pPreparedSQL = 0; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't tested this locally, but it appears there are 3 placeholders and 2 values.