replace __linux__ with _WIN32 define.

This commit is contained in:
v-dareck 2017-02-01 17:36:41 -08:00
parent 044836b048
commit 1f9d1583d1
3 changed files with 14 additions and 14 deletions

View file

@ -102,18 +102,18 @@ sqlsrv_conn* core_sqlsrv_connect( sqlsrv_context& henv_cp, sqlsrv_context& henv_
sqlsrv_malloc_auto_ptr<SQLWCHAR> wconn_string; sqlsrv_malloc_auto_ptr<SQLWCHAR> wconn_string;
unsigned int wconn_len = 0; unsigned int wconn_len = 0;
#ifndef __linux__ #ifdef _WIN32
sqlsrv_context* henv = &henv_cp; // by default use the connection pooling henv sqlsrv_context* henv = &henv_cp; // by default use the connection pooling henv
#else #else
sqlsrv_context* henv = &henv_ncp; // by default do not use the connection pooling henv sqlsrv_context* henv = &henv_ncp; // by default do not use the connection pooling henv
#endif #endif // _WIN32
try { try {
// Due to the limitations on connection pooling in unixODBC 2.3.1 driver manager, we do not consider // Due to the limitations on connection pooling in unixODBC 2.3.1 driver manager, we do not consider
// the connection string attributes to set (enable/disable) connection pooling. // the connection string attributes to set (enable/disable) connection pooling.
// Instead, MSPHPSQL connection pooling is set according to the ODBCINST.INI file in [ODBC] section. // Instead, MSPHPSQL connection pooling is set according to the ODBCINST.INI file in [ODBC] section.
#ifdef __linux__ #ifndef _WIN32
char pooling_string[ 128 ] = {0}; char pooling_string[ 128 ] = {0};
SQLGetPrivateProfileString( "ODBC", "Pooling", "0", pooling_string, sizeof( pooling_string ), "ODBCINST.INI" ); SQLGetPrivateProfileString( "ODBC", "Pooling", "0", pooling_string, sizeof( pooling_string ), "ODBCINST.INI" );
@ -138,7 +138,7 @@ sqlsrv_conn* core_sqlsrv_connect( sqlsrv_context& henv_cp, sqlsrv_context& henv_
} }
} }
} }
#endif #endif // !_WIN32
SQLHANDLE temp_conn_h; SQLHANDLE temp_conn_h;
core::SQLAllocHandle( SQL_HANDLE_DBC, *henv, &temp_conn_h TSRMLS_CC ); core::SQLAllocHandle( SQL_HANDLE_DBC, *henv, &temp_conn_h TSRMLS_CC );
@ -162,7 +162,7 @@ sqlsrv_conn* core_sqlsrv_connect( sqlsrv_context& henv_cp, sqlsrv_context& henv_
} }
SQLSMALLINT output_conn_size; SQLSMALLINT output_conn_size;
#ifdef __linux__ #ifndef _WIN32
// unixODBC 2.3.1 requires a non-wide SQLDriverConnect call while pooling enabled. // unixODBC 2.3.1 requires a non-wide SQLDriverConnect call while pooling enabled.
// connection handle has been allocated using henv_cp, means pooling enabled in a PHP script // connection handle has been allocated using henv_cp, means pooling enabled in a PHP script
if ( henv == &henv_cp ) if ( henv == &henv_cp )
@ -175,7 +175,7 @@ sqlsrv_conn* core_sqlsrv_connect( sqlsrv_context& henv_cp, sqlsrv_context& henv_
} }
#else #else
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 );
#endif #endif // !_WIN32
// clear the connection string from memory to remove sensitive data (such as a password). // 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()); memset( const_cast<char*>(conn_str.c_str()), 0, conn_str.size());
@ -214,13 +214,13 @@ sqlsrv_conn* core_sqlsrv_connect( sqlsrv_context& henv_cp, sqlsrv_context& henv_
// SQLGetInfo works when r = SQL_SUCCESS_WITH_INFO (non-pooled connection) // SQLGetInfo works when r = SQL_SUCCESS_WITH_INFO (non-pooled connection)
// but fails if the connection is using a pool, i.e. r= SQL_SUCCESS. // but fails if the connection is using a pool, i.e. r= SQL_SUCCESS.
// Thus, in Linux, we don't call determine_server_version() for a connection that uses pool. // Thus, in Linux, we don't call determine_server_version() for a connection that uses pool.
#ifdef __linux__ #ifndef _WIN32
if ( r == SQL_SUCCESS_WITH_INFO ) { if ( r == SQL_SUCCESS_WITH_INFO ) {
#endif #endif // !_WIN32
determine_server_version( conn TSRMLS_CC ); determine_server_version( conn TSRMLS_CC );
#ifdef __linux__ #ifndef _WIN32
} }
#endif #endif // !_WIN32
} }
catch( std::bad_alloc& ) { catch( std::bad_alloc& ) {
memset( const_cast<char*>( conn_str.c_str()), 0, conn_str.size() ); memset( const_cast<char*>( conn_str.c_str()), 0, conn_str.size() );

View file

@ -2152,11 +2152,11 @@ void get_field_as_string( sqlsrv_stmt* stmt, SQLUSMALLINT field_index, sqlsrv_ph
// with Linux connection pooling may not get a truncated warning back but the actual field_len_temp // with Linux connection pooling may not get a truncated warning back but the actual field_len_temp
// can be greater than the initallen value. // can be greater than the initallen value.
#ifdef __linux__ #ifndef _WIN32
if( is_truncated_warning( state ) || initiallen < field_len_temp) { if( is_truncated_warning( state ) || initiallen < field_len_temp) {
#else #else
if( is_truncated_warning( state ) ) { if( is_truncated_warning( state ) ) {
#endif #endif // !_WIN32
SQLLEN dummy_field_len; SQLLEN dummy_field_len;

View file

@ -118,11 +118,11 @@ size_t sqlsrv_stream_read( php_stream* stream, _Out_writes_bytes_(count) char* b
// with unixODBC connection pooling enabled the truncated state may not be returned so check the actual length read // with unixODBC connection pooling enabled the truncated state may not be returned so check the actual length read
// with buffer length. // with buffer length.
#ifdef __linux__ #ifndef _WIN32
if( is_truncated_warning( state ) || count < read) { if( is_truncated_warning( state ) || count < read) {
#else #else
if( is_truncated_warning( state ) ) { if( is_truncated_warning( state ) ) {
#endif #endif // !_WIN32
switch( c_type ) { switch( c_type ) {
// As per SQLGetData documentation, if the length of character data exceeds the BufferLength, // As per SQLGetData documentation, if the length of character data exceeds the BufferLength,