codekingpro/portable-devtools
116k
1/*-------------------------------------------------------------------------2 *3 * partcache.h4 *5 * Copyright (c) 1996-2023, PostgreSQL Global Development Group6 *7 * src/include/utils/partcache.h8 *9 *-------------------------------------------------------------------------10 */11#ifndef PARTCACHE_H12#define PARTCACHE_H13 14#include "access/attnum.h"15#include "fmgr.h"16#include "nodes/parsenodes.h"17#include "nodes/pg_list.h"18#include "nodes/primnodes.h"19#include "partitioning/partdefs.h"20#include "utils/relcache.h"21 22/*23 * Information about the partition key of a relation24 */25typedef struct PartitionKeyData26{27 PartitionStrategy strategy; /* partitioning strategy */28 int16 partnatts; /* number of columns in the partition key */29 AttrNumber *partattrs; /* attribute numbers of columns in the30 * partition key or 0 if it's an expr */31 List *partexprs; /* list of expressions in the partitioning32 * key, one for each zero-valued partattrs */33 34 Oid *partopfamily; /* OIDs of operator families */35 Oid *partopcintype; /* OIDs of opclass declared input data types */36 FmgrInfo *partsupfunc; /* lookup info for support funcs */37 38 /* Partitioning collation per attribute */39 Oid *partcollation;40 41 /* Type information per attribute */42 Oid *parttypid;43 int32 *parttypmod;44 int16 *parttyplen;45 bool *parttypbyval;46 char *parttypalign;47 Oid *parttypcoll;48} PartitionKeyData;49 50 51extern PartitionKey RelationGetPartitionKey(Relation rel);52extern List *RelationGetPartitionQual(Relation rel);53extern Expr *get_partition_qual_relid(Oid relid);54 55/*56 * PartitionKey inquiry functions57 */58static inline int59get_partition_strategy(PartitionKey key)60{61 return key->strategy;62}63 64static inline int65get_partition_natts(PartitionKey key)66{67 return key->partnatts;68}69 70static inline List *71get_partition_exprs(PartitionKey key)72{73 return key->partexprs;74}75 76/*77 * PartitionKey inquiry functions - one column78 */79static inline int1680get_partition_col_attnum(PartitionKey key, int col)81{82 return key->partattrs[col];83}84 85static inline Oid86get_partition_col_typid(PartitionKey key, int col)87{88 return key->parttypid[col];89}90 91static inline int3292get_partition_col_typmod(PartitionKey key, int col)93{94 return key->parttypmod[col];95}96 97static inline Oid98get_partition_col_collation(PartitionKey key, int col)99{100 return key->partcollation[col];101}102 103#endif /* PARTCACHE_H */104 