PostgreSQL Source Code: src/backend/optimizer/plan/planagg.c Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

30

49

52 Oid eqop, Oid sortop, bool reverse_sort,

53 bool nulls_first);

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73void

75{

80 List *aggs_list;

83

84

86

87

88 if (parse->hasAggs)

89 return;

90

91 Assert(parse->setOperations);

92 Assert(parse->rowMarks == NIL);

93

94

95

96

97

98

99

100

102 parse->hasWindowFuncs)

103 return;

104

105

106

107

108

109

110 if (parse->cteList)

111 return;

112

113

114

115

116

117

118

119

120

121

122 jtnode = parse->jointree;

124 {

126 return;

128 }

130 return;

134 ;

136 ;

137 else

138 return;

139

140

141

142

143

144 aggs_list = NIL;

146 return;

147

148

149

150

151

152

153

154 foreach(lc, aggs_list)

155 {

157 Oid eqop;

158 bool reverse;

159

160

161

162

163

165 if (OidIsValid(eqop))

166 elog(ERROR, "could not find equality operator for ordering operator %u",

168

169

170

171

172

173

174

175

176

178 continue;

180 continue;

181

182

183 return;

184 }

185

186

187

188

189

190

191

192

193

194

195 foreach(lc, aggs_list)

196 {

198

202 -1,

204 }

205

206

207

208

209

210

211

212

213

214

215

216

217

218

219

224 root->processed_tlist),

225 aggs_list,

227}

228

229

230

231

232

233

234

235

236

237static bool

239{

241

242

243

244

245

246 foreach(lc, root->agginfos)

247 {

250 Oid aggsortop;

253

254 Assert(aggref->agglevelsup == 0);

256 return false;

257

258

259

260

261

262

263

264

265

266

267

268

269

270

272 return false;

273

274

275

276

277

278

279

281 return false;

282

285 return false;

286

288

290 return false;

291

293 return false;

294

299 mminfo->subroot = NULL;

300 mminfo->path = NULL;

302 mminfo->param = NULL;

303

304 *context = lappend(*context, mminfo);

305 }

306 return true;

307}

308

309

310

311

312

313

314

315

316

317static bool

319 Oid eqop, Oid sortop, bool reverse_sort, bool nulls_first)

320{

328 Path *sorted_path;

329 Cost path_cost;

330 double path_fraction;

331

332

333

334

335

336

337

338

342 subroot->parent_root = root;

344

345

351

354

355

358

360

362

364

365

366

367

368

369

370

371

372

373

377 false);

380

381

382 parse->havingQual = NULL;

385 parse->hasDistinctOn = false;

386 parse->hasAggs = false;

387

388

392

393 ntest->argisrow = false;

395

396

398 parse->jointree->quals = (Node *)

400

401

404 sortcl->eqop = eqop;

405 sortcl->sortop = sortop;

408 sortcl->hashable = false;

410

411

412 parse->limitOffset = NULL;

416 true);

417

418

419

420

421

424

426

427

428

429

430

431

432

435

436

437

438

439

440 if (final_rel->rows > 1.0)

441 path_fraction = 1.0 / final_rel->rows;

442 else

443 path_fraction = 1.0;

444

445 sorted_path =

448 NULL,

449 path_fraction);

450 if (!sorted_path)

451 return false;

452

453

454

455

456

457

461

462

463

464

465

466

467

470

471

472 mminfo->subroot = subroot;

473 mminfo->path = sorted_path;

474 mminfo->pathcost = path_cost;

475

476 return true;

477}

478

479

480

481

482static void

484{

485 root->group_pathkeys = NIL;

486 root->window_pathkeys = NIL;

487 root->distinct_pathkeys = NIL;

488

489 root->sort_pathkeys =

491 root->parse->sortClause,

492 root->parse->targetList);

493

494 root->query_pathkeys = root->sort_pathkeys;

495}

496

497

498

499

500

501static Oid

503{

506 Oid aggsortop;

507

508

513 aggsortop = aggform->aggsortop;

515

516 return aggsortop;

517}

#define OidIsValid(objectId)

bool contain_mutable_functions(Node *clause)

#define palloc_object(type)

Assert(PointerIsAligned(start, uint64))

#define HeapTupleIsValid(tuple)

static void * GETSTRUCT(const HeapTupleData *tuple)

List * lappend(List *list, void *datum)

List * lcons(void *datum, List *list)

bool list_member(const List *list, const void *datum)

bool type_is_rowtype(Oid typid)

Oid get_equality_op_for_ordering_op(Oid opno, bool *reverse)

TargetEntry * makeTargetEntry(Expr *expr, AttrNumber resno, char *resname, bool resjunk)

Const * makeConst(Oid consttype, int32 consttypmod, Oid constcollid, int constlen, Datum constvalue, bool constisnull, bool constbyval)

char * pstrdup(const char *in)

Oid exprType(const Node *expr)

Oid exprCollation(const Node *expr)

#define IsA(nodeptr, _type_)

Index assignSortGroupRef(TargetEntry *tle, List *tlist)

Path * get_cheapest_fractional_path_for_pathkeys(List *paths, List *pathkeys, Relids required_outer, double fraction)

List * make_pathkeys_for_sortclauses(PlannerInfo *root, List *sortclauses, List *tlist)

MinMaxAggPath * create_minmaxagg_path(PlannerInfo *root, RelOptInfo *rel, PathTarget *target, List *mmaggregates, List *quals)

Path * apply_projection_to_path(PlannerInfo *root, RelOptInfo *rel, Path *path, PathTarget *target)

void add_path(RelOptInfo *parent_rel, Path *new_path)

#define planner_rt_fetch(rti, root)

FormData_pg_aggregate * Form_pg_aggregate

#define lfirst_node(type, lc)

static int list_length(const List *l)

#define linitial_node(type, l)

static Oid fetch_agg_sort_op(Oid aggfnoid)

void preprocess_minmax_aggregates(PlannerInfo *root)

static bool can_minmax_aggs(PlannerInfo *root, List **context)

static void minmax_qp_callback(PlannerInfo *root, void *extra)

static bool build_minmax_path(PlannerInfo *root, MinMaxAggInfo *mminfo, Oid eqop, Oid sortop, bool reverse_sort, bool nulls_first)

RelOptInfo * query_planner(PlannerInfo *root, query_pathkeys_callback qp_callback, void *qp_extra)

char * choose_plan_name(PlannerGlobal *glob, const char *name, bool always_number)

static Datum Int64GetDatum(int64 X)

static Datum ObjectIdGetDatum(Oid X)

static struct subre * parse(struct vars *v, int stopper, int type, struct state *init, struct state *final)

RelOptInfo * fetch_upper_rel(PlannerInfo *root, UpperRelationKind kind, Relids relids)

void IncrementVarSublevelsUp(Node *node, int delta_sublevels_up, int min_sublevels_up)

NullTestType nulltesttype

Selectivity tuple_fraction

void SS_identify_outer_params(PlannerInfo *root)

void SS_charge_for_initplans(PlannerInfo *root, RelOptInfo *final_rel)

Param * SS_make_initplan_output_param(PlannerInfo *root, Oid resulttype, int32 resulttypmod, Oid resultcollation)

void ReleaseSysCache(HeapTuple tuple)

HeapTuple SearchSysCache1(int cacheId, Datum key1)

#define create_pathtarget(root, tlist)