joao-r-reis commented on code in PR #1822:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1822#discussion_r1803249941


##########
conn.go:
##########
@@ -1430,6 +1525,24 @@ func (c *Conn) executeQuery(ctx context.Context, qry 
*Query) *Iter {
        case *resultVoidFrame:
                return &Iter{framer: framer}
        case *resultRowsFrame:
+               if x.meta.newMetadataID != nil {
+                       stmtCacheKey := 
c.session.stmtsLRU.keyFor(c.host.HostID(), c.currentKeyspace, qry.stmt)
+                       inflight, ok := c.session.stmtsLRU.get(stmtCacheKey)
+                       if !ok {
+                               // We didn't find the stmt in the cache, so we 
just re-prepare it
+                               return c.executeQuery(ctx, qry)
+                       }
+
+                       // Updating the result metadata id in prepared stmt
+                       //
+                       // If a RESULT/Rows message reports
+                       //      changed resultset metadata with the 
Metadata_changed flag, the reported new
+                       //      resultset metadata must be used in subsequent 
executions
+                       inflight.preparedStatment.resultMetadataID = 
x.meta.newMetadataID
+                       inflight.preparedStatment.response = x.meta

Review Comment:
   Doing it the same way as handling of `UNPREPARED` is not really ideal, it is 
just evicting the prepared statement from the cache and forcing the driver to 
re-prepare.
   
   Replacing `inflight.preparedStatement` won't fix anything unless this field 
is made `atomic`, I was thinking of replacing the whole `inflight` object in 
the cache so we don't have to worry about synchronization or having to make 
things `atomic` (since the cache itself already does this). I think this can be 
done by creating a new `inflight` object (with a new copy of the 
`preparedStatement` object) and just calling `*preparedLRU.add` since it looks 
like it has "upsert" semantics.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to