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

GetFeature requests broken with MSSQL Driver #5172

Closed
geographika opened this issue Sep 21, 2015 · 3 comments
Closed

GetFeature requests broken with MSSQL Driver #5172

geographika opened this issue Sep 21, 2015 · 3 comments

Comments

@geographika
Copy link
Member

I have updated my system to using MS7 (with a dev build from http://www.gisinternals.com).

WMS layers are all working fine but all WFS layers are broken. Any GetFeature request returns the following:

Query error. msMSSQL2008LayerGetItems: tried to find the geometry column in the results from the database, but couldnt find it. Is it miss-capitialized? 'GEOM'

My layer configurations have not changed (and work fine in 6.4), and looking at SQL Profiler the initial query to get the column names runs successfully and returns a GEOM field.
I've looked at changes to https://github.com/mapserver/mapserver/blob/branch-7-0/mapmssql2008.c and can't see what would have changed to cause this error.

@geographika
Copy link
Member Author

From discussions with @szekerest

This issue appears to be a problem in the ODBC driver. Actually SQLDescribeCol returns only
the first character of the column names, that's why the geometry column cannot be identified. This is >probably due to a misinterpretation of the widechar strings as single byte strings somewhere in the >driver.

I'm not sure what is meant by ODBC driver - the underlying Windows ODBC driver, or the driver based on mapmssql2008.c.

All was working fine (and still is) in MapServer 6.4, so I'm not sure what has changed in version 7.

geographika added a commit to geographika/mapserver that referenced this issue Mar 8, 2016
@geographika
Copy link
Member Author

After getting the code to compile and setting up the debugger on Windows I was able to find the cause of this issue.

It appears there have been changes to the ODBC types since Windows 2003.

Some ODBC functions that were previously defined with SQLINTEGER and
SQLUINTEGER parameters have been changed where appropriate to use the new SQLLEN and
SQLULEN typedefs. These changes are listed in the next section, Function Declaration Changes.

https://msdn.microsoft.com/en-us/library/ms716287(v=vs.85).aspx

When debugging the following error was thrown just after the SQLDescribeCol function.

Run-Time Check Failure #2 - Stack around the variable 'columnSize' was corrupted.

Fixing the first type led to the next error:

debug_error

After changing all the SQLINTEGER and SQLUINTEGER to SQLLEN and SQLULEN respectively, the GetFeature requests worked again.

I have created a pull request at #5262

szekerest added a commit that referenced this issue Mar 9, 2016
Update to new ODBC types SQLLEN and SQLULEN to fix issue #5172
@szekerest
Copy link
Member

Thank you for tracking this issue down, I've tested and it could solve the problem indeed.

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

No branches or pull requests

2 participants