applied peer review comments
This commit is contained in:
parent
64e08eb1a0
commit
0e70a95d63
|
@ -143,8 +143,7 @@ sqlsrv_conn* core_sqlsrv_connect( sqlsrv_context& henv_cp, sqlsrv_context& henv_
|
|||
}
|
||||
|
||||
SQLSMALLINT output_conn_size;
|
||||
r = SQLDriverConnectW( conn->handle(), NULL, reinterpret_cast<SQLWCHAR*>(wconn_string.get()),
|
||||
static_cast<SQLSMALLINT>(wconn_len), NULL, 0, &output_conn_size, SQL_DRIVER_NOPROMPT);
|
||||
r = SQLDriverConnectW( conn->handle(), NULL, reinterpret_cast<SQLWCHAR*>(wconn_string.get()), static_cast<SQLSMALLINT>( wconn_len ), NULL, 0, &output_conn_size, SQL_DRIVER_NOPROMPT );
|
||||
|
||||
// clear the connection string from memory to remove sensitive data (such as a password).
|
||||
memset( const_cast<char*>(conn_str.c_str()), 0, conn_str.size());
|
||||
|
|
|
@ -53,7 +53,7 @@ void core_sqlsrv_minit( sqlsrv_context** henv_cp, sqlsrv_context** henv_ncp, err
|
|||
LOG( SEV_ERROR, "Failed to retrieve Windows version information." );
|
||||
throw core::CoreException();
|
||||
}
|
||||
#endif
|
||||
#endif //_WIN32
|
||||
|
||||
SQLHANDLE henv = SQL_NULL_HANDLE;
|
||||
SQLRETURN r;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
#ifndef _WIN32
|
||||
#include <type_traits>
|
||||
#include <uchar.h>
|
||||
#endif // _WIN32
|
||||
#endif // !_WIN32
|
||||
|
||||
|
||||
using namespace core;
|
||||
|
@ -236,7 +236,6 @@ SQLRETURN number_to_string( Number* number_data, _Out_ void* buffer, SQLLEN buff
|
|||
|
||||
#endif // _WIN32
|
||||
|
||||
|
||||
}
|
||||
|
||||
template <typename Number, typename Char>
|
||||
|
|
|
@ -233,7 +233,7 @@ sqlsrv_stmt* core_sqlsrv_create_stmt( sqlsrv_conn* conn, driver_stmt_factory stm
|
|||
{
|
||||
sqlsrv_malloc_auto_ptr<sqlsrv_stmt> stmt;
|
||||
SQLHANDLE stmt_h = SQL_NULL_HANDLE;
|
||||
sqlsrv_stmt* return_stmt;
|
||||
sqlsrv_stmt* return_stmt = NULL;
|
||||
|
||||
try {
|
||||
|
||||
|
@ -1169,18 +1169,10 @@ void core_sqlsrv_set_query_timeout( sqlsrv_stmt* stmt, long timeout TSRMLS_DC )
|
|||
|
||||
// set the LOCK_TIMEOUT on the server.
|
||||
char lock_timeout_sql[ 32 ];
|
||||
#ifndef _WIN32
|
||||
int written = snprintf( lock_timeout_sql, sizeof( lock_timeout_sql ), "SET LOCK_TIMEOUT %d",
|
||||
lock_timeout );
|
||||
|
||||
int written = snprintf( lock_timeout_sql, sizeof( lock_timeout_sql ), "SET LOCK_TIMEOUT %d", lock_timeout );
|
||||
SQLSRV_ASSERT( (written != -1 && written != sizeof( lock_timeout_sql )),
|
||||
"stmt_option_query_timeout: snprintf failed. Shouldn't ever fail." );
|
||||
#else
|
||||
int written = sprintf_s( lock_timeout_sql, sizeof( lock_timeout_sql ), "SET LOCK_TIMEOUT %d",
|
||||
lock_timeout );
|
||||
|
||||
SQLSRV_ASSERT( (written != -1 && written != sizeof( lock_timeout_sql )),
|
||||
"stmt_option_query_timeout: sprintf_s failed. Shouldn't ever fail." );
|
||||
#endif // !_WIN32
|
||||
|
||||
core::SQLExecDirect( stmt, lock_timeout_sql TSRMLS_CC );
|
||||
|
||||
|
@ -1266,12 +1258,13 @@ bool core_sqlsrv_send_stream_packet( sqlsrv_stmt* stmt TSRMLS_DC )
|
|||
// the size of wbuffer is set for the worst case of UTF-8 to UTF-16 conversion, which is a
|
||||
// expansion of 2x the UTF-8 size.
|
||||
SQLWCHAR wbuffer[ PHP_STREAM_BUFFER_SIZE + 1 ];
|
||||
int wbuffer_size = static_cast<int>( sizeof( wbuffer ) / sizeof( SQLWCHAR ));
|
||||
DWORD last_error_code = ERROR_SUCCESS;
|
||||
// buffer_size is the # of wchars. Since it set to stmt->param_buffer_size / 2, this is accurate
|
||||
#ifndef _WIN32
|
||||
int wsize = SystemLocale::ToUtf16Strict( stmt->current_stream.encoding, buffer, static_cast<int>(read), wbuffer, static_cast<int>(sizeof( wbuffer ) / sizeof( SQLWCHAR )), &last_error_code );
|
||||
int wsize = SystemLocale::ToUtf16Strict( stmt->current_stream.encoding, buffer, static_cast<int>(read), wbuffer, wbuffer_size, &last_error_code );
|
||||
#else
|
||||
int wsize = MultiByteToWideChar( stmt->current_stream.encoding, MB_ERR_INVALID_CHARS, buffer, static_cast<int>( read ), wbuffer, static_cast<int>( sizeof( wbuffer ) / sizeof( wchar_t )));
|
||||
int wsize = MultiByteToWideChar( stmt->current_stream.encoding, MB_ERR_INVALID_CHARS, buffer, static_cast<int>( read ), wbuffer, wbuffer_size );
|
||||
last_error_code = GetLastError();
|
||||
#endif // !_WIN32
|
||||
|
||||
|
|
|
@ -34,12 +34,6 @@
|
|||
#define LANG_NEUTRAL 0x00
|
||||
#define SUBLANG_DEFAULT 0x01 // user default
|
||||
|
||||
// #ifndef _GETLASTERROR
|
||||
// #define _GETLASTERROR
|
||||
// void SSetLastError(DWORD err);
|
||||
// unsigned int GGetLastError();
|
||||
// #endif
|
||||
|
||||
DWORD FormatMessageA(
|
||||
DWORD dwFlags,
|
||||
LPCVOID lpSource,
|
||||
|
|
|
@ -448,9 +448,6 @@ VerSetConditionMask(
|
|||
);
|
||||
|
||||
|
||||
|
||||
//#include <basetsd.h>
|
||||
|
||||
//// ntdef.h
|
||||
#define __unaligned
|
||||
#ifndef UNALIGNED
|
||||
|
|
Loading…
Reference in a new issue