diff --git a/go/go.mod b/go/go.mod index 6e78a6c3ac..c002f226c5 100644 --- a/go/go.mod +++ b/go/go.mod @@ -59,7 +59,7 @@ require ( github.com/cespare/xxhash v1.1.0 github.com/creasty/defaults v1.6.0 github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2 - github.com/dolthub/go-mysql-server v0.17.1-0.20231105071709-422c3fee20f6 + github.com/dolthub/go-mysql-server v0.17.1-0.20231107171708-b0d61a50e286 github.com/dolthub/swiss v0.1.0 github.com/goccy/go-json v0.10.2 github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 diff --git a/go/go.sum b/go/go.sum index e4cad6f057..1a490d371f 100644 --- a/go/go.sum +++ b/go/go.sum @@ -181,8 +181,10 @@ github.com/dolthub/fslock v0.0.3 h1:iLMpUIvJKMKm92+N1fmHVdxJP5NdyDK5bK7z7Ba2s2U= github.com/dolthub/fslock v0.0.3/go.mod h1:QWql+P17oAAMLnL4HGB5tiovtDuAjdDTPbuqx7bYfa0= github.com/dolthub/go-icu-regex v0.0.0-20230524105445-af7e7991c97e h1:kPsT4a47cw1+y/N5SSCkma7FhAPw7KeGmD6c9PBZW9Y= github.com/dolthub/go-icu-regex v0.0.0-20230524105445-af7e7991c97e/go.mod h1:KPUcpx070QOfJK1gNe0zx4pA5sicIK1GMikIGLKC168= -github.com/dolthub/go-mysql-server v0.17.1-0.20231105071709-422c3fee20f6 h1:gWdydyqAiA0U51NUfdRGYeUiHkRM/OWM0KmNjUF3Wvk= -github.com/dolthub/go-mysql-server v0.17.1-0.20231105071709-422c3fee20f6/go.mod h1:YKNZpEARxfNl5LUyIZ8oHEoMDM7DzjnPlhl9cj89QBg= +github.com/dolthub/go-mysql-server v0.17.1-0.20231102000456-6985ecd1f59f h1:klP1BLlTLwnFSRAPEa3oQRwuEjnpqedWa1KdGDjmT2E= +github.com/dolthub/go-mysql-server v0.17.1-0.20231102000456-6985ecd1f59f/go.mod h1:YKNZpEARxfNl5LUyIZ8oHEoMDM7DzjnPlhl9cj89QBg= +github.com/dolthub/go-mysql-server v0.17.1-0.20231107171708-b0d61a50e286 h1:p8sxDMAgUlzKPJdO6O4PlMPtTShAAcEAeNgRrCgFOaQ= +github.com/dolthub/go-mysql-server v0.17.1-0.20231107171708-b0d61a50e286/go.mod h1:YKNZpEARxfNl5LUyIZ8oHEoMDM7DzjnPlhl9cj89QBg= github.com/dolthub/ishell v0.0.0-20221214210346-d7db0b066488 h1:0HHu0GWJH0N6a6keStrHhUAK5/o9LVfkh44pvsV4514= github.com/dolthub/ishell v0.0.0-20221214210346-d7db0b066488/go.mod h1:ehexgi1mPxRTk0Mok/pADALuHbvATulTh6gzr7NzZto= github.com/dolthub/jsonpath v0.0.2-0.20230525180605-8dc13778fd72 h1:NfWmngMi1CYUWU4Ix8wM+USEhjc+mhPlT9JUR/anvbQ= diff --git a/go/libraries/doltcore/sqle/writer/prolly_fk_indexer.go b/go/libraries/doltcore/sqle/writer/prolly_fk_indexer.go index fbef8e6a5d..e1bd724129 100644 --- a/go/libraries/doltcore/sqle/writer/prolly_fk_indexer.go +++ b/go/libraries/doltcore/sqle/writer/prolly_fk_indexer.go @@ -26,13 +26,15 @@ import ( ) type prollyFkIndexer struct { - writer *prollyTableWriter - index index.DoltIndex - pRange prolly.Range + writer *prollyTableWriter + index index.DoltIndex + pRange prolly.Range + refCheck bool } var _ sql.Table = (*prollyFkIndexer)(nil) var _ sql.IndexedTable = (*prollyFkIndexer)(nil) +var _ sql.ReferenceChecker = (*prollyFkIndexer)(nil) // Name implements the interface sql.Table. func (n *prollyFkIndexer) Name() string { @@ -49,6 +51,11 @@ func (n *prollyFkIndexer) Schema() sql.Schema { return n.writer.sqlSch } +func (n *prollyFkIndexer) SetReferenceCheck() error { + n.refCheck = true + return nil +} + // Collation implements the interface sql.Table. func (n *prollyFkIndexer) Collation() sql.CollationID { return sql.CollationID(n.writer.sch.GetCollation()) @@ -84,23 +91,19 @@ func (n *prollyFkIndexer) PartitionRows(ctx *sql.Context, _ sql.Partition) (sql. pkToIdxMap[i] = j } } - + rangeIter, err := idxWriter.IterRange(ctx, n.pRange) + if err != nil { + return nil, err + } if primary, ok := n.writer.primary.(prollyIndexWriter); ok { - rangeIter, err := idxWriter.IterRange(ctx, n.pRange) - if err != nil { - return nil, err - } return &prollyFkPkRowIter{ rangeIter: rangeIter, pkToIdxMap: pkToIdxMap, primary: primary, sqlSch: n.writer.sqlSch, + refCheck: n.refCheck, }, nil } else { - rangeIter, err := idxWriter.IterRange(ctx, n.pRange) - if err != nil { - return nil, err - } return &prollyFkKeylessRowIter{ rangeIter: rangeIter, primary: n.writer.primary.(prollyKeylessWriter), @@ -115,6 +118,7 @@ type prollyFkPkRowIter struct { pkToIdxMap val.OrdinalMapping primary prollyIndexWriter sqlSch sql.Schema + refCheck bool } var _ sql.RowIter = prollyFkPkRowIter{} @@ -149,6 +153,11 @@ func (iter prollyFkPkRowIter) Next(ctx *sql.Context) (sql.Row, error) { continue // referential integrity broken } + if iter.refCheck { + // no need to deserialize + return nil, nil + } + nextRow := make(sql.Row, len(iter.primary.keyMap)+len(iter.primary.valMap)) for from := range iter.primary.keyMap { to := iter.primary.keyMap.MapOrdinal(from)