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 1q69lg-0007KA-NA for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Jun 2023 12:57:04 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1q69lf-0003pV-Jy for pgsql-bugs@arkaria.postgresql.org; Mon, 05 Jun 2023 12:57:03 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1q69ii-00005b-B7 for pgsql-bugs@lists.postgresql.org; Mon, 05 Jun 2023 12:54:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1q69if-000NPT-5L for pgsql-bugs@lists.postgresql.org; Mon, 05 Jun 2023 12:53:59 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 355CrrTp4158149; Mon, 5 Jun 2023 08:53:53 -0400 From: Tom Lane To: ijustloveit13@gmail.com cc: pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17960: pg_dump does not backup generated columns correctly. In-reply-to: <17960-1a424b3d6792d769@postgresql.org> References: <17960-1a424b3d6792d769@postgresql.org> Comments: In-reply-to PG Bug reporting form message dated "Sun, 04 Jun 2023 12:20:56 -0000" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <4158147.1685969633.1@sss.pgh.pa.us> Date: Mon, 05 Jun 2023 08:53:53 -0400 Message-ID: <4158148.1685969633@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk PG Bug reporting form writes: > pg_dump does not wite DEFAULT for generated columns. So, it produces error > when restoring. It works fine for me, and if it didn't work fine for other people we'd have had a lot of other bug reports by now. Please provide a concrete example. > The strange part is that when I create the table again, fill it with data > and use pg_dump to bacup, it is correct, but the current table in the > database producecs wrong backup. Hmm ... what minor release of pg_dump are you using? I wonder if you are hitting the bug fixed here: Author: Tom Lane Branch: master Release: REL_15_BR [0b126c6a4] 2021-11-22 15:25:48 -0500 Branch: REL_14_STABLE Release: REL_14_2 [aedc4600d] 2021-11-22 15:25:48 -0500 Branch: REL_13_STABLE Release: REL_13_6 [6fc8b145e] 2021-11-22 15:25:48 -0500 Branch: REL_12_STABLE Release: REL_12_10 [1e7f588ad] 2021-11-22 15:25:48 -0500 Fix pg_dump --inserts mode for generated columns with dropped columns. If a table contains a generated column that's preceded by a dropped column, dumpTableData_insert failed to account for the dropped column, and would emit DEFAULT placeholder(s) in the wrong column(s). This resulted in failures at restore time. The default COPY code path did not have this bug, likely explaining why it wasn't noticed sooner. regards, tom lane