diff --git a/go/libraries/doltcore/schema/index_coll.go b/go/libraries/doltcore/schema/index_coll.go index ba6a798312..27229aa82a 100644 --- a/go/libraries/doltcore/schema/index_coll.go +++ b/go/libraries/doltcore/schema/index_coll.go @@ -16,20 +16,10 @@ package schema import ( "fmt" - "os" "sort" "strings" ) -// EnableSpatialIndex enables the creation and use of spatial indexes -var EnableSpatialIndex = false - -func init() { - if v := os.Getenv("DOLT_ENABLE_SPATIAL_INDEX"); v != "" { - EnableSpatialIndex = true - } -} - type IndexCollection interface { // AddIndex adds the given index, overwriting any current indexes with the same name or columns. // It does not perform any kind of checking, and is intended for schema modifications. @@ -184,9 +174,6 @@ func (ixc *indexCollectionImpl) AddIndexByColTags(indexName string, tags []uint6 // validateColumnIndexable returns an error if the column given cannot be used in an index func validateColumnIndexable(c Column) error { - if !EnableSpatialIndex && IsColSpatialType(c) { - return fmt.Errorf("cannot create an index over spatial type columns") - } return nil } diff --git a/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go b/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go index f52f8f21d4..86f1cd775b 100644 --- a/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go +++ b/go/libraries/doltcore/sqle/enginetest/dolt_engine_test.go @@ -343,25 +343,21 @@ func TestSpatialScriptsPrepared(t *testing.T) { func TestSpatialIndexScripts(t *testing.T) { skipOldFormat(t) - schema.EnableSpatialIndex = true enginetest.TestSpatialIndexScripts(t, newDoltHarness(t)) } func TestSpatialIndexScriptsPrepared(t *testing.T) { skipOldFormat(t) - schema.EnableSpatialIndex = true enginetest.TestSpatialIndexScriptsPrepared(t, newDoltHarness(t)) } func TestSpatialIndexPlans(t *testing.T) { skipOldFormat(t) - schema.EnableSpatialIndex = true enginetest.TestSpatialIndexPlans(t, newDoltHarness(t)) } func TestSpatialIndexPlansPrepared(t *testing.T) { skipOldFormat(t) - schema.EnableSpatialIndex = true enginetest.TestSpatialIndexPlansPrepared(t, newDoltHarness(t)) } diff --git a/go/libraries/doltcore/sqle/tables.go b/go/libraries/doltcore/sqle/tables.go index a72be60478..0e70aff251 100644 --- a/go/libraries/doltcore/sqle/tables.go +++ b/go/libraries/doltcore/sqle/tables.go @@ -1800,8 +1800,8 @@ func (t *AlterableDoltTable) CreateIndex(ctx *sql.Context, idx sql.IndexDef) err if err := branch_control.CheckAccess(ctx, branch_control.Permissions_Write); err != nil { return err } - if !schema.EnableSpatialIndex && idx.Constraint != sql.IndexConstraint_None && idx.Constraint != sql.IndexConstraint_Unique { - return fmt.Errorf("only the following types of index constraints are supported: none, unique") + if idx.Constraint != sql.IndexConstraint_None && idx.Constraint != sql.IndexConstraint_Unique && idx.Constraint != sql.IndexConstraint_Spatial { + return fmt.Errorf("only the following types of index constraints are supported: none, unique, spatial") } columns := make([]string, len(idx.Columns)) @@ -2176,8 +2176,8 @@ func (t *AlterableDoltTable) UpdateForeignKey(ctx *sql.Context, fkName string, s // CreateIndexForForeignKey implements sql.ForeignKeyTable func (t *AlterableDoltTable) CreateIndexForForeignKey(ctx *sql.Context, idx sql.IndexDef) error { - if !schema.EnableSpatialIndex && idx.Constraint != sql.IndexConstraint_None && idx.Constraint != sql.IndexConstraint_Unique { - return fmt.Errorf("only the following types of index constraints are supported: none, unique") + if idx.Constraint != sql.IndexConstraint_None && idx.Constraint != sql.IndexConstraint_Unique && idx.Constraint != sql.IndexConstraint_Spatial { + return fmt.Errorf("only the following types of index constraints are supported: none, unique, spatial") } columns := make([]string, len(idx.Columns)) for i, indexCol := range idx.Columns { diff --git a/go/libraries/doltcore/sqle/temp_table.go b/go/libraries/doltcore/sqle/temp_table.go index 67a11e375e..7af1383840 100644 --- a/go/libraries/doltcore/sqle/temp_table.go +++ b/go/libraries/doltcore/sqle/temp_table.go @@ -257,8 +257,8 @@ func (t *TempTable) IndexedAccess(_ sql.IndexLookup) sql.IndexedTable { } func (t *TempTable) CreateIndex(ctx *sql.Context, idx sql.IndexDef) error { - if !schema.EnableSpatialIndex && idx.Constraint != sql.IndexConstraint_None && idx.Constraint != sql.IndexConstraint_Unique { - return fmt.Errorf("only the following types of index constraints are supported: none, unique") + if idx.Constraint != sql.IndexConstraint_None && idx.Constraint != sql.IndexConstraint_Unique && idx.Constraint != sql.IndexConstraint_Spatial { + return fmt.Errorf("only the following types of index constraints are supported: none, unique, spatial") } cols := make([]string, len(idx.Columns)) for i, c := range idx.Columns { diff --git a/integration-tests/bats/spatial-index.bats b/integration-tests/bats/spatial-index.bats index 4e166f6f27..5fbbdec7eb 100644 --- a/integration-tests/bats/spatial-index.bats +++ b/integration-tests/bats/spatial-index.bats @@ -10,23 +10,16 @@ teardown() { teardown_common } -@test "spatial-index: spatial indexes disabled" { - skip_nbf_not_dolt - run dolt sql -q "create table t (p point srid 0 not null, spatial index(p))" - [ "$status" -eq 1 ] - [[ "$output" =~ "only the following types of index constraints are supported" ]] || false -} - @test "spatial-index: spatial indexes enabled" { skip_nbf_not_dolt - DOLT_ENABLE_SPATIAL_INDEX=1 run dolt sql -q "create table t (p point srid 0 not null, spatial index(p))" + run dolt sql -q "create table t (p point srid 0 not null, spatial index(p))" [ "$status" -eq 0 ] } @test "spatial-index: not supported in old format" { rm -rf .dolt dolt init --old-format - DOLT_ENABLE_SPATIAL_INDEX=1 run dolt sql -q "create table t (p point srid 0 not null, spatial index(p))" + run dolt sql -q "create table t (p point srid 0 not null, spatial index(p))" [ "$status" -eq 1 ] [[ "$output" =~ "spatial indexes are only supported in storage format" ]] || false } \ No newline at end of file diff --git a/integration-tests/bats/sql-spatial-types.bats b/integration-tests/bats/sql-spatial-types.bats index b30054cf91..5db6aa02ac 100644 --- a/integration-tests/bats/sql-spatial-types.bats +++ b/integration-tests/bats/sql-spatial-types.bats @@ -156,34 +156,6 @@ teardown() { [[ "$output" =~ "can't use Spatial Types as Primary Key" ]] || false } -@test "sql-spatial-types: prevent creating index on point type" { - dolt sql -q "create table point_tbl (p point)" - run dolt sql -q "create index idx on point_tbl (p)" - [ "$status" -eq 1 ] - [[ "$output" =~ "cannot create an index over spatial type columns" ]] || false -} - -@test "sql-spatial-types: prevent creating index on linestring types" { - dolt sql -q "create table line_tbl (l linestring)" - run dolt sql -q "create index idx on line_tbl (l)" - [ "$status" -eq 1 ] - [[ "$output" =~ "cannot create an index over spatial type columns" ]] || false -} - -@test "sql-spatial-types: prevent creating index on polygon types" { - dolt sql -q "create table poly_tbl (p polygon)" - run dolt sql -q "create index idx on poly_tbl (p)" - [ "$status" -eq 1 ] - [[ "$output" =~ "cannot create an index over spatial type columns" ]] || false -} - -@test "sql-spatial-types: prevent creating index on geometry types" { - dolt sql -q "create table geom_tbl (g geometry)" - run dolt sql -q "create index idx on geom_tbl (g)" - [ "$status" -eq 1 ] - [[ "$output" =~ "cannot create an index over spatial type columns" ]] || false -} - @test "sql-spatial-types: allow index on non-spatial columns of spatial table" { dolt sql -q "create table poly_tbl (a int, p polygon)" dolt sql -q "create index idx on poly_tbl (a)"