blocking in old format and adding test

This commit is contained in:
James Cor
2023-02-21 11:07:46 -08:00
parent b73c59c1a7
commit e9ab728161
2 changed files with 25 additions and 0 deletions

View File

@@ -17,6 +17,7 @@ package encoding
import (
"context"
"errors"
"fmt"
"sync"
"github.com/dolthub/dolt/go/libraries/doltcore/schema"
@@ -349,6 +350,14 @@ func MarshalSchemaAsNomsValue(ctx context.Context, vrw types.ValueReadWriter, sc
return nil, err
}
if vrw.Format().VersionString() != types.Format_DOLT.VersionString() {
for _, idx := range sch.Indexes().AllIndexes() {
if idx.IsSpatial() {
return nil, fmt.Errorf("spatial indexes are only supported in storage format __DOLT__")
}
}
}
if vrw.Format().UsesFlatbuffers() {
return SerializeSchema(ctx, vrw, sch)
}
@@ -423,6 +432,14 @@ func UnmarshalSchemaNomsValue(ctx context.Context, nbf *types.NomsBinFormat, sch
return nil, err
}
if nbf.VersionString() != types.Format_DOLT.VersionString() {
for _, idx := range sch.Indexes().AllIndexes() {
if idx.IsSpatial() {
return nil, fmt.Errorf("spatial indexes are only supported in storage format __DOLT__")
}
}
}
if sd.PkOrdinals == nil {
// schemaData will not have PK ordinals in old versions of Dolt
// this sets the default PK ordinates for subsequent cache lookups

View File

@@ -19,4 +19,12 @@ teardown() {
@test "spatial-index: spatial indexes enabled" {
DOLT_ENABLE_SPATIAL_INDEX=1 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))"
[ "$status" -eq 1 ]
[[ "$output" =~ "spatial indexes are only supported in storage format" ]] || false
}