Merge branch 'AlwaysEncrypted' into AlwaysEncrypted

This commit is contained in:
Hadis Fard 2017-09-14 15:21:07 -07:00 committed by GitHub
commit 8495cb10a6
66 changed files with 245 additions and 194 deletions

View file

@ -3,7 +3,7 @@
// //
// Contents: JScript build configuration used by buildconf.bat // Contents: JScript build configuration used by buildconf.bat
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Implements the PDO object for PDO_SQLSRV // Contents: Implements the PDO object for PDO_SQLSRV
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: initialization routines for PDO_SQLSRV // Contents: initialization routines for PDO_SQLSRV
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -5,7 +5,7 @@
// //
// Copyright Microsoft Corporation // Copyright Microsoft Corporation
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Implements the PDOStatement object for the PDO_SQLSRV // Contents: Implements the PDOStatement object for the PDO_SQLSRV
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Utility functions used by both connection or statement functions // Contents: Utility functions used by both connection or statement functions
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -6,7 +6,7 @@
// //
// Contents: Declarations for the extension // Contents: Declarations for the extension
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Version resource // Contents: Version resource
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -6,7 +6,7 @@
// Contents: Contains functions for handling Windows format strings // Contents: Contains functions for handling Windows format strings
// and UTF-16 on non-Windows platforms // and UTF-16 on non-Windows platforms
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -4,7 +4,7 @@
// Contents: Contains functions for handling Windows format strings // Contents: Contains functions for handling Windows format strings
// and UTF-16 on non-Windows platforms // and UTF-16 on non-Windows platforms
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Contains functions for handling UTF-16 on non-Windows platforms // Contents: Contains functions for handling UTF-16 on non-Windows platforms
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Contains functions for handling UTF-16 on non-Windows platforms // Contents: Contains functions for handling UTF-16 on non-Windows platforms
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Core routines that use connection handles shared between sqlsrv and pdo_sqlsrv // Contents: Core routines that use connection handles shared between sqlsrv and pdo_sqlsrv
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: common initialization routines shared by PDO and sqlsrv // Contents: common initialization routines shared by PDO and sqlsrv
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Result sets // Contents: Result sets
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License
@ -342,12 +342,12 @@ struct row_dtor_closure {
sqlsrv_error* odbc_get_diag_rec( _In_ sqlsrv_stmt* odbc, _In_ SQLSMALLINT record_number ) sqlsrv_error* odbc_get_diag_rec( _In_ sqlsrv_stmt* odbc, _In_ SQLSMALLINT record_number )
{ {
SQLWCHAR wsql_state[ SQL_SQLSTATE_BUFSIZE ]; SQLWCHAR wsql_state[ SQL_SQLSTATE_BUFSIZE ];
SQLWCHAR wnative_message[ SQL_MAX_MESSAGE_LENGTH + 1 ]; SQLWCHAR wnative_message[ SQL_MAX_ERROR_MESSAGE_LENGTH + 1 ];
SQLINTEGER native_code; SQLINTEGER native_code;
SQLSMALLINT wnative_message_len = 0; SQLSMALLINT wnative_message_len = 0;
SQLRETURN r = SQLGetDiagRecW( SQL_HANDLE_STMT, odbc->handle(), record_number, wsql_state, &native_code, wnative_message, SQLRETURN r = SQLGetDiagRecW( SQL_HANDLE_STMT, odbc->handle(), record_number, wsql_state, &native_code, wnative_message,
SQL_MAX_MESSAGE_LENGTH + 1, &wnative_message_len ); SQL_MAX_ERROR_MESSAGE_LENGTH + 1, &wnative_message_len );
if( !SQL_SUCCEEDED( r ) || r == SQL_NO_DATA ) { if( !SQL_SUCCEEDED( r ) || r == SQL_NO_DATA ) {
return NULL; return NULL;
} }

View file

@ -6,7 +6,7 @@
// //
// Contents: Core routines and constants shared by the Microsoft Drivers for PHP for SQL Server // Contents: Core routines and constants shared by the Microsoft Drivers for PHP for SQL Server
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License
@ -173,6 +173,8 @@ const int SQL_SERVER_MAX_FIELD_SIZE = 8000;
const int SQL_SERVER_MAX_PRECISION = 38; const int SQL_SERVER_MAX_PRECISION = 38;
const int SQL_SERVER_MAX_TYPE_SIZE = 0; const int SQL_SERVER_MAX_TYPE_SIZE = 0;
const int SQL_SERVER_MAX_PARAMS = 2100; const int SQL_SERVER_MAX_PARAMS = 2100;
// increase the maximum message length to accommodate for the long error returned for operand type clash
const int SQL_MAX_ERROR_MESSAGE_LENGTH = SQL_MAX_MESSAGE_LENGTH * 4;
// max size of a date time string when converting from a DateTime object to a string // max size of a date time string when converting from a DateTime object to a string
const int MAX_DATETIME_STRING_LEN = 256; const int MAX_DATETIME_STRING_LEN = 256;
@ -773,9 +775,9 @@ struct sqlsrv_error : public sqlsrv_error_const {
sqlsrv_error( _In_ SQLCHAR* sql_state, _In_ SQLCHAR* message, _In_ SQLINTEGER code, _In_ bool printf_format = false ) sqlsrv_error( _In_ SQLCHAR* sql_state, _In_ SQLCHAR* message, _In_ SQLINTEGER code, _In_ bool printf_format = false )
{ {
sqlstate = reinterpret_cast<SQLCHAR*>( sqlsrv_malloc( SQL_SQLSTATE_BUFSIZE )); sqlstate = reinterpret_cast<SQLCHAR*>( sqlsrv_malloc( SQL_SQLSTATE_BUFSIZE ));
native_message = reinterpret_cast<SQLCHAR*>( sqlsrv_malloc( SQL_MAX_MESSAGE_LENGTH + 1 )); native_message = reinterpret_cast<SQLCHAR*>( sqlsrv_malloc( SQL_MAX_ERROR_MESSAGE_LENGTH + 1 ));
strcpy_s( reinterpret_cast<char*>( sqlstate ), SQL_SQLSTATE_BUFSIZE, reinterpret_cast<const char*>( sql_state )); strcpy_s( reinterpret_cast<char*>( sqlstate ), SQL_SQLSTATE_BUFSIZE, reinterpret_cast<const char*>( sql_state ));
strcpy_s( reinterpret_cast<char*>( native_message ), SQL_MAX_MESSAGE_LENGTH + 1, reinterpret_cast<const char*>( message )); strcpy_s( reinterpret_cast<char*>( native_message ), SQL_MAX_ERROR_MESSAGE_LENGTH + 1, reinterpret_cast<const char*>( message ));
native_code = code; native_code = code;
format = printf_format; format = printf_format;
} }
@ -1849,11 +1851,11 @@ namespace core {
// and return a more helpful message prepended to the ODBC errors if that error occurs // and return a more helpful message prepended to the ODBC errors if that error occurs
if( !SQL_SUCCEEDED( r )) { if( !SQL_SUCCEEDED( r )) {
SQLCHAR err_msg[ SQL_MAX_MESSAGE_LENGTH + 1 ] = { '\0' }; SQLCHAR err_msg[ SQL_MAX_ERROR_MESSAGE_LENGTH + 1 ] = { '\0' };
SQLSMALLINT len = 0; SQLSMALLINT len = 0;
SQLRETURN rtemp = ::SQLGetDiagField( stmt->handle_type(), stmt->handle(), 1, SQL_DIAG_MESSAGE_TEXT, SQLRETURN rtemp = ::SQLGetDiagField( stmt->handle_type(), stmt->handle(), 1, SQL_DIAG_MESSAGE_TEXT,
err_msg, SQL_MAX_MESSAGE_LENGTH, &len ); err_msg, SQL_MAX_ERROR_MESSAGE_LENGTH, &len );
CHECK_SQL_ERROR_OR_WARNING( rtemp, stmt ) { CHECK_SQL_ERROR_OR_WARNING( rtemp, stmt ) {
@ -1983,6 +1985,17 @@ namespace core {
} }
} }
inline void SQLDescribeParam( _Inout_ sqlsrv_stmt* stmt, _In_ SQLSMALLINT paramno, _Out_opt_ SQLSMALLINT* data_type, _Out_opt_ SQLULEN* col_size,
_Out_opt_ SQLSMALLINT* decimal_digits, _Out_opt_ SQLSMALLINT* nullable TSRMLS_DC )
{
SQLRETURN r;
r = ::SQLDescribeParam( stmt->handle(), paramno, data_type, col_size, decimal_digits, nullable );
CHECK_SQL_ERROR_OR_WARNING( r, stmt ) {
throw CoreException();
}
}
inline void SQLEndTran( _In_ SQLSMALLINT handleType, _Inout_ sqlsrv_conn* conn, _In_ SQLSMALLINT completionType TSRMLS_DC ) inline void SQLEndTran( _In_ SQLSMALLINT handleType, _Inout_ sqlsrv_conn* conn, _In_ SQLSMALLINT completionType TSRMLS_DC )
{ {
SQLRETURN r = ::SQLEndTran( handleType, conn->handle(), completionType ); SQLRETURN r = ::SQLEndTran( handleType, conn->handle(), completionType );
@ -2202,6 +2215,17 @@ namespace core {
} }
} }
inline void SQLSetDescField( _Inout_ sqlsrv_stmt* stmt, _In_ SQLSMALLINT rec_num, _In_ SQLSMALLINT fld_id, _In_reads_bytes_opt_( str_len ) SQLPOINTER value_ptr, _In_ SQLINTEGER str_len TSRMLS_DC )
{
SQLRETURN r;
SQLHDESC hIpd = NULL;
core::SQLGetStmtAttr( stmt, SQL_ATTR_IMP_PARAM_DESC, &hIpd, 0, 0 );
r = ::SQLSetDescField( hIpd, rec_num, fld_id, value_ptr, str_len );
CHECK_SQL_ERROR_OR_WARNING( r, stmt ) {
throw CoreException();
}
}
inline void SQLSetEnvAttr( _Inout_ sqlsrv_context& ctx, _In_ SQLINTEGER attr, _In_reads_bytes_opt_(str_len) SQLPOINTER value_ptr, _In_ SQLINTEGER str_len TSRMLS_DC ) inline void SQLSetEnvAttr( _Inout_ sqlsrv_context& ctx, _In_ SQLINTEGER attr, _In_reads_bytes_opt_(str_len) SQLPOINTER value_ptr, _In_ SQLINTEGER str_len TSRMLS_DC )
{ {

View file

@ -3,7 +3,7 @@
// //
// Contents: Core routines that use statement handles shared between sqlsrv and pdo_sqlsrv // Contents: Core routines that use statement handles shared between sqlsrv and pdo_sqlsrv
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License
@ -101,6 +101,8 @@ void default_sql_size_and_scale( _Inout_ sqlsrv_stmt* stmt, _In_opt_ unsigned in
// given a zval and encoding, determine the appropriate sql type, column size, and decimal scale (if appropriate) // given a zval and encoding, determine the appropriate sql type, column size, and decimal scale (if appropriate)
void default_sql_type( _Inout_ sqlsrv_stmt* stmt, _In_opt_ SQLULEN paramno, _In_ zval* param_z, _In_ SQLSRV_ENCODING encoding, void default_sql_type( _Inout_ sqlsrv_stmt* stmt, _In_opt_ SQLULEN paramno, _In_ zval* param_z, _In_ SQLSRV_ENCODING encoding,
_Out_ SQLSMALLINT& sql_type TSRMLS_DC ); _Out_ SQLSMALLINT& sql_type TSRMLS_DC );
void ae_get_sql_type_info( _Inout_ sqlsrv_stmt* stmt, _In_opt_ SQLULEN paramno, _In_ SQLSMALLINT direction, _In_ zval* param_z, _In_ SQLSRV_ENCODING encoding,
_Out_ SQLSMALLINT& sql_type, _Out_ SQLULEN& column_size, _Out_ SQLSMALLINT& decimal_digits TSRMLS_DC );
void col_cache_dtor( _Inout_ zval* data_z ); void col_cache_dtor( _Inout_ zval* data_z );
void field_cache_dtor( _Inout_ zval* data_z ); void field_cache_dtor( _Inout_ zval* data_z );
void finalize_output_parameters( _Inout_ sqlsrv_stmt* stmt TSRMLS_DC ); void finalize_output_parameters( _Inout_ sqlsrv_stmt* stmt TSRMLS_DC );
@ -110,8 +112,8 @@ stmt_option const* get_stmt_option( sqlsrv_conn const* conn, _In_ zend_ulong key
bool is_valid_sqlsrv_phptype( _In_ sqlsrv_phptype type ); bool is_valid_sqlsrv_phptype( _In_ sqlsrv_phptype type );
// assure there is enough space for the output parameter string // assure there is enough space for the output parameter string
void resize_output_buffer_if_necessary( _Inout_ sqlsrv_stmt* stmt, _Inout_ zval* param_z, _In_ SQLULEN paramno, SQLSRV_ENCODING encoding, void resize_output_buffer_if_necessary( _Inout_ sqlsrv_stmt* stmt, _Inout_ zval* param_z, _In_ SQLULEN paramno, SQLSRV_ENCODING encoding,
_In_ SQLSMALLINT c_type, _In_ SQLSMALLINT sql_type, _In_ SQLULEN column_size, _Out_writes_(buffer_len) SQLPOINTER& buffer, _In_ SQLSMALLINT c_type, _In_ SQLSMALLINT sql_type, _In_ SQLULEN column_size, _In_ SQLSMALLINT decimal_digits,
_Out_ SQLLEN& buffer_len TSRMLS_DC ); _Out_writes_(buffer_len) SQLPOINTER& buffer, _Out_ SQLLEN& buffer_len TSRMLS_DC );
bool reset_ae_stream_cursor( _Inout_ sqlsrv_stmt* stmt ); bool reset_ae_stream_cursor( _Inout_ sqlsrv_stmt* stmt );
void save_output_param_for_later( _Inout_ sqlsrv_stmt* stmt, _Inout_ sqlsrv_output_param& param TSRMLS_DC ); void save_output_param_for_later( _Inout_ sqlsrv_stmt* stmt, _Inout_ sqlsrv_output_param& param TSRMLS_DC );
// send all the stream data // send all the stream data
@ -436,16 +438,20 @@ void core_sqlsrv_bind_param( _Inout_ sqlsrv_stmt* stmt, _In_ SQLUSMALLINT param_
( encoding == SQLSRV_ENCODING_SYSTEM || encoding == SQLSRV_ENCODING_UTF8 || ( encoding == SQLSRV_ENCODING_SYSTEM || encoding == SQLSRV_ENCODING_UTF8 ||
encoding == SQLSRV_ENCODING_BINARY ), "core_sqlsrv_bind_param: invalid encoding" ); encoding == SQLSRV_ENCODING_BINARY ), "core_sqlsrv_bind_param: invalid encoding" );
// if the sql type is unknown, then set the default based on the PHP type passed in if ( stmt->conn->ce_option.enabled && ( sql_type == SQL_UNKNOWN_TYPE || column_size == SQLSRV_UNKNOWN_SIZE )) {
if( sql_type == SQL_UNKNOWN_TYPE ) { ae_get_sql_type_info( stmt, param_num, direction, param_z, encoding, sql_type, column_size, decimal_digits TSRMLS_CC );
default_sql_type( stmt, param_num, param_z, encoding, sql_type TSRMLS_CC );
} }
else {
// if the sql type is unknown, then set the default based on the PHP type passed in
if ( sql_type == SQL_UNKNOWN_TYPE ) {
default_sql_type( stmt, param_num, param_z, encoding, sql_type TSRMLS_CC );
}
// if the size is unknown, then set the default based on the PHP type passed in // if the size is unknown, then set the default based on the PHP type passed in
if( column_size == SQLSRV_UNKNOWN_SIZE ) { if ( column_size == SQLSRV_UNKNOWN_SIZE ) {
default_sql_size_and_scale( stmt, static_cast<unsigned int>( param_num ), param_z, encoding, column_size, decimal_digits TSRMLS_CC ); default_sql_size_and_scale( stmt, static_cast<unsigned int>(param_num), param_z, encoding, column_size, decimal_digits TSRMLS_CC );
}
} }
// determine the ODBC C type // determine the ODBC C type
c_type = default_c_type( stmt, param_num, param_z, encoding TSRMLS_CC ); c_type = default_c_type( stmt, param_num, param_z, encoding TSRMLS_CC );
@ -538,7 +544,7 @@ void core_sqlsrv_bind_param( _Inout_ sqlsrv_stmt* stmt, _In_ SQLUSMALLINT param_
// since this is an output string, assure there is enough space to hold the requested size and // since this is an output string, assure there is enough space to hold the requested size and
// set all the variables necessary (param_z, buffer, buffer_len, and ind_ptr) // set all the variables necessary (param_z, buffer, buffer_len, and ind_ptr)
resize_output_buffer_if_necessary( stmt, param_z, param_num, encoding, c_type, sql_type, column_size, resize_output_buffer_if_necessary( stmt, param_z, param_num, encoding, c_type, sql_type, column_size, decimal_digits,
buffer, buffer_len TSRMLS_CC ); buffer, buffer_len TSRMLS_CC );
// save the parameter to be adjusted and/or converted after the results are processed // save the parameter to be adjusted and/or converted after the results are processed
@ -552,7 +558,8 @@ void core_sqlsrv_bind_param( _Inout_ sqlsrv_stmt* stmt, _In_ SQLUSMALLINT param_
// avoid this silent truncation, we set the column_size to be "MAX" size for // avoid this silent truncation, we set the column_size to be "MAX" size for
// string types. This will guarantee that there is no silent truncation for // string types. This will guarantee that there is no silent truncation for
// output parameters. // output parameters.
if( direction == SQL_PARAM_OUTPUT ) { // if column encryption is enabled, at this point the correct column size has been set by SQLDescribeParam
if( direction == SQL_PARAM_OUTPUT && !stmt->conn->ce_option.enabled ) {
switch( sql_type ) { switch( sql_type ) {
@ -663,6 +670,13 @@ void core_sqlsrv_bind_param( _Inout_ sqlsrv_stmt* stmt, _In_ SQLUSMALLINT param_
core::SQLBindParameter( stmt, param_num + 1, direction, core::SQLBindParameter( stmt, param_num + 1, direction,
c_type, sql_type, column_size, decimal_digits, buffer, buffer_len, &ind_ptr TSRMLS_CC ); c_type, sql_type, column_size, decimal_digits, buffer, buffer_len, &ind_ptr TSRMLS_CC );
if ( stmt->conn->ce_option.enabled && sql_type == SQL_TYPE_TIMESTAMP )
{
if ( decimal_digits == 3 )
core::SQLSetDescField( stmt, param_num + 1, SQL_CA_SS_SERVER_TYPE, (SQLPOINTER)SQL_SS_TYPE_DATETIME, 0 );
else if (decimal_digits == 0)
core::SQLSetDescField( stmt, param_num + 1, SQL_CA_SS_SERVER_TYPE, (SQLPOINTER)SQL_SS_TYPE_SMALLDATETIME, 0 );
}
} }
catch( core::CoreException& e ) { catch( core::CoreException& e ) {
stmt->free_param_data( TSRMLS_C ); stmt->free_param_data( TSRMLS_C );
@ -2004,6 +2018,13 @@ void default_sql_size_and_scale( _Inout_ sqlsrv_stmt* stmt, _In_opt_ unsigned in
} }
} }
void ae_get_sql_type_info( _Inout_ sqlsrv_stmt* stmt, _In_opt_ SQLULEN paramno, _In_ SQLSMALLINT direction, _In_ zval* param_z, _In_ SQLSRV_ENCODING encoding,
_Out_ SQLSMALLINT& sql_type, _Out_ SQLULEN& column_size, _Out_ SQLSMALLINT& decimal_digits TSRMLS_DC )
{
SQLSMALLINT Nullable;
core::SQLDescribeParam( stmt, paramno + 1, &sql_type, &column_size, &decimal_digits, &Nullable );
}
void col_cache_dtor( _Inout_ zval* data_z ) void col_cache_dtor( _Inout_ zval* data_z )
{ {
col_cache* cache = static_cast<col_cache*>( Z_PTR_P( data_z )); col_cache* cache = static_cast<col_cache*>( Z_PTR_P( data_z ));
@ -2485,8 +2506,8 @@ bool is_valid_sqlsrv_phptype( _In_ sqlsrv_phptype type )
// stmt->param_ind_ptrs are modified to hold the correct values for SQLBindParameter // stmt->param_ind_ptrs are modified to hold the correct values for SQLBindParameter
void resize_output_buffer_if_necessary( _Inout_ sqlsrv_stmt* stmt, _Inout_ zval* param_z, _In_ SQLULEN paramno, SQLSRV_ENCODING encoding, void resize_output_buffer_if_necessary( _Inout_ sqlsrv_stmt* stmt, _Inout_ zval* param_z, _In_ SQLULEN paramno, SQLSRV_ENCODING encoding,
_In_ SQLSMALLINT c_type, _In_ SQLSMALLINT sql_type, _In_ SQLULEN column_size, _Out_writes_(buffer_len) SQLPOINTER& buffer, _In_ SQLSMALLINT c_type, _In_ SQLSMALLINT sql_type, _In_ SQLULEN column_size, _In_ SQLSMALLINT decimal_digits,
_Out_ SQLLEN& buffer_len TSRMLS_DC ) _Out_writes_(buffer_len) SQLPOINTER& buffer, _Out_ SQLLEN& buffer_len TSRMLS_DC )
{ {
SQLSRV_ASSERT( column_size != SQLSRV_UNKNOWN_SIZE, "column size should be set to a known value." ); SQLSRV_ASSERT( column_size != SQLSRV_UNKNOWN_SIZE, "column size should be set to a known value." );
buffer_len = Z_STRLEN_P( param_z ); buffer_len = Z_STRLEN_P( param_z );
@ -2501,6 +2522,12 @@ void resize_output_buffer_if_necessary( _Inout_ sqlsrv_stmt* stmt, _Inout_ zval*
// account for the NULL terminator returned by ODBC and needed by Zend to avoid a "String not null terminated" debug warning // account for the NULL terminator returned by ODBC and needed by Zend to avoid a "String not null terminated" debug warning
SQLULEN field_size = column_size; SQLULEN field_size = column_size;
// with AE on, when column_size is retrieved from SQLDescribeParam, column_size does not include the decimal place
// include the decimal for output params by adding elem_size
if ( stmt->conn->ce_option.enabled && decimal_digits > 0 )
{
field_size += elem_size;
}
if (column_size == SQL_SS_LENGTH_UNLIMITED) { if (column_size == SQL_SS_LENGTH_UNLIMITED) {
field_size = SQL_SERVER_MAX_FIELD_SIZE / elem_size; field_size = SQL_SERVER_MAX_FIELD_SIZE / elem_size;
} }

View file

@ -3,7 +3,7 @@
// //
// Contents: Implementation of PHP streams for reading SQL Server data // Contents: Implementation of PHP streams for reading SQL Server data
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -5,7 +5,7 @@
// //
// Comments: Mostly error handling and some type handling // Comments: Mostly error handling and some type handling
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License
@ -220,7 +220,7 @@ bool core_sqlsrv_get_odbc_error( _Inout_ sqlsrv_context& ctx, _In_ int record_nu
SQLRETURN r = SQL_SUCCESS; SQLRETURN r = SQL_SUCCESS;
SQLSMALLINT wmessage_len = 0; SQLSMALLINT wmessage_len = 0;
SQLWCHAR wsqlstate[ SQL_SQLSTATE_BUFSIZE ] = { L'\0' }; SQLWCHAR wsqlstate[ SQL_SQLSTATE_BUFSIZE ] = { L'\0' };
SQLWCHAR wnative_message[ SQL_MAX_MESSAGE_LENGTH + 1 ] = { L'\0' }; SQLWCHAR wnative_message[ SQL_MAX_ERROR_MESSAGE_LENGTH + 1 ] = { L'\0' };
SQLSRV_ENCODING enc = ctx.encoding(); SQLSRV_ENCODING enc = ctx.encoding();
switch( h_type ) { switch( h_type ) {
@ -245,7 +245,7 @@ bool core_sqlsrv_get_odbc_error( _Inout_ sqlsrv_context& ctx, _In_ int record_nu
default: default:
error = new ( sqlsrv_malloc( sizeof( sqlsrv_error ))) sqlsrv_error(); error = new ( sqlsrv_malloc( sizeof( sqlsrv_error ))) sqlsrv_error();
r = SQLGetDiagRecW( h_type, h, record_number, wsqlstate, &error->native_code, wnative_message, r = SQLGetDiagRecW( h_type, h, record_number, wsqlstate, &error->native_code, wnative_message,
SQL_MAX_MESSAGE_LENGTH + 1, &wmessage_len ); SQL_MAX_ERROR_MESSAGE_LENGTH + 1, &wmessage_len );
// don't use the CHECK* macros here since it will trigger reentry into the error handling system // don't use the CHECK* macros here since it will trigger reentry into the error handling system
// Workaround for a bug in unixODBC 2.3.4 when connection pooling is enabled (PDO SQLSRV). // Workaround for a bug in unixODBC 2.3.4 when connection pooling is enabled (PDO SQLSRV).
// Instead of returning false, we return an empty error message to prevent the driver from throwing an exception. // Instead of returning false, we return an empty error message to prevent the driver from throwing an exception.
@ -290,12 +290,12 @@ void core_sqlsrv_format_driver_error( _In_ sqlsrv_context& ctx, _In_ sqlsrv_erro
// allocate space for the formatted message // allocate space for the formatted message
formatted_error = new (sqlsrv_malloc( sizeof( sqlsrv_error ))) sqlsrv_error(); formatted_error = new (sqlsrv_malloc( sizeof( sqlsrv_error ))) sqlsrv_error();
formatted_error->sqlstate = reinterpret_cast<SQLCHAR*>( sqlsrv_malloc( SQL_SQLSTATE_BUFSIZE )); formatted_error->sqlstate = reinterpret_cast<SQLCHAR*>( sqlsrv_malloc( SQL_SQLSTATE_BUFSIZE ));
formatted_error->native_message = reinterpret_cast<SQLCHAR*>( sqlsrv_malloc( SQL_MAX_MESSAGE_LENGTH + 1 )); formatted_error->native_message = reinterpret_cast<SQLCHAR*>( sqlsrv_malloc( SQL_MAX_ERROR_MESSAGE_LENGTH + 1 ));
DWORD rc = FormatMessage( FORMAT_MESSAGE_FROM_STRING, reinterpret_cast<LPSTR>( custom_error->native_message ), 0, 0, DWORD rc = FormatMessage( FORMAT_MESSAGE_FROM_STRING, reinterpret_cast<LPSTR>( custom_error->native_message ), 0, 0,
reinterpret_cast<LPSTR>( formatted_error->native_message ), SQL_MAX_MESSAGE_LENGTH, args ); reinterpret_cast<LPSTR>( formatted_error->native_message ), SQL_MAX_ERROR_MESSAGE_LENGTH, args );
if( rc == 0 ) { if( rc == 0 ) {
strcpy_s( reinterpret_cast<char*>( formatted_error->native_message ), SQL_MAX_MESSAGE_LENGTH, strcpy_s( reinterpret_cast<char*>( formatted_error->native_message ), SQL_MAX_ERROR_MESSAGE_LENGTH,
reinterpret_cast<char*>( INTERNAL_FORMAT_ERROR )); reinterpret_cast<char*>( INTERNAL_FORMAT_ERROR ));
} }

View file

@ -4,7 +4,7 @@
// Contents: Contains functions for handling Windows format strings // Contents: Contains functions for handling Windows format strings
// and UTF-16 on non-Windows platforms // and UTF-16 on non-Windows platforms
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -4,7 +4,7 @@
// Contents: Contains a portable abstraction for interlocked, atomic // Contents: Contains a portable abstraction for interlocked, atomic
// operations on int32_t and pointer types. // operations on int32_t and pointer types.
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -4,7 +4,7 @@
// Contents: Contains a portable abstraction for interlocked, atomic // Contents: Contains a portable abstraction for interlocked, atomic
// operations on int32_t and pointer types. // operations on int32_t and pointer types.
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -4,7 +4,7 @@
// Contents: Contains a portable abstraction for interlocked, singly // Contents: Contains a portable abstraction for interlocked, singly
// linked list. // linked list.
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Contains portable classes for localization // Contents: Contains portable classes for localization
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -5,7 +5,7 @@
// Must be included in one c/cpp file per binary // Must be included in one c/cpp file per binary
// A build error will occur if this inclusion policy is not followed // A build error will occur if this inclusion policy is not followed
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -20,7 +20,7 @@
// pecuniary loss) arising out of the use of or inability to use // pecuniary loss) arising out of the use of or inability to use
// this SDK, even if Microsoft has been advised of the possibility // this SDK, even if Microsoft has been advised of the possibility
// of such damages. // of such damages.
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Contains the minimal definitions to build on non-Windows platforms // Contents: Contains the minimal definitions to build on non-Windows platforms
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -1,7 +1,7 @@
//--------------------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------------------
// File: typedefs_for_linux.h // File: typedefs_for_linux.h
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -4,7 +4,7 @@
// File: version.h // File: version.h
// Contents: Version number constants // Contents: Version number constants
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License
@ -27,7 +27,7 @@
// Increase Minor with backward compatible new functionalities and API changes. // Increase Minor with backward compatible new functionalities and API changes.
// Increase Patch for backward compatible fixes. // Increase Patch for backward compatible fixes.
#define SQLVERSION_MAJOR 5 #define SQLVERSION_MAJOR 5
#define SQLVERSION_MINOR 0 #define SQLVERSION_MINOR 1
#define SQLVERSION_PATCH 0 #define SQLVERSION_PATCH 0
#define SQLVERSION_BUILD 0 #define SQLVERSION_BUILD 0

View file

@ -3,7 +3,7 @@
// //
// Contents: include for definition of Windows types for non-Windows platforms // Contents: include for definition of Windows types for non-Windows platforms
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -4,7 +4,7 @@
// Contents: This module defines helper functions to prevent // Contents: This module defines helper functions to prevent
// integer overflow bugs. // integer overflow bugs.
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Contains the minimal definitions to build on non-Windows platforms // Contents: Contains the minimal definitions to build on non-Windows platforms
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Contains the minimal definitions to build on non-Windows platforms // Contents: Contains the minimal definitions to build on non-Windows platforms
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: JScript build configuration used by buildconf.bat // Contents: JScript build configuration used by buildconf.bat
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Routines that use connection handles // Contents: Routines that use connection handles
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -2,7 +2,7 @@
// File: init.cpp // File: init.cpp
// Contents: initialization routines for the extension // Contents: initialization routines for the extension
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -8,7 +8,7 @@
// //
// Comments: Also contains "internal" declarations shared across source files. // Comments: Also contains "internal" declarations shared across source files.
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Routines that use statement handles // Contents: Routines that use statement handles
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -3,7 +3,7 @@
// //
// Contents: Version resource // Contents: Version resource
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -5,7 +5,7 @@
// //
// Comments: Mostly error handling and some type handling // Comments: Mostly error handling and some type handling
// //
// Microsoft Drivers 5.0 for PHP for SQL Server // Microsoft Drivers 5.1 for PHP for SQL Server
// Copyright(c) Microsoft Corporation // Copyright(c) Microsoft Corporation
// All rights reserved. // All rights reserved.
// MIT License // MIT License

View file

@ -45,5 +45,5 @@ echo "$count sales accounted for the first $$salesTotal in revenue.\n";
/* Cancel the pending results. The statement can be reused. */ /* Cancel the pending results. The statement can be reused. */
sqlsrv_cancel( $stmt); sqlsrv_cancel( $stmt);
?> ?>
--EXPECT-- --EXPECTREGEX--
57 sales accounted for the first $104171.7607 in revenue. [3-5][0-9] sales accounted for the first \$10[0-9]{4}\.[0-9]{2,4} in revenue.

View file

@ -31,11 +31,11 @@ $conn = null;
print "Done"; print "Done";
?> ?>
--EXPECT-- --EXPECTREGEX--
Array Array
( \(
[0] => 21S01 \[0\] => 21S01
[1] => 213 \[1\] => 213
[2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Column name or number of supplied values does not match table definition. \[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Column name or number of supplied values does not match table definition\.
) \)
Done Done

View file

@ -102,9 +102,7 @@ function test_ColumnEncryption( $server, $uid, $pwd, $msodbcsql_maj )
$expected = "Invalid value specified for connection string attribute 'ColumnEncryption'"; $expected = "Invalid value specified for connection string attribute 'ColumnEncryption'";
verify_output( $e, $expected ); verify_output( $e, $expected );
} }
} }
?> ?>
--EXPECTF-- --EXPECTF--
Done Done

View file

@ -71,30 +71,30 @@ Connect using a custom keystore provider with some required inputs missing
echo "Done\n"; echo "Done\n";
?> ?>
--EXPECT-- --EXPECTREGEX--
Connecting... with column encryption Connecting\.\.\. with column encryption
Connected successfully with ColumnEncryption enabled and KSP specified. Connected successfully with ColumnEncryption enabled and KSP specified\.
Connecting... with an invalid input to CEKeystoreProvider Connecting\.\.\. with an invalid input to CEKeystoreProvider
Failed to connect. Failed to connect.
SQLSTATE[HY024]: [Microsoft][ODBC Driver 13 for SQL Server]Invalid attribute value SQLSTATE\[HY024\]: \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Invalid attribute value
Connecting... with an empty path Connecting\.\.\. with an empty path
Failed to connect. Failed to connect.
SQLSTATE[IMSSP]: Invalid value for loading a custom keystore provider. SQLSTATE\[IMSSP\]: Invalid value for loading a custom keystore provider\.
Connecting... without a path Connecting\.\.\. without a path
Failed to connect. Failed to connect.
SQLSTATE[IMSSP]: The path to the custom keystore provider is missing. SQLSTATE\[IMSSP\]: The path to the custom keystore provider is missing\.
Connecting... without a name Connecting\.\.\. without a name
Failed to connect. Failed to connect.
SQLSTATE[IMSSP]: The name of the custom keystore provider is missing. SQLSTATE\[IMSSP\]: The name of the custom keystore provider is missing\.
Connecting... without a key Connecting\.\.\. without a key
Failed to connect. Failed to connect.
SQLSTATE[IMSSP]: The encryption key for the custom keystore provider is missing. SQLSTATE\[IMSSP\]: The encryption key for the custom keystore provider is missing\.
Connecting... with all required inputs Connecting\.\.\. with all required inputs
Connected successfully with ColumnEncryption enabled and KSP specified. Connected successfully with ColumnEncryption enabled and KSP specified\.
Done Done

View file

@ -29,5 +29,5 @@ Array
\( \(
\[0\] => 42S22 \[0\] => 42S22
\[1\] => 207 \[1\] => 207
\[2\] => \[Microsoft\]\[ODBC Driver (09|10|11|12|13) for SQL Server\]\[SQL Server\]Invalid column name 'IntColX'\. \[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Invalid column name 'IntColX'\.
\) \)

View file

@ -91,13 +91,13 @@ conn native code and native message are NULL\.
Warning: PDOStatement::bindParam\(\): SQLSTATE\[HY093\]: Invalid parameter number: parameter was not defined in .+(\/|\\)pdo_errorinfo_emulateprepare\.php on line [0-9]+ Warning: PDOStatement::bindParam\(\): SQLSTATE\[HY093\]: Invalid parameter number: parameter was not defined in .+(\/|\\)pdo_errorinfo_emulateprepare\.php on line [0-9]+
Warning: PDOStatement::execute\(\): SQLSTATE\[07002\]: COUNT field incorrect: 0 \[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]COUNT field incorrect or syntax error in .+(\/|\\)pdo_errorinfo_emulateprepare\.php on line [0-9]+ Warning: PDOStatement::execute\(\): SQLSTATE\[07002\]: COUNT field incorrect: 0 \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]COUNT field incorrect or syntax error in .+(\/|\\)pdo_errorinfo_emulateprepare\.php on line [0-9]+
Statement error info: Statement error info:
Array Array
\( \(
\[0\] => 07002 \[0\] => 07002
\[1\] => 0 \[1\] => 0
\[2\] => \[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]COUNT field incorrect or syntax error \[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]COUNT field incorrect or syntax error
\) \)
Connection error info: Connection error info:
Array Array

View file

@ -77,9 +77,9 @@ function RunTest()
RunTest(); RunTest();
?> ?>
--EXPECT-- --EXPECTREGEX--
 
Number of rows: 1 Number of rows: 1
SQLSTATE[42000]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Implicit conversion from data type sql_variant to nvarchar(max) is not allowed. Use the CONVERT function to run this query. SQLSTATE\[42000\]: \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Implicit conversion from data type sql_variant to nvarchar\(max\) is not allowed. Use the CONVERT function to run this query.
Done Done
Test "pdo_param_output_select_variant" completed successfully. Test \"pdo_param_output_select_variant\" completed successfully\.

View file

@ -131,10 +131,10 @@ function RunTest()
RunTest(); RunTest();
?> ?>
--EXPECT-- --EXPECTREGEX--
 
SQLSTATE[22018]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Operand type clash: nvarchar(max) is incompatible with sql_variant SQLSTATE\[22018\]: \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Operand type clash: nvarchar\(max\) is incompatible with sql_variant
SQLSTATE[22018]: [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Operand type clash: nvarchar(max) is incompatible with sql_variant SQLSTATE\[22018\]: \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Operand type clash: nvarchar\(max\) is incompatible with sql_variant
Done Done
Test "pdo_param_output_variants" completed successfully. Test \"pdo_param_output_variants\" completed successfully\.

View file

@ -79,7 +79,7 @@ Array
\) \)
Prepare with emulate prepare and no bindparam options: Prepare with emulate prepare and no bindparam options:
Fatal error: Uncaught PDOException: SQLSTATE\[42000\]: \[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]\[SQL Server\]Implicit conversion from data type varchar to varbinary\(max\) is not allowed\. Use the CONVERT function to run this query\. in .+(\/|\\)pdo_prepare_emulatePrepare_binary\.php:[0-9]+ Fatal error: Uncaught PDOException: SQLSTATE\[42000\]: \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Implicit conversion from data type varchar to varbinary\(max\) is not allowed\. Use the CONVERT function to run this query\. in .+(\/|\\)pdo_prepare_emulatePrepare_binary\.php:[0-9]+
Stack trace: Stack trace:
#0 .+(\/|\\)pdo_prepare_emulatePrepare_binary\.php\([0-9]+\): PDOStatement->execute\(\) #0 .+(\/|\\)pdo_prepare_emulatePrepare_binary\.php\([0-9]+\): PDOStatement->execute\(\)
#1 {main} #1 {main}

View file

@ -66,27 +66,27 @@ function RunTest()
RunTest(); RunTest();
?> ?>
--EXPECT-- --EXPECTREGEX--
Starting test... Starting test\.\.\.
Setting query timeout as an attribute in connection Setting query timeout as an attribute in connection
array(3) { array\(3\) \{
[0]=> \[0\]=>
string(5) "HYT00" string\(5\) \"HYT00\"
[1]=> \[1\]=>
int(0) int\(0\)
[2]=> \[2\]=>
string(63) "[Microsoft][ODBC Driver 13 for SQL Server]Query timeout expired" string\(63\) \"\[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Query timeout expired\"
} \}
Setting query timeout in the statement Setting query timeout in the statement
array(3) { array\(3\) \{
[0]=> \[0\]=>
string(5) "HYT00" string\(5\) \"HYT00\"
[1]=> \[1\]=>
int(0) int\(0\)
[2]=> \[2\]=>
string(63) "[Microsoft][ODBC Driver 13 for SQL Server]Query timeout expired" string\(63\) \"\[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Query timeout expired\"
} \}
Done Done
Test "pdo_query_timeout" completed successfully. Test \"pdo_query_timeout\" completed successfully\.

View file

@ -20,7 +20,7 @@ UTF-8 connection strings
?> ?>
--EXPECTREGEX-- --EXPECTREGEX--
Fatal error: Uncaught PDOException: SQLSTATE\[(28000|08001|HYT00)\]: .*\[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\](\[SQL Server\])?(Named Pipes Provider: Could not open a connection to SQL Server \[2\]\. |Login timeout expired|Login failed for user 'sa'\.) in .+(\/|\\)pdo_utf8_conn\.php:[0-9]+ Fatal error: Uncaught PDOException: SQLSTATE\[(28000|08001|HYT00)\]: .*\[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\](\[SQL Server\])?(Named Pipes Provider: Could not open a connection to SQL Server \[2\]\. |Login timeout expired|Login failed for user 'sa'\.) in .+(\/|\\)pdo_utf8_conn\.php:[0-9]+
Stack trace: Stack trace:
#0 .+(\/|\\)pdo_utf8_conn\.php\([0-9]+\): PDO->__construct\('sqlsrv:Server=l\.\.\.', 'sa', 'Sunshine4u'\) #0 .+(\/|\\)pdo_utf8_conn\.php\([0-9]+\): PDO->__construct\('sqlsrv:Server=l\.\.\.', 'sa', 'Sunshine4u'\)
#1 {main} #1 {main}

View file

@ -35,4 +35,4 @@ Error Message: An unsupported attribute was designated on the PDO object\.
Warning: PDO::getAttribute\(\): SQLSTATE\[IM001\]: Driver does not support this function: driver does not support that attribute in .+(\/|\\)pdo_warnings\.php on line [0-9]+ Warning: PDO::getAttribute\(\): SQLSTATE\[IM001\]: Driver does not support this function: driver does not support that attribute in .+(\/|\\)pdo_warnings\.php on line [0-9]+
Warning: PDOStatement::execute\(\): SQLSTATE\[42000\]: Syntax error or access violation: 156 \[Microsoft\]\[ODBC Driver [0-9]+ for SQL Server\]\[SQL Server\]Incorrect syntax near the keyword 'TABLE'\. in .+(\/|\\)pdo_warnings\.php on line [0-9]+ Warning: PDOStatement::execute\(\): SQLSTATE\[42000\]: Syntax error or access violation: 156 \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Incorrect syntax near the keyword 'TABLE'\. in .+(\/|\\)pdo_warnings\.php on line [0-9]+

View file

@ -50,8 +50,8 @@ Array
\[SQLSTATE\] => 42000 \[SQLSTATE\] => 42000
\[1\] => 257 \[1\] => 257
\[code\] => 257 \[code\] => 257
\[2\] => \[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]\[SQL Server\]Implicit conversion from data type varchar\(max\) to varbinary\(max\) is not allowed\. Use the CONVERT function to run this query\. \[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Implicit conversion from data type varchar\(max\) to varbinary\(max\) is not allowed\. Use the CONVERT function to run this query\.
\[message\] => \[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]\[SQL Server\]Implicit conversion from data type varchar\(max\) to varbinary\(max\) is not allowed\. Use the CONVERT function to run this query\. \[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Implicit conversion from data type varchar\(max\) to varbinary\(max\) is not allowed\. Use the CONVERT function to run this query\.
\) \)
\[1\] => Array \[1\] => Array
@ -60,8 +60,8 @@ Array
\[SQLSTATE\] => 42000 \[SQLSTATE\] => 42000
\[1\] => 8180 \[1\] => 8180
\[code\] => 8180 \[code\] => 8180
\[2\] => \[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]\[SQL Server\]Statement\(s\) could not be prepared\. \[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Statement\(s\) could not be prepared\.
\[message\] => \[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]\[SQL Server\]Statement\(s\) could not be prepared\. \[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Statement\(s\) could not be prepared\.
\) \)
\) \)

View file

@ -90,12 +90,12 @@ Repro();
?> ?>
--EXPECTREGEX-- --EXPECTREGEX--
 
Test begins... Test begins\.\.\.
\[Microsoft\]\[ODBC Driver 13 for SQL Server\]\[SQL Server\]Cannot insert explicit value for identity column in table '.+' when IDENTITY_INSERT is set to OFF. \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Cannot insert explicit value for identity column in table '.+' when IDENTITY_INSERT is set to OFF\.
544 544
23000 23000
Number of rows inserted: 2 Number of rows inserted: 2
Number of rows fetched: 2 Number of rows fetched: 2
Done Done
Test "sqlsrv_statement_complex_query" completed successfully. Test \"sqlsrv_statement_complex_query\" completed successfully\.

View file

@ -167,7 +167,8 @@ Test simple insert, fetch and update with ColumnEncryption enabled and a custome
sqlsrv_free_stmt($stmt); sqlsrv_free_stmt($stmt);
$callResult = '1900-01-01'; $callResult = '1900-01-01';
$params = array( array( 1, SQLSRV_PARAM_IN ), array( &$callResult, SQLSRV_PARAM_OUT, null, SQLSRV_SQLTYPE_DATE)); //when binding parameter using sqlsrv_query in a column encryption enabled connection, need to provide the sql_type in all parameters
$params = array( array( 1, SQLSRV_PARAM_IN, null, SQLSRV_SQLTYPE_INT ), array( &$callResult, SQLSRV_PARAM_OUT, null, SQLSRV_SQLTYPE_DATE));
$callArgs = "?, ?"; $callArgs = "?, ?";
$stmt = sqlsrv_query($conn, "{ CALL [$procName] ($callArgs)}", $params); $stmt = sqlsrv_query($conn, "{ CALL [$procName] ($callArgs)}", $params);
if (! $stmt ) if (! $stmt )
@ -187,7 +188,8 @@ Test simple insert, fetch and update with ColumnEncryption enabled and a custome
sqlsrv_free_stmt($stmt); sqlsrv_free_stmt($stmt);
$callResult = '000-00-0000'; $callResult = '000-00-0000';
$params = array( array( 1, SQLSRV_PARAM_IN ), array( &$callResult, SQLSRV_PARAM_OUT, null, SQLSRV_SQLTYPE_CHAR(11))); //when binding parameter using sqlsrv_query in a column encryption enabled connection, need to provide the sql_type in all parameters
$params = array( array( 1, SQLSRV_PARAM_IN, null, SQLSRV_SQLTYPE_INT ), array( &$callResult, SQLSRV_PARAM_OUT, null, SQLSRV_SQLTYPE_CHAR(11)));
$callArgs = "?, ?"; $callArgs = "?, ?";
$stmt = sqlsrv_query($conn, "{ CALL [$procName] ($callArgs)}", $params); $stmt = sqlsrv_query($conn, "{ CALL [$procName] ($callArgs)}", $params);
if (! $stmt ) if (! $stmt )

View file

@ -254,9 +254,9 @@ array\(1\) \{
\["code"\]=> \["code"\]=>
int\(0\) int\(0\)
\[2\]=> \[2\]=>
string\(68\) "\[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]Numeric value out of range" string\(68\) "\[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Numeric value out of range"
\["message"\]=> \["message"\]=>
string\(68\) "\[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]Numeric value out of range" string\(68\) "\[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Numeric value out of range"
\} \}
\} \}
NULL NULL
@ -292,9 +292,9 @@ array\(1\) \{
\["code"\]=> \["code"\]=>
int\(0\) int\(0\)
\[2\]=> \[2\]=>
string\(68\) "\[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]Numeric value out of range" string\(68\) "\[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Numeric value out of range"
\["message"\]=> \["message"\]=>
string\(68\) "\[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]Numeric value out of range" string\(68\) "\[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Numeric value out of range"
\} \}
\} \}
NULL NULL

View file

@ -129,11 +129,11 @@ function RunTest()
RunTest(); RunTest();
?> ?>
--EXPECT-- --EXPECTREGEX--
 
[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Operand type clash: varchar(max) is incompatible with sql_variant \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Operand type clash: varchar\(max\) is incompatible with sql_variant
[Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Operand type clash: varchar(max) is incompatible with sql_variant \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Operand type clash: varchar\(max\) is incompatible with sql_variant
Done Done
Test "sqlsrv_param_output_variants" completed successfully. Test \"sqlsrv_param_output_variants\" completed successfully\.

View file

@ -94,9 +94,9 @@ Repro();
--EXPECTREGEX-- --EXPECTREGEX--
 
Test begins... Test begins...
(.*\[Driver Manager\]|\[Microsoft\](\[ODBC Driver 13 for SQL Server\]|\[ODBC Driver Manager\]))([ ]{0,1}Function sequence error) (.*\[Driver Manager\]|\[Microsoft\](\[ODBC Driver 1[1-9] for SQL Server\]|\[ODBC Driver Manager\]))([ ]{0,1}Function sequence error)
0 0
(HY010) (HY010)
Done Done
Test "sqlsrv_statement_cancel" completed successfully. Test \"sqlsrv_statement_cancel\" completed successfully\.

View file

@ -60,15 +60,15 @@ function Repro()
Repro(); Repro();
?> ?>
--EXPECT-- --EXPECTREGEX--
 
Test begins... Test begins...
[Microsoft][ODBC Driver 13 for SQL Server]Query timeout expired \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Query timeout expired
0 0
HYT00 HYT00
[Microsoft][ODBC Driver 13 for SQL Server]Query timeout expired \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Query timeout expired
0 0
HYT00 HYT00
Done Done
Test "sqlsrv_statement_query_timeout" completed successfully. Test \"sqlsrv_statement_query_timeout\" completed successfully\.

View file

@ -74,15 +74,15 @@ function Repro()
Repro(); Repro();
?> ?>
--EXPECT-- --EXPECTREGEX--
 
Test begins... Test begins...
[Microsoft][ODBC Driver 13 for SQL Server]Query timeout expired \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Query timeout expired
0 0
HYT00 HYT00
[Microsoft][ODBC Driver 13 for SQL Server]Query timeout expired \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Query timeout expired
0 0
HYT00 HYT00
Done Done
Test "sqlsrv_statement_query_timeout_transaction" completed successfully. Test \"sqlsrv_statement_query_timeout_transaction\" completed successfully\.

View file

@ -32,14 +32,14 @@ sqlsrv_close($conn);
print "Done" print "Done"
?> ?>
--EXPECT-- --EXPECTREGEX--
Array Array
( \(
[0] => 22018 \[0\] => 22018
[SQLSTATE] => 22018 \[SQLSTATE\] => 22018
[1] => 245 \[1\] => 245
[code] => 245 \[code\] => 245
[2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Conversion failed when converting the varchar value 'null' to data type int. \[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Conversion failed when converting the varchar value 'null' to data type int\.
[message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Conversion failed when converting the varchar value 'null' to data type int. \[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Conversion failed when converting the varchar value 'null' to data type int\.
) \)
Done Done

View file

@ -32,14 +32,14 @@ sqlsrv_close($conn);
print "Done" print "Done"
?> ?>
--EXPECT-- --EXPECTREGEX--
Array Array
( \(
[0] => 22018 \[0\] => 22018
[SQLSTATE] => 22018 \[SQLSTATE\] => 22018
[1] => 245 \[1\] => 245
[code] => 245 \[code\] => 245
[2] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Conversion failed when converting the nvarchar value '银河' to data type int. \[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Conversion failed when converting the nvarchar value '银河' to data type int\.
[message] => [Microsoft][ODBC Driver 13 for SQL Server][SQL Server]Conversion failed when converting the nvarchar value '银河' to data type int. \[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\]Conversion failed when converting the nvarchar value '银河' to data type int\.
) \)
Done Done

View file

@ -32,27 +32,27 @@ sqlsrv_close($conn);
print "Done" print "Done"
?> ?>
--EXPECT-- --EXPECTREGEX--
Array Array
( \(
[0] => Array \[0\] => Array
( \(
[0] => IMSSP \[0\] => IMSSP
[SQLSTATE] => IMSSP \[SQLSTATE\] => IMSSP
[1] => -44 \[1\] => -44
[code] => -44 \[code\] => -44
[2] => The connection cannot process this operation because there is a statement with pending results. To make the connection available for other queries, either fetch all results or cancel or free the statement. For more information, see the product documentation about the MultipleActiveResultSets connection option. \[2\] => The connection cannot process this operation because there is a statement with pending results\. To make the connection available for other queries, either fetch all results or cancel or free the statement\. For more information, see the product documentation about the MultipleActiveResultSets connection option\.
[message] => The connection cannot process this operation because there is a statement with pending results. To make the connection available for other queries, either fetch all results or cancel or free the statement. For more information, see the product documentation about the MultipleActiveResultSets connection option. \[message\] => The connection cannot process this operation because there is a statement with pending results\. To make the connection available for other queries, either fetch all results or cancel or free the statement\. For more information, see the product documentation about the MultipleActiveResultSets connection option\.
) \)
[1] => Array \[1\] => Array
( \(
[0] => HY000 \[0\] => HY000
[SQLSTATE] => HY000 \[SQLSTATE\] => HY000
[1] => 0 \[1\] => 0
[code] => 0 \[code\] => 0
[2] => [Microsoft][ODBC Driver 13 for SQL Server]Connection is busy with results for another command \[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Connection is busy with results for another command
[message] => [Microsoft][ODBC Driver 13 for SQL Server]Connection is busy with results for another command \[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Connection is busy with results for another command
) \)
) \)

View file

@ -41,5 +41,5 @@ print "Done";
bool\(false\) bool\(false\)
string\(5\) "(42S02|08004)" string\(5\) "(42S02|08004)"
int\((3701|911)\) int\((3701|911)\)
string\([0-9]+\) "\[Microsoft\]\[ODBC Driver 13 for SQL Server\]\[SQL Server\](Cannot drop the database 'uniqueDB01_银河系', because it does not exist or you do not have permission\.|Database 'uniqueDB01_银河系' does not exist. Make sure that the name is entered correctly\.)" string\([0-9]+\) "\[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]\[SQL Server\](Cannot drop the database 'uniqueDB01_银河系', because it does not exist or you do not have permission\.|Database 'uniqueDB01_银河系' does not exist. Make sure that the name is entered correctly\.)"
Done Done

View file

@ -49,8 +49,8 @@ Array
\[SQLSTATE\] => HY000 \[SQLSTATE\] => HY000
\[1\] => 0 \[1\] => 0
\[code\] => 0 \[code\] => 0
\[2\] => \[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]Connection is busy with results for another command \[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Connection is busy with results for another command
\[message\] => \[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]Connection is busy with results for another command \[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Connection is busy with results for another command
\) \)
\) \)

View file

@ -236,8 +236,8 @@ Array
\[SQLSTATE\] => HY109 \[SQLSTATE\] => HY109
\[1\] => 0 \[1\] => 0
\[code\] => 0 \[code\] => 0
\[2\] => \[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]Invalid cursor position \[2\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Invalid cursor position
\[message\] => \[Microsoft\]\[ODBC Driver 1[0-9] for SQL Server\]Invalid cursor position \[message\] => \[Microsoft\]\[ODBC Driver 1[1-9] for SQL Server\]Invalid cursor position
\) \)
\) \)