mirror of
https://github.com/postgres/postgres.git
synced 2025-12-21 05:21:08 +03:00
Reorganize partitioning code
There's been a massive addition of partitioning code in PostgreSQL 11, with little oversight on its placement, resulting in a catalog/partition.c with poorly defined boundaries and responsibilities. This commit tries to set a couple of distinct modules to separate things a little bit. There are no code changes here, only code movement. There are three new files: src/backend/utils/cache/partcache.c src/include/partitioning/partdefs.h src/include/utils/partcache.h The previous arrangement of #including catalog/partition.h almost everywhere is no more. Authors: Amit Langote and Álvaro Herrera Discussion: https://postgr.es/m/98e8d509-790a-128c-be7f-e48a5b2d8d97@lab.ntt.co.jp https://postgr.es/m/11aa0c50-316b-18bb-722d-c23814f39059@lab.ntt.co.jp https://postgr.es/m/143ed9a4-6038-76d4-9a55-502035815e68@lab.ntt.co.jp https://postgr.es/m/20180413193503.nynq7bnmgh6vs5vm@alvherre.pgsql
This commit is contained in:
96
src/include/utils/partcache.h
Normal file
96
src/include/utils/partcache.h
Normal file
@@ -0,0 +1,96 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* partcache.h
|
||||
*
|
||||
* Copyright (c) 1996-2018, PostgreSQL Global Development Group
|
||||
*
|
||||
* src/include/utils/partcache.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef PARTCACHE_H
|
||||
#define PARTCACHE_H
|
||||
|
||||
#include "access/attnum.h"
|
||||
#include "fmgr.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#include "nodes/primnodes.h"
|
||||
#include "partitioning/partdefs.h"
|
||||
#include "utils/relcache.h"
|
||||
|
||||
/*
|
||||
* Information about the partition key of a relation
|
||||
*/
|
||||
typedef struct PartitionKeyData
|
||||
{
|
||||
char strategy; /* partitioning strategy */
|
||||
int16 partnatts; /* number of columns in the partition key */
|
||||
AttrNumber *partattrs; /* attribute numbers of columns in the
|
||||
* partition key */
|
||||
List *partexprs; /* list of expressions in the partitioning
|
||||
* key, or NIL */
|
||||
|
||||
Oid *partopfamily; /* OIDs of operator families */
|
||||
Oid *partopcintype; /* OIDs of opclass declared input data types */
|
||||
FmgrInfo *partsupfunc; /* lookup info for support funcs */
|
||||
|
||||
/* Partitioning collation per attribute */
|
||||
Oid *partcollation;
|
||||
|
||||
/* Type information per attribute */
|
||||
Oid *parttypid;
|
||||
int32 *parttypmod;
|
||||
int16 *parttyplen;
|
||||
bool *parttypbyval;
|
||||
char *parttypalign;
|
||||
Oid *parttypcoll;
|
||||
} PartitionKeyData;
|
||||
|
||||
extern void RelationBuildPartitionKey(Relation relation);
|
||||
extern void RelationBuildPartitionDesc(Relation rel);
|
||||
extern List *RelationGetPartitionQual(Relation rel);
|
||||
extern Expr *get_partition_qual_relid(Oid relid);
|
||||
|
||||
/*
|
||||
* PartitionKey inquiry functions
|
||||
*/
|
||||
static inline int
|
||||
get_partition_strategy(PartitionKey key)
|
||||
{
|
||||
return key->strategy;
|
||||
}
|
||||
|
||||
static inline int
|
||||
get_partition_natts(PartitionKey key)
|
||||
{
|
||||
return key->partnatts;
|
||||
}
|
||||
|
||||
static inline List *
|
||||
get_partition_exprs(PartitionKey key)
|
||||
{
|
||||
return key->partexprs;
|
||||
}
|
||||
|
||||
/*
|
||||
* PartitionKey inquiry functions - one column
|
||||
*/
|
||||
static inline int16
|
||||
get_partition_col_attnum(PartitionKey key, int col)
|
||||
{
|
||||
return key->partattrs[col];
|
||||
}
|
||||
|
||||
static inline Oid
|
||||
get_partition_col_typid(PartitionKey key, int col)
|
||||
{
|
||||
return key->parttypid[col];
|
||||
}
|
||||
|
||||
static inline int32
|
||||
get_partition_col_typmod(PartitionKey key, int col)
|
||||
{
|
||||
return key->parttypmod[col];
|
||||
}
|
||||
|
||||
#endif /* PARTCACHE_H */
|
||||
Reference in New Issue
Block a user