aboutsummaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2020-11-02 19:50:45 +1300
committerThomas Munro <tmunro@postgresql.org>2020-11-03 01:19:50 +1300
commit257836a75585934cc05ed7a80bccf8190d41e056 (patch)
tree5f3eb018d0f0609063669b81136036b79bf8f948 /src/include
parentcd6f479e79f3a33ef7a919c6b6c0c498c790f154 (diff)
downloadpostgresql-257836a75585934cc05ed7a80bccf8190d41e056.tar.gz
postgresql-257836a75585934cc05ed7a80bccf8190d41e056.zip
Track collation versions for indexes.
Record the current version of dependent collations in pg_depend when creating or rebuilding an index. When accessing the index later, warn that the index may be corrupted if the current version doesn't match. Thanks to Douglas Doole, Peter Eisentraut, Christoph Berg, Laurenz Albe, Michael Paquier, Robert Haas, Tom Lane and others for very helpful discussion. Author: Thomas Munro <thomas.munro@gmail.com> Author: Julien Rouhaud <rjuju123@gmail.com> Reviewed-by: Peter Eisentraut <peter.eisentraut@2ndquadrant.com> (earlier versions) Discussion: https://postgr.es/m/CAEepm%3D0uEQCpfq_%2BLYFBdArCe4Ot98t1aR4eYiYTe%3DyavQygiQ%40mail.gmail.com
Diffstat (limited to 'src/include')
-rw-r--r--src/include/catalog/catversion.h2
-rw-r--r--src/include/catalog/dependency.h25
-rw-r--r--src/include/catalog/index.h3
-rw-r--r--src/include/catalog/pg_depend.h3
-rw-r--r--src/include/catalog/pg_type.h2
-rw-r--r--src/include/nodes/parsenodes.h4
-rw-r--r--src/include/utils/pg_locale.h2
-rw-r--r--src/include/utils/rel.h1
8 files changed, 31 insertions, 11 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index 6610e3c23f7..f28f083aca7 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -53,6 +53,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 202011012
+#define CATALOG_VERSION_NO 202011013
#endif
diff --git a/src/include/catalog/dependency.h b/src/include/catalog/dependency.h
index 3baa5e498aa..901d5019cdf 100644
--- a/src/include/catalog/dependency.h
+++ b/src/include/catalog/dependency.h
@@ -160,7 +160,8 @@ extern void recordDependencyOnSingleRelExpr(const ObjectAddress *depender,
Node *expr, Oid relId,
DependencyType behavior,
DependencyType self_behavior,
- bool reverse_self);
+ bool reverse_self,
+ bool record_version);
extern ObjectClass getObjectClass(const ObjectAddress *object);
@@ -180,17 +181,30 @@ 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,
- const char *version,
- DependencyType behavior);
+ DependencyType behavior,
+ bool record_version);
extern void recordDependencyOnCurrentExtension(const ObjectAddress *object,
bool isReplace);
@@ -209,10 +223,9 @@ extern long changeDependencyFor(Oid classId, Oid objectId,
Oid refClassId, Oid oldRefObjectId,
Oid newRefObjectId);
-extern long changeDependenciesOf(Oid classId, Oid oldObjectId,
+long changeDependenciesOf(Oid classId, Oid oldObjectId,
Oid newObjectId);
-
-extern long changeDependenciesOn(Oid refClassId, Oid oldRefObjectId,
+long changeDependenciesOn(Oid refClassId, Oid oldRefObjectId,
Oid newRefObjectId);
extern Oid getExtensionOfObject(Oid classId, Oid objectId);
diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h
index f58e8675f32..f4559b09d73 100644
--- a/src/include/catalog/index.h
+++ b/src/include/catalog/index.h
@@ -121,6 +121,9 @@ 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,
diff --git a/src/include/catalog/pg_depend.h b/src/include/catalog/pg_depend.h
index 74890227952..eeafbbe8d7c 100644
--- a/src/include/catalog/pg_depend.h
+++ b/src/include/catalog/pg_depend.h
@@ -62,8 +62,7 @@ CATALOG(pg_depend,2608,DependRelationId)
*/
char deptype; /* see codes in dependency.h */
#ifdef CATALOG_VARLEN
- text refobjversion; /* version tracking, NULL if not used or
- * unknown */
+ text refobjversion; /* version of referenced object */
#endif
} FormData_pg_depend;
diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h
index 6ae6edf7e0e..d228efffc9b 100644
--- a/src/include/catalog/pg_type.h
+++ b/src/include/catalog/pg_type.h
@@ -368,6 +368,8 @@ extern void GenerateTypeDependencies(HeapTuple typeTuple,
bool isDependentType,
bool rebuild);
+extern List *GetTypeCollations(Oid typeObjectid);
+
extern void RenameTypeInternal(Oid typeOid, const char *newTypeName,
Oid typeNamespace);
diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h
index 319f77013f4..e1aeea25606 100644
--- a/src/include/nodes/parsenodes.h
+++ b/src/include/nodes/parsenodes.h
@@ -1853,7 +1853,8 @@ typedef enum AlterTableType
AT_DetachPartition, /* DETACH PARTITION */
AT_AddIdentity, /* ADD IDENTITY */
AT_SetIdentity, /* SET identity column options */
- AT_DropIdentity /* DROP IDENTITY */
+ AT_DropIdentity, /* DROP IDENTITY */
+ AT_AlterCollationRefreshVersion /* ALTER COLLATION ... REFRESH VERSION */
} AlterTableType;
typedef struct ReplicaIdentityStmt
@@ -1869,6 +1870,7 @@ 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;
diff --git a/src/include/utils/pg_locale.h b/src/include/utils/pg_locale.h
index 9cb7d91ddfb..96da132c031 100644
--- a/src/include/utils/pg_locale.h
+++ b/src/include/utils/pg_locale.h
@@ -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_actual_version(char collprovider, const char *collcollate);
+extern char *get_collation_version_for_oid(Oid collid);
#ifdef USE_ICU
extern int32_t icu_to_uchar(UChar **buff_uchar, const char *buff, size_t nbytes);
diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h
index 0b5957ba02c..c5ffea40f21 100644
--- a/src/include/utils/rel.h
+++ b/src/include/utils/rel.h
@@ -63,6 +63,7 @@ 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