Commit b82a7be6 authored by Tom Lane's avatar Tom Lane

Change pg_seclabel.provider and pg_shseclabel.provider to type "name".

These were "text", but that's a bad idea because it has collation-dependent
ordering.  No index in template0 should have collation-dependent ordering,
especially not indexes on shared catalogs.  There was general agreement
that provider names don't need to be longer than other identifiers, so we
can 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 hope
that security labels don't yet have widespread-enough usage to make it
urgent to fix.

There needs to be a regression sanity test to prevent us from making this
same mistake again; but before putting that in, we'll need to get rid of
similar brain fade in the recently-added pg_replication_origin catalog.

Note: for lack of a suitable testing environment, I've not really exercised
this change.  I trust the buildfarm will show up any mistakes.
parent e4942f7a
......@@ -5648,7 +5648,7 @@
<row>
<entry><structfield>provider</structfield></entry>
<entry><type>text</type></entry>
<entry><type>name</type></entry>
<entry></entry>
<entry>The label provider associated with this label.</entry>
</row>
......@@ -5937,7 +5937,7 @@
</row>
<row>
<entry><structfield>provider</structfield></entry>
<entry><type>text</type></entry>
<entry><type>name</type></entry>
<entry></entry>
<entry>The label provider associated with this label.</entry>
</row>
......@@ -9025,7 +9025,7 @@ SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx
</row>
<row>
<entry><structfield>provider</structfield></entry>
<entry><type>text</type></entry>
<entry><type>name</type></entry>
<entry><literal><link linkend="catalog-pg-seclabel"><structname>pg_seclabel</structname></link>.provider</literal></entry>
<entry>The label provider associated with this label.</entry>
</row>
......
......@@ -163,8 +163,8 @@ GetSharedSecurityLabel(const ObjectAddress *object, const char *provider)
ObjectIdGetDatum(object->classId));
ScanKeyInit(&keys[2],
Anum_pg_shseclabel_provider,
BTEqualStrategyNumber, F_TEXTEQ,
CStringGetTextDatum(provider));
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(provider));
pg_shseclabel = heap_open(SharedSecLabelRelationId, AccessShareLock);
......@@ -220,8 +220,8 @@ GetSecurityLabel(const ObjectAddress *object, const char *provider)
Int32GetDatum(object->objectSubId));
ScanKeyInit(&keys[3],
Anum_pg_seclabel_provider,
BTEqualStrategyNumber, F_TEXTEQ,
CStringGetTextDatum(provider));
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(provider));
pg_seclabel = heap_open(SecLabelRelationId, AccessShareLock);
......@@ -256,6 +256,7 @@ SetSharedSecurityLabel(const ObjectAddress *object,
SysScanDesc scan;
HeapTuple oldtup;
HeapTuple newtup = NULL;
NameData providername;
Datum values[Natts_pg_shseclabel];
bool nulls[Natts_pg_shseclabel];
bool replaces[Natts_pg_shseclabel];
......@@ -265,7 +266,8 @@ SetSharedSecurityLabel(const ObjectAddress *object,
memset(replaces, false, sizeof(replaces));
values[Anum_pg_shseclabel_objoid - 1] = ObjectIdGetDatum(object->objectId);
values[Anum_pg_shseclabel_classoid - 1] = ObjectIdGetDatum(object->classId);
values[Anum_pg_shseclabel_provider - 1] = CStringGetTextDatum(provider);
namestrcpy(&providername, provider);
values[Anum_pg_shseclabel_provider - 1] = NameGetDatum(&providername);
if (label != NULL)
values[Anum_pg_shseclabel_label - 1] = CStringGetTextDatum(label);
......@@ -280,8 +282,8 @@ SetSharedSecurityLabel(const ObjectAddress *object,
ObjectIdGetDatum(object->classId));
ScanKeyInit(&keys[2],
Anum_pg_shseclabel_provider,
BTEqualStrategyNumber, F_TEXTEQ,
CStringGetTextDatum(provider));
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(provider));
pg_shseclabel = heap_open(SharedSecLabelRelationId, RowExclusiveLock);
......@@ -335,6 +337,7 @@ SetSecurityLabel(const ObjectAddress *object,
SysScanDesc scan;
HeapTuple oldtup;
HeapTuple newtup = NULL;
NameData providername;
Datum values[Natts_pg_seclabel];
bool nulls[Natts_pg_seclabel];
bool replaces[Natts_pg_seclabel];
......@@ -352,7 +355,8 @@ SetSecurityLabel(const ObjectAddress *object,
values[Anum_pg_seclabel_objoid - 1] = ObjectIdGetDatum(object->objectId);
values[Anum_pg_seclabel_classoid - 1] = ObjectIdGetDatum(object->classId);
values[Anum_pg_seclabel_objsubid - 1] = Int32GetDatum(object->objectSubId);
values[Anum_pg_seclabel_provider - 1] = CStringGetTextDatum(provider);
namestrcpy(&providername, provider);
values[Anum_pg_seclabel_provider - 1] = NameGetDatum(&providername);
if (label != NULL)
values[Anum_pg_seclabel_label - 1] = CStringGetTextDatum(label);
......@@ -371,8 +375,8 @@ SetSecurityLabel(const ObjectAddress *object,
Int32GetDatum(object->objectSubId));
ScanKeyInit(&keys[3],
Anum_pg_seclabel_provider,
BTEqualStrategyNumber, F_TEXTEQ,
CStringGetTextDatum(provider));
BTEqualStrategyNumber, F_NAMEEQ,
CStringGetDatum(provider));
pg_seclabel = heap_open(SecLabelRelationId, RowExclusiveLock);
......
......@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 201505153
#define CATALOG_VERSION_NO 201505181
#endif
......@@ -290,10 +290,10 @@ DECLARE_UNIQUE_INDEX(pg_default_acl_oid_index, 828, on pg_default_acl using btre
DECLARE_UNIQUE_INDEX(pg_db_role_setting_databaseid_rol_index, 2965, on pg_db_role_setting using btree(setdatabase oid_ops, setrole oid_ops));
#define DbRoleSettingDatidRolidIndexId 2965
DECLARE_UNIQUE_INDEX(pg_seclabel_object_index, 3597, on pg_seclabel using btree(objoid oid_ops, classoid oid_ops, objsubid int4_ops, provider text_ops));
DECLARE_UNIQUE_INDEX(pg_seclabel_object_index, 3597, on pg_seclabel using btree(objoid oid_ops, classoid oid_ops, objsubid int4_ops, provider name_ops));
#define SecLabelObjectIndexId 3597
DECLARE_UNIQUE_INDEX(pg_shseclabel_object_index, 3593, on pg_shseclabel using btree(objoid oid_ops, classoid oid_ops, provider text_ops));
DECLARE_UNIQUE_INDEX(pg_shseclabel_object_index, 3593, on pg_shseclabel using btree(objoid oid_ops, classoid oid_ops, provider name_ops));
#define SharedSecLabelObjectIndexId 3593
DECLARE_UNIQUE_INDEX(pg_extension_oid_index, 3080, on pg_extension using btree(oid oid_ops));
......
......@@ -25,9 +25,9 @@ CATALOG(pg_seclabel,3596) BKI_WITHOUT_OIDS
Oid objoid; /* OID of the object itself */
Oid classoid; /* OID of table containing the object */
int32 objsubid; /* column number, or 0 if not used */
NameData provider; /* name of label provider */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
text provider BKI_FORCE_NOT_NULL; /* name of label provider */
text label BKI_FORCE_NOT_NULL; /* security label of the object */
#endif
} FormData_pg_seclabel;
......
......@@ -24,9 +24,9 @@ CATALOG(pg_shseclabel,3592) BKI_SHARED_RELATION BKI_WITHOUT_OIDS
{
Oid objoid; /* OID of the shared object itself */
Oid classoid; /* OID of table containing the shared object */
NameData provider; /* name of label provider */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
text provider BKI_FORCE_NOT_NULL; /* name of label provider */
text label BKI_FORCE_NOT_NULL; /* security label of the object */
#endif
} FormData_pg_shseclabel;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment