Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8759505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:49:28+00:00 2026-06-13T14:49:28+00:00

I have the following based on another SE question ( Hash Rings On PostgreSql)

  • 0

I have the following based on another SE question ( Hash Rings On PostgreSql)

CREATE TABLE sms.tablename
(
  id uuid,
  mdate date
)

And the partitions.

CREATE TABLE sms.tablename_partition_1 ( CHECK ( sms.hash(id) = '1' ) ) INHERITS (sms.tablename);
...
CREATE TABLE sms.tablename_partition_f ( CHECK ( sms.hash(id) = 'f' ) ) INHERITS (sms.tablename);

Now here is the problems.

When i add this trigger.

CREATE TRIGGER "delete_me"
  BEFORE DELETE
  ON sms.tablename
  FOR EACH ROW
  EXECUTE PROCEDURE sms.delete_me(E'\\x');

CREATE OR REPLACE FUNCTION sms.delete_me()
  RETURNS trigger AS
$BODY$

begin

    RAISE NOTICE 'HERE !!!';
    return OLD;

end;
$BODY$
  LANGUAGE plpgsql VOLATILE SECURITY DEFINER
  COST 100;

This trigger never runs …
I can’t see the NOTICE message.
Now if i apply the same trigger to another table ( Non-Partitioned ), it works fine it does its job , the row is removed and the notice message pops up.

More Info : “PostgreSQL 9.1.6 on i686-pc-linux-gnu, compiled by
gcc-4.4.real (Ubuntu 4.4.3-4ubuntu5.1) 4.4.3, 32-bit”

I’m just trying to avoid using stored procedures on the table and keeping the ORM Clean.

EDITED :

1) No Rules Exist On The Table Or Any Of the Tables Inherited , The Same Applied to Indexes Or PK’s.

2) Running the following command.

DELETE FROM sms.tablename WHERE id = 'a5e52a04-282f-4cf4-8347-a43d68725e6b';

3) Full SQL Showing This Problem.

http://pastebin.com/mZBFEtaY
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:49:28+00:00Added an answer on June 13, 2026 at 2:49 pm

    The delete trigger fires on the child table that contains the row, not the parent. You must add the trigger to each child table.

    DO                                                                
    $$
    DECLARE
      h text;
    BEGIN
      FOR h IN SELECT to_hex(x) FROM generate_series(0,15) x LOOP
        EXECUTE format('CREATE TRIGGER "DeleteRedirector" BEFORE DELETE ON pproblem.%I FOR EACH ROW EXECUTE PROCEDURE pproblem.delete_me('''');',
                       'tablename_partition_'||h);
      END LOOP;
    END;
    $$;
    

    Demo:

    regress=# begin;
    BEGIN
    regress=# DELETE FROM pproblem.tablename;
    NOTICE:  HERE !!!
    NOTICE:  HERE !!!
    NOTICE:  HERE !!!
    DELETE 3
    regress=# rollback;
    ROLLBACK
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code to create a music playlist based on files in
I have a C programming question on the implementation of a hash table. I
I have the following requirement: Based on some user input, I need to generate
I have the following HTML code based on a tab menu format, i.e: <div
I have the following select field and based on whether the class .show-x-trend or
I have the following code that creates a submenu based on current document. The
I have requirement as following like showing ABPeoplePickerNavigationController in tabbar based application. I researched
I have a drop-down list which is generated based on the following sql query:
Let me share the following scenario: I have a ASP.NET intranet Web-based application that
i have some SQL code that is inserting values from another (non sql-based) system.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.