Cumulative Update 1 for Microsoft Drivers 3.0 for PHP for SQL Server.

This commit is contained in:
icosahedron 2012-04-09 21:48:24 +00:00
parent c727ada07e
commit efe20a6723
16 changed files with 78 additions and 58 deletions

View file

@ -1 +1 @@
Microsoft Drivers 3.0 for PHP for SQL Server (PDO driver)
Microsoft Drivers 3.0.1 for PHP for SQL Server (PDO driver)

View file

@ -28,7 +28,7 @@ Prerequisites:
extensions. For help with doing this, see the official PHP website,
http://php.net.
To compile the SQLSRV30 and PDO_SQLSRV30:
To compile the SQLSRV301 and PDO_SQLSRV301:
1) Copy the source code directories from this repository into the ext
subdirectory.

View file

@ -113,15 +113,6 @@ OACR_WARNING_POP
// included for SQL Server specific constants
#include "sqlncli.h"
// new PHP 5.3 macros redefined for PHP 5.2 backwards compatibility
#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION <= 2
#define Z_ISREF_P( pzval ) ((pzval)->is_ref != 0)
#define Z_ISREF_PP( ppzval ) Z_ISREF_P(*(ppzval))
#define Z_SET_ISREF_P( pzval ) ((pzval)->is_ref = 1)
#define Z_SET_ISREF_PP( ppzval ) Z_SET_ISREF_P(*(ppzval))
#define Z_REFCOUNT_P( pzval ) ((pzval)->refcount)
#endif
//*********************************************************************************************************************************
// Constants and Types
//*********************************************************************************************************************************
@ -1505,7 +1496,7 @@ struct sqlsrv_buffered_result_set : public sqlsrv_result_set {
// Simple macro to alleviate unused variable warnings. These are optimized out by the compiler.
// We use this since the unused variables are buried in the PHP_FUNCTION macro.
#define SQLSRV_UNUSED( var ) var = var
#define SQLSRV_UNUSED( var ) var;
// do a heap check in debug mode, but only print errors, not all of the allocations
#define MEMCHECK_SILENT 1

View file

@ -496,6 +496,16 @@ void core_sqlsrv_bind_param( sqlsrv_stmt* stmt, unsigned int param_num, int dire
ind_ptr = buffer_len;
if( direction != SQL_PARAM_INPUT ) {
#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 4
// PHP 5.4 added interned strings, so since we obviously want to change that string here in some fashion,
// we reallocate the string if it's interned
if( IS_INTERNED( buffer )) {
ZVAL_STRINGL( param_z, static_cast<const char*>(buffer), buffer_len, 1 );
buffer = Z_STRVAL_P( param_z );
buffer_len = Z_STRLEN_P( param_z );
}
#endif
// if it's a UTF-8 input output parameter (signified by the C type being SQL_C_WCHAR)
// or if the PHP type is a binary encoded string with a N(VAR)CHAR/NTEXTSQL type,
// convert it to wchar first

View file

@ -26,17 +26,8 @@
#include <string>
#include <sstream>
#if PHP_MAJOR_VERSION == 5
#if PHP_MINOR_VERSION == 2
typedef function_entry pdo_sqlsrv_function_entry;
#else
typedef const function_entry pdo_sqlsrv_function_entry;
#endif
#endif
typedef const zend_function_entry pdo_sqlsrv_function_entry;
// *** internal variables and constants ***
@ -588,7 +579,20 @@ int pdo_sqlsrv_dbh_prepare( pdo_dbh_t *dbh, const char *sql,
core_sqlsrv_prepare( driver_stmt, sql, sql_len TSRMLS_CC );
}
else if( driver_stmt->direct_query ) {
if( driver_stmt->direct_query_subst_string ) {
// we use efree rather than sqlsrv_free since sqlsrv_free may wrap another allocation scheme
// and we use estrdup below to allocate the new string, which uses emalloc
efree( reinterpret_cast<void*>( const_cast<char*>( driver_stmt->direct_query_subst_string )));
}
driver_stmt->direct_query_subst_string = estrdup( sql );
driver_stmt->direct_query_subst_string_len = sql_len;
}
// else if stmt->support_placeholders == PDO_PLACEHOLDER_NONE means that stmt->active_query_string will be
// set to the substituted query
stmt->driver_data = driver_stmt;
driver_stmt.transferred();
}

View file

@ -219,6 +219,8 @@ struct pdo_sqlsrv_stmt : public sqlsrv_stmt {
pdo_sqlsrv_stmt( sqlsrv_conn* c, SQLHANDLE handle, error_callback e, void* drv TSRMLS_DC ) :
sqlsrv_stmt( c, handle, e, drv TSRMLS_CC ),
direct_query( false ),
direct_query_subst_string( NULL ),
direct_query_subst_string_len( 0 ),
bound_column_param_types( NULL )
{
pdo_sqlsrv_dbh* db = static_cast<pdo_sqlsrv_dbh*>( c );
@ -231,7 +233,10 @@ struct pdo_sqlsrv_stmt : public sqlsrv_stmt {
// for PDO, everything is a string, so we return SQLSRV_PHPTYPE_STRING for all SQL types
virtual sqlsrv_phptype sql_type_to_php_type( SQLINTEGER sql_type, SQLUINTEGER size, bool prefer_string_to_stream );
bool direct_query; // flag set if the query should be executed directly or prepared
bool direct_query; // flag set if the query should be executed directly or prepared
const char* direct_query_subst_string; // if the query is direct, hold the substitution string if using named parameters
int direct_query_subst_string_len; // length of query string used for direct queries
// meta data for current result set
std::vector<field_meta_data*, sqlsrv_allocator< field_meta_data* > > current_meta_data;
pdo_param_type* bound_column_param_types;

View file

@ -349,6 +349,12 @@ pdo_sqlsrv_stmt::~pdo_sqlsrv_stmt( void )
sqlsrv_free( bound_column_param_types );
bound_column_param_types = NULL;
}
if( direct_query_subst_string ) {
// we use efree rather than sqlsrv_free since sqlsrv_free may wrap another allocation scheme
// and we use estrdup to allocate this string, which uses emalloc
efree( reinterpret_cast<void*>( const_cast<char*>( direct_query_subst_string )));
}
}
@ -512,13 +518,15 @@ int pdo_sqlsrv_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
// if the user is doing a direct query (PDO::SQLSRV_ATTR_DIRECT_QUERY), set the query here
if( driver_stmt->direct_query ) {
query = stmt->query_string;
query_len = stmt->query_stringlen;
}
query = driver_stmt->direct_query_subst_string;
query_len = driver_stmt->direct_query_subst_string_len;
}
// if the user is using prepare emulation (PDO::ATTR_EMULATE_PREPARES), set the query to the
// subtituted query provided by PDO
if( stmt->supports_placeholders == PDO_PLACEHOLDER_NONE ) {
query = stmt->active_query_string;
query_len = stmt->active_query_stringlen;
}

View file

@ -51,9 +51,9 @@ pdo_error PDO_ERRORS[] = {
{
SQLSRV_ERROR_DRIVER_NOT_INSTALLED,
{ IMSSP, (SQLCHAR*) "This extension requires either the Microsoft SQL Server 2008 Native Client (SP1 or later) or the "
"Microsoft SQL Server 2008 R2 Native Client ODBC Driver to communicate with SQL Server. Neither of those ODBC Drivers are currently installed. "
"Access the following URL to download the Microsoft SQL Server 2008 R2 Native Client ODBC driver for %1!s!: "
{ IMSSP, (SQLCHAR*) "This extension requires the Microsoft SQL Server 2012 Native Client ODBC Driver to "
"communicate with SQL Server. Access the following URL to download the Microsoft SQL Server 2012 Native Client "
"ODBC driver for %1!s!: "
"http://go.microsoft.com/fwlink/?LinkId=163712", -1, true }
},
{

View file

@ -18,9 +18,9 @@
// limitations under the License.
//----------------------------------------------------------------------------------------------------------------------------------
#define VER_FILEVERSION_STR "3.0.0.0"
#define VER_FILEVERSION_STR "3.0.1.0"
#define _FILEVERSION 3,0,0,0
#define SQLVERSION_MAJOR 3
#define SQLVERSION_MINOR 0
#define SQLVERSION_MMDD 0
#define SQLVERSION_MMDD 1
#define SQLVERSION_REVISION 0

View file

@ -1 +1 @@
Microsoft Drivers 3.0 for PHP for SQL Server (SQLSRV driver)
Microsoft Drivers 3.0.1 for PHP for SQL Server (SQLSRV driver)

View file

@ -28,7 +28,7 @@ Prerequisites:
extensions. For help with doing this, see the official PHP website,
http://php.net.
To compile the SQLSRV30 and PDO_SQLSRV30:
To compile the SQLSRV301 and PDO_SQLSRV301:
1) Copy the source code directories from this repository into the ext
subdirectory.

View file

@ -113,15 +113,6 @@ OACR_WARNING_POP
// included for SQL Server specific constants
#include "sqlncli.h"
// new PHP 5.3 macros redefined for PHP 5.2 backwards compatibility
#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION <= 2
#define Z_ISREF_P( pzval ) ((pzval)->is_ref != 0)
#define Z_ISREF_PP( ppzval ) Z_ISREF_P(*(ppzval))
#define Z_SET_ISREF_P( pzval ) ((pzval)->is_ref = 1)
#define Z_SET_ISREF_PP( ppzval ) Z_SET_ISREF_P(*(ppzval))
#define Z_REFCOUNT_P( pzval ) ((pzval)->refcount)
#endif
//*********************************************************************************************************************************
// Constants and Types
//*********************************************************************************************************************************
@ -1505,7 +1496,7 @@ struct sqlsrv_buffered_result_set : public sqlsrv_result_set {
// Simple macro to alleviate unused variable warnings. These are optimized out by the compiler.
// We use this since the unused variables are buried in the PHP_FUNCTION macro.
#define SQLSRV_UNUSED( var ) var = var
#define SQLSRV_UNUSED( var ) var;
// do a heap check in debug mode, but only print errors, not all of the allocations
#define MEMCHECK_SILENT 1

View file

@ -496,6 +496,16 @@ void core_sqlsrv_bind_param( sqlsrv_stmt* stmt, unsigned int param_num, int dire
ind_ptr = buffer_len;
if( direction != SQL_PARAM_INPUT ) {
#if PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION == 4
// PHP 5.4 added interned strings, so since we obviously want to change that string here in some fashion,
// we reallocate the string if it's interned
if( IS_INTERNED( buffer )) {
ZVAL_STRINGL( param_z, static_cast<const char*>(buffer), buffer_len, 1 );
buffer = Z_STRVAL_P( param_z );
buffer_len = Z_STRLEN_P( param_z );
}
#endif
// if it's a UTF-8 input output parameter (signified by the C type being SQL_C_WCHAR)
// or if the PHP type is a binary encoded string with a N(VAR)CHAR/NTEXTSQL type,
// convert it to wchar first

View file

@ -74,7 +74,7 @@ typedef int socklen_t;
#pragma warning(pop)
#if PHP_MAJOR_VERSION > 5 || PHP_MAJOR_VERSION < 5 || ( PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 2 ) || ( PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 3 )
#if PHP_MAJOR_VERSION > 5 || PHP_MAJOR_VERSION < 5 || ( PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION < 3 ) || ( PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION > 4 )
#error Trying to compile "Microsoft Drivers for PHP for SQL Server (SQLSRV Driver)" with an unsupported version of PHP
#endif
@ -85,9 +85,9 @@ typedef int socklen_t;
} // extern "C"
//**********************************************************************************************************************************
//*********************************************************************************************************************************
// Initialization Functions
//**********************************************************************************************************************************
//*********************************************************************************************************************************
// module global variables (initialized in minit and freed in mshutdown)
extern HashTable* g_ss_errors_ht;
@ -115,9 +115,9 @@ PHP_RSHUTDOWN_FUNCTION(sqlsrv);
// module info function (info returned by phpinfo())
PHP_MINFO_FUNCTION(sqlsrv);
//**********************************************************************************************************************************
//*********************************************************************************************************************************
// Connection
//**********************************************************************************************************************************
//*********************************************************************************************************************************
PHP_FUNCTION(sqlsrv_connect);
PHP_FUNCTION(sqlsrv_begin_transaction);
PHP_FUNCTION(sqlsrv_client_info);
@ -450,9 +450,9 @@ public:
//**********************************************************************************************************************************
//*********************************************************************************************************************************
// Logging
//**********************************************************************************************************************************
//*********************************************************************************************************************************
#define LOG_FUNCTION( function_name ) \
const char* _FN_ = function_name; \
SQLSRV_G( current_subsystem ) = current_log_subsystem; \

View file

@ -301,8 +301,8 @@ ss_error SS_ERRORS[] = {
{
SQLSRV_ERROR_DRIVER_NOT_INSTALLED,
{ IMSSP, (SQLCHAR*) "This extension requires the Microsoft SQL Server 2011 Native Client. "
"Access the following URL to download the Microsoft SQL Server 2011 Native Client ODBC driver for %1!s!: "
{ IMSSP, (SQLCHAR*) "This extension requires the Microsoft SQL Server 2012 Native Client. "
"Access the following URL to download the Microsoft SQL Server 2012 Native Client ODBC driver for %1!s!: "
"http://go.microsoft.com/fwlink/?LinkId=163712", -49, true }
},
@ -729,6 +729,7 @@ void copy_error_to_zval( zval** error_z, sqlsrv_error_const* error, zval** repor
zval_auto_ptr temp;
MAKE_STD_ZVAL( temp );
ZVAL_STRINGL( temp, reinterpret_cast<char*>( error->sqlstate ), SQL_SQLSTATE_SIZE, 1 );
zval_add_ref( &temp );
if( add_next_index_zval( *error_z, temp ) == FAILURE ) {
DIE( "Fatal error during error processing" );
}
@ -736,7 +737,7 @@ void copy_error_to_zval( zval** error_z, sqlsrv_error_const* error, zval** repor
if( add_assoc_zval( *error_z, "SQLSTATE", temp ) == FAILURE ) {
DIE( "Fatal error during error processing" );
}
zval_add_ref( &temp );
temp.transferred();
// native_code
if( add_next_index_long( *error_z, error->native_code ) == FAILURE ) {
@ -750,6 +751,7 @@ void copy_error_to_zval( zval** error_z, sqlsrv_error_const* error, zval** repor
// native_message
MAKE_STD_ZVAL( temp );
ZVAL_STRING( temp, reinterpret_cast<char*>( error->native_message), 1 );
zval_add_ref( &temp );
if( add_next_index_zval( *error_z, temp ) == FAILURE ) {
DIE( "Fatal error during error processing" );
}
@ -757,7 +759,6 @@ void copy_error_to_zval( zval** error_z, sqlsrv_error_const* error, zval** repor
if( add_assoc_zval( *error_z, "message", temp ) == FAILURE ) {
DIE( "Fatal error during error processing" );
}
zval_add_ref( &temp );
temp.transferred();
// If it is an error or if warning_return_as_errors is true than

View file

@ -18,9 +18,9 @@
// limitations under the License.
//----------------------------------------------------------------------------------------------------------------------------------
#define VER_FILEVERSION_STR "3.0.0.0"
#define _FILEVERSION 3,0,0,0
#define VER_FILEVERSION_STR "3.0.1.0"
#define _FILEVERSION 3,0,1,0
#define SQLVERSION_MAJOR 3
#define SQLVERSION_MINOR 0
#define SQLVERSION_MMDD 0
#define SQLVERSION_MMDD 1
#define SQLVERSION_REVISION 0