Skip to content

Fetching binary data with binary encoding caused assertion in Linux #226

@yitam

Description

@yitam

Using the pdo_sqlsrv driver, when fetching some data from a binary column using the binary encoding, it caused assertion in Linux (tested in Ubuntu 16.04 for both PHP 7.0.x and PHP 7.1.0).

This is the repro script:

	$inValue1 = "zăǽβ񏳿"; 
	$mspdo1 = new PDO("sqlsrv:Server=$server;Database=$database;TraceOn=false", $uid, $pwd);	
	$stmt = $mspdo1->query("CREATE TABLE [php_test_table_1] ([c1_int] int, [c2_binary] binary(15))");	
	$stmt = $mspdo1->prepare("INSERT INTO [php_test_table_1] (c1_int, c2_binary) VALUES (:var1, :var2)");	
	$stmt->setAttribute(constant('PDO::SQLSRV_ATTR_ENCODING'), PDO::SQLSRV_ENCODING_BINARY);	
	$stmt->bindParam(2, $inValue1);	
	$stmt->bindValue(1, 1);	
	$stmt->execute();	
	$stmt = $mspdo1->prepare("SELECT * FROM [php_test_table_1]");	
	$stmt->setAttribute(constant('PDO::SQLSRV_ATTR_ENCODING'), PDO::SQLSRV_ENCODING_BINARY);	
	$stmt->execute();	
	$row = $stmt->fetch();	
	$outValue1 = $row[1];	
	var_dump($outValue1);

Expected output:

string(15) "zăǽβ񏳿   "

Actual output:

php: .../php-sdk/php-7.1.0/pdo_sqlsrv/shared/localizationimpl.cpp:43: static int cp_iconv::GetIndex(UINT): Assertion `false' failed.
Aborted (core dumped)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions