PostgreSQL Source Code  git master
tsmapi.h
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * tsmapi.h
4  * API for tablesample methods
5  *
6  * Copyright (c) 2015-2024, PostgreSQL Global Development Group
7  *
8  * src/include/access/tsmapi.h
9  *
10  *-------------------------------------------------------------------------
11  */
12 #ifndef TSMAPI_H
13 #define TSMAPI_H
14 
15 #include "nodes/execnodes.h"
16 #include "nodes/pathnodes.h"
17 
18 
19 /*
20  * Callback function signatures --- see tablesample-method.sgml for more info.
21  */
22 
24  RelOptInfo *baserel,
25  List *paramexprs,
26  BlockNumber *pages,
27  double *tuples);
28 
30  int eflags);
31 
33  Datum *params,
34  int nparams,
35  uint32 seed);
36 
38  BlockNumber nblocks);
39 
41  BlockNumber blockno,
42  OffsetNumber maxoffset);
43 
44 typedef void (*EndSampleScan_function) (SampleScanState *node);
45 
46 /*
47  * TsmRoutine is the struct returned by a tablesample method's handler
48  * function. It provides pointers to the callback functions needed by the
49  * planner and executor, as well as additional information about the method.
50  *
51  * More function pointers are likely to be added in the future.
52  * Therefore it's recommended that the handler initialize the struct with
53  * makeNode(TsmRoutine) so that all fields are set to NULL. This will
54  * ensure that no fields are accidentally left undefined.
55  */
56 typedef struct TsmRoutine
57 {
59 
60  /* List of datatype OIDs for the arguments of the TABLESAMPLE clause */
62 
63  /* Can method produce repeatable samples across, or even within, queries? */
66 
67  /* Functions for planning a SampleScan on a physical table */
69 
70  /* Functions for executing a SampleScan on a physical table */
77 
78 
79 /* Functions in access/tablesample/tablesample.c */
80 extern TsmRoutine *GetTsmRoutine(Oid tsmhandler);
81 
82 #endif /* TSMAPI_H */
uint32 BlockNumber
Definition: block.h:31
unsigned int uint32
Definition: c.h:506
NodeTag
Definition: nodes.h:27
uint16 OffsetNumber
Definition: off.h:24
uintptr_t Datum
Definition: postgres.h:64
unsigned int Oid
Definition: postgres_ext.h:31
tree ctl root
Definition: radixtree.h:1884
Definition: pg_list.h:54
NextSampleTuple_function NextSampleTuple
Definition: tsmapi.h:74
bool repeatable_across_scans
Definition: tsmapi.h:65
EndSampleScan_function EndSampleScan
Definition: tsmapi.h:75
NodeTag type
Definition: tsmapi.h:58
SampleScanGetSampleSize_function SampleScanGetSampleSize
Definition: tsmapi.h:68
BeginSampleScan_function BeginSampleScan
Definition: tsmapi.h:72
NextSampleBlock_function NextSampleBlock
Definition: tsmapi.h:73
InitSampleScan_function InitSampleScan
Definition: tsmapi.h:71
List * parameterTypes
Definition: tsmapi.h:61
bool repeatable_across_queries
Definition: tsmapi.h:64
struct TsmRoutine TsmRoutine
void(* InitSampleScan_function)(SampleScanState *node, int eflags)
Definition: tsmapi.h:29
OffsetNumber(* NextSampleTuple_function)(SampleScanState *node, BlockNumber blockno, OffsetNumber maxoffset)
Definition: tsmapi.h:40
BlockNumber(* NextSampleBlock_function)(SampleScanState *node, BlockNumber nblocks)
Definition: tsmapi.h:37
TsmRoutine * GetTsmRoutine(Oid tsmhandler)
Definition: tablesample.c:27
void(* SampleScanGetSampleSize_function)(PlannerInfo *root, RelOptInfo *baserel, List *paramexprs, BlockNumber *pages, double *tuples)
Definition: tsmapi.h:23
void(* BeginSampleScan_function)(SampleScanState *node, Datum *params, int nparams, uint32 seed)
Definition: tsmapi.h:32
void(* EndSampleScan_function)(SampleScanState *node)
Definition: tsmapi.h:44