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.96) (envelope-from ) id 1vSs7t-007oaQ-1Y for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Dec 2025 07:27:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vSs7q-003aeH-0c for pgsql-hackers@arkaria.postgresql.org; Tue, 09 Dec 2025 07:27:10 +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.96) (envelope-from ) id 1vSs7p-003ae8-2e for pgsql-hackers@lists.postgresql.org; Tue, 09 Dec 2025 07:27:10 +0000 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vSs7n-003zuG-0m for pgsql-hackers@lists.postgresql.org; Tue, 09 Dec 2025 07:27:09 +0000 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-42b3d7c1321so3179644f8f.3 for ; Mon, 08 Dec 2025 23:27:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765265225; x=1765870025; darn=lists.postgresql.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=wA8It8ANvGUb9MQldIOdhEGIasUL3jROZsg02Gd9puM=; b=aAYL3hX8njhNfNqhmR8p5E0znVrLX9lYD8CDzToZnXn/+/TcdiqL8vQcpf953mg/bM LxpsyU6jbNMh3xR0EcEypeklgx5Jz2gue7MDd9+ftDPlZnBDkWsfeNmWXW7oo7Ex/mk2 I5bg3hB/Q0jYH+lGGEj6eWcchbCEIbBdVLyQJW0iktuup7au3iF6jeiP2wmsptUdlzu9 0NxnLVpelPzIqUgvFTOtnjdMi0/JmTtFLH+OByp1j0eBcWNYt8yV66svFbruv54+eIiF KokXrah4EGjn+qOp3cE7gyy9iUXr5eYcfd8iiUCtEEBWIjnwSeXjEbisnunJ9zA14l23 GGdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765265225; x=1765870025; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=wA8It8ANvGUb9MQldIOdhEGIasUL3jROZsg02Gd9puM=; b=KV+CLgt3TR+0yCnsHDKXSjrLcpa6V4+Zerkmiuz62zgMABGh47ZYoOB/sJqld3J09U Pcpb4mcPTYWuIg4m/11xxV+peQDrHW9el28jWBkQKg0z07wyppx/0Rgvtnag1tiXNCnW HFVq4j6fcB0/MsIZ7ZE0iI/Xr19ELh1hV5plG0TccGY7KKRscRvakoG8qTDR2QT0Z246 mA4sVATQ3EmbP/C6rGWX3bN2gnR8fJ0BvIWj2M4pZLTvzEkEdzbwW0LiMgJ4t7JI1vLm ihp9icdtbB8FE5blRUlz6p3+a6AbnzvefBDdDKtg6BSET0BhJ2+YxPmI9NreYzGjITAE SFLw== X-Forwarded-Encrypted: i=1; AJvYcCUdzPpsKCRmwIL4c/5N7sVkugx7JCcjex2gWy/8T4fTah8acyTxAGoAywTP2oTp+7cEw3DpWi3sNQHUViLt@lists.postgresql.org X-Gm-Message-State: AOJu0YwUwtCyUxzxr6vVaF2v4hjwRNeo8PNxdI7QO/fwDn2aZqzld47Q doyf5eUmsgJ+RhkEjE8+Ota7fPFdG43Y8iTl3aIro91aKcs2B86NwkIG X-Gm-Gg: ASbGnctaVZgUTLUncB2eW3zVbjC4qT78qLentohM/vY4nyfxD+L3lVdsJwcpGC5yJjr 7RH1CQ1AZi/0o2goq0JmgVb/0ANN9qMS7tt9tbjCQ1wW/ZQMNdLOTpVQJ3wSkon7UUq9soS+Z7o QRpi0xwZIko1o2X2JFn3HGw9rNrT0S6NaMWO3Htm++fuW2sEF2u6wv7KdsXAwmYJl40UY37sCeA mxOuGlvT5Ot/m4tn4nXyHBF/Bc25tWnjX9O9pvcDGWl28AgrqVX07ZfUSuher9GIVynUexsBO9X WyixnqVyHOppMHFrGBMxwmOfEofUHqdSAq+sJEGicF9Vr6rvDeVzL7b4rJHo4PNGsyNsjxF+kk1 yrvrpLfVq31/Yd6A5kA0I93IXr2qEpPE4hBgNMo0D+kqXE40HQBr5g2f8ZVl4FAQodlrxtCwXu/ 1PlQCAI7Lhi9VNWv1TkAUFLObbtdfDEUGDQD2ZrU4GGtzhDC/j0QmuiykdVaKdW8m1/4mZdwaFI jWM3/A2kiAUDYS8sPt4fWlRGkDrccuY4ys9MTbEDzg0jg== X-Google-Smtp-Source: AGHT+IFVKxOiZyANxDXAiSuV4k+6N0ydDe3kXLQ9RbiIQ0938jiwHpEpTCQwFLbHYDnyNJZpbAjG9w== X-Received: by 2002:a5d:5f49:0:b0:42b:4185:e58a with SMTP id ffacd0b85a97d-42f89f0c5b4mr10050158f8f.14.1765265224800; Mon, 08 Dec 2025 23:27:04 -0800 (PST) Received: from ip-10-97-1-34.eu-west-3.compute.internal (ec2-15-237-197-144.eu-west-3.compute.amazonaws.com. [15.237.197.144]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42f7d222506sm32024810f8f.28.2025.12.08.23.27.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Dec 2025 23:27:04 -0800 (PST) Date: Tue, 9 Dec 2025 07:27:03 +0000 From: Bertrand Drouvot To: Jelte Fennema-Nio Cc: Thomas Munro , pgsql-hackers@lists.postgresql.org Subject: Re: Safer hash table initialization macro Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On Mon, Dec 08, 2025 at 11:53:02AM +0100, Jelte Fennema-Nio wrote: > On Sat Dec 6, 2025 at 1:56 AM CET, Thomas Munro wrote: > > On Sat, Dec 6, 2025 at 3:32 AM Jelte Fennema-Nio wrote: > > > On Fri, 5 Dec 2025 at 02:30, Thomas Munro wrote: > > > create a hashmap it's still possible to call the. > > > > ... C functions without the helper macros. > > Oops, forgot to finish that sentence. Thanks for this patch series! > > Yeah. I don't think we want that sort of thing all over the place. > > We could eventually come up with a small set of tools in a central > > place though, so people can work with this stuff without also known > > C++ meta-programming voodoo. For example something like (untested, I > > didn't think about char[size], just spitballing here...): > > > > (pg_expr_has_type_p(ptr, char *) || pg_expr_has_type_p(ptr, NameData *)) > > > > ... given the definition I posted recently[1]. +#if defined(__cplusplus) +#define pg_expr_has_type_p(expr, type) (std::is_same::value) +#else +#define pg_expr_has_type_p(expr, type) \ + _Generic((expr), type: 1, default: 0) +#endif What about relying on the existing __builtin_types_compatible_p() instead of _Generic() here? Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com