Skip to content

Commit 12dcf7b

Browse files
committed
Have current_query() use ActivePortal->sourceText rather than
debug_query_string; this allows current_query() to be more accurate; docs updated; per idea from Tom
1 parent deac948 commit 12dcf7b

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

doc/src/sgml/func.sgml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.465 2008/12/31 00:08:33 tgl Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.466 2009/01/07 21:48:15 momjian Exp $ -->
22

33
<chapter id="functions">
44
<title>Functions and Operators</title>
@@ -11343,7 +11343,8 @@ postgres=# select * from unnest2(array[[1,2],[3,4]]);
1134311343
<row>
1134411344
<entry><literal><function>current_query</function></literal></entry>
1134511345
<entry><type>text</type></entry>
11346-
<entry>text of the currently executing query (might contain more than one statement)</entry>
11346+
<entry>text of the currently executing query (might match
11347+
client-supplied query or be internal query string)</entry>
1134711348
</row>
1134811349

1134911350
<row>

src/backend/utils/adt/misc.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.68 2009/01/07 19:51:21 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.69 2009/01/07 21:48:15 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -31,6 +31,7 @@
3131
#include "storage/pmsignal.h"
3232
#include "storage/procarray.h"
3333
#include "utils/builtins.h"
34+
#include "tcop/pquery.h"
3435
#include "tcop/tcopprot.h"
3536

3637
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
@@ -59,11 +60,7 @@ current_database(PG_FUNCTION_ARGS)
5960
Datum
6061
current_query(PG_FUNCTION_ARGS)
6162
{
62-
/* there is no easy way to access the more concise 'query_string' */
63-
if (debug_query_string)
64-
PG_RETURN_TEXT_P(cstring_to_text(debug_query_string));
65-
else
66-
PG_RETURN_NULL();
63+
PG_RETURN_TEXT_P(cstring_to_text(ActivePortal->sourceText));
6764
}
6865

6966
/*

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy