worryg0d commented on code in PR #1822:
URL: 
https://github.com/apache/cassandra-gocql-driver/pull/1822#discussion_r1817248175


##########
conn.go:
##########
@@ -1430,6 +1529,34 @@ func (c *Conn) executeQuery(ctx context.Context, qry 
*Query) *Iter {
        case *resultVoidFrame:
                return &Iter{framer: framer}
        case *resultRowsFrame:
+               if x.meta.newMetadataID != nil {
+                       // 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
+
+                       stmtCacheKey := 
c.session.stmtsLRU.keyFor(c.host.HostID(), c.currentKeyspace, qry.stmt)
+                       oldInflight, 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)
+                       }
+
+                       newInflight := &inflightPrepare{
+                               done: make(chan struct{}),
+                               preparedStatment: &preparedStatment{
+                                       id:               
oldInflight.preparedStatment.id,
+                                       resultMetadataID: x.meta.newMetadataID,
+                                       request:          
oldInflight.preparedStatment.request,
+                                       response:         x.meta,
+                               },
+                       }
+
+                       c.session.stmtsLRU.add(stmtCacheKey, newInflight)
+                       return c.executeQuery(ctx, qry)

Review Comment:
   I wrote an [integration 
test](https://github.com/worryg0d/gocql/commit/9717fa551bb05e1d088ce1defb3159dd5a299af5)
 for this mechanism. Could you please take a look at it to ensure that I didn't 
miss something?
   
   Also, I figured out that the driver still uses old metadata when `skipMeta` 
is set. According to the specification, the driver should ignore it when the 
`Metadata_changed` flag is set, right?
   ```
               0x0008    Metadata_changed: if set, the No_metadata flag has to 
be unset
                         and <new_metadata_id> has to be supplied. This flag is 
to be
                         used to avoid a roundtrip in case of metadata changes 
for queries
                         that requested metadata to be skipped.
   ```



-- 
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