Fix interaction of log_line_prefix's query_id and log_statement
authorBruce Momjian
Tue, 20 Apr 2021 16:57:59 +0000 (12:57 -0400)
committerBruce Momjian
Tue, 20 Apr 2021 16:57:59 +0000 (12:57 -0400)
log_statement is issued before query_id can be computed, so properly
clear the value, and document the interaction.

Reported-by: Fujii Masao, Michael Paquier
Discussion: https://postgr.es/m/[email protected]

Author: Julien Rouhaud

doc/src/sgml/config.sgml
src/backend/utils/activity/backend_status.c

index 776ab1a8c8b7924de10fb7dd04d0eb7f8aa0cfc0..dd7ebe7a9dad28a53fadf255894caa4bf5de3f05 100644 (file)
@@ -7139,6 +7139,16 @@ log_line_prefix = '%m [%p] %q%u@%d/%a '
 
         
        
+
+       
+        
+         The %Q escape always reports a zero identifier
+         for lines output by  because
+         log_statement generates output before an
+         identifier can be calculated, including invalid statements for
+         which an identifier cannot be calculated.
+        
+       
       
      
 
index 787f062f9c3d4662258add382ae2c6a5caab0a3b..a368101103042e30afda3d4ab2c3f8e239853987 100644 (file)
@@ -398,6 +398,7 @@ pgstat_bestart(void)
    lbeentry.st_state = STATE_UNDEFINED;
    lbeentry.st_progress_command = PROGRESS_COMMAND_INVALID;
    lbeentry.st_progress_command_target = InvalidOid;
+   lbeentry.st_query_id = UINT64CONST(0);
 
    /*
     * we don't zero st_progress_param here to save cycles; nobody should