Opened 15 years ago
Closed 15 years ago
#3044 closed defect (invalid)
create index sql execute problem
Reported by: | yminpark | Owned by: | warmerdam |
---|---|---|---|
Priority: | normal | Milestone: | 1.6.2 |
Component: | default | Version: | 1.6.1 |
Severity: | normal | Keywords: | create, index, executeSQL |
Cc: |
Description
Hello.
I am using GDAL 1.6.1 and I think I met a bug about sql command("create index").
I want to create attribute index on a shapefile in VS2005, so I programmed as follows :
OGRDataSource* dataSource = _dataSources[index];
OGRLayer *resultSet = NULL;
string sql;
_fileNames[index] = "LP_PA_CBND" shapefile name
_indexFields[index] = "JIBUN" field in LP_PA_CBND.dbf
sql = "CREATE INDEX ON " + _fileNames[index] + " USING " + _indexFields[index];
resultSet = dataSource->ExecuteSQL(sql.c_str(), NULL, NULL);
if (resultSet != NULL) dataSource->ReleaseResultSet(resultSet)
SQL seems to be executed successfully - After executing the SQL, LP_PA_CBND.ind & LP_PA_CBND.idm is created.
But OGR produced errors, too.
ERROR 3: Invalid number of indexes (0) in file C:\GMSIIS\Data\Spatial\22\LP_PA_CBND.ind
ERROR 4: Failed to open index file C:\GMSIIS\Data\Spatial\22\LP_PA_CBND.ind.
So, I tested above SQL using ogr2ogr command again. Then, no error has occurred and index file is generated in valid.
ogr2ogr -sql "create index on lp_pa_cbnd using jibun" -f "ESRI Shapefile" blahblah LP_PA_CBND.shp
I examined LP_PA_CBND.ind file with hexa viewer, then I found some difference. (please see the attached image.)
ogr2ogr : 00 02 00 00 00 1A 00 04 0F (in 000030h)
ExecuteSQL() : 00 00 00 00 00 00 00 00 00 (in 000030h)
Using sql command in ogr2ogr is different with dataSource.ExecuteSQL()?
Thank you for reading my poor english.
Regards.
Attachments (1)
Change History (2)
by , 15 years ago
Attachment: | compare_ind.jpg added |
---|
comment:1 by , 15 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
I'm pretty sure you have not properly destroyed your datasource with OGRDataSource::Release().
I can reproduce the behaviour you see when I execute the following OGR Python snippet :