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 1wZUsS-0015P8-34 for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jun 2026 14:34:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wZUsR-000P4d-0g for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jun 2026 14:34:55 +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 1wZUsQ-000P4U-2h for pgsql-hackers@lists.postgresql.org; Tue, 16 Jun 2026 14:34:54 +0000 Received: from mail-ej1-x62f.google.com ([2a00:1450:4864:20::62f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wZUsO-00000000kN7-2TNz for pgsql-hackers@postgresql.org; Tue, 16 Jun 2026 14:34:54 +0000 Received: by mail-ej1-x62f.google.com with SMTP id a640c23a62f3a-beb2a97cc9aso875557266b.2 for ; Tue, 16 Jun 2026 07:34:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1781620490; cv=none; d=google.com; s=arc-20240605; b=kuKmyI79eDhErUk2XBMuFUE90i2QjAEtDkOJDPUudn8gAfbIrwZhRf7BtiIdDGT7ge ZYbYc8LAUUkZAJyeUDMVn8bddI3PgASIx0MdvWKjqO054MF98b0nMgIughP89cfAcf7p wuWXmsTnnFtrctdSArbCL2CreD+IGILW20AAROWjL3yrlmyiX5fI7O+KB+TL1Qch6GSs AnsXk2DIFYutuJyZPMk1qGAElVTI6GIivirHwK/Aw1vtK4o7h4N8uBJ/Agc7O4ZGXcV6 FpEt++O8uOmFahlHkYtSUHbte2CWf9A8cbYn1hFWW5JTX3cPRpuV2UtFtLWXY+NHmMTX KUqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=Y11DHpebUz0iWxuQrMMyzDYH4NIzle/57ZWyLA0kRRc=; fh=6rmFM+Q5USXuMCMtV1NwlfoKyOmSiFRgK9RVZs2RBa0=; b=Mw1g38fZSNwHjDya9KEWY+AhfkAIbPNLtVYtuBYoORP8rgnfo4cHIDXp8Ck6y+L8u3 j+iPk9tGHwt4e50lWOOv+UN0qyxfNImEZVZZG1qM4rxjGX2EAGNtJ3VOigYidaF51AMA g9ZGYPMtHUuq+fiHSeYG4vu7SuaMV+49UPM5Mzv1dzpy3bWWgs5jvXb8PfYwLj7aM89z S+H0zImAu9vZs4pyEF1HLOd9X+ySUqu109vml59ZRmmXEo750jxoJQOFAAW9ypYyQhCE W04NMwRtLU63F+498frJg8Mmt5dOzxjseT1Mwi+Mchcy0Kxls7KwWfjr7uWjZIKqW5EQ y6kQ==; 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=1781620490; x=1782225290; 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=Y11DHpebUz0iWxuQrMMyzDYH4NIzle/57ZWyLA0kRRc=; b=Jp7yfD/hRqEWgUCwxvoNCv5LUCHB9jXo7jPs2V4sAeapcKKH0sWi5DLTV/dEW36DPr OIbi6Vgw5FKS2LUJtW+9HHOKUPH8CH/gB/5J9g7Oxge9ROlwWpEYqpA0hlLFW6EVXh3J rWcbSjDOnZ5zr/vy5X36wfuXryXZh5v68EEik4tWevA5Sz55QdW3vsCca2rzdIvyC3vB n2T+EALuTn5wWPHD+LWTxoqIjnsD14baY+xkX4dI4KyZ1GLSvWZ+Mtq053z/RHHOpK4H 9Fi1v1jD7EVxLitE9bWCF6/ayAIS3Cc21qDdGIzLAP0Z5HB2cuSCWFBH8QbIgThWm+Uf SKBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781620490; x=1782225290; 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=Y11DHpebUz0iWxuQrMMyzDYH4NIzle/57ZWyLA0kRRc=; b=jw8j3tabU2T0sior524w6ebDPaDzHY1Pg89dJU7A33XEItGs8aa1BR08840HSdTHSY Y1aOxomU+vNZCX/Nhqosqv59h9PMjisweB8opTOUM8ckjHPvDuDjLmMrr8/ZGbz3onmT sxmH7Ho+NZPSOXBIk+CHLGgvWdbXIZHw6v6EL5UarhKpsdTTuv4yh6iyOZm29z3I7UfO YjVf92hms0myD3gk3nl2hL+o4s/wD37aD+QPANsJunKskoKa4oOhQ6FNphiZ2hSLNGcX 1wi4RW8iDTtcrULdVjPkaCSGRnWQwuemU638zErYbWx6Y+2SkwJ/bRR668O2xonZf5JH FbvQ== X-Gm-Message-State: AOJu0YzWQjl/JwoVhP3RTkgQmcAuoetZDce8CITjT1eOHKlH4RLQ248Q 2+GvA4sU8+IgDD1VFW3wqtqXu0VLU9KzzpE5ONgsvuHUna403mLL1XQxFJd8D7BYHkCPsnbn1E3 HEoQyRb3ZdxeAMdNJnDSjflNsvF6LXpM= X-Gm-Gg: Acq92OGCScAd6PuTiIilQXYHwIw9SiQIb4YgPySgjuY9ajIqHpoRu1aF7mhhTOfIOiw MOIwzRmr9YyDzpKWe78MVsXnZT0e7n04uZXsJKrtzZd/XqHOAGIYnqguQmtgSqi4ShAWwvLWxWS YnzykjnKyDJoNqFi/+63cn1G7jQnglwalwrmGGQhCOlINr7MbgQ1mfTF//CUY1jj/6LQqwel1LT SUKrw9YRfiKUtFnnHizaA0ym7AwXeuPYYFiz+IQTp+c+fahxI5xz1HlioeyRdFMjpN2P5lKxFD1 bu2ncZaIV+JhdSXym3ygSi3fIKJ+jqp4fOzV/MQ= X-Received: by 2002:a17:907:1dca:b0:bed:83ee:9223 with SMTP id a640c23a62f3a-c04159b84b6mr211150566b.45.1781620490011; Tue, 16 Jun 2026 07:34:50 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Robert Haas Date: Tue, 16 Jun 2026 10:34:37 -0400 X-Gm-Features: AVVi8Cfc_b9b2vtP83uyukiCukylRcQliDXprKJ0da1fS-yCyj9HYzMY5Iul0eo Message-ID: Subject: Re: use of SPI by postgresImportForeignStatistics To: Etsuro Fujita Cc: "pgsql-hackers@postgresql.org" , Corey Huinker 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 Tue, Jun 16, 2026 at 8:04=E2=80=AFAM Etsuro Fujita wrote: > I thought it would be a good idea to use > pg_restore_attribute_stats/pg_restore_relation_stats, because future > changes in attribute/relation stats would be absorbed by these > functions, which would lower the maintenance cost of this feature. I agree that we want to reuse code, but this isn't the right way to do it. For example, when we want to look up the OID of a relation from SQL, we can say 'whatever'::regclass::oid. But when we want to do the same thing from C, we don't construct a SELECT statement and execute it via SPI. Instead, we have functions like RangeVarGetRelidExtended() which provide access to the same underlying functionality more directly. Another example is converting strings to integers. The user calls int4in(), which then hands off the call to pg_strtoint32_safe(), which can also be called via pg_strtoint32(). Hence, C code should prefer to use pg_strtoint32(), while SQL will go through int4in(). Both ultimately reach the underlying pg_strtoint32_safe() function, but the interfaces are different, so that we can have it be suitable both for SQL access and for C access. This needs to work more like that. The underlying code that ingests and updates the stats should be shared, but the stuff that is specific to a FunctionCallInfo interface needs to be separated out so that we don't need to go through that when calling from C. --=20 Robert Haas EDB: http://www.enterprisedb.com