Re: BUG #19086: pg_dump --data-only selects and do not uses index definitions for the dumped tables. - Mailing list pgsql-bugs

From Tom Lane
Subject Re: BUG #19086: pg_dump --data-only selects and do not uses index definitions for the dumped tables.
Date
Msg-id 1342348.1760575547@sss.pgh.pa.us
Whole thread Raw
In response to Re: BUG #19086: pg_dump --data-only selects and do not uses index definitions for the dumped tables.  (David Rowley <dgrowleyml@gmail.com>)
Responses Re: BUG #19086: pg_dump --data-only selects and do not uses index definitions for the dumped tables.
List pgsql-bugs
David Rowley <dgrowleyml@gmail.com> writes:
> On Thu, 16 Oct 2025 at 12:36, Tom Lane <tgl@sss.pgh.pa.us> 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



pgsql-bugs by date:

Previous
From: David Rowley
Date:
Subject: Re: BUG #19086: pg_dump --data-only selects and do not uses index definitions for the dumped tables.
Next
From: Yuri Zamyatin
Date:
Subject: Re: BUG #19078: Segfaults in tts_minimal_store_tuple() following pg_upgrade