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 1gPpMJ-0003mI-Uz for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Nov 2018 13:49:32 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gPpMI-0004iy-G3 for pgsql-hackers@arkaria.postgresql.org; Thu, 22 Nov 2018 13:49:30 +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 1gPpMI-0004ir-5O for pgsql-hackers@lists.postgresql.org; Thu, 22 Nov 2018 13:49:30 +0000 Received: from mail-yb1-xb2d.google.com ([2607:f8b0:4864:20::b2d]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gPpME-0001im-M1 for pgsql-hackers@postgresql.org; Thu, 22 Nov 2018 13:49:28 +0000 Received: by mail-yb1-xb2d.google.com with SMTP id i78-v6so3608970ybg.0 for ; Thu, 22 Nov 2018 05:49:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:references:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding:content-language; bh=XGohGMoCmBzYZ7cQobxc6QDDVL/FRhFZMue7C3Hnbgg=; b=XMs8ettt31/Uc5lsUnOmGHSH2AW8pwE/aM8WnCHgDA/j7Ri7tIHpeLCQ+2EbiMwhf3 Whu3CfI2oRsVO6B/1A5Ej8/zfcxTxb2Infube6vJ+M4tUaswt4T2ABGXVLGNff4ReXdj Dh/L9ahQdxHApl3vuYPlJYTNw74nxAhRLoUxgzhWwuNDw5/IUU/VMrsvw7UiG0zouoa7 8hrnkfKX7+ntZjc1y25Ty5tBothVGyHybRnJKXsLpWGbxGxPMCTlXPjZgL1XmPFvYqF7 NcDSc7DD9kZ2QgNSZhREZv+w0AFYxgviffVZVoF/v1cxTPy/yvTDiVyVFPfmeFY2iaUv FLAQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:references:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=XGohGMoCmBzYZ7cQobxc6QDDVL/FRhFZMue7C3Hnbgg=; b=DDdPKpEC1cofXAMUEyoto/wsO/DEw/ATc1duoWHTJbiBlOxzVp2EQ+G8GkwxUQsXLg Nyt1oBxBuku0vHXYGJOu8+LWad/H1VWpFUU9t6Ca/+MQ++6Vgow4BhJ5tYAxWoVwUKtT XBpR+2wTS/6D8dg7qhzqCWullYTCDkjc2iJW65KJNvt4yX1fJX2Q3CI86jucJMXijKIu /Cl1Ooe9+H11vJgvMNk7DuEyKuscR9S2IkwvqOOX+U4c+a+M7YgRFERrGoII/k8wVcL2 Eqhd+wAu2cAmY/7hrKSYTinmn9A3xX+Dhpx/5GDz4p7oMYHR/CDWbbFpZagqSHNLwd9B +ACg== X-Gm-Message-State: AA+aEWbhAexBQfbUHqFIWmREBJ/34jqqut1Mh3CiMmZvly/EKsl7FkFe oaQLbJOxReWlS1vMk8OwBRq+ X-Google-Smtp-Source: AFSGD/V2uZITZkK15ngU4U5iYW2y3Xu+hDy+N/3vlibcnUpJOFFizj4nH9ZRtGI21q7kIlqzFePErg== X-Received: by 2002:a25:d908:: with SMTP id q8-v6mr10915862ybg.469.1542894565436; Thu, 22 Nov 2018 05:49:25 -0800 (PST) Received: from [192.168.10.146] ([98.122.175.38]) by smtp.gmail.com with ESMTPSA id w70sm14251993yww.76.2018.11.22.05.49.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Nov 2018 05:49:24 -0800 (PST) From: Andrew Dunstan X-Google-Original-From: Andrew Dunstan Subject: Re: reg* checks in pg_upgrade are out of date To: Andres Freund , pgsql-hackers@postgresql.org, Kyotaro HORIGUCHI References: <20181122001214.p7assjzejyyul32l@alap3.anarazel.de> Message-ID: <037e152a-cb25-3bcb-4f35-bdc9988f8204@2ndQuadrant.com> Date: Thu, 22 Nov 2018 08:49:23 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20181122001214.p7assjzejyyul32l@alap3.anarazel.de> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-MW List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 11/21/18 7:12 PM, Andres Freund wrote: > Hi, > > It seems the list of reg* types and the check for them in pg_upgrade > have gone out of sync. We have the following reg* types: > > SELECT typname FROM pg_type WHERE typname LIKE 'reg%' order by typname; > ┌───────────────┐ > │ typname │ > ├───────────────┤ > │ regclass │ > │ regconfig │ > │ regdictionary │ > │ regnamespace │ > │ regoper │ > │ regoperator │ > │ regproc │ > │ regprocedure │ > │ regrole │ > │ regtype │ > └───────────────┘ > (10 rows) > > but pg_upgrade doesn't consider all of them: > > /* > * While several relkinds don't store any data, e.g. views, they can > * be used to define data types of other columns, so we check all > * relkinds. > */ > res = executeQueryOrDie(conn, > "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 ( " > " 'pg_catalog.regproc'::pg_catalog.regtype, " > " 'pg_catalog.regprocedure'::pg_catalog.regtype, " > " 'pg_catalog.regoper'::pg_catalog.regtype, " > " 'pg_catalog.regoperator'::pg_catalog.regtype, " > /* regclass.oid is preserved, so 'regclass' is OK */ > /* regtype.oid is preserved, so 'regtype' is OK */ > " 'pg_catalog.regconfig'::pg_catalog.regtype, " > " 'pg_catalog.regdictionary'::pg_catalog.regtype) AND " > " c.relnamespace = n.oid AND " > " n.nspname NOT IN ('pg_catalog', 'information_schema')"); > > (I don't get the order here btw) > > ISTM when regrole and regnamespace were added, pg_upgrade wasn't > considered. It turns out that regrole is safe, because we preserve user > oids, but regnamespace isn't afaict. I don't think it's extremely > likely that users store such reg* columns in tables, but we probably > still should fix this. > yeah, I think you're right, both about the need to fix it and the unlikelihood of it occurring in the wild. cheers andrew -- Andrew Dunstan https://www.2ndQuadrant.com PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services