From 442305ffddc1bc8d9d1d297fe174f66c090f0bc5 Mon Sep 17 00:00:00 2001 From: Bruce Momjian Date: Thu, 8 Jan 2009 00:13:22 +0000 Subject: [PATCH] Revert current_query() change to use debug_query_string again; add comment. --- doc/src/sgml/func.sgml | 3 +-- src/backend/utils/adt/misc.c | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 8b3830766d..5fc43e5efc 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -11343,8 +11343,7 @@ postgres=# select * from unnest2(array[[1,2],[3,4]]); current_query text - text of the currently executing query (might match - client-supplied query or be internal query string) + text of the currently executing query (might contain more than one statement) diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index 9ca40f85f4..a4a1a6c7bd 100644 --- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -31,7 +31,6 @@ #include "storage/pmsignal.h" #include "storage/procarray.h" #include "utils/builtins.h" -#include "tcop/pquery.h" #include "tcop/tcopprot.h" #define atooid(x) ((Oid) strtoul((x), NULL, 10)) @@ -56,11 +55,16 @@ current_database(PG_FUNCTION_ARGS) /* * current_query() * Expose the current query to the user (useful in stored procedures) + * We might want to use ActivePortal->sourceText someday. */ Datum current_query(PG_FUNCTION_ARGS) { - PG_RETURN_TEXT_P(cstring_to_text(ActivePortal->sourceText)); + /* there is no easy way to access the more concise 'query_string' */ + if (debug_query_string) + PG_RETURN_TEXT_P(cstring_to_text(debug_query_string)); + else + PG_RETURN_NULL(); } /* -- 2.39.5