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

feat: Enable read only transaction support #102

Closed
wants to merge 1 commit into from

Conversation

p0isonra1n
Copy link
Contributor

This should fix issue #98 but I am not sure the best way to test it.

@haaawk
Copy link
Contributor

haaawk commented Jul 15, 2024

I think we need the transaction to make sure that it never writes if it's marked as read only. That probably requires examining every statement it receives and throwing exception when write is received.

@haaawk
Copy link
Contributor

haaawk commented Jul 15, 2024

There's no BEGIN READONLY syntax in sqlite/libsql -> https://www.sqlite.org/lang_transaction.html

> sqlite3 ~/test.db
SQLite version 3.43.2 2023-10-10 13:08:14
Enter ".help" for usage hints.
sqlite> BEGIN READONLY;
Parse error: near "READONLY": syntax error
  BEGIN READONLY;
        ^--- error here

@haaawk haaawk closed this Jul 15, 2024
@haaawk
Copy link
Contributor

haaawk commented Jul 15, 2024

I guess we could try do this for remote only code considering tursodatabase/libsql@91f4780

@haaawk haaawk reopened this Jul 15, 2024
@haaawk
Copy link
Contributor

haaawk commented Jul 15, 2024

I guess we could try do this for remote only code considering tursodatabase/libsql@91f4780

but it seems to work only with embedded replicas which this client does not support

@haaawk
Copy link
Contributor

haaawk commented Jul 15, 2024

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
Copy link
Contributor

haaawk commented Jul 15, 2024

I'm closing this for now @p0isonra1n but feel free to reopen if you still want to work on this.

@haaawk haaawk closed this Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants