зеркало из https://github.com/microsoft/msphpsql.git
Merge branch 'dev' into php_8.2_tests
This commit is contained in:
Коммит
a5c7069b2e
|
@ -0,0 +1,9 @@
|
|||
.vs
|
||||
.vscode
|
||||
__pycache__
|
||||
*.diff
|
||||
*.exp
|
||||
*.log
|
||||
*.sh
|
||||
*.out
|
||||
test/**/**/*.php
|
|
@ -12,6 +12,7 @@ environment:
|
|||
SQLSRV_DBNAME: msphpsql_sqlsrv
|
||||
PDOSQLSRV_DBNAME: msphpsql_pdosqlsrv
|
||||
PYTHON: c:\Python36
|
||||
APPVEYOR: true
|
||||
# For details about Appveyor build worker images (VM template): https://www.appveyor.com/docs/build-environment/#build-worker-images
|
||||
matrix:
|
||||
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
|
||||
|
|
|
@ -11,6 +11,7 @@ variables:
|
|||
|
||||
trigger:
|
||||
- dev
|
||||
- fix/*
|
||||
|
||||
pr:
|
||||
- dev
|
||||
|
|
|
@ -200,7 +200,11 @@ class BuildDriver(object):
|
|||
print('Something went wrong, launching log file', logfile)
|
||||
# display log file only when not testing
|
||||
if not self.testing:
|
||||
os.startfile(os.path.join(root_dir, 'php-sdk', logfile))
|
||||
logfile_path = os.path.join(root_dir, 'php-sdk', logfile)
|
||||
if os.path.isfile(logfile_path):
|
||||
with open(logfile_path, 'r') as f:
|
||||
f.seek(0)
|
||||
print(f.read())
|
||||
os.chdir(work_dir)
|
||||
exit(1)
|
||||
|
||||
|
|
|
@ -321,7 +321,7 @@ class BuildUtil(object):
|
|||
else: # pdo_sqlsrv
|
||||
cmd_line = ' --enable-pdo --with-pdo-sqlsrv=shared ' + cmd_line
|
||||
|
||||
cmd_line = 'cscript configure.js --disable-all --enable-cli --enable-cgi --enable-json --enable-embed' + cmd_line
|
||||
cmd_line = 'cscript configure.js --disable-all --enable-cli --enable-cgi --enable-json --enable-embed --enable-mbstring' + cmd_line
|
||||
if self.thread == 'nts':
|
||||
cmd_line = cmd_line + ' --disable-zts'
|
||||
return cmd_line
|
||||
|
|
|
@ -414,10 +414,22 @@ void core_sqlsrv_bind_param( _Inout_ sqlsrv_stmt* stmt, _In_ SQLUSMALLINT param_
|
|||
}
|
||||
|
||||
// If Always Encrypted is enabled, transfer the known param meta data if applicable, which might alter param_z for decimal types
|
||||
if (stmt->conn->ce_option.enabled) {
|
||||
if (param_ptr->sql_data_type == SQL_UNKNOWN_TYPE || param_ptr->column_size == SQLSRV_UNKNOWN_SIZE) {
|
||||
if (stmt->conn->ce_option.enabled
|
||||
&& (param_ptr->sql_data_type == SQL_UNKNOWN_TYPE || param_ptr->column_size == SQLSRV_UNKNOWN_SIZE)) {
|
||||
// meta data parameters are always sorted based on parameter number
|
||||
param_ptr->copy_param_meta_ae(param_z, stmt->params_container.params_meta_ae[param_num]);
|
||||
}
|
||||
else {
|
||||
if (Z_TYPE_P(param_z) == IS_STRING && column_size == SQLSRV_UNKNOWN_SIZE) {
|
||||
size_t char_size = (encoding == SQLSRV_ENCODING_UTF8) ? sizeof(SQLWCHAR) : sizeof(char);
|
||||
SQLULEN byte_len = Z_STRLEN_P(param_z) * char_size;
|
||||
|
||||
if (byte_len > SQL_SERVER_MAX_FIELD_SIZE) {
|
||||
param_ptr->column_size = SQL_SERVER_MAX_TYPE_SIZE;
|
||||
}
|
||||
else {
|
||||
param_ptr->column_size = SQL_SERVER_MAX_FIELD_SIZE / char_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2272,18 +2284,6 @@ bool sqlsrv_param::derive_string_types_sizes(_In_ zval* param_z)
|
|||
break;
|
||||
}
|
||||
|
||||
// Derive the column size also only if it is unknown
|
||||
if (column_size == SQLSRV_UNKNOWN_SIZE) {
|
||||
size_t char_size = (encoding == SQLSRV_ENCODING_UTF8) ? sizeof(SQLWCHAR) : sizeof(char);
|
||||
SQLULEN byte_len = Z_STRLEN_P(param_z) * char_size;
|
||||
|
||||
if (byte_len > SQL_SERVER_MAX_FIELD_SIZE) {
|
||||
column_size = SQL_SERVER_MAX_TYPE_SIZE;
|
||||
} else {
|
||||
column_size = SQL_SERVER_MAX_FIELD_SIZE / char_size;
|
||||
}
|
||||
}
|
||||
|
||||
return is_numeric;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,9 +8,13 @@ fetch with all fetch styles
|
|||
$conn = new PDO( "sqlsrv:server=$server ; Database = $databaseName", "$uid", "$pwd");
|
||||
|
||||
print( "\n---------- PDO::FETCH_CLASS -------------\n" );
|
||||
$stmt = $conn->query( "select * from HumanResources.Department order by GroupName" );
|
||||
$stmt = $conn->query( "select DepartmentID, Name, GroupName from HumanResources.Department order by GroupName" );
|
||||
|
||||
class cc {
|
||||
public $DepartmentID;
|
||||
public $Name;
|
||||
public $GroupName;
|
||||
|
||||
function __construct( $arg ) {
|
||||
echo "$arg";
|
||||
}
|
||||
|
@ -26,7 +30,7 @@ fetch with all fetch styles
|
|||
}
|
||||
|
||||
print( "\n---------- PDO::FETCH_INTO -------------\n" );
|
||||
$stmt = $conn->query( "select * from HumanResources.Department order by GroupName" );
|
||||
$stmt = $conn->query( "select DepartmentID, Name, GroupName from HumanResources.Department order by GroupName" );
|
||||
$c_obj = new cc( '' );
|
||||
|
||||
$stmt->setFetchMode(PDO::FETCH_INTO, $c_obj);
|
||||
|
|
|
@ -25,6 +25,10 @@ fetches the rows in a result set in an array
|
|||
print "\n-----------\n";
|
||||
|
||||
class cc {
|
||||
public $ContactTypeID;
|
||||
public $Name;
|
||||
public $ModifiedDate;
|
||||
|
||||
function __construct( $arg ) {
|
||||
echo "$arg\n";
|
||||
}
|
||||
|
@ -34,7 +38,7 @@ fetches the rows in a result set in an array
|
|||
}
|
||||
};
|
||||
|
||||
$stmt = $conn->query( 'SELECT TOP(2) * FROM Person.ContactType' );
|
||||
$stmt = $conn->query( 'SELECT TOP(2) ContactTypeID, Name, ModifiedDate FROM Person.ContactType' );
|
||||
$all = $stmt->fetchAll( PDO::FETCH_CLASS, 'cc', array( 'Hi!' ));
|
||||
var_dump( $all );
|
||||
|
||||
|
|
|
@ -26,9 +26,13 @@ while ( $row = $stmt->fetch() ){
|
|||
}
|
||||
|
||||
echo "\n........ query with a new class ............\n";
|
||||
$query = 'select * from HumanResources.Department order by GroupName';
|
||||
$query = 'select DepartmentID, Name, GroupName from HumanResources.Department order by GroupName';
|
||||
// query with a class
|
||||
class cc {
|
||||
public $DepartmentID;
|
||||
public $Name;
|
||||
public $GroupName;
|
||||
|
||||
function __construct( $arg ) {
|
||||
echo "$arg";
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ $tsql1 = "UPDATE Production.ProductReview
|
|||
//
|
||||
$reviewID = 3;
|
||||
|
||||
$comments = utf8_encode("testing 1, 2, 3, 4. Testing.");
|
||||
$comments = mb_convert_encoding("testing 1, 2, 3, 4. Testing.", 'ISO-8859-1', 'UTF-8');
|
||||
$params1 = array(
|
||||
array( $comments, null ),
|
||||
array( $reviewID, null )
|
||||
|
|
|
@ -7,6 +7,8 @@ retrieves each row of a result set as an instance of the Product class defined i
|
|||
/* Define the Product class. */
|
||||
class Product
|
||||
{
|
||||
|
||||
|
||||
/* Constructor */
|
||||
public function ProductConstruct($ID)
|
||||
{
|
||||
|
@ -17,6 +19,8 @@ class Product
|
|||
public $StockedQty;
|
||||
public $SafetyStockLevel;
|
||||
private $UnitPrice;
|
||||
public $Name;
|
||||
public $Color;
|
||||
function getPrice()
|
||||
{
|
||||
return $this->UnitPrice;
|
||||
|
|
|
@ -27,7 +27,7 @@ $tsql1 = "UPDATE Production.ProductReview
|
|||
// utf8_encode to simulate an application that uses UTF-8 encoded data.
|
||||
//
|
||||
$reviewID = 3;
|
||||
$comments = utf8_encode("testing");
|
||||
$comments = mb_convert_encoding("testing", 'ISO-8859-1', 'UTF-8');
|
||||
$params1 = array(
|
||||
array($comments,
|
||||
SQLSRV_PARAM_IN,
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
--TEST--
|
||||
GitHub issue 1391 - string truncation error when binding some parameters as longer strings the second time
|
||||
--DESCRIPTION--
|
||||
The test shows the same parameters, though bound as short strings in the first insertion, can be bound as longer strings in the subsequent insertions.
|
||||
--ENV--
|
||||
PHPT_EXEC=true
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc'); ?>
|
||||
--FILE--
|
||||
<?php
|
||||
|
||||
require_once("MsSetup.inc");
|
||||
|
||||
function dropTable($conn, $tableName)
|
||||
{
|
||||
$drop = "IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'" . $tableName . "') AND type in (N'U')) DROP TABLE $tableName";
|
||||
$conn->exec($drop);
|
||||
}
|
||||
|
||||
try {
|
||||
$conn = new PDO("sqlsrv:server=$server; Database = $databaseName;", $uid, $pwd);
|
||||
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
dropTable($conn, 'long_strings');
|
||||
|
||||
$tsql = <<<CREATESQL
|
||||
CREATE TABLE long_strings (
|
||||
id bigint IDENTITY(1,1) NOT NULL,
|
||||
four_thousand varchar(4002) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
|
||||
var_max varchar(max) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
|
||||
nvar_max varchar(max) NOT NULL,
|
||||
CONSTRAINT PK__long_strings__1391E83F512B1391 PRIMARY KEY (id))
|
||||
CREATESQL;
|
||||
|
||||
$conn->exec($tsql);
|
||||
|
||||
$tsql = <<<INSERTSQL
|
||||
INSERT INTO long_strings (four_thousand, var_max, nvar_max) VALUES (?, ?, ?)
|
||||
INSERTSQL;
|
||||
|
||||
$stmt = $conn->prepare($tsql);
|
||||
|
||||
// Bind and execute short string values first
|
||||
$fourThousand = '4';
|
||||
$varMax = 'v';
|
||||
$nvarMax = 'n';
|
||||
$stmt->bindParam(1, $fourThousand);
|
||||
$stmt->bindParam(2, $varMax);
|
||||
$stmt->bindParam(3, $nvarMax);
|
||||
$stmt->execute();
|
||||
|
||||
// Bind and execute long string values second, on same $stmt
|
||||
$fourThousand = str_repeat('4', 4001);
|
||||
$varMax = str_repeat('v', 4001);
|
||||
$nvarMax = str_repeat('n', 4001);
|
||||
$stmt->bindParam(1, $fourThousand);
|
||||
$stmt->bindParam(2, $varMax);
|
||||
$stmt->bindParam(3, $nvarMax);
|
||||
$stmt->execute();
|
||||
|
||||
// fetch the data
|
||||
$stmt = $conn->prepare("SELECT COUNT(*) FROM long_strings");
|
||||
$stmt->execute();
|
||||
$row = $stmt->fetch(PDO::FETCH_NUM);
|
||||
echo $row[0]."\n";
|
||||
|
||||
dropTable($conn, 'long_strings');
|
||||
|
||||
echo "Done\n";
|
||||
} catch (PdoException $e) {
|
||||
echo $e->getMessage();
|
||||
}
|
||||
|
||||
?>
|
||||
--EXPECT--
|
||||
2
|
||||
Done
|
|
@ -3,7 +3,11 @@ Test some error conditions of Azure AD Managed Identity support
|
|||
--DESCRIPTION--
|
||||
This test expects certain exceptions to be thrown under some conditions.
|
||||
--SKIPIF--
|
||||
<?php require('skipif.inc');?>
|
||||
<?php
|
||||
require('skipif.inc');
|
||||
require('skipif_Appveyor.inc');
|
||||
require('skipif_unix.inc');
|
||||
?>
|
||||
--FILE--
|
||||
<?php
|
||||
require_once("MsCommon_mid-refactor.inc");
|
||||
|
@ -41,7 +45,9 @@ function connectInvalidServer()
|
|||
$conn = new PDO("sqlsrv:server = invalidServer; $connectionInfo", null, null);
|
||||
echo $message . $testCase . PHP_EOL;
|
||||
} catch(PDOException $e) {
|
||||
// TODO: check the exception message here
|
||||
echo "Failed to connect\n";
|
||||
print_r($e->getMessage());
|
||||
echo "\n";
|
||||
}
|
||||
} catch(PDOException $e) {
|
||||
print_r($e->getMessage());
|
||||
|
@ -72,7 +78,9 @@ function connectInvalidServerWithUser()
|
|||
$conn = new PDO("sqlsrv:server = invalidServer; $connectionInfo", $user, null);
|
||||
echo $message . $testCase . PHP_EOL;
|
||||
} catch(PDOException $e) {
|
||||
// TODO: check the exception message here
|
||||
echo "Failed to connect\n";
|
||||
print_r($e->getMessage());
|
||||
echo "\n";
|
||||
}
|
||||
} catch(PDOException $e) {
|
||||
print_r($e->getMessage());
|
||||
|
|
|
@ -20,7 +20,7 @@ try {
|
|||
--EXPECTREGEX--
|
||||
Array
|
||||
\(
|
||||
\[(DriverDllName|DriverName)\] => (msodbcsql1[1-9].dll|(libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib))
|
||||
\[(DriverDllName|DriverName)\] => (msodbcsql1[1-9].dll|(libmsodbcsql-[0-9]{2}\.[0-9]{1,2}\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib))
|
||||
\[DriverODBCVer\] => [0-9]{1,2}\.[0-9]{1,2}
|
||||
\[DriverVer\] => [0-9]{1,2}\.[0-9]{1,2}\.[0-9]{4}
|
||||
\[ExtensionVer\] => [0-9]\.[0-9]+\.[0-9](-(RC[1-9]?|beta[1-9]))?(\.[0-9]+)?(\+[0-9]+)?
|
||||
|
|
|
@ -125,7 +125,7 @@ SQLSTATE\[IMSSP\]: A read-only attribute was designated on the PDO object.
|
|||
Get Result PDO::ATTR_CLIENT_VERSION :
|
||||
array\(4\) {
|
||||
\[\"(DriverDllName|DriverName)\"\]=>
|
||||
(string\([0-9]+\) \"msodbcsql1[1-9].dll\"|string\([0-9]+\) \"(libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib)\")
|
||||
(string\([0-9]+\) \"msodbcsql1[1-9].dll\"|string\([0-9]+\) \"(libmsodbcsql-[0-9]{2}\.[0-9]{1,2}\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib)\")
|
||||
\["DriverODBCVer"\]=>
|
||||
string\(5\) \"[0-9]{1,2}\.[0-9]{1,2}\"
|
||||
\["DriverVer"\]=>
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
<?php
|
||||
if (getenv('APPVEYOR')) {
|
||||
die("skip Appveyor pipeline");
|
||||
}
|
|
@ -15,7 +15,7 @@ var_dump( $client_info );
|
|||
--EXPECTREGEX--
|
||||
array\(4\) {
|
||||
\[\"(DriverDllName|DriverName)\"\]=>
|
||||
(string\([0-9]+\) \"msodbcsql1[1-9].dll\"|string\([0-9]+\) \"(libmsodbcsql-[0-9]{2}\.[0-9]\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib)\")
|
||||
(string\([0-9]+\) \"msodbcsql1[1-9].dll\"|string\([0-9]+\) \"(libmsodbcsql-[0-9]{2}\.[0-9]{1,2}\.so\.[0-9]\.[0-9]|libmsodbcsql.[0-9]{2}.dylib)\")
|
||||
\[\"DriverODBCVer\"\]=>
|
||||
string\(5\) \"[0-9]{1,2}\.[0-9]{1,2}\"
|
||||
\[\"DriverVer\"\]=>
|
||||
|
|
Загрузка…
Ссылка в новой задаче