| 1264 | |
| 1265 | |
| 1266 | void Monitoring::putRequest(SnapshotData::DumpRecord& record, const Request* request, |
| 1267 | const string& plan) |
| 1268 | { |
| 1269 | fb_assert(request); |
| 1270 | |
| 1271 | const auto dbb = request->req_attachment->att_database; |
| 1272 | |
| 1273 | record.reset(rel_mon_statements); |
| 1274 | |
| 1275 | // request id |
| 1276 | record.storeInteger(f_mon_stmt_id, request->getRequestId()); |
| 1277 | // attachment id |
| 1278 | if (request->req_attachment) |
| 1279 | record.storeInteger(f_mon_stmt_att_id, request->req_attachment->att_attachment_id); |
| 1280 | // state, transaction ID, timestamp |
| 1281 | if (request->req_transaction && (request->req_flags & req_active)) |
| 1282 | { |
| 1283 | const bool is_stalled = (request->req_flags & req_stall); |
| 1284 | record.storeInteger(f_mon_stmt_state, is_stalled ? mon_state_stalled : mon_state_active); |
| 1285 | record.storeInteger(f_mon_stmt_tra_id, request->req_transaction->tra_number); |
| 1286 | record.storeTimestampTz(f_mon_stmt_timestamp, request->getTimeStampTz()); |
| 1287 | |
| 1288 | SINT64 clock; |
| 1289 | if (request->req_timer && request->req_timer->getExpireClock(clock)) |
| 1290 | { |
| 1291 | ISC_TIMESTAMP_TZ ts; |
| 1292 | memcpy(&ts, &clock, sizeof(clock)); |
| 1293 | record.storeTimestampTz(f_mon_stmt_timer, ts); |
| 1294 | } |
| 1295 | } |
| 1296 | else |
| 1297 | record.storeInteger(f_mon_stmt_state, mon_state_idle); |
| 1298 | |
| 1299 | const Statement* const statement = request->getStatement(); |
| 1300 | |
| 1301 | // Since ODS 13.1 statement text and plan is put into mon$compiled_statements |
| 1302 | if (dbb->getEncodedOdsVersion() < ODS_13_1) |
| 1303 | { |
| 1304 | // sql text |
| 1305 | if (statement->sqlText) |
| 1306 | record.storeString(f_mon_stmt_sql_text, *statement->sqlText); |
| 1307 | |
| 1308 | // explained plan |
| 1309 | if (plan.hasData()) |
| 1310 | record.storeString(f_mon_stmt_expl_plan, plan); |
| 1311 | } |
| 1312 | |
| 1313 | // statistics |
| 1314 | const int stat_id = fb_utils::genUniqueId(); |
| 1315 | record.storeGlobalId(f_mon_stmt_stat_id, getGlobalId(stat_id)); |
| 1316 | |
| 1317 | // statement timeout, milliseconds |
| 1318 | record.storeInteger(f_mon_stmt_timeout, request->req_timeout); |
| 1319 | |
| 1320 | if (dbb->getEncodedOdsVersion() >= ODS_13_1) |
| 1321 | record.storeInteger(f_mon_stmt_cmp_stmt_id, statement->getStatementId()); |
| 1322 | |
| 1323 | record.write(); |
nothing calls this directly
no test coverage detected