Re: Server table rows permanently fixed (cannot be deleted or truncated)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: fredmw7(at)gmail(dot)com
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Server table rows permanently fixed (cannot be deleted or truncated)
Date: 2022-11-17 16:04:15
Message-ID: 1834626.1668701055@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Fred Williams <fredmw7(at)gmail(dot)com> writes:
> I am unable to delete or edit a specific range of table rows (I'll call
> them corrupted rows) for a specific primary key. If I truncate the entire
> table, the corrupted rows remain. In the corrupted rows, I can successfully
> update non-primary key fields, but not primary-key fields.

> *Miscellaneous*

> 1. The problem does not occur on a test server using the same exact
> table.
> 2. If I rename the table, I can remove the corrupted rows and/or update
> the primary keys (such as changing the DateTime). However, when I rename it
> back, the corrupted rows reappear!

TBH, I'm suspecting pilot error. I wonder whether you have another
table by the same name in a different schema, which is the one
containing the "corrupted" rows, and after you rename this table
out of the way you're unintentionally accessing the other one.

That theory doesn't explain the rows surviving TRUNCATE, but
maybe inheritance could --- IIRC, TRUNCATE will not touch child
tables. So maybe the alias table is also an inheritance child
of the one you are modifying?

This command in psql would clarify much:

postgres=# \d+ *."NCAASchedule"

regards, tom lane

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Andres Freund 2022-11-17 18:55:29 Re: WAL segments removed from primary despite the fact that logical replication slot needs it.
Previous Message David G. Johnston 2022-11-17 16:04:08 Re: Server table rows permanently fixed (cannot be deleted or truncated)