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 1mcCPZ-0007Px-Ht for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Oct 2021 20:05:37 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mcCPW-0000mV-So for pgsql-hackers@arkaria.postgresql.org; Sun, 17 Oct 2021 20:05:34 +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 1mcCPV-0000mL-PW for pgsql-hackers@lists.postgresql.org; Sun, 17 Oct 2021 20:05:34 +0000 Received: from wout2-smtp.messagingengine.com ([64.147.123.25]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mcCPT-0005RP-6p for pgsql-hackers@lists.postgresql.org; Sun, 17 Oct 2021 20:05:32 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 385EF3200974; Sun, 17 Oct 2021 16:05:29 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Sun, 17 Oct 2021 16:05:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=XBJCvY+74ZoVfCK8F0kxw9+oYOs3c0ZmkLc4s+oyp5Y=; b=QTEINJPx syz1m+s3p8E3swT/Xb4WYXB4cMODLQFxwCS/tRea12BaIVslw5+3f15bb2JZWDhe OccJ0mFhAFnw/30QkhOTaJ4pMU7C1VgvjpPmHfcg+ETe/ttIQheYMSEq6hc9x2fb fPPm+sGcatWzpUzhqFyG3GahL8BPPYsMZIFSNxCCF4X/VFWoenZknH3RUNcBZy99 M1UuVIkj9dbYLhCqriW3cu4AlK2ReIoKvBYVmUZn870oPnTiiAePJALXt8/WJyZA IZNK3Z6+uA2Unz6xFIYJHEbDmd6R9iRUa1l9DL7te8+L6XiTYIi7oF2Fwl3y31zg OC9fbHat4WQ2sQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddukedgudeggecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfggtggugfgjsehtke ertddttdejnecuhfhrohhmpeetlhhvrghrohcujfgvrhhrvghrrgcuoegrlhhvhhgvrhhr vgesrghlvhhhrdhnohdqihhprdhorhhgqeenucggtffrrghtthgvrhhnpedujeevjeffje evuddutedvkeeiueeitddvieelfeekveejudefgeeuvdejhfeuleenucffohhmrghinhep vghnthgvrhhprhhishgvuggsrdgtohhmnecuvehluhhsthgvrhfuihiivgeptdenucfrrg hrrghmpehmrghilhhfrhhomheprghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhr gh X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 17 Oct 2021 16:05:28 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id AAADC2A04B5; Sun, 17 Oct 2021 17:05:25 -0300 (-03) Date: Sun, 17 Oct 2021 17:05:25 -0300 From: Alvaro Herrera To: Tom Lane Cc: pgsql-hackers@lists.postgresql.org Subject: Re: Refactoring pg_dump's getTables() Message-ID: <202110172005.z4gsdny63hzt@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <1240992.1634419055@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Oct-16, Tom Lane wrote: > Attached is a proposed patch that refactors getTables() along the > same lines as some previous work (eg 047329624, ed2c7f65b, daa9fe8a5) > to avoid having multiple partially-redundant copies of the SQL query. > This gets rid of nearly 300 lines of duplicative spaghetti code, > creates a uniform style for dealing with cross-version changes > (replacing at least three different methods currently being used > for that in this same stretch of code), and allows moving some > comments to be closer to the code they describe. Yeah, this seems a lot better than the original coding. Maybe I would group together the changes that all require the same version test, rather than keeping the output columns in the same order. This reduces the number of branches. Because the follow-on code uses column names rather than numbers, there is no reason to keep related columns together. But it's a clear improvement even without that. -- Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/ "Puedes vivir sólo una vez, pero si lo haces bien, una vez es suficiente"