2

I am getting an error with Postgres 10 when trying to delete a large object ERROR: large object 16709 does not exist even though I can show 16709 does exist. I don't know if it is relevant, but the large object was created using pyscopg2 on Python 3.

EDIT: I confirmed that I can still fetch the data from the database, and that it is correct. I just can't delete it.

tagger1=# select l.oid from pg_largeobject_metadata l where l.oid = 16709;
  oid
-------
 16709
(1 row)

tagger1=# select count(1) from pg_largeobject where loid = 16709;
 count
-------
   747
(1 row)

tagger1=# select lo_unlink(16709) from pg_largeobject;
ERROR:  large object 16709 does not exist

1 Answer 1

4

Simply omit the FROM clause:

SELECT lo_unlink(16709);

The problem is that your statement tries to run this for every row in pg_largeobject, but after the first execution the large object is already gone.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. Turns out in my program I was trying to unlink() twice using the pyscopg2 object, and then I made this mistake when debugging interactively.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.