Code Monkey home page Code Monkey logo

Comments (5)

MathieuBordere avatar MathieuBordere commented on July 20, 2024 1

Oh, it's because the QUERY codepath doesn't do a VfsPoll to propagate any changes to the database.

Yeah, it's "read only" and doesn't go through raft.

from dqlite.

cole-miller avatar cole-miller commented on July 20, 2024

Specifically, running (in pseudocode):

stmt = PREPARE("CREATE TABLE foo (n INT)");
QUERY(stmt);

works fine, but afterward attempting to prepare a statement like SELECT * FROM foo will fail with "no such table". I haven't figured out why this is -- sqlite3_step does get called on the CREATE statement and returns SQLITE_DONE, which should also be what happens when running an EXEC request.

from dqlite.

cole-miller avatar cole-miller commented on July 20, 2024

Oh, it's because the QUERY codepath doesn't do a VfsPoll to propagate any changes to the database.

from dqlite.

cole-miller avatar cole-miller commented on July 20, 2024

I think it should be possible to implement the new request (pre-bikeshed name: GENEXEC) to reuse the existing code in leaderExecV2 and query__batch -- experimenting with that now.

from dqlite.

freeekanayaka avatar freeekanayaka commented on July 20, 2024

One other option that might be a bit easier both for the client and for the server is to modify the response the PREPARE request adding a flag indicating if the statement is read-only or not. That flag can be stored in the dqlite_stmt object along with the statement ID, and subsequent calls to dqlite_step will invoke the correct API (either QUERY or EXEC) based on that flag.

The sqlite3_stmt_readonly SQLite function can be used by the server when processing the PREPARE request to determine the value of the flag to include in the response.

YMMV

from dqlite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.