33 #include "utils/fmgrprotos.h"
102 !((
Const *) pctnode)->constisnull)
105 if (samplefract >= 0 && samplefract <= 100 && !isnan(samplefract))
106 samplefract /= 100.0f;
148 if (percent < 0 || percent > 100 || isnan(percent))
150 (
errcode(ERRCODE_INVALID_TABLESAMPLE_ARGUMENT),
151 errmsg(
"sample percentage must be between 0 and 100")));
158 dcutoff = rint(((
double)
PG_UINT32_MAX + 1) * percent / 100);
160 sampler->
seed = seed;
193 hashinput[1] = sampler->
seed;
199 for (; nextblock < nblocks; nextblock++)
203 hashinput[0] = nextblock;
206 (
int)
sizeof(hashinput)));
207 if (hash < sampler->cutoff)
211 if (nextblock < nblocks)
250 if (tupoffset > maxoffset)
253 sampler->
lt = tupoffset;
static OffsetNumber system_nextsampletuple(SampleScanState *node, BlockNumber blockno, OffsetNumber maxoffset)
static void system_initsamplescan(SampleScanState *node, int eflags)
static void system_beginsamplescan(SampleScanState *node, Datum *params, int nparams, uint32 seed)
Datum tsm_system_handler(PG_FUNCTION_ARGS)
static BlockNumber system_nextsampleblock(SampleScanState *node, BlockNumber nblocks)
static void system_samplescangetsamplesize(PlannerInfo *root, RelOptInfo *baserel, List *paramexprs, BlockNumber *pages, double *tuples)
#define InvalidBlockNumber
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