pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pg_get_triggerdef does not use the schema qualified procedure name
2+ messages / 2 participants
[nested] [flat]

* pg_get_triggerdef does not use the schema qualified procedure name
@ 2019-09-26 20:01 AJ Welch <awelch0100@gmail.com>
  2019-09-26 22:47 ` Re: pg_get_triggerdef does not use the schema qualified procedure name Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: AJ Welch @ 2019-09-26 20:01 UTC (permalink / raw)
  To: pgsql-general

Hi,

I noticed that pg_get_triggerdef doesn't seem to use the schema qualified
name of procedures/functions. Is it supposed to? Is there a way to get it
to?

z1h=# \x auto
Expanded display is used automatically.
z1h=# select tg.tgname "name", nsp.nspname "schema", cls.relname table_name,
       pg_get_triggerdef(tg.oid) full_definition, proc.proname proc_name,
       nspp.nspname proc_schema, tg.tgenabled enabled
from pg_trigger tg
join pg_class cls on cls.oid = tg.tgrelid
join pg_namespace nsp on nsp.oid = cls.relnamespace
join pg_proc proc on proc.oid = tg.tgfoid
join pg_namespace nspp on nspp.oid = proc.pronamespace
where not tg.tgisinternal
order by schema, table_name, name;
-[ RECORD 1
]---+---------------------------------------------------------------------------------------------------------------------
name            | users_updated_at
schema          | z1h
table_name      | users
full_definition | CREATE TRIGGER users_updated_at BEFORE UPDATE ON
z1h.users FOR EACH ROW EXECUTE PROCEDURE update_updated_at_column()
proc_name       | update_updated_at_column
proc_schema     | public
enabled         | O

This causes problems for tools like migra
<https://djrobstep.com/docs/migra; that
try to use the output of pg_get_triggerdef to recreate triggers that were
defined in schemas other than public.

Thanks,
AJ

^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: pg_get_triggerdef does not use the schema qualified procedure name
  2019-09-26 20:01 pg_get_triggerdef does not use the schema qualified procedure name AJ Welch <awelch0100@gmail.com>
@ 2019-09-26 22:47 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2019-09-26 22:47 UTC (permalink / raw)
  To: AJ Welch <awelch0100@gmail.com>; +Cc: pgsql-general

AJ Welch <awelch0100@gmail.com> writes:
> I noticed that pg_get_triggerdef doesn't seem to use the schema qualified
> name of procedures/functions. Is it supposed to? Is there a way to get it
> to?

Generally the policy of such functions is to schema-qualify names that
wouldn't be found in the current search_path.  So you could get what
you want by setting a restrictive search_path beforehand, maybe just ''.

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2019-09-26 22:47 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2019-09-26 20:01 pg_get_triggerdef does not use the schema qualified procedure name AJ Welch <awelch0100@gmail.com>
2019-09-26 22:47 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox