Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vqeLP-00F83a-23 for pgsql-general@arkaria.postgresql.org; Thu, 12 Feb 2026 21:35:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vqeLN-00BR1d-0d for pgsql-general@arkaria.postgresql.org; Thu, 12 Feb 2026 21:35:26 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vqeLM-00BR1V-2f for pgsql-general@lists.postgresql.org; Thu, 12 Feb 2026 21:35:25 +0000 Received: from mail-oo1-xc2d.google.com ([2607:f8b0:4864:20::c2d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vqeLL-00000000Nof-2tGo for pgsql-general@postgresql.org; Thu, 12 Feb 2026 21:35:25 +0000 Received: by mail-oo1-xc2d.google.com with SMTP id 006d021491bc7-6769719821dso106949eaf.2 for ; Thu, 12 Feb 2026 13:35:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1770932121; cv=none; d=google.com; s=arc-20240605; b=SWWWsX3PScGd7KWUAoXpWMZnHOEk5OMvYfX3NIuio8oYHW3DRo1LoLWUocMuKoxbTl +10LICFbxzbn6juDO7gZHIEEPsRyd1qsGgj1dfHADY+fuCcqD0mdSultRjm//WDinMDJ Ev844m7TF25nMEkEtJbtdF58RaqXrhXwEbYQd7ov1p4r7fJPstDCj40reyjtylWMUzoV mFsGMsi76b4abyzg98RPBy5s61XGl+hFxPGSORKXemX+34EhwV45iqclFj586tuswdZG Qh85fm49CCs+/aadY5RbQEduqqniAZeCtsobcHodu74TGmvs7IvpyKd/AWE/mZiulheu pkhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=to:subject:message-id:date:from:mime-version:dkim-signature; bh=fQpESDWO3kEeKvkZwpYO3jvRIFdI9TclPewbGc6qzmI=; fh=KNSq+t9BltSXFnT3Yof/aKGBtqxeA+bTALiYdvTslaY=; b=iX3u6ZUI+nXIugbwulIlfWD2yiIxX3QwR+uvMLqamj2c3FmSkY0HMmk5zhThyM4QwD ZUn5PRyf9zKux+g1OSuJWNNjxPu1/1vQ0ReFA7iqxuadAcyG18l+S0AUHoB2NSElk7/r VQukxw7CJL30PNfqUinEwU8PuSH5TdxA3+Y+Eob64B6CTBM+mg/xGRE2z2ILkZA8jKwW JcyK3i/qscz92h2H4ylpdRkG/SYBcGGdE4+AyoRaobYuvWyk4nBjmRjth/8HU2J14RV3 bL6UiF5FM/dJNqMVAe+VT7R2tpx98Qi2L65dHorSXfOjmnjUH1LWKbu7+Q69X/4Z5gkf q6Wg==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770932121; x=1771536921; darn=postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=fQpESDWO3kEeKvkZwpYO3jvRIFdI9TclPewbGc6qzmI=; b=OH4MoDBFRFzsTWryjAQqPZcvArLOVWku32r6nQH6rxi8m5yk2XpYRFFo34ZNzHYO4I a9IwSF1ODZJAXCFR4xbsJTEhuSmWjeYKx2kGV9TgjdvxJnjn521lePkv1USIs/XwpMWk Z9XRzEa4xqZtz5roCt4obFUN7clrDqwU1nfLciXTOm67ouqEiS02Q+XLjStrYqEC8IaX DaIHZ4u/lEd/cejrBhprynXDtqJsqf6NKoaTw5tj3kgg2lISSp/bK5YZt606hUyGW5Zk aOujAnPdM/QtYImUvqHkt6vIgLNg2wylEe6gcPgpw0AiFu+1CWlzbndoLZPasr/fjC8q F0ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770932121; x=1771536921; h=to:subject:message-id:date:from:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=fQpESDWO3kEeKvkZwpYO3jvRIFdI9TclPewbGc6qzmI=; b=opH6d+IsYN/SEbESUsOinLywxBa+4X7HVHed6NF4TohmM0p8G8KOCf5/STpQnjW5vk 7/eVXHOnkAihlF80mwBEN1mrm+tyxatbInU1dK6X8/MYC5aCikunMK2UHOArpWgGnPVZ Gk261dosLso4gVc+/9TB0ntSrNH68w+5kojXSm4bTUS0RHQRkLuNnjJc9qmnvBdjCETY E6QBemQeUEZa2HaSdC3EllZhbla+69abAekCpUH117mLIaa7s3LV3ky1UiQIvvLB8dga 3CArvs+X9AJxLpqxqL1VY88er7ccAnD/rfAaCviIU4e+5CdzNDT55CPgctT2FZpmA7jj jQtw== X-Gm-Message-State: AOJu0YzrSpygXpremd+2jS907Aid8wo/JX6NwY3HCk0/NyrbDCgoR+0t ck+o6OKefACvu34EZfxvjXGUBpD/LSi81uB+0K1LKXAGE75iTgwSieNFFagmbHrnLp8oYCHPWJ+ HoFSnKD3upFc84PlpbVrdanLj4zyJ5hJs0MPM X-Gm-Gg: AZuq6aLuaQNGu+/1GnjE5dY07Hj6GkZi9BJjWjyprhxPgLRIQbTpDI4UW7baTUPK4He Wf5LOBFC5Ty7OQ7m7DwRJJ7lD+lQjLqUx//TWmQwU+XzGQspY62wUjs3Qaf8MsHSTVrPsaLTU7/ 7/rB/yQsejW2eilZG4+9dlNCkVNwZdu0QGkwmZsUy3EMTQwUpjMH4zvjUMhdWHrqUVI7QyVa2uB M8uTRyDoUH78bBPZMyHJM5sYYs/Xx2JZ6n/CZR5GuN0QZb4deA+atNg7/0kKo/2s4msKPQemizV 8OJZlMJN X-Received: by 2002:a05:6820:6aea:b0:65c:f821:9dd6 with SMTP id 006d021491bc7-67723dde1f3mr135177eaf.42.1770932121342; Thu, 12 Feb 2026 13:35:21 -0800 (PST) MIME-Version: 1.0 From: Ron Johnson Date: Thu, 12 Feb 2026 16:35:09 -0500 X-Gm-Features: AZwV_Qjc6N1JDUgeF0D8p9Fl-gNhHC-XVLxlgfmrcghkMpGWiMRbh-Ry28dAFR0 Message-ID: Subject: pg_restore failed on foreign key constraint To: pgsql-general Content-Type: multipart/alternative; boundary="000000000000039559064aa744d2" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --000000000000039559064aa744d2 Content-Type: text/plain; charset="UTF-8" When running pg_restore 17.7 against a PG 14.20 database directory dump, I got this in the log: pg_restore: while PROCESSING TOC: pg_restore: from TOC entry 171927; 2606 3149123877 FK CONSTRAINT rel_user_email fk_rel_user_email_2 TAP pg_restore: error: could not execute query: ERROR: insert or update on table "rel_user_email" violates foreign key constraint "fk_rel_user_email_2" DETAIL: Key (access_email_id)=(2073) is not present in table "access_email". Command was: ALTER TABLE ONLY public.rel_user_email ADD CONSTRAINT fk_rel_user_email_2 FOREIGN KEY (access_email_id) REFERENCES public.access_email(access_email_id); So, I went to the source database: TAPd=# \d rel_user_email Table "public.rel_user_email" Column | Type | Collation | Nullable | Default -----------------+-----------------------------+-----------+----------+--------- user_id | integer | | not null | access_email_id | integer | | not null | modified_by | integer | | | modified_on | timestamp without time zone | | not null | Indexes: "idx_rel_user_email" UNIQUE, btree (user_id, access_email_id) Foreign-key constraints: "fk_rel_user_email_1" FOREIGN KEY (user_id) REFERENCES access_user(user_id) "fk_rel_user_email_2" FOREIGN KEY (access_email_id) REFERENCES access_email(access_email_id) TAPd=# select * from rel_user_email where access_email_id=2073; user_id | access_email_id | modified_by | modified_on ---------+-----------------+-------------+------------------------- 2452 | 2073 | 41 | 2013-03-11 10:52:20.331 (1 row) TAPd=# \d access_email Table "public.access_email" Column | Type | Collation | Nullable | Default -----------------+-----------------------------+-----------+----------+------------------------------------------------------- access_email_id | integer | | not null | nextval('access_email_access_email_id_seq'::regclass) type | numeric(10,0) | | | email_address | character varying(255) | | | created_on | timestamp without time zone | | not null | modified_on | timestamp without time zone | | | created_by | integer | | | modified_by | integer | | | Indexes: "pk_access_email" PRIMARY KEY, btree (access_email_id) Referenced by: TABLE "rel_user_email" CONSTRAINT "fk_rel_user_email_2" FOREIGN KEY (access_email_id) REFERENCES access_email(access_email_id) TAPd=# select * from access_email where access_email_id=2073; access_email_id | type | email_address | created_on | modified_on | created_by | modified_by -----------------+------+---------------+------------+-------------+------------+------------- (0 rows) Looks like index corruption. $ pg_amcheck -t public.rel_user_email -t public.access_email TAPd $ echo $? 0 $ pg_amcheck -i idx_rel_user_email -i pk_access_email --parent-check --heapallindexed TAPd $ echo $? 0 But amcheck shows no problems. Before I get worried that there' s corrupt data: am I missing something obvious? -- Death to , and butter sauce. Don't boil me, I'm still alive. lobster! --000000000000039559064aa744d2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
When running pg_restore 17.7 against a PG 14.20 datab= ase directory dump, I got this in the log:

pg_restore: while PROCESS= ING TOC:
pg_restore: from TOC entry 171927; 2606 3149123877 FK CONSTRAIN= T rel_user_email fk_rel_user_email_2 TAP
pg_restore: error: could not ex= ecute query: ERROR: =C2=A0insert or update on table "rel_user_email&qu= ot; violates foreign key constraint "fk_rel_user_email_2"
DETA= IL: =C2=A0Key (access_email_id)=3D(2073) is not present in table "acce= ss_email".
Command was: ALTER TABLE ONLY public.rel_user_email
= =C2=A0 =C2=A0 ADD CONSTRAINT fk_rel_user_email_2 FOREIGN KEY (access_email_= id) REFERENCES public.access_email(access_email_id);
<= br>
So, I went to the source database:

<= font face=3D"monospace">TAPd=3D# \d rel_user_email
=C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Table = "public.rel_user_email"
=C2=A0 =C2=A0 =C2=A0Column =C2=A0 =C2= =A0 =C2=A0| =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Type =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 | Collation | Nullable | Default
-------------= ----+-----------------------------+-----------+----------+---------
=C2= =A0user_id =C2=A0 =C2=A0 =C2=A0 =C2=A0 | integer =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 | not null |
=C2=A0access_email_id | integer =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 | not null |
=C2=A0modified_by =C2=A0 =C2=A0 | integer = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
= =C2=A0modified_on =C2=A0 =C2=A0 | timestamp without time zone | =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 | not null |
Indexes:
=C2=A0 =C2=A0 "i= dx_rel_user_email" UNIQUE, btree (user_id, access_email_id)
Foreign= -key constraints:
=C2=A0 =C2=A0 "fk_rel_user_email_1" FOREIGN = KEY (user_id) REFERENCES access_user(user_id)
=C2=A0 =C2=A0 "fk_rel= _user_email_2" FOREIGN KEY (access_email_id) REFERENCES access_email(a= ccess_email_id)

TAPd=3D# select * from rel_user_email where access_e= mail_id=3D2073;
=C2=A0user_id | access_email_id | modified_by | =C2=A0 = =C2=A0 =C2=A0 modified_on =C2=A0 =C2=A0 =C2=A0
---------+--------------= ---+-------------+-------------------------
=C2=A0 =C2=A0 2452 | =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A02073 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= 41 | 2013-03-11 10:52:20.331
(1 row)

TAPd=3D# \d acces= s_email
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0Table "public.access_email"=
=C2=A0 =C2=A0 =C2=A0Column =C2=A0 =C2=A0 =C2=A0| =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0Type =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | Collat= ion | Nullable | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0Default =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0
-----------------+--------= ---------------------+-----------+----------+------------------------------= -------------------------
=C2=A0access_email_id | integer =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 | not null | nextval('access_email_access_email_id_se= q'::regclass)
=C2=A0type =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0| = numeric(10,0) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
=C2=A0em= ail_address =C2=A0 | character varying(255) =C2=A0 =C2=A0 =C2=A0| =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
=C2= =A0created_on =C2=A0 =C2=A0 =C2=A0| timestamp without time zone | =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 | not null |
=C2=A0modified_on =C2=A0 =C2= =A0 | timestamp without time zone | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
=C2=A0created_by =C2=A0 =C2=A0 =C2= =A0| integer =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0|
=C2=A0modified_by =C2=A0 =C2=A0 | integer =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 | =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0|
Indexes:
=C2=A0 =C2= =A0 "pk_access_email" PRIMARY KEY, btree (access_email_id)
Ref= erenced by:
=C2=A0 =C2=A0 TABLE "rel_user_email" CONSTRAINT &q= uot;fk_rel_user_email_2" FOREIGN KEY (access_email_id) REFERENCES acce= ss_email(access_email_id)

TAPd=3D# select * from access_email where = access_email_id=3D2073;
=C2=A0access_email_id | type | email_address | c= reated_on | modified_on | created_by | modified_by
-----------------+--= ----+---------------+------------+-------------+------------+-------------<= br>(0 rows)


Looks like index corruption= .=C2=A0=C2=A0

$ pg_amchec= k -t public.rel_user_email -t public.access_email TAPd
$ echo $?
0
$ pg_amcheck -i idx_rel_user_email = -i pk_access_email --parent-check --heapallindexed TAPd
$ echo $?
0

But amcheck shows no problems.
Before I get worried that there' s corrupt=C2=A0data: am I = missing something obvious?

--
Death to <Redacted>, and= butter sauce.
Don't boil me, I'm still alive.
<= ;Redacted> lobster!
--000000000000039559064aa744d2--