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 1sOuYm-001wDk-EV for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Jul 2024 07:37:48 +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 1sOuYk-006jxd-Ao for pgsql-hackers@arkaria.postgresql.org; Wed, 03 Jul 2024 07:37:47 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sOuYj-006jxV-Vt for pgsql-hackers@lists.postgresql.org; Wed, 03 Jul 2024 07:37:46 +0000 Received: from smtp.outgoing.loopia.se ([93.188.3.37]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sOuYi-000BNN-PE for pgsql-hackers@lists.postgresql.org; Wed, 03 Jul 2024 07:37:46 +0000 Received: from s807.loopia.se (localhost [127.0.0.1]) by s807.loopia.se (Postfix) with ESMTP id 2290A302879E for ; Wed, 03 Jul 2024 09:37:43 +0200 (CEST) Received: from s980.loopia.se (unknown [172.22.191.6]) by s807.loopia.se (Postfix) with ESMTP id 12B202E28537 for ; Wed, 03 Jul 2024 09:37:43 +0200 (CEST) Received: from s474.loopia.se (unknown [172.22.191.5]) by s980.loopia.se (Postfix) with ESMTP id 1114E22015E8 for ; Wed, 03 Jul 2024 09:37:43 +0200 (CEST) X-Virus-Scanned: amavisd-new at amavis.loopia.se X-Spam-Flag: NO X-Spam-Score: -1.2 X-Spam-Level: X-Spam-Status: No, score=-1.2 tagged_above=-999 required=6.2 tests=[ALL_TRUSTED=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1] autolearn=disabled Authentication-Results: s474.loopia.se (amavisd-new); dkim=pass (2048-bit key) header.d=yesql.se Received: from s899.loopia.se ([172.22.191.5]) by s474.loopia.se (s474.loopia.se [172.22.190.14]) (amavisd-new, port 10024) with UTF8LMTP id Ex-p-ni1aJH9 for ; Wed, 3 Jul 2024 09:37:42 +0200 (CEST) X-Loopia-Auth: user X-Loopia-User: daniel@yesql.se X-Loopia-Originating-IP: 89.255.232.193 Received: from smtpclient.apple (customer-89-255-232-193.stosn.net [89.255.232.193]) (Authenticated sender: daniel@yesql.se) by s899.loopia.se (Postfix) with ESMTPSA id 8A68D2C8B9E7 for ; Wed, 03 Jul 2024 09:37:42 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yesql.se; s=loopiadkim1707475645; t=1719992262; bh=MlQrwznDkzMZgad/F34/6O3I1iEsP+yse73XVmVdHUo=; h=From:Subject:Date:To; b=ZZQIojxdRcEqWdZz9kv5JfkEplKiOcDu5ttcxdTa+eBykmQgCpXkN2hBu1iQyLgkq a2CwQDPLScz6v45H1LJ0wSOkCE5vdrXaByxA5/xUkOJUlu4a6vuzhoVbyVGeO2vS+n vlZY4G96Bv1aV5eqx828B264xaPsTcKY5JQRLNxW1cg7T+JCmwnWggih1paUTumEXD lyXVeYNdsNFc4TrlHm7FmgCW3W8cQ8Yqt8H3atRtphdUIzpCF0sHd0Br5Qx52fdnlH EVdIMfcwMNHsM8LCSgYGpOtRny+/+6n5fCl8s/5n2H+WMrEKd+/9NalwOu96cMy9HD WcxZ7mZ2IpH+Q== From: Daniel Gustafsson Content-Type: multipart/mixed; boundary="Apple-Mail=_0024AF68-445F-4B80-865E-B9F3DBD923A2" Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Additional minor pg_dump cleanups Message-Id: Date: Wed, 3 Jul 2024 09:37:32 +0200 To: PostgreSQL Hackers X-Mailer: Apple Mail (2.3774.600.62) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --Apple-Mail=_0024AF68-445F-4B80-865E-B9F3DBD923A2 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Re-reading Nathans recent 8213df9effaf I noticed a few more small things = which can be cleaned up. In two of the get functions we lack a = fast-path for when no tuples are found which leads to pg_malloc(0) calls. Another = thing is that we in one place reset the PQExpBuffer immediately after creating it = which isn't required. -- Daniel Gustafsson --Apple-Mail=_0024AF68-445F-4B80-865E-B9F3DBD923A2 Content-Disposition: attachment; filename=0001-Remove-superfluous-PQExpBuffer-resetting.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Remove-superfluous-PQExpBuffer-resetting.patch" Content-Transfer-Encoding: quoted-printable =46rom=20f1a0952d441dfcfe45e77d939598b427c1e40bb9=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Daniel=20Gustafsson=20= =0ADate:=20Wed,=203=20Jul=202024=2009:11:05=20= +0200=0ASubject:=20[PATCH=201/2]=20Remove=20superfluous=20PQExpBuffer=20= resetting=0A=0ASince=20the=20buffer=20was=20just=20created,=20there=20is=20= no=20reason=20to=20immediately=0Areset=20it.=0A---=0A=20= src/bin/pg_dump/pg_dump.c=20|=202=20--=0A=201=20file=20changed,=202=20= deletions(-)=0A=0Adiff=20--git=20a/src/bin/pg_dump/pg_dump.c=20= b/src/bin/pg_dump/pg_dump.c=0Aindex=207aec016a9f..7ccf943522=20100644=0A= ---=20a/src/bin/pg_dump/pg_dump.c=0A+++=20b/src/bin/pg_dump/pg_dump.c=0A= @@=20-4198,8=20+4198,6=20@@=20getPublications(Archive=20*fout)=0A=20=0A=20= =09query=20=3D=20createPQExpBuffer();=0A=20=0A-=09= resetPQExpBuffer(query);=0A-=0A=20=09/*=20Get=20the=20publications.=20*/=0A= =20=09if=20(fout->remoteVersion=20>=3D=20130000)=0A=20=09=09= appendPQExpBufferStr(query,=0A--=20=0A2.39.3=20(Apple=20Git-146)=0A=0A= --Apple-Mail=_0024AF68-445F-4B80-865E-B9F3DBD923A2 Content-Disposition: attachment; filename=0002-Add-fastpaths-for-when-no-objects-are-found.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0002-Add-fastpaths-for-when-no-objects-are-found.patch" Content-Transfer-Encoding: quoted-printable =46rom=204777fc98ee642b99c2bdab250e2a6311ee3022e6=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Daniel=20Gustafsson=20= =0ADate:=20Wed,=203=20Jul=202024=2009:12:12=20= +0200=0ASubject:=20[PATCH=202/2]=20Add=20fastpaths=20for=20when=20no=20= objects=20are=20found=0A=0AIf=20there=20are=20no=20objects=20found,=20= there=20is=20no=20reason=20to=20inspect=20the=0Aresult=20columns=20and=20= mallocing=20a=20zero-sized=20(which=20will=20be=201=20byte=0Ain=20= reality)=20heap=20buffer=20for=20it.=20Add=20fast-paths=20like=20how=20= other=0Aobject=20inspection=20functions=20are=20already=20doing=20it.=0A= ---=0A=20src/bin/pg_dump/pg_dump.c=20|=208=20++++++++=0A=201=20file=20= changed,=208=20insertions(+)=0A=0Adiff=20--git=20= a/src/bin/pg_dump/pg_dump.c=20b/src/bin/pg_dump/pg_dump.c=0Aindex=20= 7ccf943522..6e0ddb637e=20100644=0A---=20a/src/bin/pg_dump/pg_dump.c=0A= +++=20b/src/bin/pg_dump/pg_dump.c=0A@@=20-4222,6=20+4222,9=20@@=20= getPublications(Archive=20*fout)=0A=20=0A=20=09ntups=20=3D=20= PQntuples(res);=0A=20=0A+=09if=20(ntups=20=3D=3D=200)=0A+=09=09goto=20= cleanup;=0A+=0A=20=09i_tableoid=20=3D=20PQfnumber(res,=20"tableoid");=0A=20= =09i_oid=20=3D=20PQfnumber(res,=20"oid");=0A=20=09i_pubname=20=3D=20= PQfnumber(res,=20"pubname");=0A@@=20-4260,6=20+4263,8=20@@=20= getPublications(Archive=20*fout)=0A=20=09=09/*=20Decide=20whether=20we=20= want=20to=20dump=20it=20*/=0A=20=09=09= selectDumpableObject(&(pubinfo[i].dobj),=20fout);=0A=20=09}=0A+=0A= +cleanup:=0A=20=09PQclear(res);=0A=20=0A=20=09destroyPQExpBuffer(query);=0A= @@=20-5701,6=20+5706,8=20@@=20getExtensions(Archive=20*fout,=20int=20= *numExtensions)=0A=20=09res=20=3D=20ExecuteSqlQuery(fout,=20query->data,=20= PGRES_TUPLES_OK);=0A=20=0A=20=09ntups=20=3D=20PQntuples(res);=0A+=09if=20= (ntups=20=3D=3D=200)=0A+=09=09goto=20cleanup;=0A=20=0A=20=09extinfo=20=3D=20= (ExtensionInfo=20*)=20pg_malloc(ntups=20*=20sizeof(ExtensionInfo));=0A=20= =0A@@=20-5730,6=20+5737,7=20@@=20getExtensions(Archive=20*fout,=20int=20= *numExtensions)=0A=20=09=09selectDumpableExtension(&(extinfo[i]),=20= dopt);=0A=20=09}=0A=20=0A+cleanup:=0A=20=09PQclear(res);=0A=20=09= destroyPQExpBuffer(query);=0A=20=0A--=20=0A2.39.3=20(Apple=20Git-146)=0A=0A= --Apple-Mail=_0024AF68-445F-4B80-865E-B9F3DBD923A2--