@@ -203,6 +203,8 @@ void handle_sql_intrans_unrecoverable_error(struct sqlclntstate *clnt);
203203void comdb2_set_sqlite_vdbe_dtprec (Vdbe * p );
204204static int execute_sql_query_offload (struct sqlthdstate * , struct sqlclntstate * );
205205static int record_query_cost (struct sql_thread * , struct sqlclntstate * );
206+ static void free_normalized_sql (struct sqlclntstate * clnt );
207+ void free_original_normalized_sql (struct sqlclntstate * clnt );
206208
207209static int sql_debug_logf_int (struct sqlclntstate * clnt , const char * func ,
208210 int line , const char * fmt , va_list args )
@@ -1247,13 +1249,7 @@ static void sql_statement_done(struct sql_thread *thd, struct reqlogger *logger,
12471249
12481250 thd -> crtshard = 0 ;
12491251
1250- unsigned long long rqid = clnt -> osql .rqid ;
1251- if (rqid != 0 && rqid != OSQL_RQID_USE_UUID )
1252- reqlog_set_rqid (logger , & rqid , sizeof (rqid ));
1253- else if (!comdb2uuid_is_zero (clnt -> osql .uuid )) {
1254- /* have an "id_set" instead? */
1255- reqlog_set_rqid (logger , clnt -> osql .uuid , sizeof (uuid_t ));
1256- }
1252+ reqlog_set_rqid_from_clnt (logger , clnt );
12571253
12581254 LISTC_T (struct sql_hist ) lst ;
12591255 listc_init (& lst , offsetof(struct sql_hist , lnk ));
@@ -1266,15 +1262,15 @@ static void sql_statement_done(struct sql_thread *thd, struct reqlogger *logger,
12661262 h -> cost .time = comdb2_time_epochms () - thd -> startms ;
12671263 h -> cost .prepTime = thd -> prepms ;
12681264 h -> when = thd -> stime ;
1269- h -> txnid = rqid ;
1265+ h -> txnid = clnt -> osql . rqid ;
12701266
12711267 time_metric_add (thedb -> service_time , h -> cost .time );
12721268 clnt -> last_cost = (int64_t ) h -> cost .cost ;
12731269
12741270 /* request logging framework takes care of logging long sql requests */
12751271 reqlog_set_cost (logger , h -> cost .cost );
1276- if (rqid ) {
1277- reqlog_logf (logger , REQL_INFO , "rqid=%llx" , rqid );
1272+ if (clnt -> osql . rqid ) {
1273+ reqlog_logf (logger , REQL_INFO , "rqid=%llx" , clnt -> osql . rqid );
12781274 }
12791275 reqlog_set_netwaitus (logger , clnt -> netwaitus );
12801276
@@ -1696,17 +1692,15 @@ static void reqlog_setup_begin_commit_rollback(struct sqlthdstate *thd, struct s
16961692 query_stats_setup (thd , clnt );
16971693
16981694 if (reqlog_get_event (thd -> logger ) == EV_SQL ) {
1699- unsigned char fp [FINGERPRINTSZ ];
1700- size_t len ;
17011695 char stmt [9 ] = {0 }; // begin, commit, or rollback
17021696 int i = 0 ;
17031697 for (const char * s = clnt -> sql ; * s != '\0' && * s != ' ' && i < sizeof (stmt ) - 1 ; s ++ , i ++ ) {
17041698 stmt [i ] = (char ) tolower (* s );
17051699 }
1706- if ( gbl_fingerprint_queries ) {
1707- calc_fingerprint ( stmt , & len , fp );
1708- reqlog_set_fingerprint ( thd -> logger , ( const char * ) fp , FINGERPRINTSZ );
1709- }
1700+
1701+ /* Reset so we don't print the stale fingerprint */
1702+ free_normalized_sql ( clnt );
1703+ free_original_normalized_sql ( clnt );
17101704 }
17111705 log_queue_time (thd -> logger , clnt );
17121706}
@@ -1838,7 +1832,7 @@ int handle_sql_begin(struct sqlthdstate *thd, struct sqlclntstate *clnt,
18381832
18391833 if (sideeffects == TRANS_CLNTCOMM_NORMAL ) {
18401834 /* for chunks and SPs, don't end the request */
1841- reqlog_end_request (thd -> logger , -1 , __func__ , __LINE__ );
1835+ reqlog_end_request (thd -> logger , rc , __func__ , __LINE__ );
18421836 }
18431837
18441838 return rc ;
@@ -2392,7 +2386,7 @@ int handle_sql_commitrollback(struct sqlthdstate *thd,
23922386 clnt -> osql .xerr .errval = ERR_BLOCK_FAILED + ERR_VERIFY ;
23932387 sql_set_sqlengine_state (clnt , __FILE__ , __LINE__ ,
23942388 SQLENG_NORMAL_PROCESS );
2395- outrc = CDB2ERR_VERIFY_ERROR ;
2389+ outrc = rc = CDB2ERR_VERIFY_ERROR ;
23962390 Pthread_mutex_lock (& clnt -> wait_mutex );
23972391 clnt -> ready_for_heartbeats = 0 ;
23982392 Pthread_mutex_unlock (& clnt -> wait_mutex );
@@ -2537,12 +2531,13 @@ int handle_sql_commitrollback(struct sqlthdstate *thd,
25372531
25382532done :
25392533 reset_clnt_flags (clnt );
2534+ reqlog_set_rqid_from_clnt (thd -> logger , clnt );
25402535 if (clnt -> osql .sock_started == 0 )
25412536 comdb2uuid_clear (clnt -> osql .uuid );
25422537
25432538 if (sideeffects == TRANS_CLNTCOMM_NORMAL ) {
25442539 /* end request only for non-chunk and non-SP transactions */
2545- reqlog_end_request (thd -> logger , -1 , __func__ , __LINE__ );
2540+ reqlog_end_request (thd -> logger , rc , __func__ , __LINE__ );
25462541 }
25472542
25482543 /* if this is a retry, let the upper layer free the structure */
0 commit comments