Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jbfdE-0004PS-NG for pgsql-bugs@arkaria.postgresql.org; Thu, 21 May 2020 07:28:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jbfdD-0000Ve-Av for pgsql-bugs@arkaria.postgresql.org; Thu, 21 May 2020 07:28:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jbfdD-0000VX-2n for pgsql-bugs@lists.postgresql.org; Thu, 21 May 2020 07:28:43 +0000 Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jbfd6-000509-PY for pgsql-bugs@lists.postgresql.org; Thu, 21 May 2020 07:28:42 +0000 Received: by mail-pj1-x1030.google.com with SMTP id 5so2671566pjd.0 for ; Thu, 21 May 2020 00:28:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=p39NOSyIUh3iWz4unezit8R28k0p3SSN2OsmbHrEjO4=; b=lpHJYDEmTE+N9qsoUdMEGMPrO8yK9dScIYAiA/WXyU5C7GFOorEPa7uIp1ArqA5pOx XLsaliUa1efSgr+2LE7css5gZZeZBJusaAt+lrbncGK/XGwoMJdimc5qpZgt4WXiGfZV 58tJmIXCWyIqpdylMzOImGP784Rjo63G3vsmvARPRyaM0S3PXmUEKBY3YPrzQ5mnwd5K NNE9p2URHgDvdcuycXCuh4y+u/KD7aaxx/SM5NKtueqTqv+XXDGEcGVEi06ClO8YmWz2 THE64yYUqONJQhrUF4AlenFs7arffwZzPmOVBeeWyRvOMRH5Yv7jtq6YdoMtLR5zIQxJ j1lQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=p39NOSyIUh3iWz4unezit8R28k0p3SSN2OsmbHrEjO4=; b=kf9S0Znq/dsg/j+Dleus07m4RAR8pBKW80ngyxhTDo5fVASlGCWOTqx0AnH3kOCJ6u wTrOHwpfaU3U6/t8FMVQgtK27/zT+SzxtjeGGCrUODe0tifwRd0mYIMJBAXrjByWfMvV TH2c9iekCHZM7+0olqYWPOHl/dbeLr96gZTekUUaHFTzMyYxxJ6A9WprG5P3IRjwMnTq 660ACt4cXoO6LQFiAyEQmaNarwiqYkFYqISpC4JxB+z4WFzOlPOYfREsnDbprN7PLlD5 QxW2QNHT/KqT2ZwSZ1kSxG7pXb03e0hfG7JXlIaVEIw4mEpZfMoOZ/eHOVs0j1L++pHD WgEQ== X-Gm-Message-State: AOAM53229tzUF2P29tiKyWI0Ghvb4LdxdYIxNl5W/qamm9K34Ufstlre ejNBlMbgiMsVGHc4T7khQ7g= X-Google-Smtp-Source: ABdhPJy5LPI4+GB1Vep3Rp0hrt3UukaePZvnTqxfXKf2lmki9v2m1YJUaiVHigyDjj5OuDAaRtpC+A== X-Received: by 2002:a17:902:8a89:: with SMTP id p9mr8143115plo.221.1590046115276; Thu, 21 May 2020 00:28:35 -0700 (PDT) Received: from [127.0.0.1] ([47.251.3.230]) by smtp.gmail.com with ESMTPSA id q7sm3321418pgs.13.2020.05.21.00.28.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 May 2020 00:28:34 -0700 (PDT) From: wenjing zeng Message-Id: Content-Type: multipart/mixed; boundary="Apple-Mail=_3C69A151-5964-4BDD-8A78-949175F6AE86" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [bug] Table not have typarray when created by single user mode Date: Thu, 21 May 2020 15:28:28 +0800 In-Reply-To: <983.1589904568@sss.pgh.pa.us> Cc: Alvaro Herrera , pgsql-bugs@lists.postgresql.org, tushar To: Tom Lane , shawn wang References: <20200519153239.GA17266@alvherre.pgsql> <983.1589904568@sss.pgh.pa.us> X-Mailer: Apple Mail (2.3608.80.23.2.2) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Apple-Mail=_3C69A151-5964-4BDD-8A78-949175F6AE86 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > 2020=E5=B9=B45=E6=9C=8820=E6=97=A5 =E4=B8=8A=E5=8D=8812:09=EF=BC=8CTom = Lane =E5=86=99=E9=81=93=EF=BC=9A >=20 > Alvaro Herrera writes: >> I think the argument to have that error check there, is that it's a >> cross-check to avoid pg_upgrade bugs for cases where >> binary_upgrade_next_array_type_oid is not set when it should have = been >> set. But I think we've hammered the pg_upgrade code sufficiently = now, >> that we don't need that check anymore. Any bugs that result in that >> behavior will be very evident by lack of consistency on some upgrade >> anyway. >=20 > I don't buy that argument at all; that's a pretty critical cross-check > IMO, because it's quite important that pg_upgrade control all type = OIDs > assigned in the new cluster. And I think it's probably easier to > break than you're hoping :-( >=20 > I think a safer fix is to replace the IsUnderPostmaster check in > heap_create_with_catalog with !IsBootstrapProcessingMode() or the > like. That would have the result that we'd create array types for > the information_schema views, as well as the system views made in > system_views.sql, which is slightly annoying but probably no real > harm in the big scheme of things. (I wonder if we ought to reverse > the sense of the adjacent relkind check, turning it into a blacklist, > while at it.) Thanks for your help, This method passed all regression tests and = pg_upgrade checks. It looks perfect. Wenjing --Apple-Mail=_3C69A151-5964-4BDD-8A78-949175F6AE86 Content-Disposition: attachment; filename=incomplete_array_type_in_single_user_mode_v2.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="incomplete_array_type_in_single_user_mode_v2.patch" Content-Transfer-Encoding: 7bit diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index e393c93..ba5716b 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -1272,8 +1272,10 @@ heap_create_with_catalog(const char *relname, * do not create any array types for system catalogs (ie, those made * during initdb). We do not create them where the use of a relation as * such is an implementation detail: toast tables, sequences and indexes. + * + * Only the Bootstrap mode is limited. */ - if (IsUnderPostmaster && (relkind == RELKIND_RELATION || + if (!IsBootstrapProcessingMode() && (relkind == RELKIND_RELATION || relkind == RELKIND_VIEW || relkind == RELKIND_MATVIEW || relkind == RELKIND_FOREIGN_TABLE || --Apple-Mail=_3C69A151-5964-4BDD-8A78-949175F6AE86 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii > > I remain however of the opinion that doing this sort of thing in > single-user mode, or really much of anything beyond emergency > vacuuming, is unwise. > > regards, tom lane --Apple-Mail=_3C69A151-5964-4BDD-8A78-949175F6AE86--