JSON and stats interface refactor (#6833)

* JSON and stats interface refactor

* Fix some tests

* fix more tests

* [ga-format-pr] Run go/utils/repofmt/format_repo.sh and go/Godeps/update.sh

* bump

* bump

* cleanup

* json keys are ordered

* bump

* keep ordered json string for CV types

---------

Co-authored-by: max-hoffman <max-hoffman@users.noreply.github.com>
This commit is contained in:
Maximilian Hoffman
2023-10-18 20:29:31 -07:00
committed by GitHub
parent 0bf4975025
commit 5364ef3786
21 changed files with 244 additions and 282 deletions

View File

@@ -662,7 +662,7 @@ func getJsonDocumentColAsString(sqlCtx *sql.Context, col interface{}) (string, e
case string:
return v, nil
case types.JSONDocument:
text, err := v.ToString(sqlCtx)
text, err := v.JSONString()
if err != nil {
return "", err
}

View File

@@ -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.20231018213356-8bc741c7d1b6
github.com/dolthub/go-mysql-server v0.17.1-0.20231018224248-6247e6e50cbb
github.com/dolthub/swiss v0.1.0
github.com/goccy/go-json v0.10.2
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510

View File

@@ -181,8 +181,14 @@ 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.20231018213356-8bc741c7d1b6 h1:TXQ7pWVgkX0eAjnUeMXLbMKIWEmKIJi2EIcrz7QyTvM=
github.com/dolthub/go-mysql-server v0.17.1-0.20231018213356-8bc741c7d1b6/go.mod h1:hR90Xk0HxzlbaPuhjRfVgpwvFbfTUzlkrTYunOBG2hE=
github.com/dolthub/go-mysql-server v0.17.1-0.20231018154343-d614f4f6409c h1:K8KNcTPQrxP3Gf3cRSPiBZG8aWCDuWgY+98tDcuPcPE=
github.com/dolthub/go-mysql-server v0.17.1-0.20231018154343-d614f4f6409c/go.mod h1:kL5S5WfmgeiVos4SAUQ2O1LoXbDvwRombuGoCh19az4=
github.com/dolthub/go-mysql-server v0.17.1-0.20231018162558-22e7c9807aa1 h1:zJLLG3oey3lEXG1G5I5NZ3VNYdaOLHLP5tVOOVdZAcI=
github.com/dolthub/go-mysql-server v0.17.1-0.20231018162558-22e7c9807aa1/go.mod h1:kL5S5WfmgeiVos4SAUQ2O1LoXbDvwRombuGoCh19az4=
github.com/dolthub/go-mysql-server v0.17.1-0.20231018163015-f5294ffe08dc h1:psbF9CdSVKxHz/NN7ls/e2sO9tAAgGMdoPc8c5WINeA=
github.com/dolthub/go-mysql-server v0.17.1-0.20231018163015-f5294ffe08dc/go.mod h1:kL5S5WfmgeiVos4SAUQ2O1LoXbDvwRombuGoCh19az4=
github.com/dolthub/go-mysql-server v0.17.1-0.20231018224248-6247e6e50cbb h1:zbePDIAOxhaXTvvGDOVvrmo92R7XZVyH5FTeay3/Ybw=
github.com/dolthub/go-mysql-server v0.17.1-0.20231018224248-6247e6e50cbb/go.mod h1:hR90Xk0HxzlbaPuhjRfVgpwvFbfTUzlkrTYunOBG2hE=
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=
@@ -193,6 +199,8 @@ github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81 h1:7/v8q9X
github.com/dolthub/sqllogictest/go v0.0.0-20201107003712-816f3ae12d81/go.mod h1:siLfyv2c92W1eN/R4QqG/+RjjX5W2+gCTRjZxBjI3TY=
github.com/dolthub/swiss v0.1.0 h1:EaGQct3AqeP/MjASHLiH6i4TAmgbG/c4rA6a1bzCOPc=
github.com/dolthub/swiss v0.1.0/go.mod h1:BeucyB08Vb1G9tumVN3Vp/pyY4AMUnr9p7Rz7wJ7kAQ=
github.com/dolthub/vitess v0.0.0-20231011212939-750452c13fa0 h1:ETjYviQleYq+2KuflGbTdRLuk0zw45HXCHS6ApVM6o8=
github.com/dolthub/vitess v0.0.0-20231011212939-750452c13fa0/go.mod h1:IwjNXSQPymrja5pVqmfnYdcy7Uv7eNJNBPK/MEh9OOw=
github.com/dolthub/vitess v0.0.0-20231018211336-45c2d7dce528 h1:DUHzyi+/Wn9/59zPkz7ghXktRQlB9j486jUEjg5fMs8=
github.com/dolthub/vitess v0.0.0-20231018211336-45c2d7dce528/go.mod h1:IwjNXSQPymrja5pVqmfnYdcy7Uv7eNJNBPK/MEh9OOw=
github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=

View File

@@ -21,7 +21,6 @@ import (
"strings"
"github.com/dolthub/go-mysql-server/sql"
"github.com/dolthub/go-mysql-server/sql/types"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb"
"github.com/dolthub/dolt/go/libraries/doltcore/doltdb/durable"
@@ -387,23 +386,22 @@ type FkCVMeta struct {
Table string `json:"Table"`
}
var _ types.JSONValue = FkCVMeta{}
var _ sql.JSONWrapper = FkCVMeta{}
func (m FkCVMeta) Unmarshall(ctx *sql.Context) (val types.JSONDocument, err error) {
return types.JSONDocument{Val: m}, nil
func (m FkCVMeta) ToInterface() interface{} {
return map[string]interface{}{
"Columns": m.Columns,
"ForeignKey": m.ForeignKey,
"Index": m.Index,
"OnDelete": m.OnDelete,
"OnUpdate": m.OnUpdate,
"ReferencedColumns": m.ReferencedColumns,
"ReferencedIndex": m.ReferencedIndex,
"ReferencedTable": m.ReferencedTable,
"Table": m.Table,
}
}
func (m FkCVMeta) Compare(ctx *sql.Context, v types.JSONValue) (cmp int, err error) {
ours := types.JSONDocument{Val: m}
return ours.Compare(ctx, v)
}
func (m FkCVMeta) ToString(ctx *sql.Context) (string, error) {
return m.PrettyPrint(), nil
}
var _ types.JSONValue = FkCVMeta{}
// PrettyPrint is a custom pretty print function to match the old format's
// output which includes additional whitespace between keys, values, and array elements.
func (m FkCVMeta) PrettyPrint() string {

View File

@@ -54,19 +54,19 @@ type UniqCVMeta struct {
Name string `json:"Name"`
}
func (m UniqCVMeta) ToInterface() interface{} {
return map[string]interface{}{
"Columns": m.Columns,
"Name": m.Name,
}
}
var _ sql.JSONWrapper = UniqCVMeta{}
func (m UniqCVMeta) Unmarshall(ctx *sql.Context) (val types.JSONDocument, err error) {
return types.JSONDocument{Val: m}, nil
}
func (m UniqCVMeta) Compare(ctx *sql.Context, v types.JSONValue) (cmp int, err error) {
ours := types.JSONDocument{Val: m}
return ours.Compare(ctx, v)
}
func (m UniqCVMeta) ToString(ctx *sql.Context) (string, error) {
return m.PrettyPrint(), nil
}
func (m UniqCVMeta) PrettyPrint() string {
jsonStr := fmt.Sprintf(`{`+
`"Name": "%s", `+
@@ -136,6 +136,8 @@ type NullViolationMeta struct {
Columns []string `json:"Columns"`
}
var _ sql.JSONWrapper = NullViolationMeta{}
func newNotNullViolationMeta(violations []string, value val.Tuple) (prolly.ConstraintViolationMeta, error) {
info, err := json.Marshal(NullViolationMeta{Columns: violations})
if err != nil {
@@ -147,26 +149,23 @@ func newNotNullViolationMeta(violations []string, value val.Tuple) (prolly.Const
}, nil
}
func (m NullViolationMeta) ToInterface() interface{} {
return map[string]interface{}{
"Columns": m.Columns,
}
}
func (m NullViolationMeta) Unmarshall(ctx *sql.Context) (val types.JSONDocument, err error) {
return types.JSONDocument{Val: m}, nil
}
func (m NullViolationMeta) Compare(ctx *sql.Context, v types.JSONValue) (cmp int, err error) {
ours := types.JSONDocument{Val: m}
return ours.Compare(ctx, v)
}
func (m NullViolationMeta) ToString(ctx *sql.Context) (string, error) {
return fmt.Sprintf("{Columns: [%s]}", strings.Join(m.Columns, ",")), nil
}
// CheckCVMeta holds metadata describing a check constraint violation.
type CheckCVMeta struct {
Name string `json:"Name"`
Expression string `json:"Expression"`
}
var _ types.JSONValue = CheckCVMeta{}
var _ sql.JSONWrapper = CheckCVMeta{}
// newCheckCVMeta creates a new CheckCVMeta from a schema |sch| and a check constraint name |checkName|. If the
// check constraint is not found in the specified schema, an error is returned.
@@ -189,23 +188,14 @@ func newCheckCVMeta(sch schema.Schema, checkName string) (CheckCVMeta, error) {
}, nil
}
// Unmarshall implements types.JSONValue
// Unmarshall implements sql.JSONWrapper
func (m CheckCVMeta) Unmarshall(_ *sql.Context) (val types.JSONDocument, err error) {
return types.JSONDocument{Val: m}, nil
}
// Compare implements types.JSONValue
func (m CheckCVMeta) Compare(ctx *sql.Context, v types.JSONValue) (cmp int, err error) {
ours := types.JSONDocument{Val: m}
return ours.Compare(ctx, v)
}
// ToString implements types.JSONValue
func (m CheckCVMeta) ToString(_ *sql.Context) (string, error) {
jsonStr := fmt.Sprintf(`{`+
`"Name": "%s", `+
`"Expression": "%s"}`,
m.Name,
m.Expression)
return jsonStr, nil
func (m CheckCVMeta) ToInterface() interface{} {
return map[string]interface{}{
"Name": m.Name,
"Expression": m.Expression,
}
}

View File

@@ -72,7 +72,7 @@ func (ti *jsonType) ConvertValueToNomsValue(ctx context.Context, vrw types.Value
return nil, err
}
jsVal, ok := jsDoc.(sqltypes.JSONValue)
jsVal, ok := jsDoc.(sql.JSONWrapper)
if !ok {
return nil, fmt.Errorf(`"%v" cannot convert value "%v" of type "%T" as it is invalid`, ti.String(), v, v)
}
@@ -97,7 +97,7 @@ func (ti *jsonType) FormatValue(v types.Value) (*string, error) {
}
if noms, ok := v.(types.JSON); ok {
// TODO(andy) fix context
s, err := json.NomsJSON(noms).ToString(sql.NewEmptyContext())
s, err := json.NomsJSON(noms).JSONString()
if err != nil {
return nil, err
}

View File

@@ -20,7 +20,6 @@ import (
"time"
"unsafe"
"github.com/dolthub/go-mysql-server/sql"
"github.com/shopspring/decimal"
"gopkg.in/src-d/go-errors.v1"
@@ -145,7 +144,7 @@ func wrapConvertValueToNomsValue(
vInt = int64(val)
case types.JSON:
var err error
vInt, err = json.NomsJSON(val).ToString(sql.NewEmptyContext())
vInt, err = json.NomsJSON(val).JSONString()
if err != nil {
return nil, err
}

View File

@@ -2094,7 +2094,7 @@ var MergeScripts = []queries.ScriptTest{
{
Query: "select violation_type, pk, violation_info from dolt_constraint_violations_test",
Expected: []sql.Row{
{uint16(4), 2, types.JSONDocument{Val: merge.NullViolationMeta{Columns: []string{"c0"}}}},
{uint16(4), 2, merge.NullViolationMeta{Columns: []string{"c0"}}},
},
},
},

View File

@@ -760,8 +760,8 @@ var SchemaChangeTestsConstraints = []MergeScriptTest{
{
Query: "select violation_type, pk, col2, violation_info from dolt_constraint_violations_t;",
Expected: []sql.Row{
{uint(2), "1", "same", types.JSONDocument{Val: merge.UniqCVMeta{Columns: []string{"col2"}, Name: "unique1"}}},
{uint(2), "10", "same", types.JSONDocument{Val: merge.UniqCVMeta{Columns: []string{"col2"}, Name: "unique1"}}},
{uint(2), "1", "same", merge.UniqCVMeta{Columns: []string{"col2"}, Name: "unique1"}},
{uint(2), "10", "same", merge.UniqCVMeta{Columns: []string{"col2"}, Name: "unique1"}},
},
},
{
@@ -1997,7 +1997,7 @@ var SchemaChangeTestsSchemaConflicts = []MergeScriptTest{
{
Query: "select violation_type, pk, violation_info from dolt_constraint_violations_t",
Expected: []sql.Row{
{uint16(4), 3, types.JSONDocument{Val: merge.NullViolationMeta{Columns: []string{"col1"}}}},
{uint16(4), 3, merge.NullViolationMeta{Columns: []string{"col1"}}},
},
},
},

View File

@@ -36,7 +36,7 @@ var DoltStatsTests = []queries.ScriptTest{
},
Assertions: []queries.ScriptTestAssertion{
{
Query: " SELECT mcv_cnt from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(mcv_cnt JSON path '$.McvCount')) as dt where table_name = 'xy' and column_name = 'y,z'",
Query: " SELECT mcv_cnt from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(mcv_cnt JSON path '$.mcv_counts')) as dt where table_name = 'xy' and column_name = 'y,z'",
Expected: []sql.Row{
{types.JSONDocument{Val: []interface{}{
float64(1),
@@ -46,7 +46,7 @@ var DoltStatsTests = []queries.ScriptTest{
},
},
{
Query: " SELECT mcv from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(mcv JSON path '$.Mcv')) as dt where table_name = 'xy' and column_name = 'y,z'",
Query: " SELECT mcv from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(mcv JSON path '$.mcvs')) as dt where table_name = 'xy' and column_name = 'y,z'",
Expected: []sql.Row{
{types.JSONDocument{Val: []interface{}{
[]interface{}{float64(1), "a"},
@@ -56,7 +56,7 @@ var DoltStatsTests = []queries.ScriptTest{
},
},
{
Query: " SELECT x,z from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(x bigint path '$.UpperBound[0]', z text path '$.UpperBound[1]')) as dt where table_name = 'xy' and column_name = 'y,z'",
Query: " SELECT x,z from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(x bigint path '$.upper_bound[0]', z text path '$.upper_bound[1]')) as dt where table_name = 'xy' and column_name = 'y,z'",
Expected: []sql.Row{
{2, "a"},
},
@@ -76,23 +76,23 @@ var DoltStatsTests = []queries.ScriptTest{
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "SELECT json_length(json_extract(histogram, \"$.buckets\")) from information_schema.column_statistics where column_name = 'x'",
Query: "SELECT json_length(json_extract(histogram, \"$.statistic.buckets\")) from information_schema.column_statistics where column_name = 'x'",
Expected: []sql.Row{{32}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Count')) as dt where table_name = 'xy' and column_name = 'x'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.row_count')) as dt where table_name = 'xy' and column_name = 'x'",
Expected: []sql.Row{{float64(30000)}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Null')) as dt where table_name = 'xy' and column_name = 'x'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.null_count')) as dt where table_name = 'xy' and column_name = 'x'",
Expected: []sql.Row{{float64(0)}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Distinct')) as dt where table_name = 'xy' and column_name = 'x'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.distinct_count')) as dt where table_name = 'xy' and column_name = 'x'",
Expected: []sql.Row{{float64(30000)}},
},
{
Query: " SELECT max(bound_cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(bound_cnt int path '$.BoundCount')) as dt where table_name = 'xy' and column_name = 'x'",
Query: " SELECT max(bound_cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(bound_cnt int path '$.bound_count')) as dt where table_name = 'xy' and column_name = 'x'",
Expected: []sql.Row{{int64(1)}},
},
},
@@ -107,30 +107,30 @@ var DoltStatsTests = []queries.ScriptTest{
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "SELECT json_length(json_extract(histogram, \"$.buckets\")) from information_schema.column_statistics where column_name = 'z'",
Query: "SELECT json_length(json_extract(histogram, \"$.statistic.buckets\")) from information_schema.column_statistics where column_name = 'z'",
Expected: []sql.Row{{2}},
},
{
// bucket boundary duplication
Query: "SELECT json_value(histogram, \"$.distinct\", 'signed') from information_schema.column_statistics where column_name = 'z'",
Query: "SELECT json_value(histogram, \"$.statistic.distinct_count\", 'signed') from information_schema.column_statistics where column_name = 'z'",
Expected: []sql.Row{{202}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Count')) as dt where table_name = 'xy' and column_name = 'z'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.row_count')) as dt where table_name = 'xy' and column_name = 'z'",
Expected: []sql.Row{{float64(400)}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Null')) as dt where table_name = 'xy' and column_name = 'z'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.null_count')) as dt where table_name = 'xy' and column_name = 'z'",
Expected: []sql.Row{{float64(200)}},
},
{
// chunk border double count
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Distinct')) as dt where table_name = 'xy' and column_name = 'z'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.distinct_count')) as dt where table_name = 'xy' and column_name = 'z'",
Expected: []sql.Row{{float64(202)}},
},
{
// max bound count is an all nulls chunk
Query: " SELECT max(bound_cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(bound_cnt int path '$.BoundCount')) as dt where table_name = 'xy' and column_name = 'z'",
Query: " SELECT max(bound_cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(bound_cnt int path '$.bound_count')) as dt where table_name = 'xy' and column_name = 'z'",
Expected: []sql.Row{{int64(183)}},
},
},
@@ -146,25 +146,25 @@ var DoltStatsTests = []queries.ScriptTest{
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "SELECT json_length(json_extract(histogram, \"$.buckets\")) from information_schema.column_statistics where column_name = 'z'",
Query: "SELECT json_length(json_extract(histogram, \"$.statistic.buckets\")) from information_schema.column_statistics where column_name = 'z'",
Expected: []sql.Row{{152}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Count')) as dt where table_name = 'xy' and column_name = 'z'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.row_count')) as dt where table_name = 'xy' and column_name = 'z'",
Expected: []sql.Row{{float64(30000)}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Null')) as dt where table_name = 'xy' and column_name = 'z'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.null_count')) as dt where table_name = 'xy' and column_name = 'z'",
Expected: []sql.Row{{float64(10000)}},
},
{
// border NULL double count
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Distinct')) as dt where table_name = 'xy' and column_name = 'z'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.distinct_count')) as dt where table_name = 'xy' and column_name = 'z'",
Expected: []sql.Row{{float64(20036)}},
},
{
// max bound count is nulls chunk
Query: " SELECT max(bound_cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(bound_cnt int path '$.BoundCount')) as dt where table_name = 'xy' and column_name = 'z'",
Query: " SELECT max(bound_cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(bound_cnt int path '$.bound_count')) as dt where table_name = 'xy' and column_name = 'z'",
Expected: []sql.Row{{int64(440)}},
},
},
@@ -180,24 +180,24 @@ var DoltStatsTests = []queries.ScriptTest{
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "SELECT json_length(json_extract(histogram, \"$.buckets\")) from information_schema.column_statistics where column_name = 'x,z'",
Query: "SELECT json_length(json_extract(histogram, \"$.statistic.buckets\")) from information_schema.column_statistics where column_name = 'x,z'",
Expected: []sql.Row{{155}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Count')) as dt where table_name = 'xy' and column_name = 'x,z'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.row_count')) as dt where table_name = 'xy' and column_name = 'x,z'",
Expected: []sql.Row{{float64(30000)}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Null')) as dt where table_name = 'xy' and column_name = 'x,z'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.null_count')) as dt where table_name = 'xy' and column_name = 'x,z'",
Expected: []sql.Row{{float64(10000)}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Distinct')) as dt where table_name = 'xy' and column_name = 'x,z'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.distinct_count')) as dt where table_name = 'xy' and column_name = 'x,z'",
Expected: []sql.Row{{float64(30000)}},
},
{
// max bound count is nulls chunk
Query: " SELECT max(bound_cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(bound_cnt int path '$.BoundCount')) as dt where table_name = 'xy' and column_name = 'x,z'",
Query: " SELECT max(bound_cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(bound_cnt int path '$.bound_count')) as dt where table_name = 'xy' and column_name = 'x,z'",
Expected: []sql.Row{{int64(1)}},
},
},
@@ -233,24 +233,24 @@ var DoltStatsTests = []queries.ScriptTest{
},
Assertions: []queries.ScriptTestAssertion{
{
Query: "SELECT json_length(json_extract(histogram, \"$.buckets\")) from information_schema.column_statistics where column_name = 'x'",
Query: "SELECT json_length(json_extract(histogram, \"$.statistic.buckets\")) from information_schema.column_statistics where column_name = 'x'",
Expected: []sql.Row{{26}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Count')) as dt where table_name = 'xy' and column_name = 'x'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.row_count')) as dt where table_name = 'xy' and column_name = 'x'",
Expected: []sql.Row{{float64(30000)}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Null')) as dt where table_name = 'xy' and column_name = 'x'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.null_count')) as dt where table_name = 'xy' and column_name = 'x'",
Expected: []sql.Row{{float64(0)}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Distinct')) as dt where table_name = 'xy' and column_name = 'x'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.distinct_count')) as dt where table_name = 'xy' and column_name = 'x'",
Expected: []sql.Row{{float64(30000)}},
},
{
// max bound count is nulls chunk
Query: " SELECT max(bound_cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(bound_cnt int path '$.BoundCount')) as dt where table_name = 'xy' and column_name = 'x'",
Query: " SELECT max(bound_cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(bound_cnt int path '$.bound_count')) as dt where table_name = 'xy' and column_name = 'x'",
Expected: []sql.Row{{int64(1)}},
},
},
@@ -270,24 +270,24 @@ var DoltStatsTests = []queries.ScriptTest{
Expected: []sql.Row{{"z"}, {"z,x"}},
},
{
Query: "SELECT json_length(json_extract(histogram, \"$.buckets\")) from information_schema.column_statistics where column_name = 'z,x'",
Query: "SELECT json_length(json_extract(histogram, \"$.statistic.buckets\")) from information_schema.column_statistics where column_name = 'z,x'",
Expected: []sql.Row{{42}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Count')) as dt where table_name = 'xy' and column_name = 'z,x'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.row_count')) as dt where table_name = 'xy' and column_name = 'z,x'",
Expected: []sql.Row{{float64(30000)}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Null')) as dt where table_name = 'xy' and column_name = 'z,x'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.null_count')) as dt where table_name = 'xy' and column_name = 'z,x'",
Expected: []sql.Row{{float64(0)}},
},
{
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(cnt int path '$.Distinct')) as dt where table_name = 'xy' and column_name = 'z,x'",
Query: " SELECT sum(cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(cnt int path '$.distinct_count')) as dt where table_name = 'xy' and column_name = 'z,x'",
Expected: []sql.Row{{float64(30000)}},
},
{
// max bound count is nulls chunk
Query: " SELECT max(bound_cnt) from information_schema.column_statistics join json_table(histogram, '$.buckets[*]' COLUMNS(bound_cnt int path '$.BoundCount')) as dt where table_name = 'xy' and column_name = 'z,x'",
Query: " SELECT max(bound_cnt) from information_schema.column_statistics join json_table(histogram, '$.statistic.buckets[*]' COLUMNS(bound_cnt int path '$.bound_count')) as dt where table_name = 'xy' and column_name = 'z,x'",
Expected: []sql.Row{{int64(1)}},
},
},

View File

@@ -25,6 +25,7 @@ import (
"testing"
"github.com/dolthub/go-mysql-server/sql"
gmstypes "github.com/dolthub/go-mysql-server/sql/types"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -149,7 +150,7 @@ func testJsonValue(t *testing.T, test jsonValueTest, setupCommon []testCommand)
// special logic for comparing JSONValues
if js, ok := exp.(json.NomsJSON); ok {
cmp, err := js.Compare(sql.NewEmptyContext(), act.(json.NomsJSON))
cmp, err := gmstypes.CompareJSON(js, act.(json.NomsJSON))
require.NoError(t, err)
assert.Zero(t, cmp)
} else {

View File

@@ -38,20 +38,17 @@ const (
// logic to be kept separate from the storage-layer code in pkg types.
type NomsJSON types.JSON
var _ gmstypes.JSONValue = NomsJSON{}
var _ sql.JSONWrapper = NomsJSON{}
// NomsJSONFromJSONValue converts a sql.JSONValue to a NomsJSON value.
func NomsJSONFromJSONValue(ctx context.Context, vrw types.ValueReadWriter, val gmstypes.JSONValue) (NomsJSON, error) {
func NomsJSONFromJSONValue(ctx context.Context, vrw types.ValueReadWriter, val sql.JSONWrapper) (NomsJSON, error) {
if noms, ok := val.(NomsJSON); ok {
return noms, nil
}
sqlDoc, err := val.Unmarshall(sql.NewContext(ctx))
if err != nil {
return NomsJSON{}, err
}
sqlVal := val.ToInterface()
v, err := marshalJSON(ctx, vrw, sqlDoc.Val)
v, err := marshalJSON(ctx, vrw, sqlVal)
if err != nil {
return NomsJSON{}, err
}
@@ -136,6 +133,19 @@ func marshalJSONObject(ctx context.Context, vrw types.ValueReadWriter, obj map[s
return types.NewMap(ctx, vrw, vals...)
}
func (v NomsJSON) ToInterface() interface{} {
nomsVal, err := types.JSON(v).Inner()
if err != nil {
panic(err)
}
val, err := unmarshalJSON(context.Background(), nomsVal)
if err != nil {
panic(err)
}
return val
}
// Unmarshall implements the sql.JSONValue interface.
func (v NomsJSON) Unmarshall(ctx *sql.Context) (doc gmstypes.JSONDocument, err error) {
nomsVal, err := types.JSON(v).Inner()
@@ -193,23 +203,9 @@ func unmarshalJSONObject(ctx context.Context, m types.Map) (obj map[string]inter
return
}
// Compare implements the sql.JSONValue interface.
func (v NomsJSON) Compare(ctx *sql.Context, other gmstypes.JSONValue) (cmp int, err error) {
noms, ok := other.(NomsJSON)
if !ok {
doc, err := v.Unmarshall(ctx)
if err != nil {
return 0, err
}
return doc.Compare(ctx, other)
}
return types.JSON(v).Compare(ctx, types.JSON(noms))
}
// ToString implements the sql.JSONValue interface.
func (v NomsJSON) ToString(ctx *sql.Context) (string, error) {
return NomsJSONToString(ctx, v)
// JSONString implements the sql.JSONWrapper interface.
func (v NomsJSON) JSONString() (string, error) {
return NomsJSONToString(context.Background(), v)
}
func NomsJSONToString(ctx context.Context, js NomsJSON) (string, error) {

View File

@@ -92,7 +92,7 @@ func TestJSONValueMarshallingRoundTrip(t *testing.T) {
assert.Equal(t, test.doc.Val, jsDoc.Val)
// sql.JSONDocument -> NomsJSON -> string -> sql.JSONDocument
str, err := nomsVal.ToString(ctx)
str, err := nomsVal.JSONString()
assert.NoError(t, err)
var val interface{}
@@ -146,7 +146,7 @@ func TestJSONCompare(t *testing.T) {
// arrays
{`[1,2]`, `[1,2]`, 0},
// deterministic array ordering by hash
{`[1,2]`, `[1,9]`, 1},
{`[1,2]`, `[1,9]`, -1},
// objects
{`{"a": 0}`, `{"a": 0}`, 0},
@@ -154,12 +154,11 @@ func TestJSONCompare(t *testing.T) {
{`{"a": 1}`, `{"a": 0}`, 1},
}
ctx := sql.NewEmptyContext()
for _, test := range tests {
name := fmt.Sprintf("%v_%v__%d", test.left, test.right, test.cmp)
t.Run(name, func(t *testing.T) {
left, right := MustNomsJSON(test.left), MustNomsJSON(test.right)
cmp, err := left.Compare(ctx, right)
cmp, err := gmstypes.CompareJSON(left, right)
require.NoError(t, err)
assert.Equal(t, test.cmp, cmp)
})

View File

@@ -299,7 +299,7 @@ func getSchemaFragmentsOfType(ctx *sql.Context, tbl *WritableDoltTable, fragType
}
// Extract Created Time from JSON column
createdTime, err := getCreatedTime(ctx, sqlRow[extraIdx].(gmstypes.JSONValue))
createdTime, err := getCreatedTime(ctx, sqlRow[extraIdx].(sql.JSONWrapper))
frags = append(frags, schemaFragment{
name: sqlRow[nameIdx].(string),
@@ -326,15 +326,12 @@ func loadDefaultSqlMode() (string, error) {
return s, nil
}
func getCreatedTime(ctx *sql.Context, extraCol gmstypes.JSONValue) (int64, error) {
doc, err := extraCol.Unmarshall(ctx)
if err != nil {
return 0, err
}
func getCreatedTime(ctx *sql.Context, extraCol sql.JSONWrapper) (int64, error) {
doc := extraCol.ToInterface()
err = fmt.Errorf("value %v does not contain creation time", doc.Val)
err := fmt.Errorf("value %v does not contain creation time", doc)
obj, ok := doc.Val.(map[string]interface{})
obj, ok := doc.(map[string]interface{})
if !ok {
return 0, err
}

View File

@@ -140,13 +140,13 @@ func TestSchemaTableMigrationV1(t *testing.T) {
// Annoying difference in representation between storage versions here
jsonDoc, ok := row[3].(gmstypes.JSONDocument)
if ok {
row[3], err = jsonDoc.ToString(nil)
row[3], err = jsonDoc.JSONString()
row[3] = strings.ReplaceAll(row[3].(string), " ", "") // remove spaces
}
nomsJson, ok := row[3].(json.NomsJSON)
if ok {
row[3], err = nomsJson.ToString(ctx)
row[3], err = nomsJson.JSONString()
row[3] = strings.ReplaceAll(row[3].(string), " ", "") // remove spaces
}

View File

@@ -1379,7 +1379,7 @@ func testSelectQuery(t *testing.T, test SelectTest) {
assert.Equal(t, len(test.ExpectedRows[i]), len(actualRows[i]))
for j := 0; j < len(test.ExpectedRows[i]); j++ {
if _, ok := actualRows[i][j].(json.NomsJSON); ok {
cmp, err := actualRows[i][j].(json.NomsJSON).Compare(nil, test.ExpectedRows[i][j].(json.NomsJSON))
cmp, err := gmstypes.CompareJSON(actualRows[i][j].(json.NomsJSON), test.ExpectedRows[i][j].(json.NomsJSON))
assert.NoError(t, err)
assert.Equal(t, 0, cmp)
} else {

View File

@@ -19,6 +19,7 @@ import (
"testing"
"github.com/dolthub/go-mysql-server/sql"
gmstypes "github.com/dolthub/go-mysql-server/sql/types"
"github.com/google/uuid"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
@@ -422,7 +423,7 @@ func testUpdateQuery(t *testing.T, test UpdateTest) {
assert.Equal(t, len(test.ExpectedRows[i]), len(actualRows[i]))
for j := 0; j < len(test.ExpectedRows[i]); j++ {
if _, ok := actualRows[i][j].(json.NomsJSON); ok {
cmp, err := actualRows[i][j].(json.NomsJSON).Compare(nil, test.ExpectedRows[i][j].(json.NomsJSON))
cmp, err := gmstypes.CompareJSON(actualRows[i][j].(json.NomsJSON), test.ExpectedRows[i][j].(json.NomsJSON))
assert.NoError(t, err)
assert.Equal(t, 0, cmp)
} else {

View File

@@ -239,7 +239,7 @@ func (u *bucketBuilder) finalize(ctx context.Context, ns tree.NodeStore) (DoltBu
Count: uint64(u.count),
Distinct: uint64(u.distinct),
BoundCount: uint64(u.currentCnt),
Mcv: mcvRows,
Mcvs: mcvRows,
McvCount: u.mcvs.Counts(),
UpperBound: upperBound,
Null: uint64(u.nulls),

View File

@@ -69,7 +69,7 @@ func TestBucketBuilder(t *testing.T) {
bucket: DoltBucket{
Count: 15,
Distinct: 5,
Mcv: []sql.Row{{int64(4)}, {int64(2)}, {int64(3)}},
Mcvs: []sql.Row{{int64(4)}, {int64(2)}, {int64(3)}},
McvCount: []uint64{3, 4, 3},
UpperBound: sql.Row{int64(5)},
BoundCount: 2,
@@ -84,7 +84,7 @@ func TestBucketBuilder(t *testing.T) {
Count: 16,
Distinct: 6,
Null: 3,
Mcv: []sql.Row{{int64(4)}, {int64(2)}, {nil}},
Mcvs: []sql.Row{{int64(4)}, {int64(2)}, {nil}},
McvCount: []uint64{3, 4, 3},
UpperBound: sql.Row{int64(5)},
BoundCount: 2,
@@ -98,7 +98,7 @@ func TestBucketBuilder(t *testing.T) {
Count: 15,
Distinct: 6,
Null: 2,
Mcv: []sql.Row{{int64(3)}, {int64(4)}, {int64(2)}},
Mcvs: []sql.Row{{int64(3)}, {int64(4)}, {int64(2)}},
McvCount: []uint64{3, 3, 4},
UpperBound: sql.Row{int64(5)},
BoundCount: 2,
@@ -112,7 +112,7 @@ func TestBucketBuilder(t *testing.T) {
Count: 22,
Distinct: 7,
BoundCount: 1,
Mcv: []sql.Row{{int64(2)}, {int64(6)}, {int64(5)}},
Mcvs: []sql.Row{{int64(2)}, {int64(6)}, {int64(5)}},
McvCount: []uint64{4, 4, 4},
UpperBound: sql.Row{int64(7)},
},
@@ -124,7 +124,7 @@ func TestBucketBuilder(t *testing.T) {
bucket: DoltBucket{
Count: 15,
Distinct: 11,
Mcv: []sql.Row{{int64(1), int64(1)}, {int64(4), int64(1)}, {int64(2), int64(3)}},
Mcvs: []sql.Row{{int64(1), int64(1)}, {int64(4), int64(1)}, {int64(2), int64(3)}},
McvCount: []uint64{2, 3, 2},
UpperBound: sql.Row{int64(5), int64(2)},
BoundCount: 1,
@@ -138,7 +138,7 @@ func TestBucketBuilder(t *testing.T) {
Count: 5,
Distinct: 5,
Null: 3,
Mcv: []sql.Row{{int64(2), int64(2)}, {int64(1), nil}, {int64(1), int64(2)}},
Mcvs: []sql.Row{{int64(2), int64(2)}, {int64(1), nil}, {int64(1), int64(2)}},
McvCount: []uint64{1, 1, 1},
UpperBound: sql.Row{int64(2), int64(2)},
BoundCount: 1,
@@ -151,7 +151,7 @@ func TestBucketBuilder(t *testing.T) {
bucket: DoltBucket{
Count: 15,
Distinct: 9,
Mcv: []sql.Row{{"i"}, {"h"}, {"g"}},
Mcvs: []sql.Row{{"i"}, {"h"}, {"g"}},
McvCount: []uint64{2, 3, 3},
UpperBound: sql.Row{"i"},
BoundCount: 2,
@@ -164,7 +164,7 @@ func TestBucketBuilder(t *testing.T) {
bucket: DoltBucket{
Count: 15,
Distinct: 12,
Mcv: []sql.Row{{"i", int64(1)}, {"g", int64(2)}, {"h", int64(1)}},
Mcvs: []sql.Row{{"i", int64(1)}, {"g", int64(2)}, {"h", int64(1)}},
McvCount: []uint64{2, 2, 2},
UpperBound: sql.Row{"i", int64(1)},
BoundCount: 2,
@@ -196,7 +196,7 @@ func TestBucketBuilder(t *testing.T) {
require.Equal(t, int(tt.bucket.BoundCount), int(bucket.BoundCount))
require.Equal(t, tt.bucket.UpperBound, bucket.UpperBound)
require.Equal(t, tt.bucket.McvCount, bucket.McvCount)
require.Equal(t, tt.bucket.Mcv, bucket.Mcv)
require.Equal(t, tt.bucket.Mcvs, bucket.Mcvs)
})
}
}

View File

@@ -35,49 +35,36 @@ type DoltStats struct {
DistinctCount uint64
NullCount uint64
AvgSize uint64
Qualifier sql.StatQualifier
CreatedAt time.Time
Histogram DoltHistogram
Columns []string
Types []sql.Type
}
func DoltStatsFromSql(stats *stats.Stats) (*DoltStats, error) {
typs, err := parseTypeString(stats.Types)
if err != nil {
return nil, err
}
hist, err := DoltHistFromSql(stats.Histogram, typs)
func DoltStatsFromSql(stat sql.Statistic) (*DoltStats, error) {
hist, err := DoltHistFromSql(stat.Histogram(), stat.Types())
if err != nil {
return nil, err
}
return &DoltStats{
RowCount: stats.Rows,
DistinctCount: stats.Distinct,
NullCount: stats.Nulls,
AvgSize: stats.AvgSize,
CreatedAt: stats.CreatedAt,
RowCount: stat.RowCount(),
DistinctCount: stat.DistinctCount(),
NullCount: stat.NullCount(),
AvgSize: stat.AvgSize(),
CreatedAt: stat.CreatedAt(),
Histogram: hist,
Columns: stats.Columns,
Types: typs,
Columns: stat.Columns(),
Types: stat.Types(),
}, nil
}
func (s *DoltStats) toSql() *stats.Stats {
func (s *DoltStats) toSql() sql.Statistic {
typStrs := make([]string, len(s.Types))
for i, typ := range s.Types {
typStrs[i] = typ.String()
}
return &stats.Stats{
Rows: s.RowCount,
Distinct: s.DistinctCount,
Nulls: s.NullCount,
AvgSize: s.AvgSize,
CreatedAt: s.CreatedAt,
Histogram: s.Histogram.toSql(),
Columns: s.Columns,
Types: typStrs,
Version: 0,
}
return stats.NewStatistic(s.RowCount, s.DistinctCount, s.NullCount, s.AvgSize, s.CreatedAt, s.Qualifier, s.Columns, s.Types, s.Histogram.toSql())
}
type DoltHistogram []DoltBucket
@@ -86,25 +73,25 @@ type DoltBucket struct {
Count uint64
Distinct uint64
Null uint64
Mcv []sql.Row
Mcvs []sql.Row
McvCount []uint64
BoundCount uint64
UpperBound sql.Row
}
func DoltHistFromSql(hist stats.Histogram, types []sql.Type) (DoltHistogram, error) {
func DoltHistFromSql(hist sql.Histogram, types []sql.Type) (DoltHistogram, error) {
ret := make([]DoltBucket, len(hist))
var err error
for i, b := range hist {
upperBound := make(sql.Row, len(b.UpperBound))
for i, v := range b.UpperBound {
upperBound := make(sql.Row, len(b.UpperBound()))
for i, v := range b.UpperBound() {
upperBound[i], _, err = types[i].Convert(v)
if err != nil {
return nil, fmt.Errorf("failed to convert %v to type %s", v, types[i].String())
}
}
mcvs := make([]sql.Row, len(b.Mcv))
for i, mcv := range b.Mcv {
mcvs := make([]sql.Row, len(b.Mcvs()))
for i, mcv := range b.Mcvs() {
for _, v := range mcv {
conv, _, err := types[i].Convert(v)
if err != nil {
@@ -114,12 +101,12 @@ func DoltHistFromSql(hist stats.Histogram, types []sql.Type) (DoltHistogram, err
}
}
ret[i] = DoltBucket{
Count: b.Count,
Distinct: b.Distinct,
Null: b.Null,
Mcv: mcvs,
McvCount: b.McvCount,
BoundCount: b.BoundCount,
Count: b.RowCount(),
Distinct: b.DistinctCount(),
Null: b.NullCount(),
Mcvs: mcvs,
McvCount: b.McvCounts(),
BoundCount: b.BoundCount(),
UpperBound: nil,
}
}
@@ -152,26 +139,12 @@ func parseTypeString(types []string) ([]sql.Type, error) {
return ret, nil
}
func (s DoltHistogram) toSql() []stats.Bucket {
ret := make([]stats.Bucket, len(s))
func (s DoltHistogram) toSql() []*stats.Bucket {
ret := make([]*stats.Bucket, len(s))
for i, b := range s {
upperBound := make([]interface{}, len(b.UpperBound))
copy(upperBound, b.UpperBound)
mcvs := make([][]interface{}, len(b.Mcv))
for i, mcv := range b.Mcv {
for _, v := range mcv {
mcvs[i] = append(mcvs[i], v)
}
}
ret[i] = stats.Bucket{
Count: b.Count,
Distinct: b.Distinct,
Null: b.Null,
UpperBound: upperBound,
BoundCount: b.BoundCount,
Mcv: mcvs,
McvCount: b.McvCount,
}
ret[i] = stats.NewHistogramBucket(b.Count, b.Distinct, b.Null, b.BoundCount, upperBound, b.McvCount, b.Mcvs)
}
return ret
}
@@ -203,8 +176,8 @@ type Provider struct {
var _ sql.StatsProvider = (*Provider)(nil)
func (p *Provider) GetTableStats(ctx *sql.Context, db, table string) ([]*stats.Stats, error) {
var ret []*stats.Stats
func (p *Provider) GetTableStats(ctx *sql.Context, db, table string) ([]sql.Statistic, error) {
var ret []sql.Statistic
for meta, stat := range p.stats {
if strings.EqualFold(db, meta.db) && strings.EqualFold(table, meta.table) {
ret = append(ret, stat.toSql())
@@ -213,11 +186,11 @@ func (p *Provider) GetTableStats(ctx *sql.Context, db, table string) ([]*stats.S
return ret, nil
}
func (p *Provider) SetStats(ctx *sql.Context, db, table string, stats *stats.Stats) error {
func (p *Provider) SetStats(ctx *sql.Context, stats sql.Statistic) error {
meta := statsMeta{
db: strings.ToLower(db),
table: strings.ToLower(table),
pref: strings.Join(stats.Columns, ","),
db: strings.ToLower(stats.Qualifier().Db()),
table: strings.ToLower(stats.Qualifier().Table()),
pref: strings.Join(stats.Columns(), ","),
}
doltStats, err := DoltStatsFromSql(stats)
if err != nil {
@@ -227,10 +200,10 @@ func (p *Provider) SetStats(ctx *sql.Context, db, table string, stats *stats.Sta
return nil
}
func (p *Provider) GetStats(ctx *sql.Context, db, table string, cols []string) (*stats.Stats, bool) {
func (p *Provider) GetStats(ctx *sql.Context, qual sql.StatQualifier, cols []string) (sql.Statistic, bool) {
meta := statsMeta{
db: strings.ToLower(db),
table: strings.ToLower(table),
db: strings.ToLower(qual.Db()),
table: strings.ToLower(qual.Table()),
pref: strings.Join(cols, ","),
}
if s, ok := p.stats[meta]; ok {
@@ -239,10 +212,10 @@ func (p *Provider) GetStats(ctx *sql.Context, db, table string, cols []string) (
return nil, false
}
func (p *Provider) DropStats(ctx *sql.Context, db, table string, cols []string) error {
func (p *Provider) DropStats(ctx *sql.Context, qual sql.StatQualifier, cols []string) error {
meta := statsMeta{
db: strings.ToLower(db),
table: strings.ToLower(table),
db: strings.ToLower(qual.Db()),
table: strings.ToLower(qual.Table()),
pref: strings.Join(cols, ","),
}
delete(p.stats, meta)

View File

@@ -127,7 +127,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -177,7 +177,7 @@ SQL
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
echo $output
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -232,8 +232,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -287,8 +287,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -345,7 +345,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,3,3,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,3,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -398,8 +398,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -449,7 +449,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -498,7 +498,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -553,8 +553,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -608,8 +608,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -666,7 +666,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,3,3,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,3,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -719,8 +719,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -770,7 +770,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -819,7 +819,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -874,8 +874,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -929,8 +929,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -987,7 +987,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,3,3,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,3,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1040,8 +1040,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1186,7 +1186,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1238,7 +1238,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1294,8 +1294,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1352,8 +1352,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1411,7 +1411,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,3,3,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,3,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1465,8 +1465,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1519,7 +1519,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1571,7 +1571,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1627,8 +1627,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1685,8 +1685,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1744,7 +1744,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,3,3,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,3,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1798,8 +1798,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1852,7 +1852,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1904,7 +1904,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -1960,8 +1960,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -2018,8 +2018,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -2077,7 +2077,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,3,3,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,3,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -2131,8 +2131,8 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "$output" =~ 'foreign key,3,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "3" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -2184,7 +2184,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -2235,7 +2235,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -2286,7 +2286,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -2336,7 +2336,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -2386,7 +2386,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -2436,7 +2436,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""SET NULL"", ""OnUpdate"": ""SET NULL"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -2490,7 +2490,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""child"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM parent" -r=csv
log_status_eq "0"
@@ -2543,7 +2543,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child1" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,20,2,"{""Index"": ""v1"", ""Table"": ""child1"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_c1"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,20,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_c1"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child1""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child2" -r=csv
log_status_eq "0"
@@ -2605,7 +2605,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child1" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,20,2,"{""Index"": ""v1"", ""Table"": ""child1"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_c1"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,20,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_c1"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child1""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child2" -r=csv
log_status_eq "0"
@@ -2667,7 +2667,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child1" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,20,2,"{""Index"": ""v1"", ""Table"": ""child1"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_c1"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,20,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_c1"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child1""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child2" -r=csv
log_status_eq "0"
@@ -2730,7 +2730,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child1" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,20,2,"{""Index"": ""v1"", ""Table"": ""child1"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_c1"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,20,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_c1"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""parent"", ""Table"": ""child1""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations_child2" -r=csv
log_status_eq "0"
@@ -2808,7 +2808,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_t2" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Index"": ""v1"", ""Table"": ""t2"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_t2"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""t1"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,2,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_t2"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""t1"", ""Table"": ""t2""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM t1" -r=csv
log_status_eq "0"
@@ -2838,7 +2838,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_t1" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,20,2,"{""Index"": ""v1"", ""Table"": ""t1"", ""Columns"": [""v1""], ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ForeignKey"": ""fk_t1"", ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""t2"", ""ReferencedColumns"": [""v1""]}"' ]] || false
[[ "$output" =~ 'foreign key,20,2,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_t1"", ""Index"": ""v1"", ""OnDelete"": ""RESTRICT"", ""OnUpdate"": ""RESTRICT"", ""ReferencedColumns"": [""v1""], ""ReferencedIndex"": ""v1"", ""ReferencedTable"": ""t2"", ""Table"": ""t1""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM dolt_constraint_violations_t2" -r=csv
log_status_eq "0"
@@ -2885,7 +2885,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_test" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,4,3,"{""Index"": ""v1"", ""Table"": ""test"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": """", ""ReferencedTable"": ""test"", ""ReferencedColumns"": [""pk""]}"' ]] || false
[[ "$output" =~ 'foreign key,4,3,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""pk""], ""ReferencedIndex"": """", ""ReferencedTable"": ""test"", ""Table"": ""test""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM test" -r=csv
log_status_eq "0"
@@ -2924,7 +2924,7 @@ SQL
run dolt sql -q "SELECT * FROM dolt_constraint_violations_test" -r=csv
log_status_eq "0"
[[ "$output" =~ "violation_type,pk,v1,violation_info" ]] || false
[[ "$output" =~ 'foreign key,4,3,"{""Index"": ""v1"", ""Table"": ""test"", ""Columns"": [""v1""], ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ForeignKey"": ""fk_name"", ""ReferencedIndex"": """", ""ReferencedTable"": ""test"", ""ReferencedColumns"": [""pk""]}"' ]] || false
[[ "$output" =~ 'foreign key,4,3,"{""Columns"": [""v1""], ""ForeignKey"": ""fk_name"", ""Index"": ""v1"", ""OnDelete"": ""CASCADE"", ""OnUpdate"": ""CASCADE"", ""ReferencedColumns"": [""pk""], ""ReferencedIndex"": """", ""ReferencedTable"": ""test"", ""Table"": ""test""}"' ]] || false
[[ "${#lines[@]}" = "2" ]] || false
run dolt sql -q "SELECT * FROM test" -r=csv
log_status_eq "0"
@@ -2971,4 +2971,4 @@ SQL
run dolt index ls
[[ "$output" =~ "No indexes in the working set" ]] || false
}
}