Merge pull request #1427 from microsoft/dev

Merge to master for 5.11.0 beta1 release
This commit is contained in:
Sicong 2023-01-26 16:13:26 -08:00 коммит произвёл GitHub
Родитель 25c8a200a5 ee5baccde4
Коммит afdc9b6e8d
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
85 изменённых файлов: 273 добавлений и 111 удалений

9
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,9 @@
.vs
.vscode
__pycache__
*.diff
*.exp
*.log
*.sh
*.out
test/**/**/*.php

Просмотреть файл

@ -3,6 +3,33 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
## 5.11.0-beta1 - 2023-01-25
Updated PECL release packages. Here is the list of updates:
### Added
- Support for PHP 8.2
### Fixed
- Pull request [#1408](https://github.com/microsoft/msphpsql/pull/1408) - Fixed right truncation issue, unit test added by talkinnl
### Limitations
- No support for inout / output params when using sql_variant type
- No support for inout / output params when formatting decimal values
- In Linux and macOS, setlocale() only takes effect if it is invoked before the first connection. Attempting to set the locale after connecting will not work
- Always Encrypted requires [MS ODBC Driver 17+](https://docs.microsoft.com/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server)
- Only Windows Certificate Store and Azure Key Vault are supported. Custom Keystores are not yet supported
- Issue [#716](https://github.com/Microsoft/msphpsql/issues/716) - With Always Encrypted enabled, named parameters in subqueries are not supported
- Issue [#1050](https://github.com/microsoft/msphpsql/issues/1050) - With Always Encrypted enabled, insertion requires the column list for any tables with identity columns
- [Always Encrypted limitations](https://docs.microsoft.com/sql/connect/php/using-always-encrypted-php-drivers#limitations-of-the-php-drivers-when-using-always-encrypted)
### Known Issues
- This release requires ODBC Driver 17.4.2 or above. Otherwise, a warning about failing to set an attribute may be suppressed when using an older ODBC driver.
- Connection pooling on Linux or macOS is not recommended with [unixODBC](http://www.unixodbc.org/) < 2.3.7
- When pooling is enabled in Linux or macOS
- unixODBC <= 2.3.4 (Linux and macOS) might not return proper diagnostic information, such as error messages, warnings and informative messages
- due to this unixODBC bug, fetch large data (such as xml, binary) as streams as a workaround. See the examples [here](https://github.com/Microsoft/msphpsql/wiki/Features#pooling)
## 5.10.1 - 2022-05-12
Updated PECL release packages. Here is the list of updates:

Просмотреть файл

@ -4,13 +4,13 @@
The [Microsoft Drivers for PHP for Microsoft SQL Server][phpdoc] are PHP extensions that allow for the reading and writing of SQL Server data from within PHP scripts. The SQLSRV extension provides a procedural interface while the PDO_SQLSRV extension implements PHP Data Objects (PDO) for accessing data in all editions of SQL Server 2012 and later (including Azure SQL DB). These drivers rely on the [Microsoft ODBC Driver for SQL Server][odbcdoc] to handle the low-level communication with SQL Server.
This release contains the SQLSRV and PDO_SQLSRV drivers for PHP 7.3+ with improvements on both drivers and some limitations. Upcoming [releases][releases] will contain additional functionalities, bug fixes, and more.
This release contains the SQLSRV and PDO_SQLSRV drivers for PHP 8.0+ with improvements on both drivers and some limitations. Upcoming [releases][releases] will contain additional functionalities, bug fixes, and more.
## Take our survey
Thank you for taking the time to participate in the [sentiment survey](https://github.com/microsoft/msphpsql/wiki/Survey-Results). You can continue to help us improve by letting us know how we are doing and how you use [PHP][phpweb]:
<a href="https://aka.ms/mssqlphpsurvey"><img style="float: right;" height="67" width="156" src="https://sqlchoice.blob.core.windows.net/sqlchoice/static/images/survey.png"></a>
[**Click here to start the PHP survey**](https://aka.ms/mssqlphpsurvey)
### Status of Most Recent Builds
| Azure Pipelines (Linux) | AppVeyor (Windows) | Coverage (Windows) |
@ -37,8 +37,8 @@ Please follow the [Getting started](https://docs.microsoft.com/sql/connect/php/g
For full details on the system requirements for the drivers, see the [system requirements](https://docs.microsoft.com/sql/connect/php/system-requirements-for-the-php-sql-driver) on Microsoft Docs.
On the client machine:
- 7.4.x, 8.0.x, 8.1.x
- [Microsoft ODBC Driver 17 or Microsoft ODBC Driver 13][odbcdoc]
- 8.0.x, 8.1.x, 8.2.x
- [Microsoft ODBC Driver 18, 17 or 13][odbcdoc]
- If using a Web server such as Internet Information Services (IIS) or Apache, it must be configured to run PHP
On the server side, Microsoft SQL Server 2012 and above on Windows are supported, as are Microsoft SQL Server 2016 and above on Linux.
@ -47,7 +47,7 @@ On the server side, Microsoft SQL Server 2012 and above on Windows are supported
The drivers are distributed as pre-compiled extensions for PHP found on the [releases page][releases]. They are available in thread-safe and non-thread-safe versions, and in 32-bit (Windows only) and 64-bit versions. The source code for the drivers is also available, and you can compile them as thread safe or non-thread-safe versions. The thread safety configuration of your web server will determine which version you need.
If you choose to build the drivers, you must be able to build PHP 7.* or 8.* without including these extensions. For help building PHP on Windows, see the [official PHP website][phpbuild]. For details on compiling the drivers, see the [documentation](https://github.com/microsoft/msphpsql/blob/master/buildscripts/README.md) -- an example buildscript is provided, but you can also compile the drivers manually.
If you choose to build the drivers, you must be able to build PHP 8.* without including these extensions. For help building PHP on Windows, see the [official PHP website][phpbuild]. For details on compiling the drivers, see the [documentation](https://github.com/microsoft/msphpsql/blob/master/buildscripts/README.md) -- an example buildscript is provided, but you can also compile the drivers manually.
To load the drivers, make sure that the driver is in your PHP extension directory and enable it in your PHP installation's php.ini file by adding `extension=php_sqlsrv.dll` and/or `extension=php_pdo_sqlsrv.dll` to the ini file. If necessary, specify the extension directory using `extension_dir`, for example: `extension_dir = "C:\PHP\ext"`. Note that the precompiled binaries have different names -- substitute accordingly in php.ini. For more details on loading the drivers, see [Loading the PHP SQL Driver](https://docs.microsoft.com/sql/connect/php/loading-the-php-sql-driver) on Microsoft Docs.

Просмотреть файл

@ -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 --enable-ctype' + cmd_line
if self.thread == 'nts':
cmd_line = cmd_line + ' --disable-zts'
return cmd_line

Просмотреть файл

@ -4,7 +4,7 @@ dnl
dnl Contents: the code that will go into the configure script, indicating options,
dnl external libraries and includes, and what source files are to be compiled.
dnl
dnl Microsoft Drivers 5.10 for PHP for SQL Server
dnl Microsoft Drivers 5.11 for PHP for SQL Server
dnl Copyright(c) Microsoft Corporation
dnl All rights reserved.
dnl MIT License

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -3,7 +3,7 @@
//
// Contents: Result sets
//
// Microsoft Drivers 5.10 for PHP for SQL Server
// Microsoft Drivers 5.11 for PHP for SQL Server
// Copyright(c) Microsoft Corporation
// All rights reserved.
// MIT License

Просмотреть файл

@ -6,7 +6,7 @@
//
// Contents: Core routines and constants shared by the Microsoft Drivers for PHP for SQL Server
//
// Microsoft Drivers 5.10 for PHP for SQL Server
// Microsoft Drivers 5.11 for PHP for SQL Server
// Copyright(c) Microsoft Corporation
// All rights reserved.
// MIT License

Просмотреть файл

@ -3,7 +3,7 @@
//
// Contents: Core routines that use statement handles shared between sqlsrv and pdo_sqlsrv
//
// Microsoft Drivers 5.10 for PHP for SQL Server
// Microsoft Drivers 5.11 for PHP for SQL Server
// Copyright(c) Microsoft Corporation
// All rights reserved.
// MIT License
@ -414,10 +414,23 @@ 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 {
if (param_ptr->column_size == SQLSRV_UNKNOWN_SIZE) {
param_ptr->column_size = SQL_SERVER_MAX_FIELD_SIZE / char_size;
}
}
}
}
@ -2272,18 +2285,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;
}

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -4,7 +4,7 @@
// File: version.h
// Contents: Version number constants
//
// Microsoft Drivers 5.10 for PHP for SQL Server
// Microsoft Drivers 5.11 for PHP for SQL Server
// Copyright(c) Microsoft Corporation
// All rights reserved.
// MIT License
@ -26,8 +26,8 @@
// Increase Minor with backward compatible new functionalities and API changes.
// Increase Patch for backward compatible fixes.
#define SQLVERSION_MAJOR 5
#define SQLVERSION_MINOR 10
#define SQLVERSION_PATCH 1
#define SQLVERSION_MINOR 11
#define SQLVERSION_PATCH 0
#define SQLVERSION_BUILD 0
// For previews, set this constant to 1, 2 and so on. Otherwise, set it to 0
@ -59,7 +59,7 @@
#define _FILEVERSION SQLVERSION_MAJOR,SQLVERSION_MINOR,SQLVERSION_PATCH,SQLVERSION_BUILD
// PECL package version ('-' or '+' is not allowed) - to support Pickle do not use macros below
#define PHP_SQLSRV_VERSION "5.10.1"
#define PHP_PDO_SQLSRV_VERSION "5.10.1"
#define PHP_SQLSRV_VERSION "5.11.0beta1"
#define PHP_PDO_SQLSRV_VERSION "5.11.0beta1"
#endif // VERSION_H

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -4,7 +4,7 @@ dnl
dnl Contents: the code that will go into the configure script, indicating options,
dnl external libraries and includes, and what source files are to be compiled.
dnl
dnl Microsoft Drivers 5.10 for PHP for SQL Server
dnl Microsoft Drivers 5.11 for PHP for SQL Server
dnl Copyright(c) Microsoft Corporation
dnl All rights reserved.
dnl MIT License

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -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,

Просмотреть файл

@ -7,7 +7,7 @@
Common functions (shared by all tests).
*/
error_reporting( ~E_DEPRECATED );
$tvpIncPath = dirname(__FILE__).DIRECTORY_SEPARATOR.'..'.DIRECTORY_SEPARATOR.'inc'.DIRECTORY_SEPARATOR;
require_once($tvpIncPath. 'test_tvp_data.php');
@ -1840,4 +1840,4 @@ function compareResourceToInput($actual, $expected)
}
return $matched;
}
}

Просмотреть файл

@ -59,6 +59,7 @@ function ExecStmt()
EndTest($testName);
}
#[AllowDynamicProperties]
class Test
{
function __construct($name = 'N/A')

Просмотреть файл

@ -48,6 +48,7 @@ function FetchMode()
EndTest($testName);
}
#[AllowDynamicProperties]
class Test
{
function __construct($name = 'N/A')

Просмотреть файл

@ -72,6 +72,7 @@ function FetchAll()
EndTest($testName);
}
#[AllowDynamicProperties]
class Test1
{
public function __construct()
@ -80,6 +81,7 @@ class Test1
}
}
#[AllowDynamicProperties]
class Test2
{
public function __construct()
@ -88,6 +90,7 @@ class Test2
}
}
#[AllowDynamicProperties]
class Test3
{
public function __construct()

Просмотреть файл

@ -64,6 +64,7 @@ function FetchAll()
EndTest($testName);
}
#[AllowDynamicProperties]
class DerivedStatement extends PDOStatement
{
private function __construct($name, $conn)
@ -78,6 +79,7 @@ class DerivedStatement extends PDOStatement
}
}
#[AllowDynamicProperties]
class Test1
{
public function __construct($id, $val)

Просмотреть файл

@ -10,6 +10,7 @@ PHPT_EXEC=true
<?php
include 'MsCommon.inc';
#[AllowDynamicProperties]
class TestClass
{
private $set_calls = 0;

Просмотреть файл

@ -48,6 +48,7 @@ function Extend()
EndTest($testName);
}
#[AllowDynamicProperties]
class ExPDO extends PDO
{
public $test1 = 1;
@ -74,6 +75,7 @@ class ExPDO extends PDO
}
}
#[AllowDynamicProperties]
class ExPDOStatement extends PDOStatement
{
protected function __construct()

Просмотреть файл

@ -46,27 +46,31 @@ function Extend()
EndTest($testName);
}
#[AllowDynamicProperties]
class ExPDO extends PDO
{
public function __construct()
{
$this->protocol();
$args = func_get_args();
return (call_user_func_array(array($this, 'parent::__construct'), $args));
$callable = parent::class . '::__construct';
return (call_user_func_array($callable, $args));
}
public function exec(string $args1) : int|false
{
$this->protocol();
$args = func_get_args();
return (call_user_func_array(array($this, 'parent::exec'), $args));
$callable = parent::class . '::exec';
return (call_user_func_array($callable, $args));
}
function query(string $sql, ?int $fetchMode = null, mixed ...$fetchModeArgs): PDOStatement|false
{
$this->protocol();
$args = func_get_args();
return (call_user_func_array(array($this, 'parent::query'), $args));
$callable = parent::class . '::query';
return (call_user_func_array($callable, $args));
}
public function __call($method, $args)

Просмотреть файл

@ -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());
@ -82,10 +90,15 @@ function connectInvalidServerWithUser()
require_once('MsSetup.inc');
// Make a connection to an invalid server
// Expect to get two error messages
connectInvalidServer();
connectInvalidServerWithUser();
echo "Done\n";
?>
--EXPECT--
Failed to connect
SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [53].
Failed to connect
SQLSTATE[08001]: [Microsoft][ODBC Driver 17 for SQL Server]Named Pipes Provider: Could not open a connection to SQL Server [53].
Done

Просмотреть файл

@ -22,7 +22,6 @@ $conn = null;
testValidValues();
testInvalidValues();
testEncryptedWithODBC();
testWrongODBC();
echo "Done" . PHP_EOL;
// end test
@ -118,17 +117,6 @@ function testEncryptedWithODBC()
connectVerifyOutput($connectionOptions, "Using ODBC 13 for AE", $expected);
}
function testWrongODBC()
{
global $msodbcsqlMaj;
$value = "ODBC Driver 18 for SQL Server";
$connectionOptions = "Driver = $value;";
$expected = "The specified ODBC Driver is not found.";
connectVerifyOutput($connectionOptions, "Connect with ODBC 18", $expected);
}
?>
--EXPECT--
Done

Просмотреть файл

@ -8,6 +8,8 @@ This test should not use temporary table as it might occasionally cause deadlock
<?php
include 'MsCommon.inc';
#[AllowDynamicProperties]
class PdoTestClass
{
function __construct ()
@ -16,6 +18,7 @@ class PdoTestClass
}
}
#[AllowDynamicProperties]
class PdoTestClass2
{
function __construct ($a1, $a2)

Просмотреть файл

@ -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"\]=>

Просмотреть файл

@ -8,6 +8,7 @@ ORDER BY should work with sql_variants
<?php
require_once("MsCommon_mid-refactor.inc");
#[AllowDynamicProperties]
class Food
{
public function getFood()

Просмотреть файл

@ -24,6 +24,6 @@ if ($c !== false) {
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\]\. |TCP Provider: Error code (0x2726|0x2AF9)|Login timeout expired|Login failed for user 'sa'\.) in .+(\/|\\)pdo_utf8_conn\.php:[0-9]+
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'|Object\(SensitiveParameterValue\))\))
#1 {main}
thrown in .+(\/|\\)pdo_utf8_conn\.php on line [0-9]+

Просмотреть файл

@ -0,0 +1,4 @@
<?php
if (getenv('APPVEYOR')) {
die("skip Appveyor pipeline");
}

Просмотреть файл

@ -12,6 +12,7 @@ require('skipif_versions_old.inc');
<?php
require_once('MsCommon.inc');
#[AllowDynamicProperties]
class TestClass
{
public function __construct($a1, $a2, $a3)

Просмотреть файл

@ -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\"\]=>

Просмотреть файл

@ -20,7 +20,6 @@ sqlsrv_close($conn);
testValidValues($msodbcsqlMaj, $server, $connectionOptions);
testInvalidValues($msodbcsqlMaj, $server, $connectionOptions);
testEncryptedWithODBC($msodbcsqlMaj, $server, $connectionOptions);
testWrongODBC($msodbcsqlMaj, $server, $connectionOptions);
echo "Done\n";
// end test
@ -115,15 +114,6 @@ function testEncryptedWithODBC($msodbcsqlMaj, $server, $connectionOptions)
connectVerifyOutput($server, $connectionOptions, "Using ODBC 13 for AE", $expected);
}
function testWrongODBC($msodbcsqlMaj, $server, $connectionOptions)
{
$value = "ODBC Driver 18 for SQL Server";
$connectionOptions['Driver']=$value;
$expected = "The specified ODBC Driver is not found.";
connectVerifyOutput($server, $connectionOptions, "Connect with ODBC 18", $expected);
}
?>
--EXPECT--
Done

Просмотреть файл

@ -61,7 +61,7 @@ function isDataClassSupported($conn, &$driverCapable)
// ODBC Driver must be 17.2 or above
$driverCapable = true;
if ($version[0] < 17 || $version[1] < 2) {
if ($version[0] < 17 || ($version[0] == 17 && $version[1] < 2)) {
$driverCapable = false;
return false;
}

Просмотреть файл

@ -63,7 +63,7 @@ function isDataClassSupported($conn, &$driverCapable)
// ODBC Driver must be 17.2 or above
$driverCapable = true;
if ($version[0] < 17 || $version[1] < 2) {
if ($version[0] < 17 || ($version[0] == 17 && $version[1] < 2)) {
$driverCapable = false;
return false;
}

Просмотреть файл

@ -5,6 +5,7 @@ Test for fetch_object
--FILE--
<?php
#[AllowDynamicProperties]
class foo
{
public $stuff = "stuff";
@ -25,6 +26,7 @@ class foo
}
}
#[AllowDynamicProperties]
class foo_noargs
{
public $stuff = "stuff";

Просмотреть файл

@ -5,6 +5,7 @@ Test for fetch_object
--FILE--
<?php
#[AllowDynamicProperties]
class foo
{
public $stuff = "stuff";
@ -25,6 +26,7 @@ class foo
}
}
#[AllowDynamicProperties]
class foo_noargs
{
public $stuff = "stuff";

Просмотреть файл

@ -4,6 +4,7 @@ Test insert various data types and fetch as strings
<?php
require_once('MsCommon.inc');
#[AllowDynamicProperties]
class TestClass2
{
public function __construct($a1, $a2)
@ -12,6 +13,7 @@ class TestClass2
}
}
#[AllowDynamicProperties]
class TestClass3
{
public function __construct($a1, $a2, $a3)

Просмотреть файл

@ -5,6 +5,7 @@ Test for fetch_object with Unicode column name
--FILE--
<?php
#[AllowDynamicProperties]
class foo
{
public $stuff = "stuff";
@ -25,6 +26,7 @@ class foo
}
}
#[AllowDynamicProperties]
class foo_noargs
{
public $stuff = "stuff";

Просмотреть файл

@ -6,6 +6,7 @@ sqlsrv_fetch_object() into a class with Unicode column name
<?php
// Define the Product class
#[AllowDynamicProperties]
class Product
{
public function __construct($ID, $UID)
@ -37,6 +38,7 @@ class Product
}
}
#[AllowDynamicProperties]
class Sample extends Product
{
public function __construct($ID)

Просмотреть файл

@ -4,6 +4,8 @@ Send a large amount (10MB) using encryption. In a Linux CI environment use a sma
<?php require('skipif_azure_dw.inc'); ?>
--FILE--
<?php
#[AllowDynamicProperties]
class my_stream
{
public $total_read = 0;