mirror of
https://github.com/dolthub/dolt.git
synced 2025-12-30 08:50:01 -06:00
Merge pull request #9933 from dolthub/nicktobey/update-json
Fix performance issue when using large JSON documents in UPDATE statements.
This commit is contained in:
@@ -61,7 +61,7 @@ require (
|
||||
github.com/dolthub/dolt-mcp v0.2.2-0.20250917171427-13e4520d1c36
|
||||
github.com/dolthub/eventsapi_schema v0.0.0-20250915094920-eadfd39051ca
|
||||
github.com/dolthub/flatbuffers/v23 v23.3.3-dh.2
|
||||
github.com/dolthub/go-mysql-server v0.20.1-0.20251006192807-f7a3e3850abc
|
||||
github.com/dolthub/go-mysql-server v0.20.1-0.20251007221930-37976af33334
|
||||
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63
|
||||
github.com/edsrzf/mmap-go v1.2.0
|
||||
github.com/esote/minmaxheap v1.0.0
|
||||
|
||||
@@ -213,8 +213,8 @@ 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-20250916051405-78a38d478790 h1:zxMsH7RLiG+dlZ/y0LgJHTV26XoiSJcuWq+em6t6VVc=
|
||||
github.com/dolthub/go-icu-regex v0.0.0-20250916051405-78a38d478790/go.mod h1:F3cnm+vMRK1HaU6+rNqQrOCyR03HHhR1GWG2gnPOqaE=
|
||||
github.com/dolthub/go-mysql-server v0.20.1-0.20251006192807-f7a3e3850abc h1:kEbuDqqQ++5R/ExeKcNcQEe7MKYSn2ZJE2lBxoYQqjw=
|
||||
github.com/dolthub/go-mysql-server v0.20.1-0.20251006192807-f7a3e3850abc/go.mod h1:EeYR0apo+8j2Dyxmn2ghkPlirO2S5mT1xHBrA+Efys8=
|
||||
github.com/dolthub/go-mysql-server v0.20.1-0.20251007221930-37976af33334 h1:BBV5PxSA5wW2gDzCDnfhM1TbH2xqy2151I4sKVoVB0c=
|
||||
github.com/dolthub/go-mysql-server v0.20.1-0.20251007221930-37976af33334/go.mod h1:EeYR0apo+8j2Dyxmn2ghkPlirO2S5mT1xHBrA+Efys8=
|
||||
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63 h1:OAsXLAPL4du6tfbBgK0xXHZkOlos63RdKYS3Sgw/dfI=
|
||||
github.com/dolthub/gozstd v0.0.0-20240423170813-23a2903bca63/go.mod h1:lV7lUeuDhH5thVGDCKXbatwKy2KW80L4rMT46n+Y2/Q=
|
||||
github.com/dolthub/ishell v0.0.0-20240701202509-2b217167d718 h1:lT7hE5k+0nkBdj/1UOSFwjWpNxf+LCApbRHgnCA17XE=
|
||||
|
||||
@@ -46,6 +46,7 @@ type IndexedJsonDocument struct {
|
||||
|
||||
var _ types.JSONBytes = IndexedJsonDocument{}
|
||||
var _ types.MutableJSON = IndexedJsonDocument{}
|
||||
var _ types.ComparableJSON = IndexedJsonDocument{}
|
||||
var _ fmt.Stringer = IndexedJsonDocument{}
|
||||
var _ driver.Valuer = IndexedJsonDocument{}
|
||||
|
||||
@@ -744,3 +745,26 @@ func (i IndexedJsonDocument) Compare(ctx context.Context, other interface{}) (in
|
||||
return types.CompareJSON(ctx, val, other)
|
||||
}
|
||||
}
|
||||
|
||||
func (i IndexedJsonDocument) JsonType(ctx context.Context) (string, error) {
|
||||
typeCategory, err := i.getTypeCategory(ctx)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
switch typeCategory {
|
||||
case jsonTypeObject:
|
||||
return "OBJECT", nil
|
||||
case jsonTypeArray:
|
||||
return "ARRAY", nil
|
||||
case jsonTypeNull:
|
||||
return "NULL", nil
|
||||
case jsonTypeBoolean:
|
||||
return "BOOLEAN", nil
|
||||
case jsonTypeString:
|
||||
return "STRING", nil
|
||||
case jsonTypeNumber:
|
||||
return "DOUBLE", nil
|
||||
default:
|
||||
return "", fmt.Errorf("unknown json type category %v", typeCategory)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -358,6 +358,12 @@ func TestJsonCompare(t *testing.T) {
|
||||
largeObject := newIndexedJsonDocumentFromValue(t, ctx, ns, largeObjectWrapper)
|
||||
require.NoError(t, err)
|
||||
largeDocTests := []typetests.JsonCompareTest{
|
||||
{
|
||||
Name: "identical large objects are equal",
|
||||
Left: largeObject,
|
||||
Right: largeObject,
|
||||
Cmp: 0,
|
||||
},
|
||||
{
|
||||
Name: "large object < boolean",
|
||||
Left: largeObject,
|
||||
|
||||
Reference in New Issue
Block a user