pgsql: Implement current_query(), that shows the currently executing

Started by Bruce Momjianabout 18 years ago11 messageshackers
Jump to latest
#1Bruce Momjian
bruce@momjian.us

Log Message:
-----------
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

Modified Files:
--------------
pgsql/contrib/dblink:
dblink.c (r1.71 -> r1.72)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/contrib/dblink/dblink.c?r1=1.71&r2=1.72)
dblink.h (r1.19 -> r1.20)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/contrib/dblink/dblink.h?r1=1.19&r2=1.20)
dblink.sql.in (r1.14 -> r1.15)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/contrib/dblink/dblink.sql.in?r1=1.14&r2=1.15)
uninstall_dblink.sql (r1.5 -> r1.6)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/contrib/dblink/uninstall_dblink.sql?r1=1.5&r2=1.6)
pgsql/contrib/dblink/expected:
dblink.out (r1.21 -> r1.22)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/contrib/dblink/expected/dblink.out?r1=1.21&r2=1.22)
pgsql/contrib/dblink/sql:
dblink.sql (r1.18 -> r1.19)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/contrib/dblink/sql/dblink.sql?r1=1.18&r2=1.19)
pgsql/doc/src/sgml:
dblink.sgml (r1.3 -> r1.4)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/dblink.sgml?r1=1.3&r2=1.4)
func.sgml (r1.425 -> r1.426)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/doc/src/sgml/func.sgml?r1=1.425&r2=1.426)
pgsql/src/backend/utils/adt:
misc.c (r1.58 -> r1.59)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/adt/misc.c?r1=1.58&r2=1.59)
pgsql/src/include/catalog:
pg_proc.h (r1.485 -> r1.486)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/catalog/pg_proc.h?r1=1.485&r2=1.486)
pgsql/src/include/utils:
builtins.h (r1.310 -> r1.311)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/include/utils/builtins.h?r1=1.310&r2=1.311)

#2Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Bruce Momjian (#1)
Re: [COMMITTERS] pgsql: Implement current_query(), that shows the currently executing

Bruce Momjian wrote:

Log Message:
-----------
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

I think the agreement was that dblink_current_query was to be
implemented on top of this. In fact I don't see any reason not to.

Also, wasn't the name supposed to be client_query?

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#3Bruce Momjian
bruce@momjian.us
In reply to: Alvaro Herrera (#2)
Re: [COMMITTERS] pgsql: Implement current_query(), that shows the currently executing

Alvaro Herrera wrote:

Bruce Momjian wrote:

Log Message:
-----------
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

I think the agreement was that dblink_current_query was to be
implemented on top of this. In fact I don't see any reason not to.

Really? It seemed like just duplicate functionality.

Also, wasn't the name supposed to be client_query?

Because pg_stat_activity already has current_query (and no one has
complained about it) there was discussion to just make it current_query.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#4Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Bruce Momjian (#3)
Re: Re: [COMMITTERS] pgsql: Implement current_query(), that shows the currently executing

Bruce Momjian wrote:

Alvaro Herrera wrote:

I think the agreement was that dblink_current_query was to be
implemented on top of this. In fact I don't see any reason not to.

Really? It seemed like just duplicate functionality.

It's called "backwards compatibility". The nice thing about it is that
it doesn't cost us any extra code.

Also, wasn't the name supposed to be client_query?

Because pg_stat_activity already has current_query (and no one has
complained about it) there was discussion to just make it current_query.

I don't think you can call that an agreement. It was just a suggestion
IIRC.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#5Tom Lane
tgl@sss.pgh.pa.us
In reply to: Alvaro Herrera (#4)
Re: Re: [COMMITTERS] pgsql: Implement current_query(), that shows the currently executing

Alvaro Herrera <alvherre@commandprompt.com> writes:

Bruce Momjian wrote:

Alvaro Herrera wrote:

I think the agreement was that dblink_current_query was to be
implemented on top of this. In fact I don't see any reason not to.

Really? It seemed like just duplicate functionality.

It's called "backwards compatibility". The nice thing about it is that
it doesn't cost us any extra code.

Indeed. It's just silly to break dblink users when there's no need.

Also, wasn't the name supposed to be client_query?

Because pg_stat_activity already has current_query (and no one has
complained about it) there was discussion to just make it current_query.

I don't think you can call that an agreement. It was just a suggestion
IIRC.

Well, there wasn't any strong consensus for client_query either ...

regards, tom lane

#6Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#5)
Re: Re: [COMMITTERS] pgsql: Implement current_query(), that shows the currently executing

Tom Lane wrote:

Alvaro Herrera <alvherre@commandprompt.com> writes:

Bruce Momjian wrote:

Alvaro Herrera wrote:

I think the agreement was that dblink_current_query was to be
implemented on top of this. In fact I don't see any reason not to.

Really? It seemed like just duplicate functionality.

It's called "backwards compatibility". The nice thing about it is that
it doesn't cost us any extra code.

Indeed. It's just silly to break dblink users when there's no need.

OK. Did someone mention this before because I don't remember it and the
patch removed the dblink usage. Do we continue to document the
function?

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#7Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Bruce Momjian (#6)
Re: Re: [COMMITTERS] pgsql: Implement current_query(), that shows the currently executing

Bruce Momjian wrote:

Alvaro Herrera wrote:

I think the agreement was that dblink_current_query was to be
implemented on top of this. In fact I don't see any reason not to.

OK. Did someone mention this before because I don't remember it and the
patch removed the dblink usage. Do we continue to document the
function?

Yes, I did:

http://archives.postgresql.org/pgsql-patches/2007-05/msg00098.php

--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support

#8Bruce Momjian
bruce@momjian.us
In reply to: Alvaro Herrera (#7)
Re: Re: [COMMITTERS] pgsql: Implement current_query(), that shows the currently executing

Alvaro Herrera wrote:

Bruce Momjian wrote:

Alvaro Herrera wrote:

I think the agreement was that dblink_current_query was to be
implemented on top of this. In fact I don't see any reason not to.

OK. Did someone mention this before because I don't remember it and the
patch removed the dblink usage. Do we continue to document the
function?

Yes, I did:

http://archives.postgresql.org/pgsql-patches/2007-05/msg00098.php

I see what happened. The author said he had made the change, but the
patch didn't contain it:

http://archives.postgresql.org/pgsql-patches/2007-05/msg00132.php

FWIW I think you should still provide dblink_current_query, even if it's

only a wrapper over current_query(), for backwards compatibility.

Good point. Done as suggested (I think, or did you mean also the change
of instances to use current_query()?). Replaced dblink_current_query
with an SQL procedure wrapper, I assume that's the most efficient way of
doing it?

So do we document it or just add a function entry point?

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

#9Bruce Momjian
bruce@momjian.us
In reply to: Bruce Momjian (#8)
Re: Re: [COMMITTERS] pgsql: Implement current_query(), that shows the currently executing

Bruce Momjian wrote:

I see what happened. The author said he had made the change, but the
patch didn't contain it:

http://archives.postgresql.org/pgsql-patches/2007-05/msg00132.php

FWIW I think you should still provide dblink_current_query, even if it's

only a wrapper over current_query(), for backwards compatibility.

Good point. Done as suggested (I think, or did you mean also the change
of instances to use current_query()?). Replaced dblink_current_query
with an SQL procedure wrapper, I assume that's the most efficient way of
doing it?

I have re-added it as an undocumented dblink SQL function.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

Attachments:

/rtmp/difftext/x-diffDownload+7-0
#10Tom Lane
tgl@sss.pgh.pa.us
In reply to: Bruce Momjian (#9)
Re: Re: [COMMITTERS] pgsql: Implement current_query(), that shows the currently executing

Bruce Momjian <bruce@momjian.us> writes:

+ CREATE OR REPLACE FUNCTION dblink_current_query ()
+ RETURNS text
+ AS 'SELECT current_query()'
+ LANGUAGE SQL;

Needs to be pg_catalog.current_query

regards, tom lane

#11Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#10)
Re: Re: [COMMITTERS] pgsql: Implement current_query(), that shows the currently executing

Tom Lane wrote:

Bruce Momjian <bruce@momjian.us> writes:

+ CREATE OR REPLACE FUNCTION dblink_current_query ()
+ RETURNS text
+ AS 'SELECT current_query()'
+ LANGUAGE SQL;

Needs to be pg_catalog.current_query

Oh, good point. Done.

--
Bruce Momjian <bruce@momjian.us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +