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

odbc can not receive data from mssql , after win10 update #148

Open
lingbl opened this issue Nov 18, 2022 · 12 comments
Open

odbc can not receive data from mssql , after win10 update #148

lingbl opened this issue Nov 18, 2022 · 12 comments

Comments

@lingbl
Copy link

lingbl commented Nov 18, 2022

lua 5.1 , luasql 2.6.0 , can not receive data from mssql , when win10 installed patch KB5019959.
win10 version: 19044.2251
no error message
data = cur:fetch({})

i have try to uninstall KB5019959, and luasql work again.
The problem is file c:\windows\SysWOW64\sqlsrv32.dll is updated by patch. when use old version dll file to replace , luasql work again

@lingbl lingbl changed the title win10 Patch KB5020613 odbc can not receive data from mssql , after win10 update Nov 20, 2022
@lingbl
Copy link
Author

lingbl commented Nov 22, 2022

I compile luasql in mysys2 mingw32, should I use visual studio ???

@lingbl
Copy link
Author

lingbl commented Nov 22, 2022

I replace float by varchar(20) in database, the luasql can work properly

https://learn.microsoft.com/en-us/answers/questions/1091666/kb5019959-sqlserver-instruction-isnullamount0-some.html

@lingbl
Copy link
Author

lingbl commented Nov 23, 2022

SQLcmd = "select Week from Production_2011 where Production_LOTNO = '20221123N7E'"

luaopen_luasql_odbc()...
create_metatables()...
create_environment()...
env_connect()...
create_connection()...
conn_execute()...
conn_prepare()...
desc_params()...
raw_execute()...
create_cursor()...
create_colinfo()...
sqltypetolua()... type:6
sqltypetolua(): number
cur_fetch()...
getcursor()...
SQLFetch()...
cur_fetch():num 1
cur_fetch():alpha 0
push_column()...
push_column(): nUmber
SQLGetData()...               /* FAIL AT HERE */
fail()...
fail():SQLGetDiagRec()...
fail(): [Microsoft][ODBC SQL Server Driver] Unknown token received from SQL Server
fail():SQLGetDiagRec()...
fail(): SQL_NO_DATA
cur_close()...
cur_shut()...
stmt_shut()...
free_stmt_params()...
stmt_close()...
conn_close()...
env_close()...

Exit code: 1

Anyone can help meeeeeeeeeeeee !

@lingbl
Copy link
Author

lingbl commented Nov 23, 2022

Use float instead of double, that too small !

/* deal with data according to type /
switch (type) {
/
nUmber */
case 'u': {
printf("push_column(): nUmber\n");
/*SQLDOUBLE num; */
float num;
SQLLEN got;

		printf("SQLGetData()...\n");
		/*SQLRETURN rc = SQLGetData(hstmt, i, SQL_C_DOUBLE, &num, 0, &got);*/
		SQLRETURN rc = SQLGetData(hstmt, i, SQL_C_FLOAT, &num, 0, &got);

		if (error(rc))
			return fail(L, hSTMT, hstmt);

		if (got == SQL_NULL_DATA)
			lua_pushnil(L);
		else
			lua_pushnumber(L, num);
		printf("push_column(): num: %f \n", num);
		return 0;
	}

@tomasguisasola
Copy link
Contributor

Hi lingbl

I don't have a Windows machine nor the SQL Server to test it, sorry.

I didn't understand why you replaced a double by a float -- or did I misunderstood you attempt above? A double is bigger than a float...

Did you try to print out the value of variable 'tname'? Maybe there is another type not foreseen...

Regards,
Tomás

@lingbl
Copy link
Author

lingbl commented Nov 24, 2022

the luasql can get data "Week" correctly , when use SQL_C_FLOAT , by the way this is not my idea
https://stackoverflow.com/questions/74447805/sqlgetdata-doesnt-work-in-the-same-way-after-install-kb5019959
https://stackoverflow.com/questions/74451813/unknown-token-received-from-sql-server-error-just-started-happening-on-windows?r=SearchResults&s=3%7C21.8408

The data "Week" store in MSSQL as "float" type . The bug is: all "float" type data in MSSQL can not recieve by luasql.

@tomasguisasola
Copy link
Contributor

Hi lingbl

This problem with float X double does not seem to be a bug in LuaSQL, but in MSSQL, don't you agree? The documentation assure all C types must be supported:

https://learn.microsoft.com/en-us/sql/odbc/reference/appendixes/c-data-types?view=sql-server-ver16

Anyway, it is obvious that we can change the type of variable num from double to float, but will that change produce other incompatibilities?

Regards,
Tomás

@lingbl
Copy link
Author

lingbl commented Nov 24, 2022

Thank you Tomás !! , If this is a bug from patch, I will wait next patch to fix it.
Change "float" type to "numeric(18, 6)" in MSSQL may be a way to skip this bug.

@lingbl
Copy link
Author

lingbl commented Nov 25, 2022

Install microsoft odbc driver , and reset DSN.

@lingbl
Copy link
Author

lingbl commented Nov 26, 2022

@syslog-dw
Copy link

We are experiencing the same issue in production. Will report back if updating the ODBC driver on the client side helps or if another solution (other than rolling back the Windows update) is found.

@syslog-dw
Copy link

As far as I'm concerned, updating the MSSQL ODBC Driver on the client fixes or works around this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants