I am beginning the upgrade of our application to MapSuite 6.0. When calling winformsMap1.Refresh() I am getting this error from SQL Server:
The query processor could not produce a query plan for a query with a spatial index hint. Reason: Could not find required comparison predicate. Try removing the index hints or removing SET FORCEPLAN.
When I run the current version of the application (using MapSuite 4.5) I do not get this error. This computer is Windows 7, running SQL Server 2008 R2 Developer edition.
To repeat: I am converting code that uses MapSuite 4.5 to 6.0. This code has been running at customer locations for almost a year.
We have a class that creates a MapSuite Overlay from an XML document. This XML document defines all the tables, styling info, etc. When I test this with MapSuite 6.0, it works.
We have a user component that encapsulates WinFormsMap functionality so that map operations are done in the component on behalf of the application rather than by the application talking directly to MapSuite. When the test program for this component loads a map, it loads the overlay described above (all of data from it is coming from SQL Server) plus creates new overlays with InMemoryLayers and MsSql2008FeatureLayers fortesting various application functions. This is the application that fails on Refresh(). So it seems to me that something that’s being added to the map in this test program that our overlay creation class doesn’t do is what’s causing the error. I am hopeful I can comment out code and isolate where the problematic code is. Again, this EXACT CODE works (and has worked for almost 1-1/2 years) under MapSuite 4.5 but does not work under MapSuite 6.0. Something in the back of my brain is telling me the problem is with an empty layer not playing nicely with some change that has been made between MapSuite 4.5 and 6.0 with how it interacts with SQL Server.
Also, I took the code using MapSuite 6.0 to my old Windows XP computer, which is running SQL Server 2008 R2 Express, and the MapSuite 6.0 update still fails, so it is not the SQL Server 2008 R2 Developer edition on my new computer. That eliminates operating system and SQL Server version variables.
In the past there have been a number of others out there using MapSuite and SQL Server…I wonder if they’re still around and have upgraded as well.
Ok, I’ve narrowed this down to a single line of code.
After I use the overlay class to load the tables from SQL Server, I create a new Overlay for layers that will store features that the user can edit. This second overlay contains two MsSql2008FeatureLayers and one MapShapeLayer. When the first SQL layer isn’t added to the overlay, the error does not occur, so I narrowed it down to one layer SQL layer. This first SQL layer also has a WHERECLAUSE defined. When the WHERECLAUSE is removed, the error doesn’t occur! When I put the WHERECLAUSE back in, the error comes back. So it looks like something has changed in MapSuite 6.0 where a WHERECLAUSE applied to an empty SQL layer causes this error when the map is refreshed.
This WHERECLAUSE filters the items in the layer based on a data range because the items in the layer (when loaded) can be expired based on a date in the table.
Great! I know in theory I can probably rework the query to get the “OR” out of the WHERECLAUSE but customers can create their own XML documents to style the map the way they want and to load custom data, and since we support the WHERECLAUSE in the XML for filtering purposes we probably can’t tell customers to not use “OR” in their statement! (Loading a SQL layer from their XML style file eventually translates to the same type of code where I came across this issue, so we are presuming they would encounter the error as well.)
This is part of a rather large application, but I’m going to guess creating an overlay and adding a single SQL layer with the proper WHERECLAUSE will duplicate the error.
Thanks for your information, we have recreated this problem and create an issue for this, once our product team find out the root cause and resolve the problem, I will post in the ticket to let you know.
It is SO GOOD to hear you were able to reproduce the issue that easily. It doesn’t always work that way! I look forward to getting it fixed and returning to my MapSuite 4.5 to 6.0 update.
In our algorithm, we’ll replace “where” with “And”, in where clause, so if the where clause cantains “or”, please add () to tnem, e.g. WHERE (1=1 OR 1=1).
Is this going to be considered a bug by ThinkGeo and eventually fixed or will the above be a "permanent workaround"? Someone else is bound to do the same thing sooner or later. Seems to me if you're already converting "WHERE" to "AND" it would be easy to strip off the "WHERE", enclose what's left in parenthesis, then tack on your "AND" to the front.
Once we think the problem was resolved, we will set the ticket status as Resolved, but you can add new comments any time and the status will automatically change to pending.
So for that ticket, please add any comments there and we will keep tracking that.