On Thu, Apr 1, 2021 at 01:56:42PM -0400, Bruce Momjian wrote: > You are using: > > /* ---------- > * pgstat_get_my_queryid() - > * > * Return current backend's query identifier. > */ > uint64 > pgstat_get_my_queryid(void) > { > if (!MyBEEntry) > return 0; > > return MyBEEntry->st_queryid; > } > > Looking at log_statement: > > /* Log immediately if dictated by log_statement */ > if (check_log_statement(parsetree_list)) > { > ereport(LOG, > (errmsg("statement: %s", query_string), > errhidestmt(true), > errdetail_execute(parsetree_list))); > was_logged = true; > } > > it uses the global variable query_string. I wonder if the query hash > should be a global variable too --- this would more clearly match how we > handle top-level info like query_string. Digging into the stats system > to get top-level info does seem odd.
Also, if you go in that direction, make sure the hash it set in the same places the query string is set, though I am unclear how extensions would handle that. -- Bruce Momjian <br...@momjian.us> https://momjian.us EDB https://enterprisedb.com If only the physical world exists, free will is an illusion.