go-sqlite3 icon indicating copy to clipboard operation
go-sqlite3 copied to clipboard

Example vtable_eponymous_only misses start value assignment to cursor

Open philippfriese opened this issue 10 months ago • 0 comments

The vtable_eponymous_only example is missing a start value assignment to the vtable cursor in one of the four variants of the Filter call

For calls with zero to two parameters (none, start, and start+stop), the vtable cursor value is assigned to the table start field. The call with parameters start+stop+step is missing this assignment.

Code excerpt of Filter:

func (vc *seriesCursor) Filter(idxNum int, idxStr string, vals []any) error {
	switch {
	case len(vals) < 1:
		vc.seriesTable.start = 0
		vc.seriesTable.stop = 1000
		vc.value = vc.seriesTable.start
	case len(vals) < 2:
		vc.seriesTable.start = vals[0].(int64)
		vc.seriesTable.stop = 1000
		vc.value = vc.seriesTable.start
	case len(vals) < 3:
		vc.seriesTable.start = vals[0].(int64)
		vc.seriesTable.stop = vals[1].(int64)
		vc.value = vc.seriesTable.start
	case len(vals) < 4:
		vc.seriesTable.start = vals[0].(int64)
		vc.seriesTable.stop = vals[1].(int64)
		vc.seriesTable.step = vals[2].(int64)
	        // < - missing vc.value assignment - >
	}
	return nil
}

This leads to inconsistent behaviour where the returned values of select * from series($start, $stop, $step) do not start at the provided $start value, but at the default start value 0.

Checked for commit 7658c06.

philippfriese avatar Feb 13 '25 09:02 philippfriese