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

Commitb82a7be

Browse files
committed
Change pg_seclabel.provider and pg_shseclabel.provider to type "name".
These were "text", but that's a bad idea because it has collation-dependentordering. No index in template0 should have collation-dependent ordering,especially not indexes on shared catalogs. There was general agreementthat provider names don't need to be longer than other identifiers, so wecan fix this at a small waste of table space by changing from text to name.There's no way to fix the problem in the back branches, but we can hopethat security labels don't yet have widespread-enough usage to make iturgent to fix.There needs to be a regression sanity test to prevent us from making thissame mistake again; but before putting that in, we'll need to get rid ofsimilar brain fade in the recently-added pg_replication_origin catalog.Note: for lack of a suitable testing environment, I've not really exercisedthis change. I trust the buildfarm will show up any mistakes.
1 parente4942f7 commitb82a7be

File tree

6 files changed

+22
-18
lines changed

6 files changed

+22
-18
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5648,7 +5648,7 @@
56485648

56495649
<row>
56505650
<entry><structfield>provider</structfield></entry>
5651-
<entry><type>text</type></entry>
5651+
<entry><type>name</type></entry>
56525652
<entry></entry>
56535653
<entry>The label provider associated with this label.</entry>
56545654
</row>
@@ -5937,7 +5937,7 @@
59375937
</row>
59385938
<row>
59395939
<entry><structfield>provider</structfield></entry>
5940-
<entry><type>text</type></entry>
5940+
<entry><type>name</type></entry>
59415941
<entry></entry>
59425942
<entry>The label provider associated with this label.</entry>
59435943
</row>
@@ -9025,7 +9025,7 @@ SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx
90259025
</row>
90269026
<row>
90279027
<entry><structfield>provider</structfield></entry>
9028-
<entry><type>text</type></entry>
9028+
<entry><type>name</type></entry>
90299029
<entry><literal><link linkend="catalog-pg-seclabel"><structname>pg_seclabel</structname></link>.provider</literal></entry>
90309030
<entry>The label provider associated with this label.</entry>
90319031
</row>

‎src/backend/commands/seclabel.c

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,8 @@ GetSharedSecurityLabel(const ObjectAddress *object, const char *provider)
163163
ObjectIdGetDatum(object->classId));
164164
ScanKeyInit(&keys[2],
165165
Anum_pg_shseclabel_provider,
166-
BTEqualStrategyNumber,F_TEXTEQ,
167-
CStringGetTextDatum(provider));
166+
BTEqualStrategyNumber,F_NAMEEQ,
167+
CStringGetDatum(provider));
168168

169169
pg_shseclabel=heap_open(SharedSecLabelRelationId,AccessShareLock);
170170

@@ -220,8 +220,8 @@ GetSecurityLabel(const ObjectAddress *object, const char *provider)
220220
Int32GetDatum(object->objectSubId));
221221
ScanKeyInit(&keys[3],
222222
Anum_pg_seclabel_provider,
223-
BTEqualStrategyNumber,F_TEXTEQ,
224-
CStringGetTextDatum(provider));
223+
BTEqualStrategyNumber,F_NAMEEQ,
224+
CStringGetDatum(provider));
225225

226226
pg_seclabel=heap_open(SecLabelRelationId,AccessShareLock);
227227

@@ -256,6 +256,7 @@ SetSharedSecurityLabel(const ObjectAddress *object,
256256
SysScanDescscan;
257257
HeapTupleoldtup;
258258
HeapTuplenewtup=NULL;
259+
NameDataprovidername;
259260
Datumvalues[Natts_pg_shseclabel];
260261
boolnulls[Natts_pg_shseclabel];
261262
boolreplaces[Natts_pg_shseclabel];
@@ -265,7 +266,8 @@ SetSharedSecurityLabel(const ObjectAddress *object,
265266
memset(replaces, false,sizeof(replaces));
266267
values[Anum_pg_shseclabel_objoid-1]=ObjectIdGetDatum(object->objectId);
267268
values[Anum_pg_shseclabel_classoid-1]=ObjectIdGetDatum(object->classId);
268-
values[Anum_pg_shseclabel_provider-1]=CStringGetTextDatum(provider);
269+
namestrcpy(&providername,provider);
270+
values[Anum_pg_shseclabel_provider-1]=NameGetDatum(&providername);
269271
if (label!=NULL)
270272
values[Anum_pg_shseclabel_label-1]=CStringGetTextDatum(label);
271273

@@ -280,8 +282,8 @@ SetSharedSecurityLabel(const ObjectAddress *object,
280282
ObjectIdGetDatum(object->classId));
281283
ScanKeyInit(&keys[2],
282284
Anum_pg_shseclabel_provider,
283-
BTEqualStrategyNumber,F_TEXTEQ,
284-
CStringGetTextDatum(provider));
285+
BTEqualStrategyNumber,F_NAMEEQ,
286+
CStringGetDatum(provider));
285287

286288
pg_shseclabel=heap_open(SharedSecLabelRelationId,RowExclusiveLock);
287289

@@ -335,6 +337,7 @@ SetSecurityLabel(const ObjectAddress *object,
335337
SysScanDescscan;
336338
HeapTupleoldtup;
337339
HeapTuplenewtup=NULL;
340+
NameDataprovidername;
338341
Datumvalues[Natts_pg_seclabel];
339342
boolnulls[Natts_pg_seclabel];
340343
boolreplaces[Natts_pg_seclabel];
@@ -352,7 +355,8 @@ SetSecurityLabel(const ObjectAddress *object,
352355
values[Anum_pg_seclabel_objoid-1]=ObjectIdGetDatum(object->objectId);
353356
values[Anum_pg_seclabel_classoid-1]=ObjectIdGetDatum(object->classId);
354357
values[Anum_pg_seclabel_objsubid-1]=Int32GetDatum(object->objectSubId);
355-
values[Anum_pg_seclabel_provider-1]=CStringGetTextDatum(provider);
358+
namestrcpy(&providername,provider);
359+
values[Anum_pg_seclabel_provider-1]=NameGetDatum(&providername);
356360
if (label!=NULL)
357361
values[Anum_pg_seclabel_label-1]=CStringGetTextDatum(label);
358362

@@ -371,8 +375,8 @@ SetSecurityLabel(const ObjectAddress *object,
371375
Int32GetDatum(object->objectSubId));
372376
ScanKeyInit(&keys[3],
373377
Anum_pg_seclabel_provider,
374-
BTEqualStrategyNumber,F_TEXTEQ,
375-
CStringGetTextDatum(provider));
378+
BTEqualStrategyNumber,F_NAMEEQ,
379+
CStringGetDatum(provider));
376380

377381
pg_seclabel=heap_open(SecLabelRelationId,RowExclusiveLock);
378382

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201505153
56+
#defineCATALOG_VERSION_NO201505181
5757

5858
#endif

‎src/include/catalog/indexing.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,10 @@ DECLARE_UNIQUE_INDEX(pg_default_acl_oid_index, 828, on pg_default_acl using btre
290290
DECLARE_UNIQUE_INDEX(pg_db_role_setting_databaseid_rol_index,2965,onpg_db_role_settingusingbtree(setdatabaseoid_ops,setroleoid_ops));
291291
#defineDbRoleSettingDatidRolidIndexId2965
292292

293-
DECLARE_UNIQUE_INDEX(pg_seclabel_object_index,3597,onpg_seclabelusingbtree(objoidoid_ops,classoidoid_ops,objsubidint4_ops,providertext_ops));
293+
DECLARE_UNIQUE_INDEX(pg_seclabel_object_index,3597,onpg_seclabelusingbtree(objoidoid_ops,classoidoid_ops,objsubidint4_ops,providername_ops));
294294
#defineSecLabelObjectIndexId3597
295295

296-
DECLARE_UNIQUE_INDEX(pg_shseclabel_object_index,3593,onpg_shseclabelusingbtree(objoidoid_ops,classoidoid_ops,providertext_ops));
296+
DECLARE_UNIQUE_INDEX(pg_shseclabel_object_index,3593,onpg_shseclabelusingbtree(objoidoid_ops,classoidoid_ops,providername_ops));
297297
#defineSharedSecLabelObjectIndexId3593
298298

299299
DECLARE_UNIQUE_INDEX(pg_extension_oid_index,3080,onpg_extensionusingbtree(oidoid_ops));

‎src/include/catalog/pg_seclabel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ CATALOG(pg_seclabel,3596) BKI_WITHOUT_OIDS
2525
Oidobjoid;/* OID of the object itself */
2626
Oidclassoid;/* OID of table containing the object */
2727
int32objsubid;/* column number, or 0 if not used */
28+
NameDataprovider;/* name of label provider */
2829

2930
#ifdefCATALOG_VARLEN/* variable-length fields start here */
30-
textproviderBKI_FORCE_NOT_NULL;/* name of label provider */
3131
textlabelBKI_FORCE_NOT_NULL;/* security label of the object */
3232
#endif
3333
}FormData_pg_seclabel;

‎src/include/catalog/pg_shseclabel.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ CATALOG(pg_shseclabel,3592) BKI_SHARED_RELATION BKI_WITHOUT_OIDS
2424
{
2525
Oidobjoid;/* OID of the shared object itself */
2626
Oidclassoid;/* OID of table containing the shared object */
27+
NameDataprovider;/* name of label provider */
2728

2829
#ifdefCATALOG_VARLEN/* variable-length fields start here */
29-
textproviderBKI_FORCE_NOT_NULL;/* name of label provider */
3030
textlabelBKI_FORCE_NOT_NULL;/* security label of the object */
3131
#endif
3232
}FormData_pg_shseclabel;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp