Prefer TG_TABLE_NAME over TG_RELNAME in tests
TG_RELNAME was marked deprecated in commit 3a9ae3d2068 some 14 years ago, but
we still use it in the triggers test suite (test added in 59b4cef1eb74a a year
before deprecation). Seems about time to move over to TG_TABLE_NAME ourselves,
as TG_RELNAME is still covered by the test added in the deprecation commit.
cheers ./daniel
Attachments:
tg_relname.patchapplication/octet-stream; name=tg_relname.patch; x-unix-mode=0644Download
From deca8ccab9300e9b92edb525ef0ab4999127f849 Mon Sep 17 00:00:00 2001
From: Daniel Gustafsson <daniel@yesql.se>
Date: Wed, 23 Sep 2020 11:10:29 +0200
Subject: [PATCH] Use the non-deprecated TG_TABLE_MAME in test trigger
Commit 3a9ae3d2068 deprecated TG_RELNAME in favor of TG_TABLE_NAME,
but the existing usage in test cases has remained till today. Change
to use TG_TABLE_NAME instead (TG_RELNAME is still covered by a test
case).
---
src/test/regress/expected/triggers.out | 4 ++--
src/test/regress/sql/triggers.sql | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/test/regress/expected/triggers.out b/src/test/regress/expected/triggers.out
index 5e76b3a47e..68943a06b8 100644
--- a/src/test/regress/expected/triggers.out
+++ b/src/test/regress/expected/triggers.out
@@ -669,7 +669,7 @@ create table trigtest (i serial primary key);
create table trigtest2 (i int references trigtest(i) on delete cascade);
create function trigtest() returns trigger as $$
begin
- raise notice '% % % %', TG_RELNAME, TG_OP, TG_WHEN, TG_LEVEL;
+ raise notice '% % % %', TG_TABLE_NAME, TG_OP, TG_WHEN, TG_LEVEL;
return new;
end;$$ language plpgsql;
create trigger trigtest_b_row_tg before insert or update or delete on trigtest
@@ -955,7 +955,7 @@ begin
argstr := argstr || TG_argv[i];
end loop;
- raise notice '% % % % (%)', TG_RELNAME, TG_WHEN, TG_OP, TG_LEVEL, argstr;
+ raise notice '% % % % (%)', TG_TABLE_NAME, TG_WHEN, TG_OP, TG_LEVEL, argstr;
if TG_LEVEL = 'ROW' then
if TG_OP = 'INSERT' then
diff --git a/src/test/regress/sql/triggers.sql b/src/test/regress/sql/triggers.sql
index e228d0a8a5..c76571c24c 100644
--- a/src/test/regress/sql/triggers.sql
+++ b/src/test/regress/sql/triggers.sql
@@ -426,7 +426,7 @@ create table trigtest2 (i int references trigtest(i) on delete cascade);
create function trigtest() returns trigger as $$
begin
- raise notice '% % % %', TG_RELNAME, TG_OP, TG_WHEN, TG_LEVEL;
+ raise notice '% % % %', TG_TABLE_NAME, TG_OP, TG_WHEN, TG_LEVEL;
return new;
end;$$ language plpgsql;
@@ -662,7 +662,7 @@ begin
argstr := argstr || TG_argv[i];
end loop;
- raise notice '% % % % (%)', TG_RELNAME, TG_WHEN, TG_OP, TG_LEVEL, argstr;
+ raise notice '% % % % (%)', TG_TABLE_NAME, TG_WHEN, TG_OP, TG_LEVEL, argstr;
if TG_LEVEL = 'ROW' then
if TG_OP = 'INSERT' then
--
2.21.1 (Apple Git-122.3)
On Wed, Sep 23, 2020 at 12:07:14PM +0200, Daniel Gustafsson wrote:
TG_RELNAME was marked deprecated in commit 3a9ae3d2068 some 14 years ago, but
we still use it in the triggers test suite (test added in 59b4cef1eb74a a year
before deprecation). Seems about time to move over to TG_TABLE_NAME ourselves,
as TG_RELNAME is still covered by the test added in the deprecation commit.
No objections from here to remove that from the core tests. It is
worth noting that Debian Code Search hints that this is used in some
extensions:
https://codesearch.debian.net/search?q=TG_RELNAME&literal=1
These are pgformatter, bucardo, sql-ledger, ledgersmb and davical.
--
Michael
On Thu, Sep 24, 2020 at 5:17 AM Michael Paquier <michael@paquier.xyz> wrote:
On Wed, Sep 23, 2020 at 12:07:14PM +0200, Daniel Gustafsson wrote:
TG_RELNAME was marked deprecated in commit 3a9ae3d2068 some 14 years ago, but
we still use it in the triggers test suite (test added in 59b4cef1eb74a a year
before deprecation). Seems about time to move over to TG_TABLE_NAME ourselves,
as TG_RELNAME is still covered by the test added in the deprecation commit.No objections from here to remove that from the core tests. It is
worth noting that Debian Code Search hints that this is used in some
extensions:
https://codesearch.debian.net/search?q=TG_RELNAME&literal=1These are pgformatter, bucardo, sql-ledger, ledgersmb and davical.
That's interesting, but I think irrelevant to this patch in itself of
course. But it might be worth reaching out to some of those projects
and notifying them they're using the deprecated ones..
Thus, pushed. Thanks!
--
Magnus Hagander
Me: https://www.hagander.net/
Work: https://www.redpill-linpro.com/
On 11/3/20 10:22 AM, Magnus Hagander wrote:
On Thu, Sep 24, 2020 at 5:17 AM Michael Paquier <michael@paquier.xyz> wrote:
No objections from here to remove that from the core tests. It is
worth noting that Debian Code Search hints that this is used in some
extensions:
https://codesearch.debian.net/search?q=TG_RELNAME&literal=1These are pgformatter, bucardo, sql-ledger, ledgersmb and davical.
That's interesting, but I think irrelevant to this patch in itself of
course. But it might be worth reaching out to some of those projects
and notifying them they're using the deprecated ones..
I submitted patches to pgformatter, bucardo and ledgersmb. Both davical
and sql-ledger only seems to have them in old upgrade scripts.
Andreas
On Tue, Nov 10, 2020 at 09:50:15AM +0100, Andreas Karlsson wrote:
I submitted patches to pgformatter, bucardo and ledgersmb. Both davical and
sql-ledger only seems to have them in old upgrade scripts.
Thanks, Andreas!
--
Michael