Skip to content

Commit 6aa4406

Browse files
Remove pg_authid's TOAST table.
pg_authid's only varlena column is rolpassword, which unfortunately cannot be de-TOASTed during authentication because we haven't selected a database yet and cannot read pg_class. By removing pg_authid's TOAST table, attempts to set password hashes that require out-of-line storage will fail with a "row is too big" error instead. We may want to provide a more user-friendly error in the future, but for now let's just remove the useless TOAST table. Bumps catversion. Reported-by: Alexander Lakhin Reviewed-by: Tom Lane, Michael Paquier Discussion: https://postgr.es/m/89e8649c-eb74-db25-7945-6d6b23992394%40gmail.com
1 parent c4d5cb7 commit 6aa4406

File tree

9 files changed

+30
-29
lines changed

9 files changed

+30
-29
lines changed

src/backend/catalog/catalog.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,9 +300,7 @@ IsSharedRelation(Oid relationId)
300300
relationId == TablespaceOidIndexId)
301301
return true;
302302
/* These are their toast tables and toast indexes */
303-
if (relationId == PgAuthidToastTable ||
304-
relationId == PgAuthidToastIndex ||
305-
relationId == PgDatabaseToastTable ||
303+
if (relationId == PgDatabaseToastTable ||
306304
relationId == PgDatabaseToastIndex ||
307305
relationId == PgDbRoleSettingToastTable ||
308306
relationId == PgDbRoleSettingToastIndex ||

src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
*/
5858

5959
/* yyyymmddN */
60-
#define CATALOG_VERSION_NO 202409182
60+
#define CATALOG_VERSION_NO 202409211
6161

6262
#endif

src/include/catalog/pg_authid.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,6 @@ CATALOG(pg_authid,1260,AuthIdRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID(284
5555
*/
5656
typedef FormData_pg_authid *Form_pg_authid;
5757

58-
DECLARE_TOAST_WITH_MACRO(pg_authid, 4175, 4176, PgAuthidToastTable, PgAuthidToastIndex);
59-
6058
DECLARE_UNIQUE_INDEX(pg_authid_rolname_index, 2676, AuthIdRolnameIndexId, pg_authid, btree(rolname name_ops));
6159
DECLARE_UNIQUE_INDEX_PKEY(pg_authid_oid_index, 2677, AuthIdOidIndexId, pg_authid, btree(oid oid_ops));
6260

src/test/regress/expected/create_index.out

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2664,10 +2664,10 @@ REINDEX TABLE CONCURRENTLY pg_class; -- no catalog relation
26642664
ERROR: cannot reindex system catalogs concurrently
26652665
REINDEX INDEX CONCURRENTLY pg_class_oid_index; -- no catalog index
26662666
ERROR: cannot reindex system catalogs concurrently
2667-
-- These are the toast table and index of pg_authid.
2668-
REINDEX TABLE CONCURRENTLY pg_toast.pg_toast_1260; -- no catalog toast table
2667+
-- These are the toast table and index of pg_database.
2668+
REINDEX TABLE CONCURRENTLY pg_toast.pg_toast_1262; -- no catalog toast table
26692669
ERROR: cannot reindex system catalogs concurrently
2670-
REINDEX INDEX CONCURRENTLY pg_toast.pg_toast_1260_index; -- no catalog toast index
2670+
REINDEX INDEX CONCURRENTLY pg_toast.pg_toast_1262_index; -- no catalog toast index
26712671
ERROR: cannot reindex system catalogs concurrently
26722672
REINDEX SYSTEM CONCURRENTLY postgres; -- not allowed for SYSTEM
26732673
ERROR: cannot reindex system catalogs concurrently
@@ -2974,10 +2974,10 @@ ERROR: must be owner of schema schema_to_reindex
29742974
RESET ROLE;
29752975
GRANT USAGE ON SCHEMA pg_toast TO regress_reindexuser;
29762976
SET SESSION ROLE regress_reindexuser;
2977-
REINDEX TABLE pg_toast.pg_toast_1260;
2978-
ERROR: permission denied for table pg_toast_1260
2979-
REINDEX INDEX pg_toast.pg_toast_1260_index;
2980-
ERROR: permission denied for index pg_toast_1260_index
2977+
REINDEX TABLE pg_toast.pg_toast_1262;
2978+
ERROR: permission denied for table pg_toast_1262
2979+
REINDEX INDEX pg_toast.pg_toast_1262_index;
2980+
ERROR: permission denied for index pg_toast_1262_index
29812981
-- Clean up
29822982
RESET ROLE;
29832983
REVOKE USAGE ON SCHEMA pg_toast FROM regress_reindexuser;

src/test/regress/expected/misc_sanity.out

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ WHERE refclassid = 0 OR refobjid = 0 OR
4040
-- 2. pg_largeobject and pg_largeobject_metadata. Large object catalogs
4141
-- and toast tables are mutually exclusive and large object data is handled
4242
-- as user data by pg_upgrade, which would cause failures.
43+
-- 3. pg_authid, since its toast table cannot be accessed when it would be
44+
-- needed, i.e., during authentication before we've selected a database.
4345
SELECT relname, attname, atttypid::regtype
4446
FROM pg_class c JOIN pg_attribute a ON c.oid = attrelid
4547
WHERE c.oid < 16384 AND
@@ -53,12 +55,13 @@ ORDER BY 1, 2;
5355
pg_attribute | attfdwoptions | text[]
5456
pg_attribute | attmissingval | anyarray
5557
pg_attribute | attoptions | text[]
58+
pg_authid | rolpassword | text
5659
pg_class | relacl | aclitem[]
5760
pg_class | reloptions | text[]
5861
pg_class | relpartbound | pg_node_tree
5962
pg_largeobject | data | bytea
6063
pg_largeobject_metadata | lomacl | aclitem[]
61-
(9 rows)
64+
(10 rows)
6265

6366
-- system catalogs without primary keys
6467
--

src/test/regress/expected/tablespace.out

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,13 @@ ERROR: cannot move system relation "pg_authid_rolname_index"
5151
REINDEX (TABLESPACE regress_tblspace) TABLE CONCURRENTLY pg_authid;
5252
ERROR: cannot reindex system catalogs concurrently
5353
-- toast relations, fail
54-
REINDEX (TABLESPACE regress_tblspace) INDEX pg_toast.pg_toast_1260_index;
55-
ERROR: cannot move system relation "pg_toast_1260_index"
56-
REINDEX (TABLESPACE regress_tblspace) INDEX CONCURRENTLY pg_toast.pg_toast_1260_index;
54+
REINDEX (TABLESPACE regress_tblspace) INDEX pg_toast.pg_toast_1262_index;
55+
ERROR: cannot move system relation "pg_toast_1262_index"
56+
REINDEX (TABLESPACE regress_tblspace) INDEX CONCURRENTLY pg_toast.pg_toast_1262_index;
5757
ERROR: cannot reindex system catalogs concurrently
58-
REINDEX (TABLESPACE regress_tblspace) TABLE pg_toast.pg_toast_1260;
59-
ERROR: cannot move system relation "pg_toast_1260_index"
60-
REINDEX (TABLESPACE regress_tblspace) TABLE CONCURRENTLY pg_toast.pg_toast_1260;
58+
REINDEX (TABLESPACE regress_tblspace) TABLE pg_toast.pg_toast_1262;
59+
ERROR: cannot move system relation "pg_toast_1262_index"
60+
REINDEX (TABLESPACE regress_tblspace) TABLE CONCURRENTLY pg_toast.pg_toast_1262;
6161
ERROR: cannot reindex system catalogs concurrently
6262
-- system catalog, fail
6363
REINDEX (TABLESPACE pg_global) TABLE pg_authid;

src/test/regress/sql/create_index.sql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,9 +1126,9 @@ REINDEX TABLE CONCURRENTLY concur_reindex_tab;
11261126
COMMIT;
11271127
REINDEX TABLE CONCURRENTLY pg_class; -- no catalog relation
11281128
REINDEX INDEX CONCURRENTLY pg_class_oid_index; -- no catalog index
1129-
-- These are the toast table and index of pg_authid.
1130-
REINDEX TABLE CONCURRENTLY pg_toast.pg_toast_1260; -- no catalog toast table
1131-
REINDEX INDEX CONCURRENTLY pg_toast.pg_toast_1260_index; -- no catalog toast index
1129+
-- These are the toast table and index of pg_database.
1130+
REINDEX TABLE CONCURRENTLY pg_toast.pg_toast_1262; -- no catalog toast table
1131+
REINDEX INDEX CONCURRENTLY pg_toast.pg_toast_1262_index; -- no catalog toast index
11321132
REINDEX SYSTEM CONCURRENTLY postgres; -- not allowed for SYSTEM
11331133
REINDEX (CONCURRENTLY) SYSTEM postgres; -- ditto
11341134
REINDEX (CONCURRENTLY) SYSTEM; -- ditto
@@ -1305,8 +1305,8 @@ REINDEX SCHEMA schema_to_reindex;
13051305
RESET ROLE;
13061306
GRANT USAGE ON SCHEMA pg_toast TO regress_reindexuser;
13071307
SET SESSION ROLE regress_reindexuser;
1308-
REINDEX TABLE pg_toast.pg_toast_1260;
1309-
REINDEX INDEX pg_toast.pg_toast_1260_index;
1308+
REINDEX TABLE pg_toast.pg_toast_1262;
1309+
REINDEX INDEX pg_toast.pg_toast_1262_index;
13101310

13111311
-- Clean up
13121312
RESET ROLE;

src/test/regress/sql/misc_sanity.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ WHERE refclassid = 0 OR refobjid = 0 OR
4343
-- 2. pg_largeobject and pg_largeobject_metadata. Large object catalogs
4444
-- and toast tables are mutually exclusive and large object data is handled
4545
-- as user data by pg_upgrade, which would cause failures.
46+
-- 3. pg_authid, since its toast table cannot be accessed when it would be
47+
-- needed, i.e., during authentication before we've selected a database.
4648

4749
SELECT relname, attname, atttypid::regtype
4850
FROM pg_class c JOIN pg_attribute a ON c.oid = attrelid

src/test/regress/sql/tablespace.sql

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ REINDEX (TABLESPACE regress_tblspace) TABLE CONCURRENTLY pg_am;
4040
REINDEX (TABLESPACE regress_tblspace) TABLE pg_authid;
4141
REINDEX (TABLESPACE regress_tblspace) TABLE CONCURRENTLY pg_authid;
4242
-- toast relations, fail
43-
REINDEX (TABLESPACE regress_tblspace) INDEX pg_toast.pg_toast_1260_index;
44-
REINDEX (TABLESPACE regress_tblspace) INDEX CONCURRENTLY pg_toast.pg_toast_1260_index;
45-
REINDEX (TABLESPACE regress_tblspace) TABLE pg_toast.pg_toast_1260;
46-
REINDEX (TABLESPACE regress_tblspace) TABLE CONCURRENTLY pg_toast.pg_toast_1260;
43+
REINDEX (TABLESPACE regress_tblspace) INDEX pg_toast.pg_toast_1262_index;
44+
REINDEX (TABLESPACE regress_tblspace) INDEX CONCURRENTLY pg_toast.pg_toast_1262_index;
45+
REINDEX (TABLESPACE regress_tblspace) TABLE pg_toast.pg_toast_1262;
46+
REINDEX (TABLESPACE regress_tblspace) TABLE CONCURRENTLY pg_toast.pg_toast_1262;
4747
-- system catalog, fail
4848
REINDEX (TABLESPACE pg_global) TABLE pg_authid;
4949
REINDEX (TABLESPACE pg_global) TABLE CONCURRENTLY pg_authid;

0 commit comments

Comments
 (0)