From 7dd3e09e7db8542535879e3d10f08c5961368696 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 13 Dec 2021 14:46:02 +0100 Subject: [PATCH] Document SQL debugging for (app) devs Signed-off-by: Christoph Wurst --- developer_manual/digging_deeper/debugging.rst | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/developer_manual/digging_deeper/debugging.rst b/developer_manual/digging_deeper/debugging.rst index 3c541af3a..65423f3fe 100644 --- a/developer_manual/digging_deeper/debugging.rst +++ b/developer_manual/digging_deeper/debugging.rst @@ -85,6 +85,31 @@ Debugging HTML and templates By default Nextcloud caches HTML generated by templates. This may prevent changes to app templates, for example, from being applied on page refresh. To disable caching, see Debug mode. +Debugging SQL queries +--------------------- + +When encountering database errors during queries or migrations, it can be helpful to get a full query log. + +Debugging MariaDB queries +~~~~~~~~~~~~~~~~~~~~~~~~~ + +MariaDB can log all queries to a file or a table. + +.. code-block :: sql + + SET GLOBAL general_log = 'ON'; + SET GLOBAL log_output = 'table'; + +These global settings will enable the log on the fly. No database restart is required. + +.. code-block :: sql + + SELECT * FROM mysql.general_log + +This queries all the logged queries. + +.. Note:: On :ref:`continuous integration` this trick can give you the SQLs of various types and versions of a database quite easily in case you have to debug a matrix of setups. + Using alternative app directories ---------------------------------