Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHP 5.6 support, FIX broken build #44

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pdo_sqlsrv/core_results.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ sqlsrv_buffered_result_set::sqlsrv_buffered_result_set( sqlsrv_stmt* stmt TSRMLS
// these types are the display size
case SQL_BIGINT:
case SQL_DECIMAL:
#if (ODBCVER >= 0x0350)
case SQL_GUID:
#endif /* ODBCVER >= 0x0350 */
case SQL_NUMERIC:
core::SQLColAttribute( stmt, i + 1, SQL_DESC_DISPLAY_SIZE, NULL, 0, NULL,
reinterpret_cast<SQLLEN*>( &meta[i].length ) TSRMLS_CC );
Expand Down Expand Up @@ -396,7 +398,9 @@ sqlsrv_buffered_result_set::sqlsrv_buffered_result_set( sqlsrv_stmt* stmt TSRMLS
case SQL_CHAR:
case SQL_DATETIME:
case SQL_DECIMAL:
#if (ODBCVER >= 0x0350)
case SQL_GUID:
#endif /* ODBCVER >= 0x0350 */
case SQL_NUMERIC:
case SQL_LONGVARCHAR:
case SQL_TYPE_DATE:
Expand Down
4 changes: 2 additions & 2 deletions pdo_sqlsrv/core_sqlsrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ union sqlsrv_phptype {

// static assert for enforcing compile time conditions
template <bool b>
struct sqlsrv_static_assert;
struct sqlsrv_static_assert { static const int value; };

template <>
struct sqlsrv_static_assert<true> { static const int value = 1; };
Expand Down Expand Up @@ -1502,7 +1502,7 @@ struct sqlsrv_buffered_result_set : public sqlsrv_result_set {
#define MEMCHECK_SILENT 1

// utility functions shared by multiple callers across files
bool convert_string_from_utf16_inplace( SQLSRV_ENCODING encoding, char** string, SQLINTEGER& len);
bool convert_string_from_utf16_inplace( SQLSRV_ENCODING encoding, char** string, SQLLEN& len);
bool convert_string_from_utf16( SQLSRV_ENCODING encoding, const wchar_t* inString, SQLINTEGER cchInLen, char** outString, SQLINTEGER& cchOutLen );
wchar_t* utf16_string_from_mbcs_string( SQLSRV_ENCODING php_encoding, const char* mbcs_string,
unsigned int mbcs_len, __out unsigned int* utf16_len );
Expand Down
6 changes: 4 additions & 2 deletions pdo_sqlsrv/core_stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,9 @@ void calc_string_size( sqlsrv_stmt* stmt, SQLUSMALLINT field_index, SQLLEN sql_t
case SQL_INTEGER:
case SQL_SMALLINT:
case SQL_TINYINT:
#if (ODBCVER >= 0x0350)
case SQL_GUID:
#endif /* ODBCVER >= 0x0350 */
case SQL_FLOAT:
case SQL_DOUBLE:
case SQL_REAL:
Expand Down Expand Up @@ -1605,7 +1607,7 @@ void core_get_field_common( __inout sqlsrv_stmt* stmt, SQLUSMALLINT field_index,
php_stream* stream = NULL;
sqlsrv_stream* ss = NULL;
ALLOC_INIT_ZVAL( return_value_z );
SQLINTEGER sql_type;
SQLLEN sql_type;

SQLRETURN r = SQLColAttribute( stmt->handle(), field_index + 1, SQL_DESC_TYPE, NULL, 0, NULL, &sql_type );
CHECK_SQL_ERROR_OR_WARNING( r, stmt ) {
Expand Down Expand Up @@ -2105,7 +2107,7 @@ void get_field_as_string( sqlsrv_stmt* stmt, SQLUSMALLINT field_index, sqlsrv_ph

if( is_truncated_warning( state ) ) {

SQLINTEGER dummy_field_len;
SQLLEN dummy_field_len;

// for XML (and possibly other conditions) the field length returned is not the real field length, so
// in every pass, we double the allocation size to retrieve all the contents.
Expand Down
8 changes: 6 additions & 2 deletions pdo_sqlsrv/core_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int sqlsrv_stream_close( php_stream* stream, int /*close_handle*/ TSRMLS_DC )
size_t sqlsrv_stream_read( php_stream* stream, __out_bcount(count) char* buf, size_t count TSRMLS_DC )
{

SQLINTEGER read = 0;
SQLLEN read = 0;
SQLSMALLINT c_type = SQL_C_CHAR;
char* get_data_buffer = buf;
sqlsrv_malloc_auto_ptr<char> temp_buf;
Expand Down Expand Up @@ -201,9 +201,13 @@ php_stream_ops sqlsrv_stream_ops = {
// open a stream and return the sqlsrv_stream_ops function table as part of the
// return value. There is only one valid way to open a stream, using sqlsrv_get_field on
// certain field types. A sqlsrv stream may only be opened in read mode.

#if PHP_VERSION_ID >= 50600
static php_stream* sqlsrv_stream_opener( php_stream_wrapper* wrapper, const char*, const char* mode,
int options, char **, php_stream_context* STREAMS_DC TSRMLS_DC )
#else
static php_stream* sqlsrv_stream_opener( php_stream_wrapper* wrapper, __in char*, __in char* mode,
int options, __in char **, php_stream_context* STREAMS_DC TSRMLS_DC )
#endif
{

#if ZEND_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion pdo_sqlsrv/core_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void core_sqlsrv_register_logger( log_callback driver_logger )
// utf-16 string is released by this function if no errors occurred. Otherwise the parameters are not changed
// and false is returned.

bool convert_string_from_utf16_inplace( SQLSRV_ENCODING encoding, char** string, SQLINTEGER& len)
bool convert_string_from_utf16_inplace( SQLSRV_ENCODING encoding, char** string, SQLLEN& len)
{
SQLSRV_ASSERT( string != NULL && *string != NULL, "String must be specified" );

Expand Down
4 changes: 4 additions & 0 deletions pdo_sqlsrv/pdo_stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,9 @@ inline pdo_param_type sql_type_to_pdo_type( SQLSMALLINT sql_type )
case SQL_DECIMAL:
case SQL_DOUBLE:
case SQL_FLOAT:
#if (ODBCVER >= 0x0350)
case SQL_GUID:
#endif /* ODBCVER >= 0x0350 */
case SQL_LONGVARBINARY:
case SQL_LONGVARCHAR:
case SQL_NUMERIC:
Expand Down Expand Up @@ -1271,7 +1273,9 @@ sqlsrv_phptype pdo_sqlsrv_stmt::sql_type_to_php_type( SQLINTEGER sql_type, SQLUI
case SQL_DECIMAL:
case SQL_FLOAT:
case SQL_REAL:
#if (ODBCVER >= 0x0350)
case SQL_GUID:
#endif /* ODBCVER >= 0x0350 */
case SQL_NUMERIC:
case SQL_WCHAR:
case SQL_VARCHAR:
Expand Down
4 changes: 4 additions & 0 deletions sqlsrv/core_results.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,9 @@ sqlsrv_buffered_result_set::sqlsrv_buffered_result_set( sqlsrv_stmt* stmt TSRMLS
// these types are the display size
case SQL_BIGINT:
case SQL_DECIMAL:
#if (ODBCVER >= 0x0350)
case SQL_GUID:
#endif /* ODBCVER >= 0x0350 */
case SQL_NUMERIC:
core::SQLColAttribute( stmt, i + 1, SQL_DESC_DISPLAY_SIZE, NULL, 0, NULL,
reinterpret_cast<SQLLEN*>( &meta[i].length ) TSRMLS_CC );
Expand Down Expand Up @@ -396,7 +398,9 @@ sqlsrv_buffered_result_set::sqlsrv_buffered_result_set( sqlsrv_stmt* stmt TSRMLS
case SQL_CHAR:
case SQL_DATETIME:
case SQL_DECIMAL:
#if (ODBCVER >= 0x0350)
case SQL_GUID:
#endif /* ODBCVER >= 0x0350 */
case SQL_NUMERIC:
case SQL_LONGVARCHAR:
case SQL_TYPE_DATE:
Expand Down
4 changes: 2 additions & 2 deletions sqlsrv/core_sqlsrv.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ union sqlsrv_phptype {

// static assert for enforcing compile time conditions
template <bool b>
struct sqlsrv_static_assert;
struct sqlsrv_static_assert { static const int value; };

template <>
struct sqlsrv_static_assert<true> { static const int value = 1; };
Expand Down Expand Up @@ -1502,7 +1502,7 @@ struct sqlsrv_buffered_result_set : public sqlsrv_result_set {
#define MEMCHECK_SILENT 1

// utility functions shared by multiple callers across files
bool convert_string_from_utf16_inplace( SQLSRV_ENCODING encoding, char** string, SQLINTEGER& len);
bool convert_string_from_utf16_inplace( SQLSRV_ENCODING encoding, char** string, SQLLEN& len);
bool convert_string_from_utf16( SQLSRV_ENCODING encoding, const wchar_t* inString, SQLINTEGER cchInLen, char** outString, SQLINTEGER& cchOutLen );
wchar_t* utf16_string_from_mbcs_string( SQLSRV_ENCODING php_encoding, const char* mbcs_string,
unsigned int mbcs_len, __out unsigned int* utf16_len );
Expand Down
6 changes: 4 additions & 2 deletions sqlsrv/core_stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,9 @@ void calc_string_size( sqlsrv_stmt* stmt, SQLUSMALLINT field_index, SQLLEN sql_t
case SQL_INTEGER:
case SQL_SMALLINT:
case SQL_TINYINT:
#if (ODBCVER >= 0x0350)
case SQL_GUID:
#endif /* ODBCVER >= 0x0350 */
case SQL_FLOAT:
case SQL_DOUBLE:
case SQL_REAL:
Expand Down Expand Up @@ -1605,7 +1607,7 @@ void core_get_field_common( __inout sqlsrv_stmt* stmt, SQLUSMALLINT field_index,
php_stream* stream = NULL;
sqlsrv_stream* ss = NULL;
ALLOC_INIT_ZVAL( return_value_z );
SQLINTEGER sql_type;
SQLLEN sql_type;

SQLRETURN r = SQLColAttribute( stmt->handle(), field_index + 1, SQL_DESC_TYPE, NULL, 0, NULL, &sql_type );
CHECK_SQL_ERROR_OR_WARNING( r, stmt ) {
Expand Down Expand Up @@ -2105,7 +2107,7 @@ void get_field_as_string( sqlsrv_stmt* stmt, SQLUSMALLINT field_index, sqlsrv_ph

if( is_truncated_warning( state ) ) {

SQLINTEGER dummy_field_len;
SQLLEN dummy_field_len;

// for XML (and possibly other conditions) the field length returned is not the real field length, so
// in every pass, we double the allocation size to retrieve all the contents.
Expand Down
8 changes: 6 additions & 2 deletions sqlsrv/core_stream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ int sqlsrv_stream_close( php_stream* stream, int /*close_handle*/ TSRMLS_DC )
size_t sqlsrv_stream_read( php_stream* stream, __out_bcount(count) char* buf, size_t count TSRMLS_DC )
{

SQLINTEGER read = 0;
SQLLEN read = 0;
SQLSMALLINT c_type = SQL_C_CHAR;
char* get_data_buffer = buf;
sqlsrv_malloc_auto_ptr<char> temp_buf;
Expand Down Expand Up @@ -201,9 +201,13 @@ php_stream_ops sqlsrv_stream_ops = {
// open a stream and return the sqlsrv_stream_ops function table as part of the
// return value. There is only one valid way to open a stream, using sqlsrv_get_field on
// certain field types. A sqlsrv stream may only be opened in read mode.

#if PHP_VERSION_ID >= 50600
static php_stream* sqlsrv_stream_opener( php_stream_wrapper* wrapper, const char*, const char* mode,
int options, char **, php_stream_context* STREAMS_DC TSRMLS_DC )
#else
static php_stream* sqlsrv_stream_opener( php_stream_wrapper* wrapper, __in char*, __in char* mode,
int options, __in char **, php_stream_context* STREAMS_DC TSRMLS_DC )
#endif
{

#if ZEND_DEBUG
Expand Down
2 changes: 1 addition & 1 deletion sqlsrv/core_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void core_sqlsrv_register_logger( log_callback driver_logger )
// utf-16 string is released by this function if no errors occurred. Otherwise the parameters are not changed
// and false is returned.

bool convert_string_from_utf16_inplace( SQLSRV_ENCODING encoding, char** string, SQLINTEGER& len)
bool convert_string_from_utf16_inplace( SQLSRV_ENCODING encoding, char** string, SQLLEN& len)
{
SQLSRV_ASSERT( string != NULL && *string != NULL, "String must be specified" );

Expand Down
2 changes: 2 additions & 0 deletions sqlsrv/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ PHP_MINIT_FUNCTION(sqlsrv)
REGISTER_LONG_CONSTANT( "SQLSRV_SQLTYPE_TIMESTAMP", constant_type.value, CONST_PERSISTENT | CONST_CS );
REGISTER_LONG_CONSTANT( "SQLSRV_SQLTYPE_TINYINT", SQL_TINYINT, CONST_PERSISTENT | CONST_CS );
REGISTER_LONG_CONSTANT( "SQLSRV_SQLTYPE_UDT", SQL_SS_UDT, CONST_PERSISTENT | CONST_CS );
#if (ODBCVER >= 0x0350)
REGISTER_LONG_CONSTANT( "SQLSRV_SQLTYPE_UNIQUEIDENTIFIER", SQL_GUID, CONST_PERSISTENT | CONST_CS );
#endif /* ODBCVER >= 0x0350 */
REGISTER_LONG_CONSTANT( "SQLSRV_SQLTYPE_XML", SQL_SS_XML, CONST_PERSISTENT | CONST_CS );
constant_type.typeinfo.type = SQL_TYPE_DATE;
constant_type.typeinfo.size = 10;
Expand Down
12 changes: 10 additions & 2 deletions sqlsrv/stmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const char SS_SQLSRV_WARNING_PARAM_VAR_NOT_REF[] = "Variable parameter %d not pa
zval* convert_to_zval( SQLSRV_PHPTYPE sqlsrv_php_type, void** in_val, SQLLEN field_len );
void fetch_fields_common( __inout ss_sqlsrv_stmt* stmt, int fetch_type, __out zval* return_value, bool allow_empty_field_names
TSRMLS_DC );
bool determine_column_size_or_precision( sqlsrv_stmt const* stmt, sqlsrv_sqltype sqlsrv_type, __out SQLUINTEGER* column_size,
bool determine_column_size_or_precision( sqlsrv_stmt const* stmt, sqlsrv_sqltype sqlsrv_type, __out SQLULEN* column_size,
__out SQLSMALLINT* decimal_digits );
sqlsrv_phptype determine_sqlsrv_php_type( sqlsrv_stmt const* stmt, SQLINTEGER sql_type, SQLUINTEGER size, bool prefer_string );
void determine_stmt_has_rows( ss_sqlsrv_stmt* stmt TSRMLS_DC );
Expand Down Expand Up @@ -173,7 +173,9 @@ sqlsrv_phptype ss_sqlsrv_stmt::sql_type_to_php_type( SQLINTEGER sql_type, SQLUIN
case SQL_BIGINT:
case SQL_CHAR:
case SQL_DECIMAL:
#if (ODBCVER >= 0x0350)
case SQL_GUID:
#endif /* ODBCVER >= 0x0350 */
case SQL_NUMERIC:
case SQL_WCHAR:
case SQL_SS_VARIANT:
Expand Down Expand Up @@ -1569,7 +1571,7 @@ zval* convert_to_zval( SQLSRV_PHPTYPE sqlsrv_php_type, void** in_val, SQLLEN fie

// put in the column size and scale/decimal digits of the sql server type
// these values are taken from the MSDN page at http://msdn2.microsoft.com/en-us/library/ms711786(VS.85).aspx
bool determine_column_size_or_precision( sqlsrv_stmt const* stmt, sqlsrv_sqltype sqlsrv_type, __out SQLUINTEGER* column_size,
bool determine_column_size_or_precision( sqlsrv_stmt const* stmt, sqlsrv_sqltype sqlsrv_type, __out SQLULEN* column_size,
__out SQLSMALLINT* decimal_digits )
{
*decimal_digits = 0;
Expand All @@ -1590,9 +1592,11 @@ bool determine_column_size_or_precision( sqlsrv_stmt const* stmt, sqlsrv_sqltype
case SQL_TINYINT:
*column_size = 3;
break;
#if (ODBCVER >= 0x0350)
case SQL_GUID:
*column_size = 36;
break;
#endif /* ODBCVER >= 0x0350 */
case SQL_FLOAT:
*column_size = 53;
break;
Expand Down Expand Up @@ -1683,7 +1687,9 @@ sqlsrv_phptype determine_sqlsrv_php_type( ss_sqlsrv_stmt const* stmt, SQLINTEGER
case SQL_BIGINT:
case SQL_CHAR:
case SQL_DECIMAL:
#if (ODBCVER >= 0x0350)
case SQL_GUID:
#endif /* ODBCVER >= 0x0350 */
case SQL_NUMERIC:
case SQL_WCHAR:
sqlsrv_phptype.typeinfo.type = SQLSRV_PHPTYPE_STRING;
Expand Down Expand Up @@ -2104,7 +2110,9 @@ bool is_valid_sqlsrv_sqltype( sqlsrv_sqltype sql_type )
case SQL_INTEGER:
case SQL_SMALLINT:
case SQL_TINYINT:
#if (ODBCVER >= 0x0350)
case SQL_GUID:
#endif /* ODBCVER >= 0x0350 */
case SQL_FLOAT:
case SQL_REAL:
case SQL_LONGVARBINARY:
Expand Down