33#include "utils/fmgrprotos.h"
100 !((
Const *) pctnode)->constisnull)
103 if (samplefract >= 0 && samplefract <= 100 && !isnan(samplefract))
104 samplefract /= 100.0f;
118 *pages = baserel->
pages;
145 if (percent < 0 || percent > 100 || isnan(percent))
147 (
errcode(ERRCODE_INVALID_TABLESAMPLE_ARGUMENT),
148 errmsg(
"sample percentage must be between 0 and 100")));
155 dcutoff = rint(((
double)
PG_UINT32_MAX + 1) * percent / 100);
157 sampler->
seed = seed;
204 hashinput[0] = blockno;
205 hashinput[2] = sampler->
seed;
211 for (; tupoffset <= maxoffset; tupoffset++)
215 hashinput[1] = tupoffset;
218 (
int)
sizeof(hashinput)));
219 if (hash < sampler->cutoff)
223 if (tupoffset > maxoffset)
226 sampler->
lt = tupoffset;
static void bernoulli_samplescangetsamplesize(PlannerInfo *root, RelOptInfo *baserel, List *paramexprs, BlockNumber *pages, double *tuples)
static void bernoulli_initsamplescan(SampleScanState *node, int eflags)
Datum tsm_bernoulli_handler(PG_FUNCTION_ARGS)
static void bernoulli_beginsamplescan(SampleScanState *node, Datum *params, int nparams, uint32 seed)
static OffsetNumber bernoulli_nextsampletuple(SampleScanState *node, BlockNumber blockno, OffsetNumber maxoffset)
Node * estimate_expression_value(PlannerInfo *root, Node *node)
double clamp_row_est(double nrows)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
#define PG_RETURN_POINTER(x)
static Datum hash_any(const unsigned char *k, int keylen)
if(TABLE==NULL||TABLE_index==NULL)
void * palloc0(Size size)
#define IsA(nodeptr, _type_)
#define InvalidOffsetNumber
#define FirstOffsetNumber
#define list_make1_oid(x1)
static uint32 DatumGetUInt32(Datum X)
static float4 DatumGetFloat4(Datum X)
static unsigned hash(unsigned *uv, int n)
NextSampleTuple_function NextSampleTuple
bool repeatable_across_scans
EndSampleScan_function EndSampleScan
SampleScanGetSampleSize_function SampleScanGetSampleSize
BeginSampleScan_function BeginSampleScan
NextSampleBlock_function NextSampleBlock
InitSampleScan_function InitSampleScan
bool repeatable_across_queries