tursodatabase / libsql-client-go

Go client API for libSQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Read-only transaction support

penberg opened this issue · comments

Report on Discord:

Hi I got this error read only transactions are not supported when I execute transaction with readonly option set to true

db.BeginTx(ctx, &sql.TxOptions{
        ReadOnly: true,
})

We do have support for read-only transactions in libSQL so let's look into implementing this.

Hi, can I try implementing this?

Hey @gavsidhu, absolutely, I tagged as "help wanted" so anyone interested can have a stab at it. Feel free to drop by our Discord if you need help with it.

@penberg Let me know if my pull request #102 is the implementation you wanted.

I'm wondering what does it mean to mark transaction in database/sql as read-only and if there's any benefit of doing that.

I tested this with turso db shell and it seems that read only transactions don't work for hrana:

→  select * from test;
A 
→  begin readonly; insert into test values(101); select * from test; commit;
A   
101

Confirmed that read only transactions work only for embedded replicas which this client does not support -> tursodatabase/libsql#1555