Skip to content

Commit

Permalink
Merged changes from pecl source plus modified helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
yitam committed Aug 15, 2018
1 parent f2510c7 commit a70d271
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
8 changes: 8 additions & 0 deletions source/pdo_sqlsrv/pdo_dbh.cpp
Expand Up @@ -1369,6 +1369,14 @@ int pdo_sqlsrv_dbh_quote( _Inout_ pdo_dbh_t* dbh, _In_reads_(unquoted_len) const
// convert from char* to hex digits using os
std::basic_ostringstream<char> os;
for ( size_t index = 0; index < unquoted_len && unquoted[ index ] != '\0'; ++index ) {
// if unquoted is < 0 or > 255, that means this is a non-ascii character. Translation from non-ascii to binary is not supported.
// return an empty terminated string for now
if (( int )unquoted[ index ] < 0 || ( int )unquoted[ index ] > 255) {
*quoted_len = 0;
*quoted = reinterpret_cast<char*>( sqlsrv_malloc( *quoted_len, sizeof( char ), 1 ));
( *quoted )[ 0 ] = '\0';
return 1;
}
// when an int is < 16 and is appended to os, its hex representation which starts
// with '0' does not get appended properly (the starting '0' does not get appended)
// thus append '0' first
Expand Down
10 changes: 5 additions & 5 deletions source/shared/version.h
Expand Up @@ -28,14 +28,14 @@
// Increase Patch for backward compatible fixes.
#define SQLVERSION_MAJOR 4
#define SQLVERSION_MINOR 3
#define SQLVERSION_PATCH 0
#define SQLVERSION_PATCH 1
#define SQLVERSION_BUILD 0

// Semantic versioning pre-release
// for stable releases should be empty
// "rc" for release candidates
// "preview" for ETP
#define SEMVER_PRERELEASE "RC1"
// "-RC" for release candidates
// "-preview" for ETP
#define SEMVER_PRERELEASE
// Semantic versioning build metadata, build meta data is not counted in precedence order.
#define SEMVER_BUILDMETA

Expand All @@ -48,7 +48,7 @@
#define VER_APIVERSION_STR STRINGIFY( SQLVERSION_MAJOR ) "." STRINGIFY( SQLVERSION_MINOR ) "." STRINGIFY( SQLVERSION_PATCH )

// Remove "-" if SEMVER_PRERELEASE is empty (for stable releases)
#define VER_FILEVERSION_STR VER_APIVERSION_STR "-" SEMVER_PRERELEASE SEMVER_BUILDMETA
#define VER_FILEVERSION_STR VER_APIVERSION_STR SEMVER_PRERELEASE SEMVER_BUILDMETA
#define _FILEVERSION SQLVERSION_MAJOR,SQLVERSION_MINOR,SQLVERSION_PATCH,SQLVERSION_BUILD

// PECL package version macros (can't have '-' or '+')
Expand Down
8 changes: 4 additions & 4 deletions test/functional/pdo_sqlsrv/MsCommon.inc
Expand Up @@ -359,7 +359,7 @@ function GetTempTableName($table = '', $temporary = true)
// dropped once the connection is closed. Otherwise, the caller
// should take care of dropping the temp table afterwards.

$timestamp = round(microtime(true)*1000);
$someNumber = rand(0, 1000);

$prefix = '';
if ($temporary)
Expand All @@ -368,7 +368,7 @@ function GetTempTableName($table = '', $temporary = true)
if (strlen($table) == 0)
$table = 'php_test_table';

return $prefix . $table . '_' . $timestamp;
return $prefix . $table . '_' . $someNumber;
}

function GetTempProcName($proc = '', $temporary = true)
Expand All @@ -377,7 +377,7 @@ function GetTempProcName($proc = '', $temporary = true)
// automatically dropped once the connection is closed. Otherwise,
// the caller should take care of dropping the temp procedure afterwards.

$timestamp = round(microtime(true)*1000);
$someNumber = rand(0, 1000);

$prefix = '';
if ($temporary)
Expand All @@ -386,7 +386,7 @@ function GetTempProcName($proc = '', $temporary = true)
if (strlen($proc) == 0)
$proc = 'php_test_proc';

return $prefix . $proc . '_' . $timestamp;
return $prefix . $proc . '_' . $someNumber;
}

function PDOConnect($className, $serverName, $user, $pwd, $exitMode)
Expand Down
8 changes: 4 additions & 4 deletions test/functional/sqlsrv/MsCommon.inc
Expand Up @@ -165,7 +165,7 @@ function GetTempTableName($table = '', $temporary = true)
// dropped once the connection is closed. Otherwise, the caller
// should take care of dropping the temp table afterwards.

$timestamp = round(microtime(true)*1000);
$someNumber = rand(0, 1000);

$prefix = '';
if ($temporary)
Expand All @@ -174,7 +174,7 @@ function GetTempTableName($table = '', $temporary = true)
if (strlen($table) == 0)
$table = 'php_test_table';

return $prefix . $table . '_' . $timestamp;
return $prefix . $table . '_' . $someNumber;
}

function GetTempProcName($proc = '', $temporary = true)
Expand All @@ -183,7 +183,7 @@ function GetTempProcName($proc = '', $temporary = true)
// automatically dropped once the connection is closed. Otherwise,
// the caller should take care of dropping the temp procedure afterwards.

$timestamp = round(microtime(true)*1000);
$someNumber = rand(0, 1000);

$prefix = '';
if ($temporary)
Expand All @@ -192,7 +192,7 @@ function GetTempProcName($proc = '', $temporary = true)
if (strlen($proc) == 0)
$proc = 'php_test_proc';

return $prefix . $proc . '_' . $timestamp;
return $prefix . $proc . '_' . $someNumber;
}

function ExecuteQuery($conn, $query)
Expand Down

0 comments on commit a70d271

Please sign in to comment.