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 1vRKeT-00BJGK-2H for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Dec 2025 01:30:30 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vRKeS-006462-1M for pgsql-hackers@arkaria.postgresql.org; Fri, 05 Dec 2025 01:30:28 +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.96) (envelope-from ) id 1vRKeS-00645k-0E for pgsql-hackers@lists.postgresql.org; Fri, 05 Dec 2025 01:30:28 +0000 Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vRKeP-003CL2-2h for pgsql-hackers@lists.postgresql.org; Fri, 05 Dec 2025 01:30:27 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-7d481452588so179935b3a.3 for ; Thu, 04 Dec 2025 17:30:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764898225; x=1765503025; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=3tGFwCHBIB/PjG914hVgddKGLv6WvRdyNthYJaykvsU=; b=CowWBmhjGK1PgnjKtl4Y65xxS6g2dVZX0bkCxELo6b2SFfs0cP/U9iscvHXdlBbQre dZwJhlAc95OYpwdn4MbEVJi1IN1dfmdR31MZhih3kRN3tvLEwiJMtaejQttoY8+okwX0 ODxwT/e723uLP+mvCWhNbB/X5Wk70lEJX2l4DnzlIIlR00bzBGV6/CJsa9K4oFdwb5uK w9JdY9Ryt7CsGEvi54wTq3pXcGIYISkz/6DQy6Zi1Cfsk47ptEqNwANVcfbevPBwSARg A5S/ucdgCuhDFHU8NI/KMhGZOKrGxFP4bvpi7Uxcr6PIlYBRGwYckQl44RlIkJzAuN1C ZluA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764898225; x=1765503025; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=3tGFwCHBIB/PjG914hVgddKGLv6WvRdyNthYJaykvsU=; b=P2nQUjUlJTA5owx73xyyBkr0YCwZXUh0HIN4wwbZpdZcm5d20UjlPWK6kac43qHkbX LFVcHI2iJKXHzQlT3/+4nzpQ+eASAI/AHpTKMtjlLLFwHhM0tp2chRsjHkF0Ewd6Y0uo BG6jEgUVzuxz8c41rmi80MQBdGfpwsVFrr2qHzpwyDClHUzEGFvHrvEOXrx1o2evzhn4 k/i9mKx9E/k6g/Nvw0dbIwvJ7utinfhj9vWgMYUL3y18BdtLq4ofr+xFhTOuPbu4uwGq psfgaj5MMIBaPv76QM2OAARp0e/+vy4C2X4g9+DktKWeFcfWtiscpZgnH8crB0yZUtbZ E+uQ== X-Forwarded-Encrypted: i=1; AJvYcCWmqcI2SwJRlzItCFTdfjAMKSHkVoO9iQ6gpiSeMsIzAuy+aUPF36OYlkG2wirIkIJVMed/baIFJb3i5DaU@lists.postgresql.org X-Gm-Message-State: AOJu0YxJ0WuHuo+uVY/BPhFtCUKk8lRV3evYWCZMEhWwcKgll2W4yCJf 7jdnamFIlIVrASrgqrGkalRWr7KUPApoGIrLPuJ3W/yTq/bbxghaacpuz0qnNQIarfIvIAhCQaM oHfXX+ATnD6KVEuAsAeb8XSX9a3l8EIk= X-Gm-Gg: ASbGncvoqKf22EB50pVUsiNT7bmI2DtuNp4c42NAgq5f5uoUP8SfD1OV6VyJTUcHQH1 LDSrqO7zvBJ/uvvcUoLlP2W0r/GraG6AYHUnu9ysuGmvJ1RmUcPRxnNhzutyOoPZO4eEGKDVhiV rfwhvf2MyUiTYask48SbxmltzYKkUyYCaeU30DzKNZVcxkiTrTC5omIQD2wp/dnh7kNj4htyYav xKiBc/BGFtIVwOgL50mpu2E5QlgDvJxOi0Momln41zGCZK3qPHi7k9WLEOLGWivl0RWOqqq50zO 3DnC6t6KCQ3bmnxiaFHaAKVfkuI5sCb7OtVyKeOW6vt5jUWyDrnb X-Google-Smtp-Source: AGHT+IHH888jpK3mhjwK70Gf+B+dATyuferceG8qCO/C+CtZVx/FxTzNKn3GHw7gXo+iu0MYhkkgW1ay/mJZ3nc4a3Y= X-Received: by 2002:a05:7301:1695:b0:2a4:3592:cf89 with SMTP id 5a478bee46e88-2ab9785b6abmr5230170eec.0.1764898225240; Thu, 04 Dec 2025 17:30:25 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Thomas Munro Date: Fri, 5 Dec 2025 14:29:48 +1300 X-Gm-Features: AQt7F2r2fq0dPp8-B-daBZQuz5EepDCEbG2ln_wvX6BAdbnS4A2oaj1S2xrMzgw Message-ID: Subject: Re: Safer hash table initialization macro To: Jelte Fennema-Nio Cc: Bertrand Drouvot , pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Dec 5, 2025 at 4:30=E2=80=AFAM Jelte Fennema-Nio wrote: > I'm a bit on the fence about the C11 _Generic code to determine whether > we should use HASH_BLOBS or HASH_STRINGS based on the type of the key. > It works really nicely in practice, but I'm worried it's a bit too much > magic. Probably we should at least have an override to allow using > HASH_BLOBS anyway for a char array (in case it's not null terminated). How much of our header stuff is supposed to work from C++ too? I assume that if this is passing cpluspluscheck then it's only because those _Generic macros aren't being expanded. I suppose you could write the typeof-based version you already hinted at, but only use it for __cplusplus__ (where typeof exists as decltype). What I mean is, if something like DuckDB (C++ IIRC) wants to actually use these APIs with the new interfaces, they won't work if the macros expant to _Generic (not legal C++), but a typeof/decltype-based version should work just fine, but at the same time I don't think we'd want to use typeof just because it is available, or we'd never test the _Generic version: all 3 C compilers have something we can use for typeof, it's just not standard C before C23, and we want PostgreSQL to be a valid C11 program and actually have coverage of those code branches. Another consideration is what impact we have on the Rust world, and potentially other languages used for extensions that call C via FFI etc, if we start using _Generic in our public interfaces, as opposed to just using it in smaller ways as part of our internal assertions and C implementation code that doesn't affect extensions. Of course people using C APIs have to deal with the complexities of C evolution too, I'm not saying that's a blocker, I'm just trying to think through the impact of these sorts of API changes on the ecosystem.