fixed indendations and tabs
This commit is contained in:
parent
1e527865a9
commit
7d8004bf5a
|
@ -201,15 +201,15 @@ const connection_option PDO_CONN_OPTS[] = {
|
||||||
CONN_ATTR_STRING,
|
CONN_ATTR_STRING,
|
||||||
conn_str_append_func::func
|
conn_str_append_func::func
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
PDOConnOptionNames::Authentication,
|
PDOConnOptionNames::Authentication,
|
||||||
sizeof( PDOConnOptionNames::Authentication ),
|
sizeof( PDOConnOptionNames::Authentication ),
|
||||||
SQLSRV_CONN_OPTION_AUTHENTICATION,
|
SQLSRV_CONN_OPTION_AUTHENTICATION,
|
||||||
ODBCConnOptions::Authentication,
|
ODBCConnOptions::Authentication,
|
||||||
sizeof( ODBCConnOptions::Authentication ),
|
sizeof( ODBCConnOptions::Authentication ),
|
||||||
CONN_ATTR_STRING,
|
CONN_ATTR_STRING,
|
||||||
conn_str_append_func::func
|
conn_str_append_func::func
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
PDOConnOptionNames::ConnectionPooling,
|
PDOConnOptionNames::ConnectionPooling,
|
||||||
sizeof( PDOConnOptionNames::ConnectionPooling ),
|
sizeof( PDOConnOptionNames::ConnectionPooling ),
|
||||||
|
|
|
@ -171,26 +171,26 @@ void conn_string_parser::validate_key(const char *key, int key_len TSRMLS_DC )
|
||||||
|
|
||||||
void conn_string_parser::add_key_value_pair( const char* value, int len TSRMLS_DC )
|
void conn_string_parser::add_key_value_pair( const char* value, int len TSRMLS_DC )
|
||||||
{
|
{
|
||||||
// first need to check if the option for Authention is supported
|
// first need to check if the option for Authention is supported
|
||||||
bool valid = true;
|
bool valid = true;
|
||||||
if ( stricmp( this->current_key_name, ODBCConnOptions::Authentication ) == 0 ) {
|
if ( stricmp( this->current_key_name, ODBCConnOptions::Authentication ) == 0 ) {
|
||||||
if (len <= 0)
|
if (len <= 0)
|
||||||
valid = false;
|
valid = false;
|
||||||
else {
|
else {
|
||||||
// extract option from the value by len
|
// extract option from the value by len
|
||||||
sqlsrv_malloc_auto_ptr<char> option;
|
sqlsrv_malloc_auto_ptr<char> option;
|
||||||
option = static_cast<char*>( sqlsrv_malloc( len + 1 ) );
|
option = static_cast<char*>( sqlsrv_malloc( len + 1 ) );
|
||||||
memcpy_s( option, len + 1, value, len );
|
memcpy_s( option, len + 1, value, len );
|
||||||
option[len] = '\0';
|
option[len] = '\0';
|
||||||
|
|
||||||
valid = core_is_authentication_option_valid( option, len );
|
valid = core_is_authentication_option_valid( option, len );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if( !valid ) {
|
if( !valid ) {
|
||||||
THROW_PDO_ERROR( this->ctx, PDO_SQLSRV_ERROR_INVALID_AUTHENTICATION_OPTION, this->current_key_name );
|
THROW_PDO_ERROR( this->ctx, PDO_SQLSRV_ERROR_INVALID_AUTHENTICATION_OPTION, this->current_key_name );
|
||||||
}
|
}
|
||||||
|
|
||||||
string_parser::add_key_value_pair( value, len );
|
string_parser::add_key_value_pair( value, len );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -436,7 +436,7 @@ void sql_string_parser::parse_sql_string( TSRMLS_D ) {
|
||||||
start_pos = this->pos;
|
start_pos = this->pos;
|
||||||
next();
|
next();
|
||||||
// keep going until the next space or line break
|
// keep going until the next space or line break
|
||||||
// while (!is_white_space(this->orig_str[pos]) && !this->is_eos()) {
|
// while (!is_white_space(this->orig_str[pos]) && !this->is_eos()) {
|
||||||
while ( is_placeholder_char( this->orig_str[pos] )) {
|
while ( is_placeholder_char( this->orig_str[pos] )) {
|
||||||
next();
|
next();
|
||||||
}
|
}
|
||||||
|
|
|
@ -377,10 +377,10 @@ pdo_error PDO_ERRORS[] = {
|
||||||
PDO_SQLSRV_ERROR_EMULATE_INOUT_UNSUPPORTED,
|
PDO_SQLSRV_ERROR_EMULATE_INOUT_UNSUPPORTED,
|
||||||
{ IMSSP, (SQLCHAR*) "Statement with emulate prepare on does not support output or input_output parameters.", -72, false }
|
{ IMSSP, (SQLCHAR*) "Statement with emulate prepare on does not support output or input_output parameters.", -72, false }
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
PDO_SQLSRV_ERROR_INVALID_AUTHENTICATION_OPTION,
|
PDO_SQLSRV_ERROR_INVALID_AUTHENTICATION_OPTION,
|
||||||
{ IMSSP, (SQLCHAR*) "Invalid option for the Authentication keyword. Only SqlPassword or ActiveDirectoryPassword is supported.", -73, false }
|
{ IMSSP, (SQLCHAR*) "Invalid option for the Authentication keyword. Only SqlPassword or ActiveDirectoryPassword is supported.", -73, false }
|
||||||
},
|
},
|
||||||
{ UINT_MAX, {} }
|
{ UINT_MAX, {} }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -562,15 +562,15 @@ namespace {
|
||||||
// Place get_error_message into the anonymous namespace in pdo_util.cpp
|
// Place get_error_message into the anonymous namespace in pdo_util.cpp
|
||||||
sqlsrv_error_const* get_error_message(unsigned int sqlsrv_error_code) {
|
sqlsrv_error_const* get_error_message(unsigned int sqlsrv_error_code) {
|
||||||
|
|
||||||
sqlsrv_error_const *error_message = NULL;
|
sqlsrv_error_const *error_message = NULL;
|
||||||
int zr = (error_message = reinterpret_cast<sqlsrv_error_const*>(zend_hash_index_find_ptr(g_pdo_errors_ht, sqlsrv_error_code))) != NULL ? SUCCESS : FAILURE;
|
int zr = (error_message = reinterpret_cast<sqlsrv_error_const*>(zend_hash_index_find_ptr(g_pdo_errors_ht, sqlsrv_error_code))) != NULL ? SUCCESS : FAILURE;
|
||||||
if (zr == FAILURE) {
|
if (zr == FAILURE) {
|
||||||
DIE("get_error_message: zend_hash_index_find returned failure for sqlsrv_error_code = %1!d!", sqlsrv_error_code);
|
DIE("get_error_message: zend_hash_index_find returned failure for sqlsrv_error_code = %1!d!", sqlsrv_error_code);
|
||||||
}
|
}
|
||||||
|
|
||||||
SQLSRV_ASSERT(error_message != NULL, "get_error_message: error_message was null");
|
SQLSRV_ASSERT(error_message != NULL, "get_error_message: error_message was null");
|
||||||
|
|
||||||
return error_message;
|
return error_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pdo_sqlsrv_throw_exception( sqlsrv_error_const* error TSRMLS_DC )
|
void pdo_sqlsrv_throw_exception( sqlsrv_error_const* error TSRMLS_DC )
|
||||||
|
|
|
@ -393,7 +393,7 @@ enum PDO_ERROR_CODES {
|
||||||
PDO_SQLSRV_ERROR_INVALID_OUTPUT_PARAM_TYPE,
|
PDO_SQLSRV_ERROR_INVALID_OUTPUT_PARAM_TYPE,
|
||||||
PDO_SQLSRV_ERROR_INVALID_CURSOR_WITH_SCROLL_TYPE,
|
PDO_SQLSRV_ERROR_INVALID_CURSOR_WITH_SCROLL_TYPE,
|
||||||
PDO_SQLSRV_ERROR_EMULATE_INOUT_UNSUPPORTED,
|
PDO_SQLSRV_ERROR_EMULATE_INOUT_UNSUPPORTED,
|
||||||
PDO_SQLSRV_ERROR_INVALID_AUTHENTICATION_OPTION
|
PDO_SQLSRV_ERROR_INVALID_AUTHENTICATION_OPTION
|
||||||
};
|
};
|
||||||
|
|
||||||
extern pdo_error PDO_ERRORS[];
|
extern pdo_error PDO_ERRORS[];
|
||||||
|
|
|
@ -92,7 +92,7 @@ void common_conn_str_append_func( const char* odbc_name, const char* val, size_t
|
||||||
sqlsrv_conn* core_sqlsrv_connect( sqlsrv_context& henv_cp, sqlsrv_context& henv_ncp, driver_conn_factory conn_factory,
|
sqlsrv_conn* core_sqlsrv_connect( sqlsrv_context& henv_cp, sqlsrv_context& henv_ncp, driver_conn_factory conn_factory,
|
||||||
const char* server, const char* uid, const char* pwd,
|
const char* server, const char* uid, const char* pwd,
|
||||||
HashTable* options_ht, error_callback err, const connection_option valid_conn_opts[],
|
HashTable* options_ht, error_callback err, const connection_option valid_conn_opts[],
|
||||||
void* driver, const char* driver_func TSRMLS_DC )
|
void* driver, const char* driver_func TSRMLS_DC )
|
||||||
|
|
||||||
{
|
{
|
||||||
SQLRETURN r;
|
SQLRETURN r;
|
||||||
|
@ -163,18 +163,18 @@ sqlsrv_conn* core_sqlsrv_connect( sqlsrv_context& henv_cp, sqlsrv_context& henv_
|
||||||
|
|
||||||
SQLSMALLINT output_conn_size;
|
SQLSMALLINT output_conn_size;
|
||||||
#ifndef _WIN32
|
#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 )
|
||||||
{
|
{
|
||||||
r = SQLDriverConnect( conn->handle(), NULL, (SQLCHAR*)conn_str.c_str(), SQL_NTS, NULL, 0, &output_conn_size, SQL_DRIVER_NOPROMPT );
|
r = SQLDriverConnect( conn->handle(), NULL, (SQLCHAR*)conn_str.c_str(), SQL_NTS, NULL, 0, &output_conn_size, SQL_DRIVER_NOPROMPT );
|
||||||
}
|
}
|
||||||
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 );
|
||||||
}
|
}
|
||||||
#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 // !_WIN32
|
#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).
|
||||||
|
@ -215,11 +215,11 @@ sqlsrv_conn* core_sqlsrv_connect( sqlsrv_context& henv_cp, sqlsrv_context& henv_
|
||||||
// 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.
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
if ( r == SQL_SUCCESS_WITH_INFO ) {
|
if ( r == SQL_SUCCESS_WITH_INFO ) {
|
||||||
#endif // !_WIN32
|
#endif // !_WIN32
|
||||||
determine_server_version( conn TSRMLS_CC );
|
determine_server_version( conn TSRMLS_CC );
|
||||||
#ifndef _WIN32
|
#ifndef _WIN32
|
||||||
}
|
}
|
||||||
#endif // !_WIN32
|
#endif // !_WIN32
|
||||||
}
|
}
|
||||||
catch( std::bad_alloc& ) {
|
catch( std::bad_alloc& ) {
|
||||||
|
@ -554,14 +554,14 @@ bool core_is_conn_opt_value_escaped( const char* value, size_t value_len )
|
||||||
// if the option for the authentication is valid, returns true. This returns false otherwise.
|
// if the option for the authentication is valid, returns true. This returns false otherwise.
|
||||||
bool core_is_authentication_option_valid(const char* value, size_t value_len)
|
bool core_is_authentication_option_valid(const char* value, size_t value_len)
|
||||||
{
|
{
|
||||||
if (value_len <= 0)
|
if (value_len <= 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if( ! stricmp( value, AzureADOptions::AZURE_AUTH_SQL_PASSWORD ) || ! stricmp( value, AzureADOptions::AZURE_AUTH_AD_PASSWORD ) ) {
|
if( ! stricmp( value, AzureADOptions::AZURE_AUTH_SQL_PASSWORD ) || ! stricmp( value, AzureADOptions::AZURE_AUTH_AD_PASSWORD ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -639,33 +639,33 @@ void build_connection_string_and_set_conn_attr( sqlsrv_conn* conn, const char* s
|
||||||
if( zend_hash_index_exists( options, SQLSRV_CONN_OPTION_TRACE_FILE )) {
|
if( zend_hash_index_exists( options, SQLSRV_CONN_OPTION_TRACE_FILE )) {
|
||||||
|
|
||||||
zval* trace_value = NULL;
|
zval* trace_value = NULL;
|
||||||
trace_value = zend_hash_index_find(options, SQLSRV_CONN_OPTION_TRACE_ON);
|
trace_value = zend_hash_index_find(options, SQLSRV_CONN_OPTION_TRACE_ON);
|
||||||
|
|
||||||
if (trace_value == NULL || !zend_is_true(trace_value)) {
|
if (trace_value == NULL || !zend_is_true(trace_value)) {
|
||||||
|
|
||||||
zend_hash_index_del( options, SQLSRV_CONN_OPTION_TRACE_FILE );
|
zend_hash_index_del( options, SQLSRV_CONN_OPTION_TRACE_FILE );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zend_string *key = NULL;
|
zend_string *key = NULL;
|
||||||
zend_ulong index = -1;
|
zend_ulong index = -1;
|
||||||
zval* data = NULL;
|
zval* data = NULL;
|
||||||
|
|
||||||
ZEND_HASH_FOREACH_KEY_VAL( options, index, key, data ) {
|
ZEND_HASH_FOREACH_KEY_VAL( options, index, key, data ) {
|
||||||
int type = HASH_KEY_NON_EXISTENT;
|
int type = HASH_KEY_NON_EXISTENT;
|
||||||
type = key ? HASH_KEY_IS_STRING : HASH_KEY_IS_LONG;
|
type = key ? HASH_KEY_IS_STRING : HASH_KEY_IS_LONG;
|
||||||
|
|
||||||
// The driver layer should ensure a valid key.
|
// The driver layer should ensure a valid key.
|
||||||
DEBUG_SQLSRV_ASSERT(( type == HASH_KEY_IS_LONG ), "build_connection_string_and_set_conn_attr: invalid connection option key type." );
|
DEBUG_SQLSRV_ASSERT(( type == HASH_KEY_IS_LONG ), "build_connection_string_and_set_conn_attr: invalid connection option key type." );
|
||||||
|
|
||||||
conn_opt = get_connection_option( conn, index, valid_conn_opts TSRMLS_CC );
|
conn_opt = get_connection_option( conn, index, valid_conn_opts TSRMLS_CC );
|
||||||
|
|
||||||
if( index == SQLSRV_CONN_OPTION_MARS ) {
|
if( index == SQLSRV_CONN_OPTION_MARS ) {
|
||||||
mars_mentioned = true;
|
mars_mentioned = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
conn_opt->func( conn_opt, data, conn, connection_string TSRMLS_CC );
|
conn_opt->func( conn_opt, data, conn, connection_string TSRMLS_CC );
|
||||||
} ZEND_HASH_FOREACH_END();
|
} ZEND_HASH_FOREACH_END();
|
||||||
|
|
||||||
// MARS on if not explicitly turned off
|
// MARS on if not explicitly turned off
|
||||||
if( !mars_mentioned ) {
|
if( !mars_mentioned ) {
|
||||||
|
@ -721,7 +721,7 @@ const char* get_processor_arch( void )
|
||||||
return PROCESSOR_ARCH[2];
|
return PROCESSOR_ARCH[2];
|
||||||
} else {
|
} else {
|
||||||
DIE( "Unknown processor architecture." );
|
DIE( "Unknown processor architecture." );
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
#else
|
#else
|
||||||
SYSTEM_INFO sys_info;
|
SYSTEM_INFO sys_info;
|
||||||
|
@ -741,7 +741,7 @@ const char* get_processor_arch( void )
|
||||||
DIE( "Unknown Windows processor architecture." );
|
DIE( "Unknown Windows processor architecture." );
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
#endif // !_WIN32
|
#endif // !_WIN32
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -761,7 +761,7 @@ void determine_server_version( sqlsrv_conn* conn TSRMLS_DC )
|
||||||
errno = 0;
|
errno = 0;
|
||||||
char version_major_str[ 3 ];
|
char version_major_str[ 3 ];
|
||||||
SERVER_VERSION version_major;
|
SERVER_VERSION version_major;
|
||||||
memcpy_s( version_major_str, sizeof( version_major_str ), p, 2 );
|
memcpy_s( version_major_str, sizeof( version_major_str ), p, 2 );
|
||||||
|
|
||||||
version_major_str[ 2 ] = '\0';
|
version_major_str[ 2 ] = '\0';
|
||||||
version_major = static_cast<SERVER_VERSION>( atoi( version_major_str ));
|
version_major = static_cast<SERVER_VERSION>( atoi( version_major_str ));
|
||||||
|
@ -831,7 +831,7 @@ size_t core_str_zval_is_true( zval* value_z )
|
||||||
}
|
}
|
||||||
|
|
||||||
// save adjustments to the value made by stripping whitespace at the end
|
// save adjustments to the value made by stripping whitespace at the end
|
||||||
Z_STRLEN_P( value_z ) = val_len;
|
Z_STRLEN_P( value_z ) = val_len;
|
||||||
|
|
||||||
const char VALID_TRUE_VALUE_1[] = "true";
|
const char VALID_TRUE_VALUE_1[] = "true";
|
||||||
const char VALID_TRUE_VALUE_2[] = "1";
|
const char VALID_TRUE_VALUE_2[] = "1";
|
||||||
|
|
|
@ -181,9 +181,8 @@ const int SQL_SERVER_2008_DEFAULT_DATETIME_PRECISION = 34;
|
||||||
const int SQL_SERVER_2008_DEFAULT_DATETIME_SCALE = 7;
|
const int SQL_SERVER_2008_DEFAULT_DATETIME_SCALE = 7;
|
||||||
|
|
||||||
namespace AzureADOptions {
|
namespace AzureADOptions {
|
||||||
|
const char AZURE_AUTH_SQL_PASSWORD[] = "SqlPassword";
|
||||||
const char AZURE_AUTH_SQL_PASSWORD[] = "SqlPassword";
|
const char AZURE_AUTH_AD_PASSWORD[] = "ActiveDirectoryPassword";
|
||||||
const char AZURE_AUTH_AD_PASSWORD[] = "ActiveDirectoryPassword";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// types for conversions on output parameters (though they can be used for input parameters, they are ignored)
|
// types for conversions on output parameters (though they can be used for input parameters, they are ignored)
|
||||||
|
@ -1128,7 +1127,7 @@ enum SQLSRV_CONN_OPTIONS {
|
||||||
SQLSRV_CONN_OPTION_ATTACHDBFILENAME,
|
SQLSRV_CONN_OPTION_ATTACHDBFILENAME,
|
||||||
SQLSRV_CONN_OPTION_APPLICATION_INTENT,
|
SQLSRV_CONN_OPTION_APPLICATION_INTENT,
|
||||||
SQLSRV_CONN_OPTION_MULTI_SUBNET_FAILOVER,
|
SQLSRV_CONN_OPTION_MULTI_SUBNET_FAILOVER,
|
||||||
SQLSRV_CONN_OPTION_AUTHENTICATION,
|
SQLSRV_CONN_OPTION_AUTHENTICATION,
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
SQLSRV_CONN_OPTION_CONN_RETRY_COUNT,
|
SQLSRV_CONN_OPTION_CONN_RETRY_COUNT,
|
||||||
SQLSRV_CONN_OPTION_CONN_RETRY_INTERVAL,
|
SQLSRV_CONN_OPTION_CONN_RETRY_INTERVAL,
|
||||||
|
|
|
@ -353,7 +353,7 @@ enum SS_ERROR_CODES {
|
||||||
SS_SQLSRV_ERROR_CONNECT_BRACES_NOT_ESCAPED,
|
SS_SQLSRV_ERROR_CONNECT_BRACES_NOT_ESCAPED,
|
||||||
SS_SQLSRV_ERROR_INVALID_OUTPUT_PARAM_TYPE,
|
SS_SQLSRV_ERROR_INVALID_OUTPUT_PARAM_TYPE,
|
||||||
SS_SQLSRV_ERROR_PARAM_VAR_NOT_REF,
|
SS_SQLSRV_ERROR_PARAM_VAR_NOT_REF,
|
||||||
SS_SQLSRV_ERROR_INVALID_AUTHENTICATION_OPTION
|
SS_SQLSRV_ERROR_INVALID_AUTHENTICATION_OPTION
|
||||||
};
|
};
|
||||||
|
|
||||||
extern ss_error SS_ERRORS[];
|
extern ss_error SS_ERRORS[];
|
||||||
|
|
Loading…
Reference in a new issue