Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sEtP4-004NlS-FZ for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Jun 2024 16:22:23 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sEtP3-009gVq-O3 for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Jun 2024 16:22:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sEtP3-009gVA-9u for pgsql-hackers@lists.postgresql.org; Wed, 05 Jun 2024 16:22:21 +0000 Received: from mail-ed1-x529.google.com ([2a00:1450:4864:20::529]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sEtP0-003bX2-Sr for pgsql-hackers@postgresql.org; Wed, 05 Jun 2024 16:22:20 +0000 Received: by mail-ed1-x529.google.com with SMTP id 4fb4d7f45d1cf-57a30dbdb7fso3494357a12.3 for ; Wed, 05 Jun 2024 09:22:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717604537; x=1718209337; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Z90+lbrQOPbyrgcIW2LTtqqUkGhr922x6ebH/4CshPc=; b=mNrn3/U7CsY40fQKUnlLMJ72DjSFMYT/EteeGn9hVSqRaNRR0A1t6eE8DBWJqA/55b A3S5RnMiIqJox4E8ESRlyaN7JSzcSukZKndgy4LWIoxsgX7fBEVcK0s1Q9QYsfw7b8Ln ka78gZQHb31aaY2I9G59w9lKhYWVy0QJVOeeflA8ey7zQPU0OX8hPzjeeEbxwUBBj3/K gdbQtrD4B9DfKn5W+PydlomP+qvAPTWAXcaNnEW+06rb6yrovQOBWyRWU6xxvDYIoJQe Nybe+Hrmr/QccR3gC3H9y0QoktbSItMHUYK4RLEpFPV3p0S2OIPdJYMuMq3UOhqBgujb jKeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717604537; x=1718209337; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=Z90+lbrQOPbyrgcIW2LTtqqUkGhr922x6ebH/4CshPc=; b=lWMTIuYIVK2mSN309u3rUzjj+OqsQj2mxdIcRtfGfHrFYrIheauKqn+BoqZ29kUkVR hgge3q2kntnCMxku9TOJP3vUQov85XoYCgw5BwCI/KxsppuMRVKOSyxEGimB1CqZEfaN lNKUhT9qUDySTWdITIWGWiWw5eXfQABVVTVHBwY/8xSkxchWyFlI5Ci2V9f/bDACI8Mw AHWQOwJ+iMdJUv90CHqj74zTp8GTsg6au24AOfGKoWQw9o0LzjVSrTOfJ93F5ZA+/Zx2 1hGxWhC6B4i1xCTOe7ofDdq95xDRzSktSTcUQ503nM6XU0c5/Qg/Na5FIghYap023tio oWXg== X-Gm-Message-State: AOJu0YxbgZZcDt5BsgDPCZUkx3l/NG4aYqpKnIIiKWgHJsPva14jmXhe LOFfy7C9XagjheqIbLy1gx7Y/WP6xzPhVifR95JRPPxni9m7JG3pzcEJuwNCuDWV9VDL+ZzKNOW gDCDCZd9DNsGTlp/YV4WdmvZkdyXutA== X-Google-Smtp-Source: AGHT+IHWRmXGz8WUZMhgLpz23dZg4Opvm2GJ8KxzVckgJiN5OjP/KLhix8ZV6dIfQkiXcbTOW7+txHn+LLranP4pqQY= X-Received: by 2002:a50:c351:0:b0:57a:6ed5:b327 with SMTP id 4fb4d7f45d1cf-57a8b6b3a64mr1977618a12.12.1717604536994; Wed, 05 Jun 2024 09:22:16 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Neil Conway Date: Wed, 5 Jun 2024 12:22:03 -0400 Message-ID: Subject: Re: small pg_dump code cleanup To: Nathan Bossart Cc: pgsql-hackers@postgresql.org Content-Type: multipart/alternative; boundary="0000000000004ad42d061a26f849" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000004ad42d061a26f849 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Jun 5, 2024 at 11:14=E2=80=AFAM Nathan Bossart wrote: > In fact, many of the functions in this area don't actually need to return anything, so we can trim some code and hopefully reduce confusion a > bit. Patch attached. > Nice cleanup! Two minor comments: (1) Names like `getXXX` for these functions suggest to me that they return a value, rather than side-effecting. I realize some variants continue to return a value, but the majority no longer do. Perhaps a name like lookupXXX() or readXXX() would be clearer? (2) These functions malloc() a single ntups * sizeof(struct) allocation and then index into it to fill-in each struct before entering it into the hash table. It might be more straightforward to just malloc each individual struct. Neil --0000000000004ad42d061a26f849 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, Jun 5, 2024 at 11:14=E2=80=AFAM Natha= n Bossart <nathandbossart@gm= ail.com> wrote:
=C2=A0In fact, many of the functions in this area don't actually= need to
return anything, so we can trim some code and hopefully reduce confusion a<= br> bit.=C2=A0 Patch attached.

Nice cleanup= ! Two minor comments:

(1) Names like `getXXX` for = these functions suggest=C2=A0to me that they return a value, rather than si= de-effecting. I realize some variants continue to return a value, but the m= ajority no longer do. Perhaps a name like lookupXXX() or readXXX() would be= clearer?

(2) These functions malloc() a single nt= ups * sizeof(struct) allocation and then index into it to fill-in each stru= ct before entering it into the hash table. It might be more straightforward= to just malloc each individual struct.

Neil
=

--0000000000004ad42d061a26f849--