]> granicus.if.org Git - postgresql/blob - src/include/access/tsmapi.h
Phase 2 of pgindent updates.
[postgresql] / src / include / access / tsmapi.h
1 /*-------------------------------------------------------------------------
2  *
3  * tsmapi.h
4  *        API for tablesample methods
5  *
6  * Copyright (c) 2015-2017, 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/relation.h"
17
18
19 /*
20  * Callback function signatures --- see tablesample-method.sgml for more info.
21  */
22
23 typedef void (*SampleScanGetSampleSize_function) (PlannerInfo *root,
24                                                                                                   RelOptInfo *baserel,
25                                                                                                   List *paramexprs,
26                                                                                                   BlockNumber *pages,
27                                                                                                   double *tuples);
28
29 typedef void (*InitSampleScan_function) (SampleScanState *node,
30                                                                                  int eflags);
31
32 typedef void (*BeginSampleScan_function) (SampleScanState *node,
33                                                                                   Datum *params,
34                                                                                   int nparams,
35                                                                                   uint32 seed);
36
37 typedef BlockNumber (*NextSampleBlock_function) (SampleScanState *node);
38
39 typedef OffsetNumber (*NextSampleTuple_function) (SampleScanState *node,
40                                                                                                   BlockNumber blockno,
41                                                                                                   OffsetNumber maxoffset);
42
43 typedef void (*EndSampleScan_function) (SampleScanState *node);
44
45 /*
46  * TsmRoutine is the struct returned by a tablesample method's handler
47  * function.  It provides pointers to the callback functions needed by the
48  * planner and executor, as well as additional information about the method.
49  *
50  * More function pointers are likely to be added in the future.
51  * Therefore it's recommended that the handler initialize the struct with
52  * makeNode(TsmRoutine) so that all fields are set to NULL.  This will
53  * ensure that no fields are accidentally left undefined.
54  */
55 typedef struct TsmRoutine
56 {
57         NodeTag         type;
58
59         /* List of datatype OIDs for the arguments of the TABLESAMPLE clause */
60         List       *parameterTypes;
61
62         /* Can method produce repeatable samples across, or even within, queries? */
63         bool            repeatable_across_queries;
64         bool            repeatable_across_scans;
65
66         /* Functions for planning a SampleScan on a physical table */
67         SampleScanGetSampleSize_function SampleScanGetSampleSize;
68
69         /* Functions for executing a SampleScan on a physical table */
70         InitSampleScan_function InitSampleScan; /* can be NULL */
71         BeginSampleScan_function BeginSampleScan;
72         NextSampleBlock_function NextSampleBlock;       /* can be NULL */
73         NextSampleTuple_function NextSampleTuple;
74         EndSampleScan_function EndSampleScan;   /* can be NULL */
75 } TsmRoutine;
76
77
78 /* Functions in access/tablesample/tablesample.c */
79 extern TsmRoutine *GetTsmRoutine(Oid tsmhandler);
80
81 #endif                                                  /* TSMAPI_H */