mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +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:
@ -11,7 +11,11 @@
|
||||
#ifndef PARTBOUNDS_H
|
||||
#define PARTBOUNDS_H
|
||||
|
||||
#include "catalog/partition.h"
|
||||
#include "fmgr.h"
|
||||
#include "nodes/parsenodes.h"
|
||||
#include "nodes/pg_list.h"
|
||||
#include "partitioning/partdefs.h"
|
||||
#include "utils/relcache.h"
|
||||
|
||||
|
||||
/*
|
||||
@ -101,7 +105,34 @@ typedef struct PartitionRangeBound
|
||||
} PartitionRangeBound;
|
||||
|
||||
extern int get_hash_partition_greatest_modulus(PartitionBoundInfo b);
|
||||
extern int partition_list_bsearch(FmgrInfo *partsupfunc, Oid *partcollation,
|
||||
extern uint64 compute_hash_value(int partnatts, FmgrInfo *partsupfunc,
|
||||
Datum *values, bool *isnull);
|
||||
extern List *get_qual_from_partbound(Relation rel, Relation parent,
|
||||
PartitionBoundSpec *spec);
|
||||
extern bool partition_bounds_equal(int partnatts, int16 *parttyplen,
|
||||
bool *parttypbyval, PartitionBoundInfo b1,
|
||||
PartitionBoundInfo b2);
|
||||
extern PartitionBoundInfo partition_bounds_copy(PartitionBoundInfo src,
|
||||
PartitionKey key);
|
||||
extern void check_new_partition_bound(char *relname, Relation parent,
|
||||
PartitionBoundSpec *spec);
|
||||
extern void check_default_allows_bound(Relation parent, Relation defaultRel,
|
||||
PartitionBoundSpec *new_spec);
|
||||
|
||||
extern PartitionRangeBound *make_one_range_bound(PartitionKey key, int index,
|
||||
List *datums, bool lower);
|
||||
extern int32 partition_hbound_cmp(int modulus1, int remainder1, int modulus2,
|
||||
int remainder2);
|
||||
extern int32 partition_rbound_cmp(int partnatts, FmgrInfo *partsupfunc,
|
||||
Oid *partcollation, Datum *datums1,
|
||||
PartitionRangeDatumKind *kind1, bool lower1,
|
||||
PartitionRangeBound *b2);
|
||||
extern int32 partition_rbound_datum_cmp(FmgrInfo *partsupfunc,
|
||||
Oid *partcollation,
|
||||
Datum *rb_datums, PartitionRangeDatumKind *rb_kind,
|
||||
Datum *tuple_datums, int n_tuple_datums);
|
||||
extern int partition_list_bsearch(FmgrInfo *partsupfunc,
|
||||
Oid *partcollation,
|
||||
PartitionBoundInfo boundinfo,
|
||||
Datum value, bool *is_equal);
|
||||
extern int partition_range_bsearch(int partnatts, FmgrInfo *partsupfunc,
|
||||
@ -114,11 +145,5 @@ extern int partition_range_datum_bsearch(FmgrInfo *partsupfunc,
|
||||
int nvalues, Datum *values, bool *is_equal);
|
||||
extern int partition_hash_bsearch(PartitionBoundInfo boundinfo,
|
||||
int modulus, int remainder);
|
||||
extern uint64 compute_hash_value(int partnatts, FmgrInfo *partsupfunc,
|
||||
Datum *values, bool *isnull);
|
||||
extern int32 partition_rbound_datum_cmp(FmgrInfo *partsupfunc,
|
||||
Oid *partcollation,
|
||||
Datum *rb_datums, PartitionRangeDatumKind *rb_kind,
|
||||
Datum *tuple_datums, int n_tuple_datums);
|
||||
|
||||
#endif /* PARTBOUNDS_H */
|
||||
|
24
src/include/partitioning/partdefs.h
Normal file
24
src/include/partitioning/partdefs.h
Normal file
@ -0,0 +1,24 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* partdefs.h
|
||||
* Base definitions for partitioned table handling
|
||||
*
|
||||
* Copyright (c) 2007-2018, PostgreSQL Global Development Group
|
||||
*
|
||||
* src/include/partitioning/partdefs.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
#ifndef PARTDEFS_H
|
||||
#define PARTDEFS_H
|
||||
|
||||
|
||||
typedef struct PartitionBoundInfoData *PartitionBoundInfo;
|
||||
|
||||
typedef struct PartitionKeyData *PartitionKey;
|
||||
|
||||
typedef struct PartitionBoundSpec PartitionBoundSpec;
|
||||
|
||||
typedef struct PartitionDescData *PartitionDesc;
|
||||
|
||||
#endif /* PARTDEFS_H */
|
@ -14,9 +14,10 @@
|
||||
#ifndef PARTPRUNE_H
|
||||
#define PARTPRUNE_H
|
||||
|
||||
#include "catalog/partition.h"
|
||||
#include "nodes/execnodes.h"
|
||||
#include "nodes/relation.h"
|
||||
|
||||
|
||||
/*
|
||||
* PartitionPruneContext
|
||||
*
|
||||
|
Reference in New Issue
Block a user