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 1u2akI-002wmW-3e for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Apr 2025 19:05:58 +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 1u2akG-006LLQ-AO for pgsql-hackers@arkaria.postgresql.org; Wed, 09 Apr 2025 19:05:56 +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 1u2akF-006LLH-V9 for pgsql-hackers@lists.postgresql.org; Wed, 09 Apr 2025 19:05:56 +0000 Received: from mail-yw1-x112a.google.com ([2607:f8b0:4864:20::112a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u2akD-004OFJ-18 for pgsql-hackers@lists.postgresql.org; Wed, 09 Apr 2025 19:05:55 +0000 Received: by mail-yw1-x112a.google.com with SMTP id 00721157ae682-703cd93820fso329987b3.2 for ; Wed, 09 Apr 2025 12:05:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1744225551; x=1744830351; darn=lists.postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=Mpdk5jYWJ0xdMd9/lAUpshyirLTHxkcbDFyfiPW1Bv0=; b=ZaVDQNw6vjX6JjP/WtL9+g4uT+sbpVnmshh9oqN5itSg0bNIYP/af3kGHWOnKtJtDx qL5c3QTZWH9YQK82Y6GKh0Qe6lD3ZCKSrokMbz4hYhjclNTqNvmonsSfR5GLbxsxxe60 0ofawLx/rgZ2uqk0DnWGMqGFzB1fJRE+ItrxXdGTvSK2gj7W/6r9XB05W+jO8TC7KJpE 5/vrOtzygIeIZgWb+SyxxywoQLcnqt/aTM5XBUyLiPRUnHmpecoRGbH0C0GgE0gK/VLy LYf27oe2YXI0hhAbLUzmiNHNctOHQZbS2Af1irtAqRs3FQ77HVMo1TtbTUzVWBSAutSP wwow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744225551; x=1744830351; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=Mpdk5jYWJ0xdMd9/lAUpshyirLTHxkcbDFyfiPW1Bv0=; b=r4AM2xMOiF/xdbbretxNHK/xXAnVr4AyiW7SHkkaMdTGnnxy084LiTo991usc8ZCcr Yl9fjoXDR5MXrBSN5QHTLNG9jGKySzKwnxUO9AWV+zkHwvDtRqRPoC9jmHBA35sU9f+U nOpoUI1hcObtuVwqFLHiBT8wMMAo6KqWiQCKSPEE2+aLpZ13gOnA48pXUlPrEqSkqKtG encXb7+ZyEP3IIgq2q8Dl8b59BqnE89R7HdOCSLlXKqIxAWlk9dv7y711Ez7AnpHSgws WiOx89hZ+QPzm1rMIciNpEaPC/quEzKNx2rgUldWjCx2hZ+QWtIvWfUOGOybDoA+QjtD 8Taw== X-Forwarded-Encrypted: i=1; AJvYcCVARr4rRYsNKEzqZnmZDqWGxlFQq29YJ8TIYwxr9HZG0/gtjTui3At877Y+34fGp3SSP+OfFoFGaXVaN0/X@lists.postgresql.org X-Gm-Message-State: AOJu0Yws8IWUGMZwVxQIdhAgDarCGu5PSHIdiRwK2RXZZ0yJaUfuveK6 JUWdcVxiYj+GEgxHH5MR/FCin3pB1n767pj26kKefyqxmC6Q31XC X-Gm-Gg: ASbGncsSkS3WROi8mKy6FN8Yrm5Cxn8u50KYyNkE7j32f78zYYy1Sagzx66WkNIlaAF NuFLACRgZP7fqkc7HyM4AdLE//r8bMvXjax7wyMXRsc4N8L/IX5DOQWXuK1fcmgjgU6QhO18vu3 62EEY3b5gtXNDBZ9DJ9EreVz6ZE6kL5ZWV0KQRgvgFSDIdieX2lDeVx7h2XudxcXv8VHxmuGVl0 /TpEd514OM42zQkECvmmJDY8Kiry5WXPT1SvYCIZIu5ilVE+5fJ33L5j8mar+KTd4lHyv+ifu1Q /ybL6oY6+86ods8YGyIB+t4cyBEGf6a8K3klHAudnmNr6fFz1tgTofJ9EVBL0e5Mp/9t58rvUaR plxIVkERu949sInTnsKA6Vzc35EhfAbQ= X-Google-Smtp-Source: AGHT+IEVUNP6O+2NNt4jCmIDlCSk7zj1+P8UEap6nDpZyXk58HbgwobDI9O7Xjb1Ujn/nyQRzbi6rw== X-Received: by 2002:a05:690c:6b07:b0:703:b4a7:f148 with SMTP id 00721157ae682-7053ae7099cmr58031157b3.25.1744225550972; Wed, 09 Apr 2025 12:05:50 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 00721157ae682-7053e39cacbsm4013107b3.98.2025.04.09.12.05.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Apr 2025 12:05:50 -0700 (PDT) Date: Wed, 9 Apr 2025 14:05:48 -0500 From: Nathan Bossart To: Michael Paquier Cc: Euler Taveira , Amit Kapila , Alexander Lakhin , Tom Lane , "Jonathan S. Katz" , PostgreSQL Hackers Subject: Re: Large expressions in indexes can't be stored (non-TOASTable) Message-ID: References: <4c2a6100-738e-48cc-8a11-2d85f95ae0ed@app.fastmail.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="rlj1lnUl5BzZdqgn" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --rlj1lnUl5BzZdqgn Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Apr 09, 2025 at 01:20:29PM +0900, Michael Paquier wrote: > I guess that's the consensus, then. No objections to the removal here. That would look like the attached. There are still a couple of other known TOAST snapshot issues I need to revisit, but this sidesteps a few of them. But this'll need to wait for a couple of months until v19 development begins. -- nathan --rlj1lnUl5BzZdqgn Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="v1-0001-Remove-pg_replication_origin-s-TOAST-table.patch" From 932a7ff2623c3185f6f98194233d3d99807909fe Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Wed, 9 Apr 2025 14:00:31 -0500 Subject: [PATCH v1 1/1] Remove pg_replication_origin's TOAST table. --- src/backend/catalog/catalog.c | 2 -- src/backend/replication/logical/origin.c | 12 ++++++++++++ src/include/catalog/pg_replication_origin.h | 2 -- src/include/replication/origin.h | 7 +++++++ src/test/regress/expected/misc_functions.out | 4 ++++ src/test/regress/expected/misc_sanity.out | 6 +++++- src/test/regress/sql/misc_functions.sql | 3 +++ src/test/regress/sql/misc_sanity.sql | 3 +++ 8 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c index a6edf614606..a7eb60dd2d2 100644 --- a/src/backend/catalog/catalog.c +++ b/src/backend/catalog/catalog.c @@ -315,8 +315,6 @@ IsSharedRelation(Oid relationId) relationId == PgDbRoleSettingToastIndex || relationId == PgParameterAclToastTable || relationId == PgParameterAclToastIndex || - relationId == PgReplicationOriginToastTable || - relationId == PgReplicationOriginToastIndex || relationId == PgShdescriptionToastTable || relationId == PgShdescriptionToastIndex || relationId == PgShseclabelToastTable || diff --git a/src/backend/replication/logical/origin.c b/src/backend/replication/logical/origin.c index 6583dd497da..22b4aa0b382 100644 --- a/src/backend/replication/logical/origin.c +++ b/src/backend/replication/logical/origin.c @@ -264,6 +264,18 @@ replorigin_create(const char *roname) SysScanDesc scan; ScanKeyData key; + /* + * To avoid needing a TOAST table for pg_replication_origin, we restrict + * replication origin names to 512 bytes. This should be more than enough + * for all practical use. + */ + if (strlen(roname) > MAX_RONAME_LEN) + ereport(ERROR, + (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), + errmsg("replication origin name is too long"), + errdetail("Repilcation origin names must be no longer than %d bytes.", + MAX_RONAME_LEN))); + roname_d = CStringGetTextDatum(roname); Assert(IsTransactionState()); diff --git a/src/include/catalog/pg_replication_origin.h b/src/include/catalog/pg_replication_origin.h index deb43065fe9..7ade8bbda39 100644 --- a/src/include/catalog/pg_replication_origin.h +++ b/src/include/catalog/pg_replication_origin.h @@ -54,8 +54,6 @@ CATALOG(pg_replication_origin,6000,ReplicationOriginRelationId) BKI_SHARED_RELAT typedef FormData_pg_replication_origin *Form_pg_replication_origin; -DECLARE_TOAST_WITH_MACRO(pg_replication_origin, 4181, 4182, PgReplicationOriginToastTable, PgReplicationOriginToastIndex); - DECLARE_UNIQUE_INDEX_PKEY(pg_replication_origin_roiident_index, 6001, ReplicationOriginIdentIndex, pg_replication_origin, btree(roident oid_ops)); DECLARE_UNIQUE_INDEX(pg_replication_origin_roname_index, 6002, ReplicationOriginNameIndex, pg_replication_origin, btree(roname text_ops)); diff --git a/src/include/replication/origin.h b/src/include/replication/origin.h index 9cb2248fa9f..095b3e6fa50 100644 --- a/src/include/replication/origin.h +++ b/src/include/replication/origin.h @@ -33,6 +33,13 @@ typedef struct xl_replorigin_drop #define InvalidRepOriginId 0 #define DoNotReplicateId PG_UINT16_MAX +/* + * To avoid needing a TOAST table for pg_replication_origin, we restrict + * replication origin names to 512 bytes. This should be more than enough for + * all practical use. + */ +#define MAX_RONAME_LEN (512) + extern PGDLLIMPORT RepOriginId replorigin_session_origin; extern PGDLLIMPORT XLogRecPtr replorigin_session_origin_lsn; extern PGDLLIMPORT TimestampTz replorigin_session_origin_timestamp; diff --git a/src/test/regress/expected/misc_functions.out b/src/test/regress/expected/misc_functions.out index d3f5d16a672..db1431a87f7 100644 --- a/src/test/regress/expected/misc_functions.out +++ b/src/test/regress/expected/misc_functions.out @@ -914,3 +914,7 @@ SELECT test_relpath(); (1 row) +-- pg_replication_origin.roname length restriction +SELECT pg_replication_origin_create(repeat('0123456789abcdef', 33)); +ERROR: replication origin name is too long +DETAIL: Repilcation origin names must be no longer than 512 bytes. diff --git a/src/test/regress/expected/misc_sanity.out b/src/test/regress/expected/misc_sanity.out index b032a3f4761..0cb58311329 100644 --- a/src/test/regress/expected/misc_sanity.out +++ b/src/test/regress/expected/misc_sanity.out @@ -42,6 +42,9 @@ WHERE refclassid = 0 OR refobjid = 0 OR -- as user data by pg_upgrade, which would cause failures. -- 3. pg_authid, since its toast table cannot be accessed when it would be -- needed, i.e., during authentication before we've selected a database. +-- 4. pg_replication_origin, since its toast table would only be used for +-- replication origin names, which we can avoid with a reasonable length +-- restriction. SELECT relname, attname, atttypid::regtype FROM pg_class c JOIN pg_attribute a ON c.oid = attrelid WHERE c.oid < 16384 AND @@ -61,7 +64,8 @@ ORDER BY 1, 2; pg_class | relpartbound | pg_node_tree pg_largeobject | data | bytea pg_largeobject_metadata | lomacl | aclitem[] -(10 rows) + pg_replication_origin | roname | text +(11 rows) -- system catalogs without primary keys -- diff --git a/src/test/regress/sql/misc_functions.sql b/src/test/regress/sql/misc_functions.sql index aaebb298330..7122ff6133d 100644 --- a/src/test/regress/sql/misc_functions.sql +++ b/src/test/regress/sql/misc_functions.sql @@ -411,3 +411,6 @@ CREATE FUNCTION test_relpath() AS :'regresslib' LANGUAGE C; SELECT test_relpath(); + +-- pg_replication_origin.roname length restriction +SELECT pg_replication_origin_create(repeat('0123456789abcdef', 33)); diff --git a/src/test/regress/sql/misc_sanity.sql b/src/test/regress/sql/misc_sanity.sql index 135793871b4..545b2b48989 100644 --- a/src/test/regress/sql/misc_sanity.sql +++ b/src/test/regress/sql/misc_sanity.sql @@ -45,6 +45,9 @@ WHERE refclassid = 0 OR refobjid = 0 OR -- as user data by pg_upgrade, which would cause failures. -- 3. pg_authid, since its toast table cannot be accessed when it would be -- needed, i.e., during authentication before we've selected a database. +-- 4. pg_replication_origin, since its toast table would only be used for +-- replication origin names, which we can avoid with a reasonable length +-- restriction. SELECT relname, attname, atttypid::regtype FROM pg_class c JOIN pg_attribute a ON c.oid = attrelid -- 2.39.5 (Apple Git-154) --rlj1lnUl5BzZdqgn--