Opened 13 years ago

Closed 13 years ago

#3654 closed defect (fixed)

Sql Server 2008 key column name truncation under 5.7-development

Reported by: panzel Owned by: tamas
Priority: high Milestone:
Component: Input - Native MS SQL Server Support Version: svn-trunk (development)
Severity: critical Keywords:
Cc:

Description

All,

It appears that the name of the key column, specified in a map file's DATA statement for use against a SQL Server 2008 database, is truncated by two characters. This problem does not appear in 5.6.3; it appears in the 5.7-DEV libraries and executables retrieved Friday January 7, 2011. Below I present the creation of a simple database table with one record, the map file for use against 5.6.3, then the same showing the error against 5.7-DEV, and finally the map file with two extra letters ("XX") added in the DATA statement and resultant success against 5.7-DEV. In all cases the "drawmap" utility was used to demonstrate the problem; to duplicate the problem you will need to adjust directory names and the database connection string to reflect your test environment.

  1. Creation of a test database with a single line:

create table T (keycol int identity, datacol geometry)

insert into T (datacol) values (geometry::STGeomFromText(

'LINESTRING (10 10, 20 10, 20 20, 10 20, 15 15)', 0));

  1. A map file for 5.6:

MAP # file m_56.map

imagetype jpeg status on size 500 500 extent 0 0 30 30 layer

status on connectiontype plugin plugin 'C:\ms4w\Apache\specialplugins\msplugin_mssql2008.dll' connection 'server=.\mssqlserve08R;database=test;Integrated Security=true'

data 'datacol from T using unique keycol using SRID=0'

type line class style color 0 255 0 width 2 end end

end

END

  1. Run under 5.6.3's drawmap

set path=C:\ms4w\Apache\cgi-bin;C:\ms4w\Apache\cgi-bin\mapscript\csharp;%oldpath% set drawmap=C:\ms4w\Apache\cgi-bin\mapscript\csharp\drawmap.exe

%drawmap% m_56.map m_56.jpg

# Map layers 1; Map name = MS Layer [0] name: Image URL = ; Image path = Image height = 500; width = 500

...the JPEG file is created

  1. The Map file modified for 5.7DEV by pointing to a different plugin:

MAP # file m_57_a.map Only the plugin has been changed

imagetype jpeg status on size 500 500 extent 0 0 30 30 layer

status on connectiontype plugin plugin 'C:\SVN\BAF\External\MapServer\Library-5.7.DEV-x32\msplugin_mssql2008.dll' connection 'server=.\mssqlserve08R;database=test;Integrated Security=true'

data 'datacol from T using unique keycol using SRID=0'

type line class style color 0 255 0 width 2 end end

end

END

  1. Executing against 5.7:

set path=C:\SVN\BAF\External\MapServer\Distribution-5.7.DEV-x32\bin;%oldpath% set drawmap=C:\SVN\BAF\External\MapServer\Distribution-5.7.DEV-x32\bin\ms\csharp\drawmap.exe

%drawmap% m_57_a.map m_57_a.jpg

# Map layers 1; Map name = MS Layer [0] name:

Unhandled Exception: System.ApplicationException: msDrawMap(): Image handling er ror. Failed to draw layer named '(null)'.;msMSSQL2008LayerGetShape(): Query erro

  1. Error executing MSSQL2008 SQL statement: SELECT datacol.STAsBinary(),convert(

varchar(20), keyc) from T WHERE datacol.STIntersects(geometry::STGeomFromText('P OLYGON((0 0,30 0,30 30,0 30,0 0))',0)) = 1 -[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'keyc'.

at OSGeo.MapServer.mapObj.draw() at DrawMap.Main(String[] args)

...no JPEG file is created

  1. The map file modified by adding an "XX" to the key column name in the mapfile:

MAP # file m_57_b.map plugin for 5.7, dummy "XX" in column name.

imagetype jpeg status on size 500 500 extent 0 0 30 30 layer

status on connectiontype plugin plugin 'C:\SVN\BAF\External\MapServer\Library-5.7.DEV-x32\msplugin_mssql2008.dll' connection 'server=.\mssqlserve08R;database=test;Integrated Security=true'

data 'datacol from T using unique keycolXX using SRID=0'

type line class style color 0 255 0 width 2 end end

end

END

  1. Executed against 5.7 with dummy XX in column name:

set path=C:\SVN\BAF\External\MapServer\Distribution-5.7.DEV-x32\bin;%oldpath% set drawmap=C:\SVN\BAF\External\MapServer\Distribution-5.7.DEV-x32\bin\ms\csharp\drawmap.exe

%drawmap% m_57_b.map m_57_b.jpg

# Map layers 1; Map name = MS Layer [0] name: Image URL = ; Image path = Image height = 500; width = 500

...the JPEG file is created

Change History (2)

comment:1 by tamas, 13 years ago

Owner: changed from hobu to tamas

comment:2 by tamas, 13 years ago

Resolution: fixed
Status: newclosed

Fixed in trunk r11066

Note: See TracTickets for help on using tickets.