-
Notifications
You must be signed in to change notification settings - Fork 32
Fix debug printing of SQL(U)LEN variables #233
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
Conversation
This fixes the debug printing of SQL(U)LEN variable types. This type is defined as a long on WIN32, but a __int64 on WIN64. The "%llu"/"%lld" specifier had be used from the start, before the need for an x86 driver was considered and stayed like that mostly since. The values logged by an x86 drivers contains the actual values of the variable, but one needs to convert to hexa, remove the upper 4 byte and convert back, which is cumbersome. The values are now promoted to a (u)int64_t in the logging statements, so printf will always log the correct value. This change also updates some other few incorrect specifiers.
driver/tracing.h
Outdated
| case 'N': /* long/int64_t unsigned */ \ | ||
| _n = snprintf(_BUFF + _ps, _AVAIL(_ps), "%llu", \ | ||
| val ? *(uint64_t *)(uintptr_t)val : 0); \ | ||
| val ? (int64_t)*(SQLULEN *)(uintptr_t)val : 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.
Should this one be uint64_t to match llu?
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.
It should indeed, I've updated it. Thanks for catching it.
- fix cast for '%llu' specifier to uint64_t
droberts195
left a comment
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.
LGTM
* Fix debug printing of SQL(U)LEN variables This fixes the debug printing of SQL(U)LEN variable types. This type is defined as a long on WIN32, but a __int64 on WIN64. The "%llu"/"%lld" specifier had be used from the start, before the need for an x86 driver was considered and stayed like that mostly since. The values logged by an x86 drivers contains the actual values of the variable, but one needs to convert to hexa, remove the upper 4 byte and convert back, which is cumbersome. The values are now promoted to a (u)int64_t in the logging statements, so printf will always log the correct value. This change also updates some other few incorrect specifiers. * address review comments - fix cast for '%llu' specifier to uint64_t (cherry picked from commit bd81338)
* Fix debug printing of SQL(U)LEN variables This fixes the debug printing of SQL(U)LEN variable types. This type is defined as a long on WIN32, but a __int64 on WIN64. The "%llu"/"%lld" specifier had be used from the start, before the need for an x86 driver was considered and stayed like that mostly since. The values logged by an x86 drivers contains the actual values of the variable, but one needs to convert to hexa, remove the upper 4 byte and convert back, which is cumbersome. The values are now promoted to a (u)int64_t in the logging statements, so printf will always log the correct value. This change also updates some other few incorrect specifiers. * address review comments - fix cast for '%llu' specifier to uint64_t (cherry picked from commit bd81338)
This fixes the debug printing of SQL(U)LEN variable types.
This type is defined as a
longon WIN32, but a__int64on WIN64.The "%llu"/"%lld" specifier had been used from the start, before the need
for an x86 driver was considered and stayed like that mostly since.
The values logged by an x86 drivers contains the actual values of the
variable, but one needs to convert to hexa, remove the upper 4 byte and
convert back to decimal, which is cumbersome.
The values are now promoted to a
(u)int64_tin the logging statements,so printf will always log the correct value.
This change also updates some other few incorrect specifiers.