Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7b37823

Browse files
committed
Expand AclMode to 64 bits
We're running out of bits for new permissions. This change doubles thenumber of permissions we can accomodate from 16 to 32, so theforthcoming new ones for vacuum/analyze don't exhaust the pool.Nathan BossartReviewed by: Bharath Rupireddy, Kyotaro Horiguchi, Stephen Frost, RobertHaas, Mark Dilger, Tom Lane, Corey Huinker, David G. Johnston, MichaelPaquier.Discussion:https://postgr.es/m/20220722203735.GB3996698@nathanxps13
1 parentb607484 commit7b37823

File tree

6 files changed

+56
-21
lines changed

6 files changed

+56
-21
lines changed

‎src/backend/nodes/outfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ _outRangeTblEntry(StringInfo str, const RangeTblEntry *node)
560560
WRITE_BOOL_FIELD(lateral);
561561
WRITE_BOOL_FIELD(inh);
562562
WRITE_BOOL_FIELD(inFromCl);
563-
WRITE_UINT_FIELD(requiredPerms);
563+
WRITE_UINT64_FIELD(requiredPerms);
564564
WRITE_OID_FIELD(checkAsUser);
565565
WRITE_BITMAPSET_FIELD(selectedCols);
566566
WRITE_BITMAPSET_FIELD(insertedCols);

‎src/bin/pg_upgrade/check.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ static void check_for_incompatible_polymorphics(ClusterInfo *cluster);
2828
staticvoidcheck_for_tables_with_oids(ClusterInfo*cluster);
2929
staticvoidcheck_for_composite_data_type_usage(ClusterInfo*cluster);
3030
staticvoidcheck_for_reg_data_type_usage(ClusterInfo*cluster);
31+
staticvoidcheck_for_aclitem_data_type_usage(ClusterInfo*cluster);
3132
staticvoidcheck_for_jsonb_9_4_usage(ClusterInfo*cluster);
3233
staticvoidcheck_for_pg_role_prefix(ClusterInfo*cluster);
3334
staticvoidcheck_for_new_tablespace_dir(ClusterInfo*new_cluster);
@@ -107,6 +108,13 @@ check_and_dump_old_cluster(bool live_check)
107108
check_for_reg_data_type_usage(&old_cluster);
108109
check_for_isn_and_int8_passing_mismatch(&old_cluster);
109110

111+
/*
112+
* PG 16 increased the size of the 'aclitem' type, which breaks the on-disk
113+
* format for existing data.
114+
*/
115+
if (GET_MAJOR_VERSION(old_cluster.major_version) <=1500)
116+
check_for_aclitem_data_type_usage(&old_cluster);
117+
110118
/*
111119
* PG 14 changed the function signature of encoding conversion functions.
112120
* Conversions from older versions cannot be upgraded automatically
@@ -1319,6 +1327,33 @@ check_for_reg_data_type_usage(ClusterInfo *cluster)
13191327
check_ok();
13201328
}
13211329

1330+
/*
1331+
* check_for_aclitem_data_type_usage
1332+
*
1333+
*aclitem changed its storage format in 16, so check for it.
1334+
*/
1335+
staticvoid
1336+
check_for_aclitem_data_type_usage(ClusterInfo*cluster)
1337+
{
1338+
charoutput_path[MAXPGPATH];
1339+
1340+
prep_status("Checking for incompatible aclitem data type in user tables");
1341+
1342+
snprintf(output_path,sizeof(output_path),"tables_using_aclitem.txt");
1343+
1344+
if (check_for_data_type_usage(cluster,"pg_catalog.aclitem",output_path))
1345+
{
1346+
pg_log(PG_REPORT,"fatal");
1347+
pg_fatal("Your installation contains the \"aclitem\" data type in user tables.\n"
1348+
"The internal format of \"aclitem\" changed in PostgreSQL version 16\n"
1349+
"so this cluster cannot currently be upgraded. You can drop the\n"
1350+
"problem columns and restart the upgrade. A list of the problem\n"
1351+
"columns is in the file:\n"
1352+
" %s",output_path);
1353+
}
1354+
else
1355+
check_ok();
1356+
}
13221357

13231358
/*
13241359
* check_for_jsonb_9_4_usage()

‎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-
#defineCATALOG_VERSION_NO202211211
60+
#defineCATALOG_VERSION_NO202211221
6161

6262
#endif

‎src/include/catalog/pg_type.dat

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,9 @@
267267
# OIDS 1000 - 1099
268268

269269
{ oid => '1033', array_type_oid => '1034', descr => 'access control list',
270-
typname => 'aclitem', typlen => '12', typbyval => 'f', typcategory => 'U',
270+
typname => 'aclitem', typlen => '16', typbyval => 'f', typcategory => 'U',
271271
typinput => 'aclitemin', typoutput => 'aclitemout', typreceive => '-',
272-
typsend => '-', typalign => 'i' },
272+
typsend => '-', typalign => 'd' },
273273
{ oid => '1042', array_type_oid => '1014',
274274
descr => 'char(length), blank-padded string, fixed storage length',
275275
typname => 'bpchar', typlen => '-1', typbyval => 'f', typcategory => 'S',

‎src/include/nodes/parsenodes.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,12 @@ typedef enum SetQuantifier
7373

7474
/*
7575
* Grantable rights are encoded so that we can OR them together in a bitmask.
76-
* The present representation of AclItem limits us to16 distinct rights,
77-
* even though AclMode is defined asuint32. See utils/acl.h.
76+
* The present representation of AclItem limits us to32 distinct rights,
77+
* even though AclMode is defined asuint64. See utils/acl.h.
7878
*
7979
* Caution: changing these codes breaks stored ACLs, hence forces initdb.
8080
*/
81-
typedefuint32AclMode;/* a bitmask of privilege bits */
81+
typedefuint64AclMode;/* a bitmask of privilege bits */
8282

8383
#defineACL_INSERT(1<<0)/* for relations */
8484
#defineACL_SELECT(1<<1)

‎src/include/utils/acl.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -59,33 +59,33 @@ typedef struct AclItem
5959
}AclItem;
6060

6161
/*
62-
* The upper16 bits of the ai_privs field of an AclItem are the grant option
63-
* bits, and the lower16 bits are the actual privileges. We use "rights"
62+
* The upper32 bits of the ai_privs field of an AclItem are the grant option
63+
* bits, and the lower32 bits are the actual privileges. We use "rights"
6464
* to mean the combined grant option and privilege bits fields.
6565
*/
66-
#defineACLITEM_GET_PRIVS(item) ((item).ai_privs &0xFFFF)
67-
#defineACLITEM_GET_GOPTIONS(item) (((item).ai_privs >>16) &0xFFFF)
66+
#defineACLITEM_GET_PRIVS(item) ((item).ai_privs &0xFFFFFFFF)
67+
#defineACLITEM_GET_GOPTIONS(item) (((item).ai_privs >>32) &0xFFFFFFFF)
6868
#defineACLITEM_GET_RIGHTS(item) ((item).ai_privs)
6969

70-
#defineACL_GRANT_OPTION_FOR(privs) (((AclMode) (privs) &0xFFFF) <<16)
71-
#defineACL_OPTION_TO_PRIVS(privs)(((AclMode) (privs) >>16) &0xFFFF)
70+
#defineACL_GRANT_OPTION_FOR(privs) (((AclMode) (privs) &0xFFFFFFFF) <<32)
71+
#defineACL_OPTION_TO_PRIVS(privs)(((AclMode) (privs) >>32) &0xFFFFFFFF)
7272

7373
#defineACLITEM_SET_PRIVS(item,privs) \
74-
((item).ai_privs = ((item).ai_privs & ~((AclMode)0xFFFF)) | \
75-
((AclMode) (privs) &0xFFFF))
74+
((item).ai_privs = ((item).ai_privs & ~((AclMode)0xFFFFFFFF)) | \
75+
((AclMode) (privs) &0xFFFFFFFF))
7676
#defineACLITEM_SET_GOPTIONS(item,goptions) \
77-
((item).ai_privs = ((item).ai_privs & ~(((AclMode)0xFFFF) <<16)) | \
78-
(((AclMode) (goptions) &0xFFFF) <<16))
77+
((item).ai_privs = ((item).ai_privs & ~(((AclMode)0xFFFFFFFF) <<32)) | \
78+
(((AclMode) (goptions) &0xFFFFFFFF) <<32))
7979
#defineACLITEM_SET_RIGHTS(item,rights) \
8080
((item).ai_privs = (AclMode) (rights))
8181

8282
#defineACLITEM_SET_PRIVS_GOPTIONS(item,privs,goptions) \
83-
((item).ai_privs = ((AclMode) (privs) &0xFFFF) | \
84-
(((AclMode) (goptions) &0xFFFF) <<16))
83+
((item).ai_privs = ((AclMode) (privs) &0xFFFFFFFF) | \
84+
(((AclMode) (goptions) &0xFFFFFFFF) <<32))
8585

8686

87-
#defineACLITEM_ALL_PRIV_BITS((AclMode)0xFFFF)
88-
#defineACLITEM_ALL_GOPTION_BITS((AclMode)0xFFFF <<16)
87+
#defineACLITEM_ALL_PRIV_BITS((AclMode)0xFFFFFFFF)
88+
#defineACLITEM_ALL_GOPTION_BITS((AclMode)0xFFFFFFFF <<32)
8989

9090
/*
9191
* Definitions for convenient access to Acl (array of AclItem).

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp