Fix crash when upgrading to Citus 6

Between restart (running the new code) and ALTER EXTENSION citus
UPGRADE there was an inconsistency where we assumed that
pg_dist_partition had the repmodel column set. Now we give it a default
value if the column doesn't exist yet.
pull/894/head
Brian Cloutier 2016-10-20 15:08:09 +03:00
parent f5ae4330be
commit c998d5b99f
1 changed files with 9 additions and 1 deletions

View File

@ -338,7 +338,15 @@ LookupDistTableCacheEntry(Oid relationId)
Anum_pg_dist_partition_repmodel, Anum_pg_dist_partition_repmodel,
tupleDescriptor, tupleDescriptor,
&isNull); &isNull);
Assert(!isNull);
if (isNull)
{
/*
* repmodel is NOT NULL but before ALTER EXTENSION citus UPGRADE the column
* doesn't exist
*/
replicationModelDatum = CharGetDatum('c');
}
oldContext = MemoryContextSwitchTo(CacheMemoryContext); oldContext = MemoryContextSwitchTo(CacheMemoryContext);
partitionKeyString = TextDatumGetCString(partitionKeyDatum); partitionKeyString = TextDatumGetCString(partitionKeyDatum);