@@ -91,6 +91,8 @@ class Connection extends PrimaryReadReplicaConnection {
9191 /** @var array<string, int> */
9292 protected $ tableDirtyWrites = [];
9393
94+ protected string $ requestId ;
95+
9496 /**
9597 * Initializes a new instance of the Connection class.
9698 *
@@ -118,6 +120,7 @@ public function __construct(
118120 $ this ->systemConfig = \OC ::$ server ->getSystemConfig ();
119121 $ this ->clock = Server::get (ClockInterface::class);
120122 $ this ->logger = Server::get (LoggerInterface::class);
123+ $ this ->requestId = Server::get (IRequestId::class)->getId ();
121124
122125 /** @var \OCP\Profiler\IProfiler */
123126 $ profiler = Server::get (IProfiler::class);
@@ -249,8 +252,7 @@ public function prepare($sql, $limit = null, $offset = null): Statement {
249252 $ platform = $ this ->getDatabasePlatform ();
250253 $ sql = $ platform ->modifyLimitQuery ($ sql , $ limit , $ offset );
251254 }
252- $ statement = $ this ->replaceTablePrefix ($ sql );
253- $ statement = $ this ->adapter ->fixupStatement ($ statement );
255+ $ statement = $ this ->finishQuery ($ sql );
254256
255257 return parent ::prepare ($ statement );
256258 }
@@ -307,8 +309,7 @@ public function executeQuery(string $sql, array $params = [], $types = [], ?Quer
307309 $ this ->ensureConnectedToPrimary ();
308310 }
309311
310- $ sql = $ this ->replaceTablePrefix ($ sql );
311- $ sql = $ this ->adapter ->fixupStatement ($ sql );
312+ $ sql = $ this ->finishQuery ($ sql );
312313 $ this ->queriesExecuted ++;
313314 $ this ->logQueryToFile ($ sql );
314315 return parent ::executeQuery ($ sql , $ params , $ types , $ qcp );
@@ -328,8 +329,7 @@ private function getQueriedTables(string $sql): array {
328329 * @throws Exception
329330 */
330331 public function executeUpdate (string $ sql , array $ params = [], array $ types = []): int {
331- $ sql = $ this ->replaceTablePrefix ($ sql );
332- $ sql = $ this ->adapter ->fixupStatement ($ sql );
332+ $ sql = $ this ->finishQuery ($ sql );
333333 $ this ->queriesExecuted ++;
334334 $ this ->logQueryToFile ($ sql );
335335 return parent ::executeUpdate ($ sql , $ params , $ types );
@@ -354,8 +354,7 @@ public function executeStatement($sql, array $params = [], array $types = []): i
354354 foreach ($ tables as $ table ) {
355355 $ this ->tableDirtyWrites [$ table ] = $ this ->clock ->now ()->getTimestamp ();
356356 }
357- $ sql = $ this ->replaceTablePrefix ($ sql );
358- $ sql = $ this ->adapter ->fixupStatement ($ sql );
357+ $ sql = $ this ->finishQuery ($ sql );
359358 $ this ->queriesExecuted ++;
360359 $ this ->logQueryToFile ($ sql );
361360 return (int )parent ::executeStatement ($ sql , $ params , $ types );
@@ -587,6 +586,12 @@ public function tableExists($table) {
587586 return $ schema ->tablesExist ([$ table ]);
588587 }
589588
589+ protected function finishQuery (string $ statement ): string {
590+ $ statement = $ this ->replaceTablePrefix ($ statement );
591+ $ statement = $ this ->adapter ->fixupStatement ($ statement );
592+ return $ statement . " -- reqid: " . $ this ->requestId ;
593+ }
594+
590595 // internal use
591596 /**
592597 * @param string $statement
0 commit comments