PostgreSQL Source Code  git master
partcache.h File Reference
#include "access/attnum.h"
#include "fmgr.h"
#include "nodes/parsenodes.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 80 of file partcache.h.

81 {
82  return key->partattrs[col];
83 }

References sort-test::key.

Referenced by ExecBuildSlotPartitionKeyDescription(), and has_partition_attrs().

◆ get_partition_col_collation()

static Oid get_partition_col_collation ( PartitionKey  key,
int  col 
)
inlinestatic

Definition at line 98 of file partcache.h.

99 {
100  return key->partcollation[col];
101 }

References sort-test::key.

Referenced by transformPartitionBound(), and transformPartitionRangeBounds().

◆ get_partition_col_typid()

static Oid get_partition_col_typid ( PartitionKey  key,
int  col 
)
inlinestatic

Definition at line 86 of file partcache.h.

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

References sort-test::key.

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

◆ get_partition_col_typmod()

static int32 get_partition_col_typmod ( PartitionKey  key,
int  col 
)
inlinestatic

Definition at line 92 of file partcache.h.

93 {
94  return key->parttypmod[col];
95 }

References sort-test::key.

Referenced by transformPartitionBound(), and transformPartitionRangeBounds().

◆ get_partition_exprs()

static List* get_partition_exprs ( PartitionKey  key)
inlinestatic

Definition at line 71 of file partcache.h.

72 {
73  return key->partexprs;
74 }

References sort-test::key.

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

◆ get_partition_natts()

static int get_partition_natts ( PartitionKey  key)
inlinestatic

Definition at line 65 of file partcache.h.

66 {
67  return key->partnatts;
68 }

References sort-test::key.

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

◆ get_partition_qual_relid()

Expr* get_partition_qual_relid ( Oid  relid)

Definition at line 304 of file partcache.c.

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

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().

◆ get_partition_strategy()

static int get_partition_strategy ( PartitionKey  key)
inlinestatic

Definition at line 59 of file partcache.h.

60 {
61  return key->strategy;
62 }

References sort-test::key.

Referenced by transformPartitionBound().

◆ RelationGetPartitionKey()

◆ RelationGetPartitionQual()

List* RelationGetPartitionQual ( Relation  rel)

Definition at line 282 of file partcache.c.

283 {
284  /* Quick exit */
285  if (!rel->rd_rel->relispartition)
286  return NIL;
287 
288  return generate_partition_qual(rel);
289 }

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

Referenced by ATExecAttachPartition(), DetachAddConstraintIfNeeded(), ExecPartitionCheck(), and set_baserel_partition_constraint().