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

MSSQL Driver no longer returns correct attributes #5702

Closed
geographika opened this Issue Nov 9, 2018 · 5 comments

Comments

Projects
None yet
2 participants
@geographika
Copy link
Member

geographika commented Nov 9, 2018

As noted in the comments here any non-string fields in a layer using the msplugin_mssql2008.dll plugin are returned as nulls or garbage when accessing via a WFS (string fields appear to be fine).

This is the same using either "gml_types" "auto" or manually setting the types.
Caused by the updates in #5602 - I rolled back the mapmssql2008.c to prior to this pull request and everything works fine again in 7.2.

It is also the case when using MapScript and trying to get a shapeObj attribute - they appear empty in the most recent version.

Not sure how best to make a test case as it requires a MSSQL database. I may try to see if this is something that can be easily added to Appveyor.

@geographika

This comment has been minimized.

Copy link
Member Author

geographika commented Nov 9, 2018

From debugging there are the following debug errors in the logs:

SQLError: [Microsoft][ODBC SQL Server Driver]Numeric value out of range

These are caused on line 1813 in mapmssql2008.c:

rc = SQLGetData(layerinfo->conn->hstmt, (SQLUSMALLINT)(t + 1), SQL_C_BINARY, dummyBuffer, 0, &needLen);

I though it may be a data issue, but this is also caused on a very simple table such as:

CREATE TABLE [dbo].[temp](
	[fid] [int] NULL,
	[name] [nvarchar](max) NULL,
	[geom] [geometry] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

@szekerest szekerest self-assigned this Nov 9, 2018

@szekerest

This comment has been minimized.

Copy link
Member

szekerest commented Nov 9, 2018

I think a sample sql script (to create the table with some contents) and the corresponding mapfile would be helpful to reproduce this

@geographika

This comment has been minimized.

Copy link
Member Author

geographika commented Nov 9, 2018

Hi @szekerest - I have created a sample Mapfile and SQL to recreate the issue in a repository at https://github.com/geographika/mapserver-mssql-test/

The output2.xml shows the issue - no integer values are returned. The 7.0 release works fine, but I can't see any recent updates that would cause it.

My sql.h file when debugging is in C:\Program Files (x86)\Windows Kits\10\Include\10.0.17134.0\um - so maybe there is some Windows ODBC driver issue if you can't recreate locally?

@szekerest

This comment has been minimized.

Copy link
Member

szekerest commented Dec 9, 2018

@geographika This problem was hopefully fixed by the recent commit.

@geographika

This comment has been minimized.

Copy link
Member Author

geographika commented Dec 10, 2018

@szekerest - many thanks for that. I've recompiled and tested and all is now fine. As I understand it the if clause is there to use ASCII strings (varchar) when ICONV support is not present, and to use Unicode strings (nvarchar) when it is.

In the original update there was a comment no conversion applied at the database, was the intention to avoid converting all values to strings in the first place? I thought this would be useful for then accessing shape values in native types, but it appears all shapeObj attributes in MapServer are always stored as strings?

EduardoCastanho added a commit to EduardoCastanho/mapserver that referenced this issue Jan 16, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.