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

select ntext and SET TEXTSIZE and SQLSRV_ATTR_DIRECT_QUERY php fatal error Invalid sql_display_size #1170

Closed
gjcarrette opened this issue Aug 5, 2020 · 4 comments

Comments

@gjcarrette
Copy link
Contributor

gjcarrette commented Aug 5, 2020

PHP Driver version or file name

php-sqlsrv-5.8.0

SQL Server version

Microsoft SQL Server 2016 (SP2) (KB4052908) - 13.0.5026.0

Client operating system

CentOS Linux release 7.6.1810 (Core). Linux 3.10.0-957.12.1.el7.x86_64 x86_64 GNU/Linux

PHP version

PHP 7.4.3 (cli) (built: Feb 27 2020 15:30:56) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
with Xdebug v2.9.6, Copyright (c) 2002-2020, by Derick Rethans
with ddtrace v0.46.0, Copyright Datadog, by Datado

Microsoft ODBC Driver version

msodbcsql17-17.4.1.1-1.x86_64

Table schema

DECLARE @t1 TABLE (C1 NVARCHAR(10), C2 NTEXT)

Problem description

If you use the prepared statement option SQLSRV_ATTR_DIRECT_QUERY = true, in addition to using SET TEXTSIZE away from the default -1, then you get a php fatal error Invalid sql_display_size

Expected behavior and actual behavior

Output should be one row from table, C1 = TEST1, C2 = NULL
You can get this output in the default settings of the attached program.
But with settings DB_OPTIONS=1 DB_SET_TEXTSIZE=1 you get
PHP Fatal error: Invalid sql_display_size

Repro code or steps to reproduce

You need to pass the database connection credentials to the attached php program using environment variables. To reproduce the error

env DB_SERVER=localhost DB_NAME=master DB_USER=user1 DB_PASS=pass1 DB_OPTIONS=1 DB_SET_TEXTSIZE=1 php error.php

But either of these combinations will produce correct output

env DB_SERVER=localhost DB_NAME=master DB_USER=user1 DB_PASS=pass1 DB_OPTIONS=0 DB_SET_TEXTSIZE=1 php error.php

env DB_SERVER=localhost DB_NAME=master DB_USER=user1 DB_PASS=pass1 DB_OPTIONS=1 DB_SET_TEXTSIZE=0 php error.php

error-program.zip

@yitam
Copy link
Contributor

yitam commented Aug 5, 2020

Thanks @gjcarrette for the report. We will investigate and get back to you.

@yitam
Copy link
Contributor

yitam commented Aug 6, 2020

Hi @gjcarrette the bug has been fixed and merged. You can test it with the next preview release.

@yitam
Copy link
Contributor

yitam commented Oct 6, 2020

Hi @gjcarrette, 5.9.0-preview1 is just released, which contains a fix to your issue. Please check.

@yitam
Copy link
Contributor

yitam commented Oct 14, 2020

Closing this issue @gjcarrette. Please feel free to reopen if necessary.

@yitam yitam closed this as completed Oct 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants