SELECT what y ou just inserted, within the same transaction
eventually COMMIT or ROLLBACK
The SELECT returns 0 rows.
What you expected to happen
In immudb 1.5.0 the SELECT returned the inserted row.
How to reproduce it (as minimally and precisely as possible)
You can use this simple code to check
package main
import (
"context"
"fmt"
"math/rand"
"time"
immuclient "github.com/codenotary/immudb/pkg/client"
)
func init() {
rand.Seed(time.Now().UnixNano())
}
var letters = []rune("abcdefghijklmnopqrstuvwxyz")
func rndString(n int) string {
b := make([]rune, n)
for i := range b {
b[i] = letters[rand.Intn(len(letters))]
}
return string(b)
}
func main() {
ctx := context.Background()
client := immuclient.NewClient()
err := client.OpenSession(ctx, []byte("immudb"), []byte("immudb"), "defaultdb")
if err != nil {
panic("Failed to open session: " + err.Error())
}
tabName := rndString(12)
q := fmt.Sprintf("CREATE TABLE %s (id INTEGER AUTO_INCREMENT, tester VARCHAR[10], PRIMARY KEY id)", tabName)
fmt.Println(q)
client.SQLExec(ctx, q, nil)
tx, err := client.NewTx(ctx)
if err != nil {
panic("Failed to open session: " + err.Error())
}
q = fmt.Sprintf("INSERT INTO %s(tester) values ('123')", tabName)
fmt.Println(q)
tx.SQLExec(ctx, q, nil)
q = fmt.Sprintf("SELECT * from %s", tabName)
fmt.Println(q)
resp, err := tx.SQLQuery(ctx, q, nil)
fmt.Printf("%+v", resp)
tx.Commit(ctx)
}
Environment
# run "immu* version" and copy/paste the output here
immudb 1.9DOM.0
Commit : 91a30ecf54cb7407626af94ef3183b07c1616539
Built by: slazzaris@gmail.com
Built at: Fri, 27 Oct 2023 11:49:04 CEST
Additional info (any other context about the problem)
What happened Pattern to trigger the bug is
INSERT
using the transactionSELECT
what y ou just inserted, within the same transactionCOMMIT
orROLLBACK
The
SELECT
returns 0 rows.What you expected to happen
In immudb 1.5.0 the
SELECT
returned the inserted row.How to reproduce it (as minimally and precisely as possible)
You can use this simple code to check
Environment
Additional info (any other context about the problem)