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 1wfaVJ-005Wh0-0R for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2026 09:48: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 1wfaVH-006aPQ-2v for pgsql-hackers@arkaria.postgresql.org; Fri, 03 Jul 2026 09:48:11 +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 1wfaVH-006aPH-1a for pgsql-hackers@lists.postgresql.org; Fri, 03 Jul 2026 09:48:11 +0000 Received: from mail-pg1-x530.google.com ([2607:f8b0:4864:20::530]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wfaVF-00000001ILN-1iaU for pgsql-hackers@postgresql.org; Fri, 03 Jul 2026 09:48:10 +0000 Received: by mail-pg1-x530.google.com with SMTP id 41be03b00d2f7-c95d0a54ea5so286874a12.0 for ; Fri, 03 Jul 2026 02:48:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1783072088; cv=none; d=google.com; s=arc-20260327; b=mwz8f+Z79ira3E8qvLSLqAszzadV+x2WMpommXJijLyMu7m7Sx1/OlVAmTvVeyZK/5 RgXswOKNBINB+l/Bw+qAOKjr5nR23va2rvMagi/qn+K0DSdb70S2Mk7XvqUrhn2YJtua ZD6f3ic/sATFKWCsZ06+Thojkw8HlGEk1LWs5l5+w1XtdmWIJcXUlgpAzwKI8uK0KWov jeIUcuJyvWa/qHMRQAh3CS/eHEiwVsGeNpwTi4ygqs4pmbYGi5eoLssnRNlx9O7FUvPr LrQYWsLXLHpWKikMW5ojKlGUxGU94+oZBPgnk1kVSWqO+318gU2iz41Zqibsr3Q7KxC9 MXgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=mk8+JPIY64XhAVXxWZH+WBcjrm/Ca8y2uj56M2h13KM=; fh=6PxWfHvWVhNlhVFjCVJhrYXxuc1eRmwduPwFGYwPTqo=; b=KLh1d9vC7YYDEVSA+57MgTC1F8oYQRXCPNQpHQgZgyqntEt/ua4mSp/xIwqJNIT73r mbs523DJp7gE25XC1XW9Z60fHyf/WoFkpenTR/fsVFsbcnVy0Tld66TdeHOkDmVQFbOV u5WuT2bH/Zsyn3M2KZXLJGPmJJPmANk3rMxVG6kLqlc+B3w297XaeeTEqe7RveBjpVom QbMs0yTrMxGbNI/lNlpFtOxRLT0P95H3qhJvFRe3xGjxPZjVfeAJbu0MPn2Xi2e1sY3Q jdclDjNw7v6uNxlHIzCfraWMPqIU8FX+gJczB7xDnMWV8t9xFjJsim/QFYmHfAbVtMcH noYA==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1783072088; x=1783676888; darn=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=mk8+JPIY64XhAVXxWZH+WBcjrm/Ca8y2uj56M2h13KM=; b=BYFfrXFZvzXAOp4wUb444v/GhJ+ufB0GoHYEB/MdFb6RH/ZuBm8HtEa216Xa6fKmDX FhrJErAlIGEt1rV7sz0dmVukvXpPRkq5DAdPqBZsZYQNTKNWXUpC7ph4WTE8U8K5/Zue R/PGBANqjkNF7pqS8r/YUOQWj61FPj/Qo3yTAxBRODStF0zt5jH8L55WfvPpPg5iLe3a sPlCkDTCe+fgaGVS+iJfGwf/piuMPWpZGSyw8O+V/T7bI1mG/g+aa2kywIHe1TE5ctZG bml9jkiRftWRHlX1RF5JhqX/5QJkpORpLaHEux/sLdApCJJ+ootiV4gtRmV7tIH0Fbn1 zc/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783072088; x=1783676888; 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=mk8+JPIY64XhAVXxWZH+WBcjrm/Ca8y2uj56M2h13KM=; b=V1Yjc8deuiTac3v/UGnKRrkTvOzDfIXerAQsnn9qjSODAAZYmRnIikbMd6u3qskB+P teGEvcicOyX4yH8XbsKypkAgYy2cAGwXkww5dSsuIBzFOAn63amKuZEcYwPxoHPKqAi+ U6DHsjtygNhBlietzqK1k87Pi/Y5IfxiLkeuERolMGH7cXyhMlFuPUUhsdFLqMksM/9C E5vfyrCzeb4ykvEeXJEcsRQ8fqZYUl+CzeotSW27Jk0fvgOmfGJBtINxvjmscf9iFTST +JIn9cFZIxETYLLmqYLv2Xfggd2bAqTNdvcqKkHXIId4ZQ9laObXr3SnrBGtQ8ryAAbp +2CA== X-Forwarded-Encrypted: i=1; AFNElJ/SETTJiW1jX+p4DWJvGwuJuMR3udz69f9SCthOPvvAOUFOjsXrY3lZQooZ2cJc5n+C9VzYmJnxOStCYru5@postgresql.org X-Gm-Message-State: AOJu0YwGUru8RhOWtA87+F6XdR992sw3Xv5tL4Bk9+oPjbQbj3P553b5 zwI/kcs23TX5zZqjlLWdJ8/ChgAuFM4QI3R4FnaYlUBLtiMc4vahN9sA6It3iK+aYIG0/eHQdBm trCvBeyErNeAR20Ceix3/qAaiuTVd6Zc= X-Gm-Gg: AfdE7cmASRxQYO7Hc6ctQErlbpNRgje8St/TTZ7msOuAotCqoS2L0nM7v40MKXOFygx TxaASXqin9YNxZN6yWMl3msJ+hg8pJ42QGaJtsHiY5c9byS4jUnvZYglHIixcwYf/8RYfqh1Sx9 q4g3NW96Vn+hHxVadByWqGnyF27Gkr+Bc08pV6npR4Kidr8/D8XqHFpM65rx0fgY20an0zJ1csB krlwzPACsqyGTaBYPsqiWHh7nd5ip/xSSBS+KUTQzf6oGaGomTR9hEA2zJYP6EHcM8S5Zo/qUw0 DzBT2TKz7jlOcimU7U8iwZGk7+cugFy+NkeHuManq6hBSFAQJSTLqbBaDikgqBI6isg6CRmv74A vsrm5ibJLuCb/eNKDQyOoMn9lcy5/Ww== X-Received: by 2002:a05:6300:624b:b0:3b2:b1f8:c745 with SMTP id adf61e73a8af0-3bfed1dfb99mr10665647637.20.1783072088232; Fri, 03 Jul 2026 02:48:08 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Etsuro Fujita Date: Fri, 3 Jul 2026 18:47:54 +0900 X-Gm-Features: AVVi8CeJ47rxphafJYS68bEeSrChlEJG6jh-GYNNz5UklFHFoaWeJ-YEBtVKD04 Message-ID: Subject: Re: use of SPI by postgresImportForeignStatistics To: Corey Huinker Cc: Robert Haas , "pgsql-hackers@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 Thu, Jul 2, 2026 at 5:35=E2=80=AFAM Corey Huinker wrote: > On Wed, Jul 1, 2026 at 8:10=E2=80=AFAM Etsuro Fujita wrote: >> On Wed, Jul 1, 2026 at 12:55=E2=80=AFAM Corey Huinker wrote: >> >> In relation to this change, I moved helper functions set_XXX_arg() >> >> that you added to relation_stats.c and attribute_stats.c to >> >> postgres_fdw.c. The helper functions had soft error handling, but in >> >> the postgres_fdw use, there is no need for that, so I removed that >> >> handling as well. >> > >> > My inclination would be to move the set_*_arg functions could be moved= to some common utility file in v20, as other FDWs will find themselves wit= h the same need. >> >> Seems like a good idea. I moved the set_*_arg functions to >> stat_utils.c, and renamed them to stats_set_*_arg. Attached is a new >> version of the patch. > > I'm concerned that by making these non-error-safe function calls availabl= e, we create a barrier to making those same functions error-safe in the fut= ure. > >> > As for removing the error-handling, it might still be handy because it= would allow us to give a more context-aware error message, rather than the= very narrow "this_string is an invalid this_type", for string that the use= r most certainly never saw. Having said that, it's something we could easil= y change back to error-safe if we wanted to. >> >> Ok, I think we could do so later if needed. > > I agree we could do it later if they were private functions, no problem. = But if they're available outside of postgres_fdw then changing them to be e= rror-safe potentially disrupts other callers. Someone please let me know if= I'm being unnecessarily cautious here. Ah, I misunderstood your comments. I agree with you here, so I'll move back the functions to postgres_fdw.c. > Other Thoughts: > > 1. The internal functions should accept a server_version_number parameter= , and we should document that setting that parameter to 0 mean that we can = assume the current version. I know that we presently have no translation is= sues going forward with statistics, but someday that won't be the case, and= if we don't have this parameter in place then it'll be too late to fix it. Good idea! Will do. > 2. Did you put import_relation_statistics and import_attribute_statistics= in statistics.h because you see them as long-term publicly visible functio= ns, and what's in stats_utils.h to be more subject to change? If so, I coul= d get behind that. If not, then I fall back to my position that they seem l= ike they belong in new relation_stats.h and attribute_stats.h, or stats_uti= ls.h. The answer is the former. I'll remove the changes made to stats_utils.h, though. > 3. The import_stats_functions in their current "bridging" form should do = null checks on all of the NullableDatum pointers, or at least Assert()s on = them. Will do. Thanks for the comments! Best regards, Etsuro Fujita