2

I had a table with large object. When I want to delete a row. I have an error: SQL Error [42704]:

ERROR: large object 123456 does not exist.

I checked in pg_largeobject and I didn't find a row with id = '123456'.

How can I delete an row which has a nonexistent object?

The trigger on the table is

CREATE TRIGGER t_filledreport BEFORE UPDATE OR DELETE ON rep_reportjob
   FOR EACH ROW EXECUTE PROCEDURE lo_manage(filledreport);
Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263
  • 1
    Can you show the `DELETE` statement and the trigger definition? – Laurenz Albe Sep 03 '21 at 07:45
  • And for example I have simple delete statement: delete from rep_reportjob rr where filledreport = 'xxxxxxx' – Gherta Nicolae Sep 03 '21 at 08:06
  • 1
    @GhertaNicolae when code is requested update the question instead of posting it as a comment. And here also post the Trigger Function `lo_manage(filledreport);` Also what is `filledreport`? It is very unusual to pass parameters to trigger functions. – Belayer Sep 03 '21 at 08:41

1 Answers1

1

There are two options:

  • temporarily disable the trigger:

    ALTER TABLE rep_reportjob DISABLE TRIGGER t_filledreport;
    DELETE ...;
    ALTER TABLE rep_reportjob ENABLE TRIGGER t_filledreport;
    
  • As superuser, tempoarily set session_replication_role to replica:

    BEGIN;
    SET LOCAL session_replication_role = replica;
    DELETE ...;
    COMMIT;
    

Caution! With triggers disabled, you can easily introduce inconsistencies!

Laurenz Albe
  • 209,280
  • 17
  • 206
  • 263