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 1sEteC-004UrK-Kw for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Jun 2024 16:38:02 +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 1sEteC-009lyA-BV for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Jun 2024 16:38:00 +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 1sEteC-009ly1-26 for pgsql-hackers@lists.postgresql.org; Wed, 05 Jun 2024 16:38:00 +0000 Received: from mail-il1-x130.google.com ([2607:f8b0:4864:20::130]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sEte9-003bcq-LQ for pgsql-hackers@postgresql.org; Wed, 05 Jun 2024 16:37:58 +0000 Received: by mail-il1-x130.google.com with SMTP id e9e14a558f8ab-36ddf683ad7so28620525ab.2 for ; Wed, 05 Jun 2024 09:37:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717605477; x=1718210277; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TuU3bclabWxyNoFhGhgi0FMVGF3ONskgQzKyfJj+D9I=; b=ZU1NHNw1axxNBTg8YRP8V/hAXUMZc8ydPgRi526Ut/G4P7NBlAAp4JQ4bh5oYxzYZM pHJLtB6b/7uTG/zmNV6AIqBFazwzPua3KwkymgNkwFvmaipS64MPv0snhjr51ngmZin0 BGWO/C5dCz+fB7Hj3VwYT6P0A63SqVDm5e8x7ejyqWbZGLgQSUf/YbkV4bg+IR0djQO4 gfz34++tvaaAriS3nL6uy23Ss0g+xt6eHs8A92wtly9ilbPI5UWjA7rviXRz70jOZw2h ElKn6IJoKgcAgoTPqzcTakM1c1vUNZhcJybrS1/SS9Pg3Beo0hx8VH4xA/iPC+NJdRsz gxBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717605477; x=1718210277; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TuU3bclabWxyNoFhGhgi0FMVGF3ONskgQzKyfJj+D9I=; b=EsgviOVLrfcyp3Nd6M8KeOz6Jl6Tl+Q/X3L+6WwSvPky2mPio0b1N6v1vmxW1KPRVg lkdet744sbiJRZ98V8kjhwjAsGdYW+hlQEw+nxVGOh0pIJcQ3WlIE3Wikzj8zD25OlvJ 7bu+DKY4wuEIySxC7BUBDS0S5LE29GBKn79df0agY2vmIyW3xiEfZM7zUi6OAh9fjJaf WHDUSe8xCH5qKBVc9A4KCY9SsypBiuSnlTBGVcLokubvwlT3aHi7AUFRV/PGndMB5ZEr 0GFnur0/frClpiwG7NGhRbUn0Zam3Qg9ZmawXiBxy9DN5vmopn6X/XsYZiArz/9qd/t9 +eCA== X-Gm-Message-State: AOJu0Yx3V8yh0+1C4Xdktk7Tk7MWWmcl+6d2E+va3boqoGgXc0HUmWCY wrhpXZU6mCoDaKjgaEdAsQJqV1oPROOwZYiF9V08i4wfhiKY8rsg X-Google-Smtp-Source: AGHT+IFZ78mHcVwG1dxMhAMRsGTpQ0ZlpujslKSCQ0fBNcNsuwDhoVF3Zh01u6ZiLKf9V5uKVYoqgA== X-Received: by 2002:a05:6e02:1a64:b0:374:9552:823c with SMTP id e9e14a558f8ab-374b1ee2892mr30204825ab.2.1717605476721; Wed, 05 Jun 2024 09:37:56 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id e9e14a558f8ab-3749921aca1sm18513825ab.51.2024.06.05.09.37.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Jun 2024 09:37:56 -0700 (PDT) Date: Wed, 5 Jun 2024 11:37:54 -0500 From: Nathan Bossart To: Neil Conway Cc: pgsql-hackers@postgresql.org Subject: Re: small pg_dump code cleanup Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jun 05, 2024 at 12:22:03PM -0400, Neil Conway wrote: > Nice cleanup! Two minor comments: Thanks for taking a look. > (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? What about collectXXX() to match similar functions in pg_dump.c (e.g., collectRoleNames(), collectComments(), collectSecLabels())? > (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. That'd increase the number of allocations quite significantly, but I'd be surprised if that was noticeable outside of extreme scenarios. At the moment, I'm inclined to leave these as-is for this reason and because I doubt it'd result in much cleanup, but I'll yield to the majority opinion here. -- nathan