Skip to content

Commit 1c175cd

Browse files
committed
Revert current_query() change to use debug_query_string again; add comment.
1 parent ae3c075 commit 1c175cd

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

doc/src/sgml/func.sgml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.466 2009/01/07 21:48:15 momjian Exp $ -->
1+
<!-- $PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.467 2009/01/08 00:13:21 momjian Exp $ -->
22

33
<chapter id="functions">
44
<title>Functions and Operators</title>
@@ -11343,8 +11343,7 @@ 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 match
11347-
client-supplied query or be internal query string)</entry>
11346+
<entry>text of the currently executing query (might contain more than one statement)</entry>
1134811347
</row>
1134911348

1135011349
<row>

src/backend/utils/adt/misc.c

+7-3
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.69 2009/01/07 21:48:15 momjian Exp $
11+
* $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.70 2009/01/08 00:13:22 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -31,7 +31,6 @@
3131
#include "storage/pmsignal.h"
3232
#include "storage/procarray.h"
3333
#include "utils/builtins.h"
34-
#include "tcop/pquery.h"
3534
#include "tcop/tcopprot.h"
3635

3736
#define atooid(x) ((Oid) strtoul((x), NULL, 10))
@@ -56,11 +55,16 @@ current_database(PG_FUNCTION_ARGS)
5655
/*
5756
* current_query()
5857
* Expose the current query to the user (useful in stored procedures)
58+
* We might want to use ActivePortal->sourceText someday.
5959
*/
6060
Datum
6161
current_query(PG_FUNCTION_ARGS)
6262
{
63-
PG_RETURN_TEXT_P(cstring_to_text(ActivePortal->sourceText));
63+
/* there is no easy way to access the more concise 'query_string' */
64+
if (debug_query_string)
65+
PG_RETURN_TEXT_P(cstring_to_text(debug_query_string));
66+
else
67+
PG_RETURN_NULL();
6468
}
6569

6670
/*

0 commit comments

Comments
 (0)