Re: pg_dump and search_path

From: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
To: Steve Thames <sthames42(at)gmail(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_dump and search_path
Date: 2015-08-11 17:31:20
Message-ID: 20150811173120.GB3040@postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Steve Thames wrote:

> SELECT a.attnum, n.nspname, c.relname, d.adsrc AS default_value
> FROM pg_attribute AS a
> JOIN pg_class AS c ON a.attrelid = c.oid
> JOIN pg_namespace AS n ON c.relnamespace = n.oid
> LEFT JOIN pg_attrdef AS d ON d.adrelid = c.oid AND d.adnum = a.attnum
> WHERE a.attnum > 0
> AND n.nspname = 'testschema'
> AND c.relname = 'testtable';

Don't ever rely on adsrc. It's useless. Use pg_get_expr(adbin)
instead. That's safe, for instance, if the sequence gets renamed.

--
Álvaro Herrera http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2015-08-11 17:41:15 Re: pg_dump and search_path
Previous Message Tom Lane 2015-08-11 17:23:19 Re: pg_dump and search_path