diff options
author | Bruce Momjian <bruce@momjian.us> | 2008-04-04 16:57:21 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 2008-04-04 16:57:21 +0000 |
commit | f96928fde90697bd6eeda85a89225e31c0b5a16d (patch) | |
tree | 9cb46365cd4271c81c01f56fe3f7d7b280b76de6 /src | |
parent | cfaf8b6b67d9cfbfe48dba8d88b4de0adc256a34 (diff) | |
download | postgresql-f96928fde90697bd6eeda85a89225e31c0b5a16d.tar.gz postgresql-f96928fde90697bd6eeda85a89225e31c0b5a16d.zip |
Implement current_query(), that shows the currently executing query.
At the same time remove dblink/dblink_current_query() as it is no longer
necessary
*BACKWARD COMPATIBILITY ISSUE* for dblink
Tomas Doran
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/utils/adt/misc.c | 16 | ||||
-rw-r--r-- | src/include/catalog/pg_proc.h | 4 | ||||
-rw-r--r-- | src/include/utils/builtins.h | 3 |
3 files changed, 20 insertions, 3 deletions
diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index 63d7c4ff589..f7aaec12f0e 100644 --- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.58 2008/01/01 19:45:52 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/utils/adt/misc.c,v 1.59 2008/04/04 16:57:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,6 +29,7 @@ #include "storage/pmsignal.h" #include "storage/procarray.h" #include "utils/builtins.h" +#include "tcop/tcopprot.h" #define atooid(x) ((Oid) strtoul((x), NULL, 10)) @@ -72,6 +73,19 @@ current_database(PG_FUNCTION_ARGS) /* + * current_query() + * Expose the current query to the user (useful in stored procedures) + */ +Datum +current_query(PG_FUNCTION_ARGS) +{ + if (debug_query_string) + PG_RETURN_TEXT_P(cstring_to_text(debug_query_string)); + else + PG_RETURN_NULL(); +} + +/* * Functions to send signals to other backends. */ static bool diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index d4d7cb5b917..fba36a018d3 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.485 2008/03/27 03:57:34 tgl Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_proc.h,v 1.486 2008/04/04 16:57:21 momjian Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -1117,6 +1117,8 @@ DESCR("convert char to char()"); DATA(insert OID = 861 ( current_database PGNSP PGUID 12 1 0 f f t f i 0 19 "" _null_ _null_ _null_ current_database - _null_ _null_ )); DESCR("returns the current database"); +DATA(insert OID = 817 ( current_query PGNSP PGUID 12 1 0 f f f f v 0 25 "" _null_ _null_ _null_ current_query - _null_ _null_ )); +DESCR("returns the currently executing query"); DATA(insert OID = 862 ( int4_mul_cash PGNSP PGUID 12 1 0 f f t f i 2 790 "23 790" _null_ _null_ _null_ int4_mul_cash - _null_ _null_ )); DESCR("multiply"); diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index f719b492c14..f80802f9bff 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2008, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.310 2008/03/25 22:42:45 tgl Exp $ + * $PostgreSQL: pgsql/src/include/utils/builtins.h,v 1.311 2008/04/04 16:57:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -414,6 +414,7 @@ extern Datum pg_ls_dir(PG_FUNCTION_ARGS); extern Datum nullvalue(PG_FUNCTION_ARGS); extern Datum nonnullvalue(PG_FUNCTION_ARGS); extern Datum current_database(PG_FUNCTION_ARGS); +extern Datum current_query(PG_FUNCTION_ARGS); extern Datum pg_cancel_backend(PG_FUNCTION_ARGS); extern Datum pg_reload_conf(PG_FUNCTION_ARGS); extern Datum pg_tablespace_databases(PG_FUNCTION_ARGS); |