More BCE.

This commit is contained in:
Nuno Cruces
2024-09-30 11:03:50 +01:00
parent e59e2ed2a2
commit 8b6c2b28fb
8 changed files with 51 additions and 35 deletions

View File

@@ -92,8 +92,10 @@ func (c *closure) BestIndex(idx *sqlite3.IndexInfo) error {
case sqlite3.INDEX_CONSTRAINT_EQ:
plan |= 1
cost /= 100
idx.ConstraintUsage[i].ArgvIndex = 1
idx.ConstraintUsage[i].Omit = true
idx.ConstraintUsage[i] = sqlite3.IndexConstraintUsage{
ArgvIndex: 1,
Omit: true,
}
}
continue
}
@@ -116,8 +118,10 @@ func (c *closure) BestIndex(idx *sqlite3.IndexInfo) error {
plan |= posi << 8
cost /= 5
posi += 1
idx.ConstraintUsage[i].ArgvIndex = posi
idx.ConstraintUsage[i].Omit = true
idx.ConstraintUsage[i] = sqlite3.IndexConstraintUsage{
ArgvIndex: posi,
Omit: true,
}
}
continue
}
@@ -126,8 +130,10 @@ func (c *closure) BestIndex(idx *sqlite3.IndexInfo) error {
case sqlite3.INDEX_CONSTRAINT_EQ:
plan |= posi << 12
posi += 1
idx.ConstraintUsage[i].ArgvIndex = posi
idx.ConstraintUsage[i].Omit = true
idx.ConstraintUsage[i] = sqlite3.IndexConstraintUsage{
ArgvIndex: posi,
Omit: true,
}
}
continue
}
@@ -136,8 +142,10 @@ func (c *closure) BestIndex(idx *sqlite3.IndexInfo) error {
case sqlite3.INDEX_CONSTRAINT_EQ:
plan |= posi << 16
posi += 1
idx.ConstraintUsage[i].ArgvIndex = posi
idx.ConstraintUsage[i].Omit = true
idx.ConstraintUsage[i] = sqlite3.IndexConstraintUsage{
ArgvIndex: posi,
Omit: true,
}
}
continue
}

View File

@@ -22,8 +22,9 @@ func getColumnAffinities(schema string) ([]affinity, error) {
return nil, err
}
types := make([]affinity, len(tab.Columns))
for i, col := range tab.Columns {
columns := tab.Columns
types := make([]affinity, len(columns))
for i, col := range columns {
types[i] = getAffinity(col.Type)
}
return types, nil

View File

@@ -99,8 +99,8 @@ func declare(db *sqlite3.Conn, _, _, _ string, arg ...string) (_ *table, err err
}
func (t *table) Close() error {
for i := range t.cols {
t.cols[i].Close()
for _, c := range t.cols {
c.Close()
}
return nil
}

View File

@@ -47,9 +47,9 @@ func zorder(ctx sqlite3.Context, arg ...sqlite3.Value) {
}
func unzorder(ctx sqlite3.Context, arg ...sqlite3.Value) {
z := arg[0].Int64()
n := arg[1].Int64()
i := arg[2].Int64()
n := arg[1].Int64()
z := arg[0].Int64()
var k int
var x int64