Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIepR-0002bg-JN for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Oct 2019 20:14:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iIepQ-0003Ee-3V for pgsql-bugs@arkaria.postgresql.org; Thu, 10 Oct 2019 20:14:28 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iIepP-0003EP-O8 for pgsql-bugs@lists.postgresql.org; Thu, 10 Oct 2019 20:14:27 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iIepN-0004Qa-Cb for pgsql-bugs@lists.postgresql.org; Thu, 10 Oct 2019 20:14:26 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x9AKEKJW001543; Thu, 10 Oct 2019 16:14:20 -0400 From: Tom Lane To: Tomas Vondra cc: Andres Freund , buschmann@nidsa.net, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #16045: vacuum_db crash and illegal memory alloc after pg_upgrade from PG11 to PG12 In-reply-to: <20191010163350.2rtcjtje6tkgilqi@development> References: <20191009132436.uugh4r3be6vw6ex4@development> <20191009135907.km2b5nrzflcz6xey@development> <20191009141841.my6k44wfiaquj3ks@development> <20191009230759.ge66neof5qj627a2@development> <19314.1570663125@sss.pgh.pa.us> <20191009232836.jg77wccqwy5fgs6s@development> <20265.1570664514@sss.pgh.pa.us> <20191010014813.3b2btmkakhrskwgd@alap3.anarazel.de> <20191010134303.bkwjzchjb2w66iro@development> <30706.1570717152@sss.pgh.pa.us> <20191010163350.2rtcjtje6tkgilqi@development> Comments: In-reply-to Tomas Vondra message dated "Thu, 10 Oct 2019 18:33:50 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1541.1570738460.1@sss.pgh.pa.us> Date: Thu, 10 Oct 2019 16:14:20 -0400 Message-ID: <1542.1570738460@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Tomas Vondra writes: > On Thu, Oct 10, 2019 at 10:19:12AM -0400, Tom Lane wrote: >> To identify such domains, I think we'd need something like >> WHERE attypid IN (recursive-WITH-query), which makes me nervous. >> We did support those starting with 8.4, which is as far back as >> pg_upgrade will go, so in theory it should work. But I think we >> had bugs with such cases in old releases. Do we want to assume >> that the source server has been updated enough to avoid any such >> bugs? The expense of such a query might be daunting, too. > For the query cost, I think we can assume the domain hierarchies are not > particularly deep (in practice I'd expect just domains directly on the > sql_identifier type). And I doubt people are using that very widely, > it's probably more like this report - ad-hoc CTAS, so just a couple of > items. So I wouldn't expect it to be a huge deal in most cases. But even > if it takes a second or two, it's a one-time cost. What I was worried about was the planner possibly trying to apply the atttypid restriction as a scan qual using a subplan, which might be rather awful. But it doesn't look like that happens. I get a hash semijoin to the CTE output, in all branches back to 8.4, on this trial query: explain with recursive sqlidoids(toid) as ( select 'information_schema.sql_identifier'::pg_catalog.regtype as toid union select oid from pg_catalog.pg_type, sqlidoids where typtype = 'd' and typbasetype = sqlidoids.toid ) SELECT n.nspname, c.relname, a.attname FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n, pg_catalog.pg_attribute a WHERE c.oid = a.attrelid AND NOT a.attisdropped AND a.atttypid in (select toid from sqlidoids) AND c.relkind IN ('r','v','i') and c.relnamespace = n.oid AND n.nspname !~ '^pg_temp_' AND n.nspname !~ '^pg_toast_temp_' AND n.nspname NOT IN ('pg_catalog', 'information_schema'); regards, tom lane