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.94.2) (envelope-from ) id 1v9C7u-00C5TM-5C for pgsql-bugs@arkaria.postgresql.org; Thu, 16 Oct 2025 00:45:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1v9C7s-0095ya-Bs for pgsql-bugs@arkaria.postgresql.org; Thu, 16 Oct 2025 00:45:51 +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.94.2) (envelope-from ) id 1v9C7s-0095yR-3O for pgsql-bugs@lists.postgresql.org; Thu, 16 Oct 2025 00:45:51 +0000 Received: from sss.pgh.pa.us ([68.162.161.243]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v9C7p-001zj4-0d for pgsql-bugs@lists.postgresql.org; Thu, 16 Oct 2025 00:45:50 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 59G0jlq61342349; Wed, 15 Oct 2025 20:45:47 -0400 From: Tom Lane To: David Rowley cc: Nathan Bossart , andrewbille@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #19086: pg_dump --data-only selects and do not uses index definitions for the dumped tables. In-reply-to: References: <19086-871ff11017d03dc5@postgresql.org> <1000041.1760471415@sss.pgh.pa.us> <1324003.1760565328@sss.pgh.pa.us> <1334977.1760571380@sss.pgh.pa.us> Comments: In-reply-to David Rowley message dated "Thu, 16 Oct 2025 13:35:24 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1342347.1760575547.1@sss.pgh.pa.us> Date: Wed, 15 Oct 2025 20:45:47 -0400 Message-ID: <1342348.1760575547@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk David Rowley writes: > On Thu, 16 Oct 2025 at 12:36, Tom Lane wrote: >> (Hmm ... but on the third hand, if we only need one of the >> two strings, couldn't we mechanize that by wrapping the >> pg_get_indexdef call in CASE WHEN c.contype IS DISTINCT FROM 'x' >> ?) > Unless I'm mistaken, it looks like the "indexdef" field is used only > when there's no corresponding constraint with contype 'p,', 'u' or > 'x'. Ah. I hadn't researched that, but it makes sense. > Wouldn't it be more like: > CASE WHEN c.conrelid IS NULL THEN > pg_catalog.pg_get_indexdef(i.indexrelid) ELSE '' END AS indexdef I'd leave out the ELSE so that you get a null if the function isn't run, but yeah. (The places saving these query results would need PQgetisnull tests, too.) regards, tom lane