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 1wAyyQ-000cvj-14 for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Apr 2026 23:39:46 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wAyyN-008Hmw-1K for pgsql-bugs@arkaria.postgresql.org; Thu, 09 Apr 2026 23:39:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wAyyM-008Hmo-3A for pgsql-bugs@lists.postgresql.org; Thu, 09 Apr 2026 23:39:44 +0000 Received: from mail-pj1-x1035.google.com ([2607:f8b0:4864:20::1035]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wAyyL-00000000F2C-3OIU for pgsql-bugs@lists.postgresql.org; Thu, 09 Apr 2026 23:39:43 +0000 Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-35d8e548a05so1473522a91.1 for ; Thu, 09 Apr 2026 16:39:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1775777981; cv=none; d=google.com; s=arc-20240605; b=K+J5ek+qVHwZb404ZDns1xq4oNCAu9bSJkFbOB1hNwPEVanvrH6ABBV7iamqIQodZI HHsPe1Qjv3QUs7FGcrcJVobk9Rpo6pHE/WAA/Axh3OhNDWXlh4U+WP7Fn8LODLOW02RB z/uzgBUedHqCYOw0ogEXWgy5KkBGbh4b38gbg5YFGDacAsrBp1fOo7Z+5bK/kCUkMuDN b7Q3yV1bRB1z2dL3HHsOGAEzzZnR2pNiq8oAk6fQLCzm6vsshAI1YusGW18tpYIStNeO CVOJjnqHTzy5MnDAItGVlbbGoOqLnRIzqNm0QdRg/OZUm9CSUUgqHyMnpdws3cPNwhnH IFDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=DKbCO0lR4caZRUhPjD7fvp37FeP67Qv3Y/MT8JT7lkY=; fh=/1lZmY6T7bz+lE3ATQVa7njGCSo8o8a5dWIIGxyQmg8=; b=CpG3dNDcOuaUtroZed2oFSHbvpZXwJxQrE8Vt4DRYBSlo03o3dEcQomTHUvNVKBeUh NpJpOrB+zR3dqWDtcXWkprsaM9q8dUF0hWRg0jWkAZTC93hGgYa7NrG+K8zO505Iqw1O cDidOB1XMBoeKnaDtbf7mWEt9u8YVvqsgEviQe3W4uA/nqV7IlDE/dAW5G4FEFefYZ0Z 3Fcz2OmcMxnwBRQKOnDAQrTRqbGxARfCyaO1ANVH/Qod7svxPTP+u++l6i/3nrLr6ZtJ k6UFGNuGchApLwMfdyzTTRad8K+e1w96Cw6m2fHM3s+sZRMi7mDHb9gyG56TJP1ZHiGn /jMg==; darn=lists.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=20251104; t=1775777981; x=1776382781; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=DKbCO0lR4caZRUhPjD7fvp37FeP67Qv3Y/MT8JT7lkY=; b=Ax9m4jpakjkZ13m3u4BLukRQlyvL38v4ujNLFyR0ejo4IJKV3x2vHAfsCfpQBwq/2i UHl3bbxSVK+JUxITHz3HNEzHKNC/AI8sn7//cDKr51y6SB07EFajCy7HlhPGRgzGW04c yvavD4BvALqiUL94lL7ON76f+RICNwn8oqmpR/SPz2JhSKyESuVBzA42jf0TSEF16T5f 7UuQZ2oEsx5t9qS7ggXXPwlKnL2eUhLB+bwB7Hv1yN/vOTonDybvNRXrOv83oYmfle3e /LE/luVedNIidvsOLDHryGaTdyT9QIL2nPEpHC6XCACoFs97pkkrGLlq/LIBI7rsT7mj zPSA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775777981; x=1776382781; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=DKbCO0lR4caZRUhPjD7fvp37FeP67Qv3Y/MT8JT7lkY=; b=M8zSnbhorsQVWUyGonrxBiVzhGt5ZPUsQe9RIcxA+DSM3hF27JDrhXfYhwkS+2QV4l tpOiqEdKfUMJwP6SQVtheZuurUY++jVNb/aBrY56OYezyRbViprKIHsXYIbEtx20PL8k wz24xbHlYhXTqWDLjr5qluqjD6qg9zSpwcwxTX5nM6qhx9WyFib6cyhQsukYLNBCf1de MVbx5JJ9PA5L4iT3sCtBLPdQdn7JKM4X7uOhfDvFmvDvA3iAfyVMD6ZalbBobyjP/5BH uUk/T4N/7JZ3N/VLTGIVmc8Od69v2Bl+kNB4cc6Ex6sdpc0BiWBpiNmwgeyT7PedAVwA HG0Q== X-Forwarded-Encrypted: i=1; AJvYcCWeFutnNik7zgQtU7kUiry4hMjKWwGNmZMNs6cyPaHJ+n7RREWPguW/z2yt0Mp1xEk7MmnN8LtIonEy@lists.postgresql.org X-Gm-Message-State: AOJu0Yx37W7yLOMflc15f9rWyNn0SJDIY8hHG+3/5ikFJQ0E9Aj35Q1X RjNnHadf1nx62ngyWqvfVxJ7osZAXySnrE7/uC6y/tWbxxTSwYkVCyurpvcU8lrY+3iejHQiEki YPGqRej1lU75ZRDgyPVmJ+94PgVV7WuM= X-Gm-Gg: AeBDiesD2HQDD/7VqaAr1xTLPKIvA6UCZxjCXVSPFECDOar9bo/InAwwRVUyP78hgxb lo2hCvkLTeW9ZgaOFqB/LI8vMJGLDgmvzk6uFt0J2eHe/i42smrYL2TeCDQrvaAfCHlkgKGZP7C VbkMfoLjAtEHQpDc+JCjQHVKEWjUTEzAabRm8rli5wgkd6a8rJeJPR7Tp1/OMrArqdmZTOEgjqv QZ+SwfTgC6GPEwRtBYiQGnu9U3+g0yQfwGNLKLMd05SOG3MnZN30QyUPdama8nH11JCUC7WqwSw VOHBxtRpZZjhyVw0i6GWkGD1AcbZIjV2J/1kz68OcvP6yub+h6y1t+MPER2VmIArmmK26UCgmo8 = X-Received: by 2002:a17:90b:17c4:b0:35e:27ec:dea with SMTP id 98e67ed59e1d1-35e42854de8mr975336a91.23.1775777980957; Thu, 09 Apr 2026 16:39:40 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Amit Langote Date: Fri, 10 Apr 2026 08:39:24 +0900 X-Gm-Features: AQROBzDCaVyvsHtkG9BNRgtXRsyOqhuiOSqVVw3bWwO09I6pPcR90Ybz4w8hTSQ Message-ID: Subject: Re: BUG: PostgreSQL 19devel throws internal opfamily error for FK with reordered referenced columns To: Matheus Alcantara Cc: Fredrik Widlert , pgsql-bugs@lists.postgresql.org, Junwang Zhao Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Apr 10, 2026 at 3:13=E2=80=AFAM Matheus Alcantara wrote: > On Thu Apr 9, 2026 at 12:27 PM -03, Fredrik Widlert wrote: > > Hello, > > > > I believe I may have found a regression in PostgreSQL 19devel, download= ed > > on 2026-04-09 > > from https://ftp.postgresql.org/pub/snapshot/dev/postgresql-snapshot.ta= r.gz. > > > > postgres=3D# select version(); > > version > > -----------------------------------------------------------------------= ------------------------------ > > PostgreSQL 19devel on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu > > 13.2.0-23ubuntu4) 13.2.0, 64-bit > > > > > > With the reproducer below, PostgreSQL 18 reports a normal foreign-key > > violation > > at INSERT time, but PostgreSQL 19devel instead throws an internal-looki= ng > > error: > > > > ERROR: operator 98 is not a member of opfamily 1976 > > -- reproducer: > > drop table if exists parent, child; > > > > create table parent ( > > app_id varchar(256) not null, > > report_id smallint not null, > > otype integer not null, > > subtype integer not null, > > ctype integer not null, > > column_name varchar(30) not null, > > primary key (app_id, report_id, otype, subtype, ctype, column_name) > > ); > > > > create table child ( > > app_id varchar(256) not null, > > report_id smallint not null, > > otype integer not null, > > subtype integer not null, > > column_name varchar(30) not null, > > ctype integer, > > -- intentionally swapped: column_name, ctype > > constraint child_fk > > foreign key (app_id, report_id, otype, subtype, column_name, ctyp= e) > > references parent (app_id, report_id, otype, subtype, column_name= , > > ctype) > > ); > > > > > > -- trigger the problem > > insert into child (app_id, report_id, otype, subtype, column_name, ctyp= e) > > values ('DEFAULT_APP', 0, -1, -1, 'ID', -1); > > > > Hi, thanks for reporting the issue. > > This seems to be related to commit 2da86c1ef9b. The issue is that in > ri_populate_fastpath_metadata, the code uses idx_rel->rd_opfamily[i] > where i is the constraint key position, but it should find the actual > index column position for pk_attnums[i]. When FK columns are in a > different order than PK columns, the constraint key position doesn't > match the index column position. > > I didn't participate in the discussion of the feature but I studied the > code a little bit after it was committed, so I'm taking a try to fix > this issue with the attached patch, which seems to work for this case. > > CC Junwang Zhao and Amit Langote since they are involved in the original > commit. Thanks for the patch and for notifying me. I will look at your patch later today, but in the meantime, I've added an open item for this: https://wiki.postgresql.org/wiki/PostgreSQL_19_Open_Items --=20 Thanks, Amit Langote