| 2280 | } |
| 2281 | |
| 2282 | static void lua_end_step(struct sqlclntstate *clnt, SP sp, |
| 2283 | sqlite3_stmt *pStmt) |
| 2284 | { |
| 2285 | Vdbe *pVdbe = (Vdbe*)pStmt; |
| 2286 | |
| 2287 | /* Check whether fingerprint has already been computed. */ |
| 2288 | if ((pVdbe == NULL) || (pVdbe->fingerprint_added == 1)) { |
| 2289 | return; |
| 2290 | } |
| 2291 | |
| 2292 | if (sp != NULL) { |
| 2293 | const char *zNormSql = sqlite3_normalized_sql(pStmt); |
| 2294 | |
| 2295 | if (zNormSql != NULL) { |
| 2296 | double cost = 0.0; |
| 2297 | int64_t prepMs = 0; |
| 2298 | int64_t timeMs; |
| 2299 | int64_t time = comdb2_time_epochms(); |
| 2300 | |
| 2301 | clnt_query_cost(sp->thd, &cost, &prepMs); |
| 2302 | timeMs = time - pVdbe->luaStartTime + prepMs; |
| 2303 | |
| 2304 | unsigned char fingerprint[FINGERPRINTSZ]; |
| 2305 | add_fingerprint(clnt, pStmt, sqlite3_sql(pStmt), zNormSql, cost, |
| 2306 | timeMs, prepMs, pVdbe->luaRows, NULL, fingerprint, 1); // TODO: Make work for query plans |
| 2307 | if (clnt->rawnodestats) |
| 2308 | add_fingerprint_to_rawstats(clnt->rawnodestats, fingerprint, cost, pVdbe->luaRows, timeMs); |
| 2309 | |
| 2310 | clnt->spcost.cost += cost; |
| 2311 | clnt->spcost.time += timeMs; |
| 2312 | clnt->spcost.prepTime += prepMs; |
| 2313 | clnt->spcost.rows += pVdbe->luaRows; |
| 2314 | |
| 2315 | pVdbe->fingerprint_added = 1; |
| 2316 | } |
| 2317 | |
| 2318 | restore_thd_cost_and_reset(sp->thd, pVdbe); |
| 2319 | } |
| 2320 | } |
| 2321 | |
| 2322 | static void lua_end_all_step(struct sqlclntstate *clnt, SP sp) |
| 2323 | { |
no test coverage detected