mirror of
https://github.com/postgres/postgres.git
synced 2025-10-16 17:07:43 +03:00
Move code for managing PartitionDescs into a new file, partdesc.c
This is similar in spirit to the existing partbounds.c file in the same directory, except that there's a lot less code in the new file created by this commit. Pending work in this area proposes to add a bunch more code related to PartitionDescs, though, and this will give us a good place to put it. Discussion: http://postgr.es/m/CA+TgmoZUwPf_uanjF==gTGBMJrn8uCq52XYvAEorNkLrUdoawg@mail.gmail.com
This commit is contained in:
57
src/backend/utils/cache/relcache.c
vendored
57
src/backend/utils/cache/relcache.c
vendored
@@ -72,6 +72,7 @@
|
||||
#include "nodes/nodeFuncs.h"
|
||||
#include "optimizer/optimizer.h"
|
||||
#include "partitioning/partbounds.h"
|
||||
#include "partitioning/partdesc.h"
|
||||
#include "rewrite/rewriteDefine.h"
|
||||
#include "rewrite/rowsecurity.h"
|
||||
#include "storage/lmgr.h"
|
||||
@@ -283,8 +284,6 @@ static OpClassCacheEnt *LookupOpclassInfo(Oid operatorClassOid,
|
||||
StrategyNumber numSupport);
|
||||
static void RelationCacheInitFileRemoveInDir(const char *tblspcpath);
|
||||
static void unlink_initfile(const char *initfilename, int elevel);
|
||||
static bool equalPartitionDescs(PartitionKey key, PartitionDesc partdesc1,
|
||||
PartitionDesc partdesc2);
|
||||
|
||||
|
||||
/*
|
||||
@@ -995,60 +994,6 @@ equalRSDesc(RowSecurityDesc *rsdesc1, RowSecurityDesc *rsdesc2)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* equalPartitionDescs
|
||||
* Compare two partition descriptors for logical equality
|
||||
*/
|
||||
static bool
|
||||
equalPartitionDescs(PartitionKey key, PartitionDesc partdesc1,
|
||||
PartitionDesc partdesc2)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (partdesc1 != NULL)
|
||||
{
|
||||
if (partdesc2 == NULL)
|
||||
return false;
|
||||
if (partdesc1->nparts != partdesc2->nparts)
|
||||
return false;
|
||||
|
||||
Assert(key != NULL || partdesc1->nparts == 0);
|
||||
|
||||
/*
|
||||
* Same oids? If the partitioning structure did not change, that is,
|
||||
* no partitions were added or removed to the relation, the oids array
|
||||
* should still match element-by-element.
|
||||
*/
|
||||
for (i = 0; i < partdesc1->nparts; i++)
|
||||
{
|
||||
if (partdesc1->oids[i] != partdesc2->oids[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now compare partition bound collections. The logic to iterate over
|
||||
* the collections is private to partition.c.
|
||||
*/
|
||||
if (partdesc1->boundinfo != NULL)
|
||||
{
|
||||
if (partdesc2->boundinfo == NULL)
|
||||
return false;
|
||||
|
||||
if (!partition_bounds_equal(key->partnatts, key->parttyplen,
|
||||
key->parttypbyval,
|
||||
partdesc1->boundinfo,
|
||||
partdesc2->boundinfo))
|
||||
return false;
|
||||
}
|
||||
else if (partdesc2->boundinfo != NULL)
|
||||
return false;
|
||||
}
|
||||
else if (partdesc2 != NULL)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* RelationBuildDesc
|
||||
*
|
||||
|
Reference in New Issue
Block a user