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

sqlsrv ClientBufferMaxKBSize is not honored when using client buffers #228

Closed
yitam opened this issue Jan 12, 2017 · 1 comment
Closed
Assignees
Projects

Comments

@yitam
Copy link
Contributor

yitam commented Jan 12, 2017

This happens only with SQLSRV in both Linux and Windows as long as there is a column of type varchar(max). Here are the steps to repro:

	$conn = sqlsrv_connect($server, array('UID'=>$uid, 'PWD'=>$pwd, 'Database'=>$database));	
	$stmt = sqlsrv_query($conn, "CREATE TABLE [php_test_table_1] ([c1_int] int, [c2_varchar_max] varchar(max))");	
	$stmt = sqlsrv_query($conn, "INSERT INTO [php_test_table_1] (c1_int, c2_varchar_max) VALUES (1, 'This is a test')");	
	
	$size = 0;	
	$stmt = sqlsrv_prepare($conn, "SELECT * FROM [php_test_table_1]", array(), array("Scrollable"=>"buffered"));
	sqlsrv_configure('ClientBufferMaxKBSize', $size);
	$attr = sqlsrv_get_config('ClientBufferMaxKBSize');	
	echo("ClientBufferMaxKBSize is $attr\n");

	sqlsrv_execute($stmt);	
	$rows = sqlsrv_has_rows($stmt);	
	var_dump($rows);

	$numRows1 = sqlsrv_num_rows($stmt);	
	echo("Number of rows: $numRows1\n");
	
	sqlsrv_execute($stmt);	
	$numRowsFetched = 0;
	while ($row = sqlsrv_fetch_array($stmt))
		$numRowsFetched++;
	echo("Number of rows fetched: $numRowsFetched\n");

If I change the column type to varchar(20) the problem is gone.

Actual output:

ClientBufferMaxKBSize is 0
bool(true)
Number of rows: 1
Number of rows fetched: 1

Expected output:

ClientBufferMaxKBSize is 0
bool(false)
Number of rows: 0
Number of rows fetched: 0
@v-dareck v-dareck self-assigned this Jan 24, 2017
@v-dareck
Copy link
Contributor

Fixed by PR #254.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
msphpsql
Completed
Development

No branches or pull requests

2 participants