Opened 8 years ago

Closed 3 years ago

#5401 closed defect (wontfix)

MSSQLSpatial driver incorrectly identifies tables with the same name but different schema as the same table

Reported by: plectrum20 Owned by: tamas
Priority: normal Milestone: closed_because_of_github_migration
Component: OGR_SF Version: 1.10.1
Severity: normal Keywords:


The MSSQLSpatial driver seems ignores the schema when checking to see if a table exists and when dropping what it thinks is an existing table.

For example, I'm trying to import a layer "Countries" into schema "schema1". There is a table already in the database "dbo.Countries" with a spatial column. When I run the query with overwrites, this existing table gets deleted and schema1.Countries is created. If overwrites are off, schema1.Counties is not imported. If I have two objects in the database already called "Countries" with different schema "dbo" and "schema2", one of them is deleted when I try to import a new object.

I have resorted to creating a new database (rather than schemas) for each mapping source I want to import from so nothing existing is over written and everything gets imported.

Change History (7)

comment:1 Changed 8 years ago by Even Rouault

Component: defaultOGR_SF
Owner: changed from warmerdam to tamas

comment:2 Changed 7 years ago by tamas

The "create spatial index" and "drop spatial index" statements don't work either with named schemas.

comment:3 Changed 7 years ago by tamas

Fixed in trunk (r27342)

comment:4 Changed 7 years ago by tamas

Fixed in branch-1.11 (r27344)

comment:5 Changed 7 years ago by tamas

Resolution: fixed
Status: newclosed

comment:6 Changed 6 years ago by bvtho

Resolution: fixed
Status: closedreopened

I'll have to reopen this issue. If you execute the following commands:

ogr2ogr -overwrite -lco OVERWRITE=YES -lco SCHEMA="dbo" -nln "roads" -a_srs EPSG:25832 -f "MSSQLSpatial" MSSQL:"server=s-gis;database=test;trusted_connection=yes"  "T:\GIS\"
ogr2ogr -overwrite -lco OVERWRITE=YES -lco SCHEMA="winter" -nln "roads" -a_srs EPSG:25832 -f "MSSQLSpatial" MSSQL:"server=s-gis;database=test;trusted_connection=yes"  "T:\GIS\"

You would expect that 2 tables in the database "test" on server "s-gis": "roads" in schema "dbo" and "roads" in schema "winter" would be created (or overwrited). However after the commands there is only one table in the database: "roads" in schema "winter".

If you however reverse the order of the commands, it behaves as expected; there is two tables in the database.

If you only execute the first command, it will create a table "roads" in "dbo" .

The commands is tested on GDAL trunk from the gisinternals site, build date 2015-11-02

comment:7 Changed 3 years ago by Even Rouault

Milestone: closed_because_of_github_migration
Resolution: wontfix
Status: reopenedclosed

This ticket has been automatically closed because Trac is no longer used for GDAL bug tracking, since the project has migrated to GitHub?. If you believe this ticket is still valid, you may file it to if it is not already reported there.

Note: See TracTickets for help on using tickets.