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 1qTe3a-00ADcH-OA for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Aug 2023 07:56:39 +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 1qTe3Z-003Guo-Ab for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Aug 2023 07:56:37 +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 1qTe3Z-003Gug-0S for pgsql-hackers@lists.postgresql.org; Wed, 09 Aug 2023 07:56:37 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qTe3X-001R1D-1m for pgsql-hackers@lists.postgresql.org; Wed, 09 Aug 2023 07:56:36 +0000 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 30B0D5C009A; Wed, 9 Aug 2023 03:56:33 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Wed, 09 Aug 2023 03:56:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm3; t=1691567793; x=1691654193; bh=7a tLfnPRcvH7VNpIfFUa/Bpx2G5xPDvGd+xQgPWxcj8=; b=lV9Aj0Gdt6pz0G9Ca4 WaEr3kR/LssIGX06NMyWJKE+AeM6Yvi6vSRMlX5nF80YpRG/WyFY8MN86Edtg+fl sZUrfkSxs/t4WlaxUXUaeo2tjXnUbif9GVqwmvr9crWsLaT6TTC13O4mb3Dg+0pU BpVkq5/EY6riRxJo5SkwVceZOBwAp6YrOHB2yzDfPx47ywVnHVtpryONihaqXvFZ QEYcGqWcNlAO0CLdxKy+2Bt/CniOUIeW09JPQqfufuUMS7IeFHbtfbaQgBvjM4OF xhaOK5vOb7hGkVtDwDDvdlnmCHHZvJCEkWb785H/T45Ydl5HK3WOLcYyNr8qCesU NzQw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm3; t=1691567793; x=1691654193; bh=7atLfnPRcvH7V NpIfFUa/Bpx2G5xPDvGd+xQgPWxcj8=; b=l3/bzczWAFLYl7QHa0zVmKGsT7lTN qFVkDKoTsWLOOS3WO+ywb99opCMwm3Bm6hIUhL8E612GZFcnyUgRR+ie7VH/ckhl 9mbu1CD/gdEezkhfYl/vBNse+4utELKlJFmzqEI4WPjGbU5UKXeI1CCJOvDB+dkV hTQWhFAsmGXKVrcBw8d9lc9za4IpEi/+Km6Fg5ExHnHaX8kYzrM76jobetX8/cCi LXg75Z0MDBKUQHdteD62/244a0n5/txOXkHF11+c1lmK1QizMhm+0T+Mt48k2f0L Zt096HExswKDdQzgoz8N7Za0CRhcX43zdnQrssDIB1dqs1/sKe1JBHDkw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrleefgdduvdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeg geegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 9 Aug 2023 03:56:30 -0400 (EDT) Date: Wed, 9 Aug 2023 16:56:27 +0900 From: Michael Paquier To: "Drouvot, Bertrand" Cc: Kyotaro Horiguchi , tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org Subject: Re: WIP: new system catalog pg_wait_event Message-ID: References: <3658241.1691161701@sss.pgh.pa.us> <0109438a-9672-322b-7638-04ad47c97d0f@gmail.com> <1dc98591-0d06-f0da-bc88-21f529d6fb8e@gmail.com> <20230808.115332.301701413576096139.horikyota.ntt@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="BCXgd8Rdde1cIW1G" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --BCXgd8Rdde1cIW1G Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, Aug 08, 2023 at 10:16:37AM +0200, Drouvot, Bertrand wrote: > Please find attached v3 adding the wait event types. +-- There will surely be at least 9 wait event types, 240 wait events and at +-- least 27 related to WAL +select count(distinct(wait_event_type)) > 8 as ok_type, + count(*) > 239 as ok, + count(*) FILTER (WHERE description like '%WAL%') > 26 AS ok_wal_desc +from pg_wait_event; The point is to check the execution of this function, so this could be simpler, like that or a GROUP BY clause with the event type: SELECT count(*) > 0 FROM pg_wait_event; SELECT wait_event_type, count(*) > 0 AS has_data FROM pg_wait_event GROUP BY wait_event_type ORDER BY wait_event_type; + printf $ic "\tmemset(values, 0, sizeof(values));\n"; + printf $ic "\tmemset(nulls, 0, sizeof(nulls));\n\n"; + printf $ic "\tvalues[0] = CStringGetTextDatum(\"%s\");\n", $last; + printf $ic "\tvalues[1] = CStringGetTextDatum(\"%s\");\n", $wev->[1]; + printf $ic "\tvalues[2] = CStringGetTextDatum(\"%s\");\n\n", $new_desc; That's overcomplicated for some code generated. Wouldn't it be simpler to generate a list of elements, with the code inserting the tuples materialized looping over it? + my $new_desc = substr $wev->[2], 1, -2; + $new_desc =~ s/'/\\'/g; + $new_desc =~ s/<.*>(.*?)<.*>/$1/g; + $new_desc =~ s//$1/g; + $new_desc =~ s/; see.*$//; Better to document what this does, the contents produced look good. + rename($ictmp, "$output_path/pg_wait_event_insert.c") + || die "rename: $ictmp to $output_path/pg_wait_event_insert.c: $!"; # seems nicer to not add that as an include path for the whole backend. waitevent_sources = files( 'wait_event.c', + 'pg_wait_event.c', ) This could use a name referring to SQL functions, say wait_event_funcs.c, with a wait_event_data.c or a wait_event_funcs_data.c? + # Don't generate .c (except pg_wait_event_insert.c) and .h files for + # Extension, LWLock and Lock, these are handled independently. + my $is_exception = $waitclass eq 'WaitEventExtension' || + $waitclass eq 'WaitEventLWLock' || + $waitclass eq 'WaitEventLock'; Perhaps it would be cleaner to use a separate loop? -- Michael --BCXgd8Rdde1cIW1G Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmTTRqsACgkQnvQgOdby QH2GaBAAmzRS+wZjjkrE+Mp1ZTOHUhKX/aofYy8uXw93Y6Hd9Wz4nUxqCAHaqkCr Bnk/QnbCrLBR6oLR/Oo/uTTKnnnzHhBl9kr3+8+77oSs4esR3EwOSY4N30iB/bwm eUlEd4Tcjy4WfZ0jtgSRd7y+ZKja8/sOp2+q4uEOaUOV6vNiPYqtHjqsoAh0Jaow WH5Pv1WxHBooVCuNE1WZT+t5dfQy+h/UKUmJt4tkaixOVuT3m/8w/4CSsXhGivjJ 9ND8X5qZJrT7gLsrITo/YGNwvDtDUseANw083kp9udtN9F7w+s0FjZBhw1gp8kg5 4FzzT/D4PWWwx96jjaF2ClCI2v2OKaphvWdyuTU6+YDeeSzUSQJYaC5o63tjMw9B DpRqSVP0PJ7/mhTnIVU+jCEtMApcklu8Ahh8AHbpNCWcgaurDaNiU2y3AcLM9nOd P60raSwMzbymvF/82SdAa39t6/jxNTkYB9pndtjnHK06nhT8pWPOT/S2iYNdYYn/ h/5mr/2G6TkmO8Yt4rC9cfsv7ARWxj4VXlf/Ixj12DLopu7ZEPDXoHsZFk5F1OWI 4qrxVYpgwx57Mai2GGbkZOQUAFcUcqgYNgkLIPrH7MPHB0WPWXIjF91AHMel+M+/ YGlsEDbfayb9PQQUTtx+n8YTTd6OFttufNsqi0CFwiVcw7mXibM= =OTHM -----END PGP SIGNATURE----- --BCXgd8Rdde1cIW1G--