Ticket #3994 (closed defect: fixed)

Opened 3 years ago

Last modified 3 years ago

osm2pgsql can't create gist index on PostGIS 2.0 geometry columns

Reported by: lr1234567 Owned by: jburgess777@…
Priority: major Milestone:
Component: osm2pgsql Version:
Keywords: Cc:

Description

In PostGIS 2.0 both 2D indexes and 3D indexes are supported and system defaults to creating 2D index. As such the gist ops names have changed.

osm2pgsql seems to hard-code the ops in output-pgsql.c looking at latest revision (r26626) lines 1371-1374

 if (Options->tblsmain_index) {
            pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_index ON %s USING GIST (way GIST_GEOMETRY_OPS) TABLESPACE %s;\n", table->name, table->name, Options->tblsmain_index);
        } else {
            pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_index ON %s USING GIST (way GIST_GEOMETRY_OPS);\n", table->name, table->name);
        }

These should be changed to get rid of the GIST_GEOMETRY_OPS so that it works with both PostGIS 1.* and 2.0 series.

so change to:

 if (Options->tblsmain_index) {
            pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_index ON %s USING GIST (way) TABLESPACE %s;\n", table->name, table->name, Options->tblsmain_index);
        } else {
            pgsql_exec(sql_conn, PGRES_COMMAND_OK, "CREATE INDEX %s_index ON %s USING GIST (way);\n", table->name, table->name);
        }

Thanks, Regina Obe

Change History

comment:1 Changed 3 years ago by amm

  • Status changed from new to closed
  • Resolution set to fixed

Thank you for the report. This should be fixed in revision r26659.

Note: See TracTickets for help on using tickets.