Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

database/gdb: How to set the isolation level for the current transaction #4006

Closed
LanceAdd opened this issue Dec 4, 2024 · 1 comment
Closed
Assignees
Labels
done This issue is done, which may be release in next version. feature planned This issue/proposal is planned into our next steps.

Comments

@LanceAdd
Copy link
Contributor

LanceAdd commented Dec 4, 2024

Is your feature request related to a problem?

Option Yes

Describe the solution you'd like

current Transaction

Transaction(ctx context.Context, f func(ctx context.Context, tx TX) error) error

and

Begin(ctx context.Context) (TX, error) 

target Transaction

Transaction(ctx context.Context, f func(ctx context.Context, tx TX) error, opts ...*TxOptions) error
Begin(ctx context.Context, opts ...*TxOptions) (TX, error) 

Describe alternatives you've considered

I can set the transaction isolation level in "database/sql", but I can't find the corresponding entry in the goframe

import (
    "database/sql"
)

txOptions := &sql.TxOptions{
    Isolation: sql.LevelRepeatableRead,
    ReadOnly:  true,
}

tx, err := db.BeginTx(ctx, txOptions)
if err != nil {
    // todo
}
defer tx.Rollback()

err = tx.Commit()
if err != nil {
      // todo
}

Additional

No response

@gqcn
Copy link
Member

gqcn commented Dec 5, 2024

@LanceAdd Hi, I'm planning adding such feature recently.

@gqcn gqcn added the planned This issue/proposal is planned into our next steps. label Dec 5, 2024
@gqcn gqcn self-assigned this Dec 5, 2024
@gqcn gqcn added the done This issue is done, which may be release in next version. label Dec 7, 2024
@gqcn gqcn closed this as completed Dec 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
done This issue is done, which may be release in next version. feature planned This issue/proposal is planned into our next steps.
Projects
None yet
Development

No branches or pull requests

2 participants