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 1sH88M-003cze-FB for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Jun 2024 20:30: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 1sH88K-009lPp-TX for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Jun 2024 20:30: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 1sH88K-009lMt-Id for pgsql-hackers@lists.postgresql.org; Tue, 11 Jun 2024 20:30:21 +0000 Received: from mail-il1-x134.google.com ([2607:f8b0:4864:20::134]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sH88I-000qb5-RB for pgsql-hackers@postgresql.org; Tue, 11 Jun 2024 20:30:20 +0000 Received: by mail-il1-x134.google.com with SMTP id e9e14a558f8ab-3759a6423a6so7204085ab.1 for ; Tue, 11 Jun 2024 13:30:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718137818; x=1718742618; 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=Fi0B9FwyqFOAme7lWLKKVmbvgtxC4U61bIp6uhDTrBU=; b=TTxzYY5sxNpraSnlxD9L2+YEbY8RXbRtq15LSZvlAovQYrVhSwjDgkzAJRvdpzK23I LfqQ/yK69S+kUFOa85IhbQrHaEx9FvkCYrOPo1Sd5/tFEkZ6mI2cA4ukllwTFbYbRODH Zky0XF4MUVkiHsqxSa7L1hNDxUDuppAOEVwDwbRzpmPSEhZYoBqgkPUzCNiyOl8hVqzq an1JkqigfdcEIPqsU/K9Pj5994KdsjrjOqTFFrSS6JpQ1evGFi4hOzweEvNUachUCoAY VmTuNiUWgJl1edM2bXg7QPyFqmdoKZA+s8hPrcCvx/Cwo4s2dItPMLTxcLfPFJsRjpml gy3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718137818; x=1718742618; 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=Fi0B9FwyqFOAme7lWLKKVmbvgtxC4U61bIp6uhDTrBU=; b=PSMvvAlwvKuA2TvCuotOhCJ0FeHAx5HV+pl5xFIqgCZTCGkpa+7uPwhNRwK/Llz4s9 g+c7AB3szuiCC4JT1Sq6m+UlDamxrTaPGkaKMce22VdypPIC8LaIEUJCOHZrFpq2qrno 6tZrmkgXu//lslVT1GkmXiGzkxto35kLUAI6bR79zNtN5dz8XKGLrVHc77NZ1zMv44xJ o3NeNDWz0bD+CPqjDlk2tYko0M5tqMiu5i/NXNiXO++hbdukmerCFCBvXzqjfmTneu73 4KAlgZKGjirA9h4RTlZALXpVJmtlk3XeIN5/FAQkh/nPG9M759AzUqXRoW/JzRDIpBhm 6ywg== X-Forwarded-Encrypted: i=1; AJvYcCUhfhx0kxUVkRbQUyN14dHjNb+y0byOkTDD2oDDeGSoE65BYkh8TIeYeHMiVZwCC9+/cfHezS+9HoUvW0IqOYkO9wccikIsOzQJleuK X-Gm-Message-State: AOJu0Yxh5qYJD8oEkKcjmcwkPFb/E3XIDkVt0e+XGyF3kjgh5nA1n4gn dGzCji+ZC6mVuwgqGmNfANGlCchAOJWPBWDQ8yDQpeQ+dGwiTyE/ X-Google-Smtp-Source: AGHT+IHQXBJaCbdhDpwTTV1nnqLQNdQgMYKETAaglWqEcLHL62CcRpIGwjjSC1EBGn0Vegjet5begg== X-Received: by 2002:a05:6e02:19cf:b0:375:a0fe:4554 with SMTP id e9e14a558f8ab-375a0fe49d3mr98648305ab.5.1718137818028; Tue, 11 Jun 2024 13:30:18 -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-37586145ba0sm23535065ab.86.2024.06.11.13.30.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 13:30:16 -0700 (PDT) Date: Tue, 11 Jun 2024 15:30:14 -0500 From: Nathan Bossart To: Tom Lane Cc: Neil Conway , pgsql-hackers@postgresql.org Subject: Re: small pg_dump code cleanup Message-ID: References: <892531.1717610334@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <892531.1717610334@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Jun 05, 2024 at 01:58:54PM -0400, Tom Lane wrote: > Nathan Bossart writes: >> On Wed, Jun 05, 2024 at 12:22:03PM -0400, Neil Conway wrote: >>> (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. > > I think that would be quite an invasive change; it would require > many hundreds of edits like > > - finfo[i].dobj.objType = DO_FUNC; > + finfo->dobj.objType = DO_FUNC; > > which aside from being tedious would create a back-patching hazard. > So I'm kind of -0.1 or so. > > Another angle to this is that Coverity and possibly other tools tend > to report that these functions leak these allocations, apparently > because they don't notice that pointers into the allocations get > stored in hash tables by a subroutine. I'm not sure if making this > change would make that worse or better. If we really want to change > it, that might be worth checking somehow before we jump. At the moment, I'm inclined to commit v1 once v18 development opens up. We can consider any additional adjustments separately. -- nathan