tursodatabase / libsql-client-go

Go client API for libSQL
MIT License
190 stars 24 forks source link

Read-only transaction support #98

Open penberg opened 9 months ago

penberg commented 9 months ago

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.

gavsidhu commented 9 months ago

Hi, can I try implementing this?

penberg commented 9 months ago

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.

p0isonra1n commented 9 months ago

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

haaawk commented 2 months ago

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.

haaawk commented 2 months ago

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
haaawk commented 2 months ago

Confirmed that read only transactions work only for embedded replicas which this client does not support -> https://github.com/tursodatabase/libsql/issues/1555