Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally use history table oid in trigger definition #35

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

mlt
Copy link
Contributor

@mlt mlt commented Aug 30, 2017

DO NOT MERGE THIS!

Also stringToQualifiedNameList was moved to utils/regproc.h in PG 10

This closes arkhipov#34
@mlt mlt force-pushed the oid branch 2 times, most recently from 4b6e2a6 to 212be1e Compare August 31, 2017 19:01
@arkhipov
Copy link
Owner

arkhipov commented Aug 31, 2017

Wow! You have done a lot since the last time we discussed this issue. I was a bit busy at the time, but I will review the PR this weekend. I was not sure if I could implement the trigger such that it would work properly with backup/restore since OIDs are not persistent over backups, so I put it off. Does your version work properly when restored from a backup?

@mlt
Copy link
Contributor Author

mlt commented Aug 31, 2017

Hey! Good to hear back! Nope, indeed it doesn't backup/restore table OIDs thus making versioning broken upon restore.
Perhaps, we could get by with a big fat warning for those willing to use OIDs and some auxiliary functions digging pg_trigger catalog and checking orphaned items in tgargs. In most cases, I think, users default to <table name>_history naming pattern so for each table with orphaned trigger (BOTH oid AND name based) we can look around in the same schema as a troubled table for one starting with the same name but different oid to suggest/fix/reinstall trigger.

select tgrelid::regclass, tgname, proname,
  (regexp_split_to_array(tgargs::text, '\\000'))[:tgnargs] args,
  rels, _oids
from pg_trigger t
join pg_proc p on t.tgfoid=p.oid
join lateral (
    select array_agg(relname) rels, array_agg(oid) _oids
    from pg_class c
    where position(tgrelid::regclass::text in relname)=1
      and c.oid!=tgrelid
  ) candidates on true

"versioning";"versioning_trigger";"versioning2";"{sys_period,270603,false}";"{versioning_history}";"{16468}"

P.S. I wonder where they (PG) define _CRT_SECURE_NO_WARNINGS for visual studio to be able to use strncpy.

@arkhipov arkhipov force-pushed the master branch 5 times, most recently from 75fe800 to 0240304 Compare November 6, 2017 21:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants