PostgreSQL Source Code: src/backend/executor/nodeLimit.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

23

27

30

31

32

33

34

35

36

37

38

41{

47

49

50

51

52

55

56

57

58

60 {

62

63

64

65

66

67

68

70

72

74

75

76

77

80

81

82

83

85 {

88 }

89

90

91

92

93 for (;;)

94 {

97 {

98

99

100

101

104 }

105

106

107

108

109

112 {

114 }

117 break;

118 }

119

120

121

122

124 break;

125

127

128

129

130

131

133

136 {

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

155 {

157 {

160 }

161 else

162 {

164

165 }

166 }

167 else

168 {

169

170

171

174 {

177 }

178

179

180

181

182

183

186 {

188 }

191 break;

192 }

193 }

194 else

195 {

196

197

198

199

201 {

204 }

205

206

207

208

211 elog(ERROR, "LIMIT subplan failed to run backwards");

214 break;

215 }

216

219

222 {

223

224

225

226

229 {

232 }

233

234

235

236

237

241 {

244 }

245 else

246 {

249 }

250 }

251 else

252 {

253

254

255

256

258 {

261 }

262

263

264

265

266

269 elog(ERROR, "LIMIT subplan failed to run backwards");

273 }

274 break;

275

279

280

281

282

283

286 elog(ERROR, "LIMIT subplan failed to run backwards");

289

290 break;

291

295

296

297

298

299

300

302 {

305 elog(ERROR, "LIMIT subplan failed to run backwards");

308 }

309 else

310 {

311

312

313

314

317

318 }

319 break;

320

324

325

326

327

328

331

332 break;

333

334 default:

335 elog(ERROR, "impossible LIMIT state: %d",

337 slot = NULL;

338 break;

339 }

340

341

343

344 return slot;

345}

346

347

348

349

350

351

352static void

354{

357 bool isNull;

358

360 {

362 econtext,

363 &isNull);

364

365 if (isNull)

367 else

368 {

370 if (node->offset < 0)

373 errmsg("OFFSET must not be negative")));

374 }

375 }

376 else

377 {

378

380 }

381

383 {

385 econtext,

386 &isNull);

387

388 if (isNull)

389 {

392 }

393 else

394 {

396 if (node->count < 0)

399 errmsg("LIMIT must not be negative")));

401 }

402 }

403 else

404 {

405

408 }

409

410

413

414

416

417

418

419

420

421

422

424}

425

426

427

428

429

432{

434 return -1;

435

437}

438

439

440

441

442

443

444

445

448{

451

452

454

455

456

457

462

464

465

466

467

468

469

470

472

473

474

475

478

479

480

481

487

488

489

490

492

496

497

498

499

500

502

503

504

505

507 {

510

513

517 node->uniqColIdx,

518 node->uniqOperators,

519 node->uniqCollations,

521 }

522

524}

525

526

527

528

529

530

531

532

533void

538

539

540void

542{

544

545

546

547

548

549

551

552

553

554

555

558}

#define Assert(condition)

int errcode(int sqlerrcode)

#define ereport(elevel,...)

void ExecReScan(PlanState *node)

ExprState * ExecInitExpr(Expr *node, PlanState *parent)

ExprState * execTuplesMatchPrepare(TupleDesc desc, int numCols, const AttrNumber *keyColIdx, const Oid *eqOperators, const Oid *collations, PlanState *parent)

void ExecSetTupleBound(int64 tuples_needed, PlanState *child_node)

void ExecEndNode(PlanState *node)

PlanState * ExecInitNode(Plan *node, EState *estate, int eflags)

void ExecInitResultTypeTL(PlanState *planstate)

TupleTableSlot * ExecInitExtraTupleSlot(EState *estate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)

TupleDesc ExecGetResultType(PlanState *planstate)

void ExecAssignExprContext(EState *estate, PlanState *planstate)

const TupleTableSlotOps * ExecGetResultSlotOps(PlanState *planstate, bool *isfixed)

#define outerPlanState(node)

static bool ExecQualAndReset(ExprState *state, ExprContext *econtext)

static TupleTableSlot * ExecProcNode(PlanState *node)

static Datum ExecEvalExprSwitchContext(ExprState *state, ExprContext *econtext, bool *isNull)

#define CHECK_FOR_INTERRUPTS()

void ExecReScanLimit(LimitState *node)

LimitState * ExecInitLimit(Limit *node, EState *estate, int eflags)

static int64 compute_tuples_needed(LimitState *node)

static void recompute_limits(LimitState *node)

void ExecEndLimit(LimitState *node)

static TupleTableSlot * ExecLimit(PlanState *pstate)

#define castNode(_type_, nodeptr)

static int64 DatumGetInt64(Datum X)

#define ScanDirectionIsForward(direction)

ScanDirection es_direction

TupleTableSlot * ecxt_innertuple

TupleTableSlot * ecxt_outertuple

TupleTableSlot * last_slot

ExprContext * ps_ExprContext

static TupleTableSlot * ExecCopySlot(TupleTableSlot *dstslot, TupleTableSlot *srcslot)