feat(storage): read only transactions (#6417)

feat(storage): read only transactions for queries (#6415)

* fix: tests

* bastle wie en grosse

* fix(database): scan as callback

* fix tests

* fix merge failures

* remove as of system time

* refactor: remove unused test

* refacotr: remove unused lines
This commit is contained in:
Silvan
2023-08-22 14:49:02 +02:00
committed by GitHub
parent 7442492b8a
commit 22af4dcd97
128 changed files with 1355 additions and 897 deletions

View File

@@ -2,7 +2,6 @@ package cockroach
import (
"database/sql"
"fmt"
"strconv"
"strings"
"time"
@@ -94,12 +93,7 @@ func (c *Config) Type() string {
}
func (c *Config) Timetravel(d time.Duration) string {
// verify that it is at least 1 micro second
if d < time.Microsecond {
d = time.Microsecond
}
return fmt.Sprintf(" AS OF SYSTEM TIME '-%d µs' ", d.Microseconds())
return ""
}
type User struct {

View File

@@ -1,61 +0,0 @@
package cockroach
import (
"testing"
"time"
)
func TestConfig_Timetravel(t *testing.T) {
type args struct {
d time.Duration
}
tests := []struct {
name string
args args
want string
}{
{
name: "no duration",
args: args{
d: 0,
},
want: " AS OF SYSTEM TIME '-1 µs' ",
},
{
name: "less than microsecond",
args: args{
d: 100 * time.Nanosecond,
},
want: " AS OF SYSTEM TIME '-1 µs' ",
},
{
name: "10 microseconds",
args: args{
d: 10 * time.Microsecond,
},
want: " AS OF SYSTEM TIME '-10 µs' ",
},
{
name: "10 milliseconds",
args: args{
d: 10 * time.Millisecond,
},
want: " AS OF SYSTEM TIME '-10000 µs' ",
},
{
name: "1 second",
args: args{
d: 1 * time.Second,
},
want: " AS OF SYSTEM TIME '-1000000 µs' ",
},
}
for _, tt := range tests {
c := &Config{}
t.Run(tt.name, func(t *testing.T) {
if got := c.Timetravel(tt.args.d); got != tt.want {
t.Errorf("Config.Timetravel() = %q, want %q", got, tt.want)
}
})
}
}