PostgreSQL Source Code  git master
partcache.h File Reference
#include "access/attnum.h"
#include "fmgr.h"
#include "nodes/pg_list.h"
#include "nodes/primnodes.h"
#include "partitioning/partdefs.h"
#include "utils/relcache.h"
Include dependency graph for partcache.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  PartitionKeyData
 

Typedefs

typedef struct PartitionKeyData PartitionKeyData
 

Functions

PartitionKey RelationGetPartitionKey (Relation rel)
 
ListRelationGetPartitionQual (Relation rel)
 
Exprget_partition_qual_relid (Oid relid)
 
static int get_partition_strategy (PartitionKey key)
 
static int get_partition_natts (PartitionKey key)
 
static Listget_partition_exprs (PartitionKey key)
 
static int16 get_partition_col_attnum (PartitionKey key, int col)
 
static Oid get_partition_col_typid (PartitionKey key, int col)
 
static int32 get_partition_col_typmod (PartitionKey key, int col)
 
static Oid get_partition_col_collation (PartitionKey key, int col)
 

Typedef Documentation

◆ PartitionKeyData

Function Documentation

◆ get_partition_col_attnum()

static int16 get_partition_col_attnum ( PartitionKey  key,
int  col 
)
inlinestatic

Definition at line 79 of file partcache.h.

References PartitionKeyData::partattrs.

Referenced by ExecBuildSlotPartitionKeyDescription(), and has_partition_attrs().

80 {
81  return key->partattrs[col];
82 }
AttrNumber * partattrs
Definition: partcache.h:28

◆ get_partition_col_collation()

static Oid get_partition_col_collation ( PartitionKey  key,
int  col 
)
inlinestatic

Definition at line 97 of file partcache.h.

References PartitionKeyData::partcollation.

Referenced by transformPartitionBound(), and transformPartitionRangeBounds().

98 {
99  return key->partcollation[col];
100 }
Oid * partcollation
Definition: partcache.h:38

◆ get_partition_col_typid()

static Oid get_partition_col_typid ( PartitionKey  key,
int  col 
)
inlinestatic

Definition at line 85 of file partcache.h.

References PartitionKeyData::parttypid.

Referenced by ExecBuildSlotPartitionKeyDescription(), transformPartitionBound(), and transformPartitionRangeBounds().

86 {
87  return key->parttypid[col];
88 }

◆ get_partition_col_typmod()

static int32 get_partition_col_typmod ( PartitionKey  key,
int  col 
)
inlinestatic

Definition at line 91 of file partcache.h.

References PartitionKeyData::parttypmod.

Referenced by transformPartitionBound(), and transformPartitionRangeBounds().

92 {
93  return key->parttypmod[col];
94 }
int32 * parttypmod
Definition: partcache.h:42

◆ get_partition_exprs()

static List* get_partition_exprs ( PartitionKey  key)
inlinestatic

Definition at line 70 of file partcache.h.

References PartitionKeyData::partexprs.

Referenced by has_partition_attrs(), transformPartitionBound(), and transformPartitionRangeBounds().

71 {
72  return key->partexprs;
73 }
List * partexprs
Definition: partcache.h:30

◆ get_partition_natts()

static int get_partition_natts ( PartitionKey  key)
inlinestatic

Definition at line 64 of file partcache.h.

References PartitionKeyData::partnatts.

Referenced by ExecBuildSlotPartitionKeyDescription(), has_partition_attrs(), and transformPartitionBound().

65 {
66  return key->partnatts;
67 }

◆ get_partition_qual_relid()

Expr* get_partition_qual_relid ( Oid  relid)

Definition at line 298 of file partcache.c.

References AccessShareLock, AND_EXPR, generate_partition_qual(), get_rel_relispartition(), linitial, list_length(), makeBoolExpr(), NIL, NoLock, relation_close(), and relation_open().

Referenced by pg_get_partconstrdef_string(), and pg_get_partition_constraintdef().

299 {
300  Expr *result = NULL;
301 
302  /* Do the work only if this relation exists and is a partition. */
303  if (get_rel_relispartition(relid))
304  {
305  Relation rel = relation_open(relid, AccessShareLock);
306  List *and_args;
307 
308  and_args = generate_partition_qual(rel);
309 
310  /* Convert implicit-AND list format to boolean expression */
311  if (and_args == NIL)
312  result = NULL;
313  else if (list_length(and_args) > 1)
314  result = makeBoolExpr(AND_EXPR, and_args, -1);
315  else
316  result = linitial(and_args);
317 
318  /* Keep the lock, to allow safe deparsing against the rel by caller. */
319  relation_close(rel, NoLock);
320  }
321 
322  return result;
323 }
#define NIL
Definition: pg_list.h:65
#define AccessShareLock
Definition: lockdefs.h:36
Expr * makeBoolExpr(BoolExprType boolop, List *args, int location)
Definition: makefuncs.c:369
static List * generate_partition_qual(Relation rel)
Definition: partcache.c:336
#define linitial(l)
Definition: pg_list.h:195
Relation relation_open(Oid relationId, LOCKMODE lockmode)
Definition: relation.c:48
#define NoLock
Definition: lockdefs.h:34
bool get_rel_relispartition(Oid relid)
Definition: lsyscache.c:1939
void relation_close(Relation relation, LOCKMODE lockmode)
Definition: relation.c:206
static int list_length(const List *l)
Definition: pg_list.h:169
Definition: pg_list.h:50

◆ get_partition_strategy()

static int get_partition_strategy ( PartitionKey  key)
inlinestatic

Definition at line 58 of file partcache.h.

References PartitionKeyData::strategy.

Referenced by transformPartitionBound().

59 {
60  return key->strategy;
61 }

◆ RelationGetPartitionKey()

◆ RelationGetPartitionQual()

List* RelationGetPartitionQual ( Relation  rel)

Definition at line 276 of file partcache.c.

References generate_partition_qual(), NIL, and RelationData::rd_rel.

Referenced by ATExecAttachPartition(), InitResultRelInfo(), and set_baserel_partition_constraint().

277 {
278  /* Quick exit */
279  if (!rel->rd_rel->relispartition)
280  return NIL;
281 
282  return generate_partition_qual(rel);
283 }
#define NIL
Definition: pg_list.h:65
Form_pg_class rd_rel
Definition: rel.h:109
static List * generate_partition_qual(Relation rel)
Definition: partcache.c:336