Details
-
Improvement
-
Status: Resolved
-
Low
-
Resolution: Won't Fix
-
None
-
None
Description
Currently the flow for executing a prepared statement in the native protocol is:
- PREPARE request
- prepared response (queryid)
- EXECUTE request (using queryid)
- RESULT response
- or UNPREPARED error response
As is today, it is the responsibility of the driver or client to maintain the query id and to send a EXECUTE message using this query id and to expect for UNPREPARED error response in case the query got evicted or the node was restarted.
With the following implications:
- Before making a EXECUTE request, there is no way to know if it got evicted.
- Before sending a PREPARE request, there is no way to know if that query has been already prepared on that host (by another connection), .
- There isn't anything else the client can do with the prepared id (no much use from the client perspective).
It would be nice to have a flag in the QUERY and BATCH requests that when set, the Cassandra node will prepare (if not already prepared) and execute the prepared query. This way we could save a few extra roundtrips and make the protocol flow for prepared statements a little more simple.