Revert per-index collation version tracking feature.

Design problems were discovered in the handling of composite types and
record types that would cause some relevant versions not to be recorded.
Misgivings were also expressed about the use of the pg_depend catalog
for this purpose.  We're out of time for this release so we'll revert
and try again.

Commits reverted:

1bf946bd: Doc: Document known problem with Windows collation versions.
cf002008: Remove no-longer-relevant test case.
ef387bed: Fix bogus collation-version-recording logic.
0fb0a050: Hide internal error for pg_collation_actual_version(<bad OID>).
ff942057: Suppress "warning: variable 'collcollate' set but not used".
d50e3b1f: Fix assertion in collation version lookup.
f24b1569: Rethink extraction of collation dependencies.
257836a7: Track collation versions for indexes.
cd6f479e: Add pg_depend.refobjversion.
7d1297df: Remove pg_collation.collversion.

Discussion: https://postgr.es/m/CA%2BhUKGLhj5t1fcjqAu8iD9B3ixJtsTNqyCCD4V0aTO9kAKAjjA%40mail.gmail.com
This commit is contained in:
Thomas Munro
2021-05-07 20:17:42 +12:00
parent a288d94c91
commit ec48314708
55 changed files with 463 additions and 1354 deletions

View File

@ -53,6 +53,6 @@
*/
/* yyyymmddN */
#define CATALOG_VERSION_NO 202104271
#define CATALOG_VERSION_NO 202105051
#endif

View File

@ -167,8 +167,7 @@ extern void recordDependencyOnSingleRelExpr(const ObjectAddress *depender,
Node *expr, Oid relId,
DependencyType behavior,
DependencyType self_behavior,
bool reverse_self,
bool record_version);
bool reverse_self);
extern ObjectClass getObjectClass(const ObjectAddress *object);
@ -188,30 +187,16 @@ extern void sort_object_addresses(ObjectAddresses *addrs);
extern void free_object_addresses(ObjectAddresses *addrs);
typedef bool(*VisitDependenciesOfCB) (const ObjectAddress *otherObject,
const char *version,
char **new_version,
void *data);
extern void visitDependenciesOf(const ObjectAddress *object,
VisitDependenciesOfCB callback,
void *data);
/* in pg_depend.c */
extern void recordDependencyOn(const ObjectAddress *depender,
const ObjectAddress *referenced,
DependencyType behavior);
extern void recordDependencyOnCollations(ObjectAddress *myself,
List *collations,
bool record_version);
extern void recordMultipleDependencies(const ObjectAddress *depender,
const ObjectAddress *referenced,
int nreferenced,
DependencyType behavior,
bool record_version);
DependencyType behavior);
extern void recordDependencyOnCurrentExtension(const ObjectAddress *object,
bool isReplace);
@ -232,6 +217,7 @@ extern long changeDependencyFor(Oid classId, Oid objectId,
extern long changeDependenciesOf(Oid classId, Oid oldObjectId,
Oid newObjectId);
extern long changeDependenciesOn(Oid refClassId, Oid oldRefObjectId,
Oid newRefObjectId);

View File

@ -136,9 +136,6 @@ extern void FormIndexDatum(IndexInfo *indexInfo,
Datum *values,
bool *isnull);
extern void index_check_collation_versions(Oid relid);
extern void index_update_collation_versions(Oid relid, Oid coll);
extern void index_build(Relation heapRelation,
Relation indexRelation,
IndexInfo *indexInfo,

View File

@ -41,6 +41,11 @@ CATALOG(pg_collation,3456,CollationRelationId)
int32 collencoding; /* encoding for this collation; -1 = "all" */
NameData collcollate; /* LC_COLLATE setting */
NameData collctype; /* LC_CTYPE setting */
#ifdef CATALOG_VARLEN /* variable-length fields start here */
text collversion BKI_DEFAULT(_null_); /* provider-dependent */
/* version of */
/* collation data */
#endif
} FormData_pg_collation;
/* ----------------
@ -50,6 +55,8 @@ CATALOG(pg_collation,3456,CollationRelationId)
*/
typedef FormData_pg_collation *Form_pg_collation;
DECLARE_TOAST(pg_collation, 8888, 8889);
DECLARE_UNIQUE_INDEX(pg_collation_name_enc_nsp_index, 3164, on pg_collation using btree(collname name_ops, collencoding int4_ops, collnamespace oid_ops));
#define CollationNameEncNspIndexId 3164
DECLARE_UNIQUE_INDEX_PKEY(pg_collation_oid_index, 3085, on pg_collation using btree(oid oid_ops));
@ -70,6 +77,7 @@ extern Oid CollationCreate(const char *collname, Oid collnamespace,
bool collisdeterministic,
int32 collencoding,
const char *collcollate, const char *collctype,
const char *collversion,
bool if_not_exists,
bool quiet);

View File

@ -63,9 +63,6 @@ CATALOG(pg_depend,2608,DependRelationId)
* field. See DependencyType in catalog/dependency.h.
*/
char deptype; /* see codes in dependency.h */
#ifdef CATALOG_VARLEN
text refobjversion; /* version of referenced object */
#endif
} FormData_pg_depend;
/* ----------------
@ -75,8 +72,6 @@ CATALOG(pg_depend,2608,DependRelationId)
*/
typedef FormData_pg_depend *Form_pg_depend;
DECLARE_TOAST(pg_depend, 8888, 8889);
DECLARE_INDEX(pg_depend_depender_index, 2673, on pg_depend using btree(classid oid_ops, objid oid_ops, objsubid int4_ops));
#define DependDependerIndexId 2673
DECLARE_INDEX(pg_depend_reference_index, 2674, on pg_depend using btree(refclassid oid_ops, refobjid oid_ops, refobjsubid int4_ops));

View File

@ -390,8 +390,6 @@ extern void GenerateTypeDependencies(HeapTuple typeTuple,
bool isDependentType,
bool rebuild);
extern List *GetTypeCollations(Oid typeObjectid);
extern void RenameTypeInternal(Oid typeOid, const char *newTypeName,
Oid typeNamespace);

View File

@ -20,5 +20,6 @@
extern ObjectAddress DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_exists);
extern void IsThereCollationInNamespace(const char *collname, Oid nspOid);
extern ObjectAddress AlterCollation(AlterCollationStmt *stmt);
#endif /* COLLATIONCMDS_H */

View File

@ -1933,7 +1933,6 @@ typedef enum AlterTableType
AT_AddIdentity, /* ADD IDENTITY */
AT_SetIdentity, /* SET identity column options */
AT_DropIdentity, /* DROP IDENTITY */
AT_AlterCollationRefreshVersion, /* ALTER COLLATION ... REFRESH VERSION */
AT_ReAddStatistics /* internal to commands/tablecmds.c */
} AlterTableType;
@ -1950,7 +1949,6 @@ typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */
AlterTableType subtype; /* Type of table alteration to apply */
char *name; /* column, constraint, or trigger to act on,
* or tablespace */
List *object; /* collation to act on if it's a collation */
int16 num; /* attribute number for columns referenced by
* number */
RoleSpec *newowner;
@ -1961,6 +1959,17 @@ typedef struct AlterTableCmd /* one subcommand of an ALTER TABLE */
} AlterTableCmd;
/* ----------------------
* Alter Collation
* ----------------------
*/
typedef struct AlterCollationStmt
{
NodeTag type;
List *collname;
} AlterCollationStmt;
/* ----------------------
* Alter Domain
*

View File

@ -103,7 +103,7 @@ typedef struct pg_locale_struct *pg_locale_t;
extern pg_locale_t pg_newlocale_from_collation(Oid collid);
extern char *get_collation_version_for_oid(Oid collid, bool missing_ok);
extern char *get_collation_actual_version(char collprovider, const char *collcollate);
#ifdef USE_ICU
extern int32_t icu_to_uchar(UChar **buff_uchar, const char *buff, size_t nbytes);

View File

@ -63,7 +63,6 @@ typedef struct RelationData
bool rd_indexvalid; /* is rd_indexlist valid? (also rd_pkindex and
* rd_replidindex) */
bool rd_statvalid; /* is rd_statlist valid? */
bool rd_version_checked; /* has version check been done yet? */
/*----------
* rd_createSubid is the ID of the highest subtransaction the rel has