PostgreSQL Source Code  git master
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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 299 of file partcache.c.

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

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 277 of file partcache.c.

278 {
279  /* Quick exit */
280  if (!rel->rd_rel->relispartition)
281  return NIL;
282 
283  return generate_partition_qual(rel);
284 }

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

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