Mimicking cascading foreign key referencing system table The Next CEO of Stack OverflowInherit...

Is it okay to majorly distort historical facts while writing a fiction story?

Is there such a thing as a proper verb, like a proper noun?

Can this note be analyzed as a non-chord tone?

Scary film where a woman has vaginal teeth

Is there an equivalent of cd - for cp or mv

Aggressive Under-Indexing and no data for missing index

Getting Stale Gas Out of a Gas Tank w/out Dropping the Tank

Does Germany produce more waste than the US?

Where do students learn to solve polynomial equations these days?

Decide between Polyglossia and Babel for LuaLaTeX in 2019

Is there a way to save my career from absolute disaster?

what's the use of '% to gdp' type of variables?

Expressing the idea of having a very busy time

Would a grinding machine be a simple and workable propulsion system for an interplanetary spacecraft?

How did Beeri the Hittite come up with naming his daughter Yehudit?

Small nick on power cord from an electric alarm clock, and copper wiring exposed but intact

Won the lottery - how do I keep the money?

Inexact numbers as keys in Association?

Can Sneak Attack be used when hitting with an improvised weapon?

What connection does MS Office have to Netscape Navigator?

In the "Harry Potter and the Order of the Phoenix" video game, what potion is used to sabotage Umbridge's speakers?

free fall ellipse or parabola?

What does "shotgun unity" refer to here in this sentence?

Traveling with my 5 year old daughter (as the father) without the mother from Germany to Mexico



Mimicking cascading foreign key referencing system table



The Next CEO of Stack OverflowInherit audit columns and triggersIs it possible to run a trigger on Table Creation in MySQLBetter way to create an Events table?Trigger to create symmetrical rowsPostgreSQL Partitioned table update triggerWithin a trigger is there a way to tell if an update or insert came from a trigger or not?Automatically add core fields to a table when createdCreate foreign key constraint on indirect dataHow to create `instead of` trigger on a table in postgres?How to create relationship metadata between tables without a foreign key check?












0















I'd like to create a table to store some additional metadata about tables, but I'm running into a number of roadblocks since foreign keys and triggers cannot be used with system tables.



On INSERT it seems easy enough to create a trigger on the metadata table that checks for a matching row in pg_class, but I'm struggling to come up with a way to delete the row when the table is dropped.



I've looked into event triggers, but I can't find a way to determine the oid of the dropped table. Based on the information on the event trigger page and here https://www.postgresql.org/docs/current/plpgsql-trigger.html#PLPGSQL-EVENT-TRIGGER it doesn't seem like there's any data provided about the object that the event affects.



Is there any way of ensuring maintained integrity between my metadata table and the referenced rows in pg_class?









share



























    0















    I'd like to create a table to store some additional metadata about tables, but I'm running into a number of roadblocks since foreign keys and triggers cannot be used with system tables.



    On INSERT it seems easy enough to create a trigger on the metadata table that checks for a matching row in pg_class, but I'm struggling to come up with a way to delete the row when the table is dropped.



    I've looked into event triggers, but I can't find a way to determine the oid of the dropped table. Based on the information on the event trigger page and here https://www.postgresql.org/docs/current/plpgsql-trigger.html#PLPGSQL-EVENT-TRIGGER it doesn't seem like there's any data provided about the object that the event affects.



    Is there any way of ensuring maintained integrity between my metadata table and the referenced rows in pg_class?









    share

























      0












      0








      0








      I'd like to create a table to store some additional metadata about tables, but I'm running into a number of roadblocks since foreign keys and triggers cannot be used with system tables.



      On INSERT it seems easy enough to create a trigger on the metadata table that checks for a matching row in pg_class, but I'm struggling to come up with a way to delete the row when the table is dropped.



      I've looked into event triggers, but I can't find a way to determine the oid of the dropped table. Based on the information on the event trigger page and here https://www.postgresql.org/docs/current/plpgsql-trigger.html#PLPGSQL-EVENT-TRIGGER it doesn't seem like there's any data provided about the object that the event affects.



      Is there any way of ensuring maintained integrity between my metadata table and the referenced rows in pg_class?









      share














      I'd like to create a table to store some additional metadata about tables, but I'm running into a number of roadblocks since foreign keys and triggers cannot be used with system tables.



      On INSERT it seems easy enough to create a trigger on the metadata table that checks for a matching row in pg_class, but I'm struggling to come up with a way to delete the row when the table is dropped.



      I've looked into event triggers, but I can't find a way to determine the oid of the dropped table. Based on the information on the event trigger page and here https://www.postgresql.org/docs/current/plpgsql-trigger.html#PLPGSQL-EVENT-TRIGGER it doesn't seem like there's any data provided about the object that the event affects.



      Is there any way of ensuring maintained integrity between my metadata table and the referenced rows in pg_class?







      postgresql trigger system-tables





      share












      share










      share



      share










      asked 3 mins ago









      user3747260user3747260

      455




      455






















          0






          active

          oldest

          votes












          Your Answer








          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "182"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f233629%2fmimicking-cascading-foreign-key-referencing-system-table%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Database Administrators Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fdba.stackexchange.com%2fquestions%2f233629%2fmimicking-cascading-foreign-key-referencing-system-table%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          ORA-01691 (unable to extend lob segment) even though my tablespace has AUTOEXTEND onORA-01692: unable to...

          Always On Availability groups resolving state after failover - Remote harden of transaction...

          Circunscripción electoral de Guipúzcoa Referencias Menú de navegaciónLas claves del sistema electoral en...