diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index d6baf84..b600879 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -1741,15 +1741,6 @@ - relhaspkey - bool - - - True if the table has (or once had) a primary key - - - - relhasrules bool diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 2aaf775..f5b171a 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -781,7 +781,6 @@ InsertPgClassTuple(Relation pg_class_desc, values[Anum_pg_class_relnatts - 1] = Int16GetDatum(rd_rel->relnatts); values[Anum_pg_class_relchecks - 1] = Int16GetDatum(rd_rel->relchecks); values[Anum_pg_class_relhasoids - 1] = BoolGetDatum(rd_rel->relhasoids); - values[Anum_pg_class_relhaspkey - 1] = BoolGetDatum(rd_rel->relhaspkey); values[Anum_pg_class_relhasrules - 1] = BoolGetDatum(rd_rel->relhasrules); values[Anum_pg_class_relhastriggers - 1] = BoolGetDatum(rd_rel->relhastriggers); values[Anum_pg_class_relhassubclass - 1] = BoolGetDatum(rd_rel->relhassubclass); diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 67ade8f..37aed71 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -99,7 +99,7 @@ static void UpdateIndexRelation(Oid indexoid, Oid heapoid, bool immediate, bool isvalid); static void index_update_stats(Relation rel, - bool hasindex, bool isprimary, + bool hasindex, Oid reltoastidxid, double reltuples); static void IndexCheckExclusion(Relation heapRelation, Relation indexRelation, @@ -1057,7 +1057,6 @@ index_create(Relation heapRelation, */ index_update_stats(heapRelation, true, - isprimary, InvalidOid, heapRelation->rd_rel->reltuples); /* Make the above update visible */ @@ -1212,22 +1211,6 @@ index_constraint_create(Relation heapRelation, } /* - * If needed, mark the table as having a primary key. We assume it can't - * have been so marked already, so no need to clear the flag in the other - * case. - * - * Note: this might better be done by callers. We do it here to avoid - * exposing index_update_stats() globally, but that wouldn't be necessary - * if relhaspkey went away. - */ - if (mark_as_primary) - index_update_stats(heapRelation, - true, - true, - InvalidOid, - heapRelation->rd_rel->reltuples); - - /* * If needed, mark the index as primary and/or deferred in pg_index. * * Note: since this is a transactional update, it's unsafe against @@ -1530,7 +1513,6 @@ FormIndexDatum(IndexInfo *indexInfo, * to ensure we can do all the necessary work in just one update. * * hasindex: set relhasindex to this value - * isprimary: if true, set relhaspkey true; else no change * reltoastidxid: if not InvalidOid, set reltoastidxid to this value; * else no change * reltuples: set reltuples to this value @@ -1547,7 +1529,7 @@ FormIndexDatum(IndexInfo *indexInfo, */ static void index_update_stats(Relation rel, - bool hasindex, bool isprimary, + bool hasindex, Oid reltoastidxid, double reltuples) { BlockNumber relpages = RelationGetNumberOfBlocks(rel); @@ -1586,9 +1568,8 @@ index_update_stats(Relation rel, * It is safe to use a non-transactional update even though our * transaction could still fail before committing. Setting relhasindex * true is safe even if there are no indexes (VACUUM will eventually fix - * it), likewise for relhaspkey. And of course the relpages and reltuples - * counts are correct (or at least more so than the old values) - * regardless. + * it). And of course the relpages and reltuples counts are correct (or + * at least more so than the old values) regardless. */ pg_class = heap_open(RelationRelationId, RowExclusiveLock); @@ -1633,14 +1614,6 @@ index_update_stats(Relation rel, rd_rel->relhasindex = hasindex; dirty = true; } - if (isprimary) - { - if (!rd_rel->relhaspkey) - { - rd_rel->relhaspkey = true; - dirty = true; - } - } if (OidIsValid(reltoastidxid)) { Assert(rd_rel->relkind == RELKIND_TOASTVALUE); @@ -1807,14 +1780,12 @@ index_build(Relation heapRelation, */ index_update_stats(heapRelation, true, - isprimary, (heapRelation->rd_rel->relkind == RELKIND_TOASTVALUE) ? RelationGetRelid(indexRelation) : InvalidOid, stats->heap_tuples); index_update_stats(indexRelation, false, - false, InvalidOid, stats->index_tuples); diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 7fe787e..a091aa0 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -605,16 +605,6 @@ vac_update_relstats(Relation relation, dirty = true; } - /* - * If we have discovered that there are no indexes, then there's no - * primary key either. This could be done more thoroughly... - */ - if (pgcform->relhaspkey && !hasindex) - { - pgcform->relhaspkey = false; - dirty = true; - } - /* We also clear relhasrules and relhastriggers if needed */ if (pgcform->relhasrules && relation->rd_rules == NULL) { diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h index e006180..589ceee 100644 --- a/src/include/catalog/pg_class.h +++ b/src/include/catalog/pg_class.h @@ -60,7 +60,6 @@ CATALOG(pg_class,1259) BKI_BOOTSTRAP BKI_ROWTYPE_OID(83) BKI_SCHEMA_MACRO */ int2 relchecks; /* # of CHECK constraints for class */ bool relhasoids; /* T if we generate OIDs for rows of rel */ - bool relhaspkey; /* has (or has had) PRIMARY KEY index */ bool relhasrules; /* has (or has had) any rules */ bool relhastriggers; /* has (or has had) any TRIGGERs */ bool relhassubclass; /* has (or has had) derived classes */ @@ -92,7 +91,7 @@ typedef FormData_pg_class *Form_pg_class; * ---------------- */ -#define Natts_pg_class 26 +#define Natts_pg_class 25 #define Anum_pg_class_relname 1 #define Anum_pg_class_relnamespace 2 #define Anum_pg_class_reltype 3 @@ -112,13 +111,12 @@ typedef FormData_pg_class *Form_pg_class; #define Anum_pg_class_relnatts 17 #define Anum_pg_class_relchecks 18 #define Anum_pg_class_relhasoids 19 -#define Anum_pg_class_relhaspkey 20 -#define Anum_pg_class_relhasrules 21 -#define Anum_pg_class_relhastriggers 22 -#define Anum_pg_class_relhassubclass 23 -#define Anum_pg_class_relfrozenxid 24 -#define Anum_pg_class_relacl 25 -#define Anum_pg_class_reloptions 26 +#define Anum_pg_class_relhasrules 20 +#define Anum_pg_class_relhastriggers 21 +#define Anum_pg_class_relhassubclass 22 +#define Anum_pg_class_relfrozenxid 23 +#define Anum_pg_class_relacl 24 +#define Anum_pg_class_reloptions 25 /* ---------------- * initial contents of pg_class @@ -130,13 +128,13 @@ typedef FormData_pg_class *Form_pg_class; */ /* Note: "3" in the relfrozenxid column stands for FirstNormalTransactionId */ -DATA(insert OID = 1247 ( pg_type PGNSP 71 0 PGUID 0 0 0 0 0 0 0 f f p r 29 0 t f f f f 3 _null_ _null_ )); +DATA(insert OID = 1247 ( pg_type PGNSP 71 0 PGUID 0 0 0 0 0 0 0 f f p r 29 0 t f f f 3 _null_ _null_ )); DESCR(""); -DATA(insert OID = 1249 ( pg_attribute PGNSP 75 0 PGUID 0 0 0 0 0 0 0 f f p r 21 0 f f f f f 3 _null_ _null_ )); +DATA(insert OID = 1249 ( pg_attribute PGNSP 75 0 PGUID 0 0 0 0 0 0 0 f f p r 21 0 f f f f 3 _null_ _null_ )); DESCR(""); -DATA(insert OID = 1255 ( pg_proc PGNSP 81 0 PGUID 0 0 0 0 0 0 0 f f p r 26 0 t f f f f 3 _null_ _null_ )); +DATA(insert OID = 1255 ( pg_proc PGNSP 81 0 PGUID 0 0 0 0 0 0 0 f f p r 26 0 t f f f 3 _null_ _null_ )); DESCR(""); -DATA(insert OID = 1259 ( pg_class PGNSP 83 0 PGUID 0 0 0 0 0 0 0 f f p r 26 0 t f f f f 3 _null_ _null_ )); +DATA(insert OID = 1259 ( pg_class PGNSP 83 0 PGUID 0 0 0 0 0 0 0 f f p r 25 0 t f f f 3 _null_ _null_ )); DESCR("");