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

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

47

63

64

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

89{

93

94

95

96

98 "ExecutorState",

100

101

102

103

104

106

108

109

110

111

122

124

126

131

134

137

139

141

143

146

150

152

154

156

158

160

164

166 estate->es_jit = NULL;

167

168

169

170

172

173 return estate;

174}

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191void

193{

194

195

196

197

198

199

201 {

202

203

204

205

207 true);

208

209 }

210

211

213 {

215 estate->es_jit = NULL;

216 }

217

218

220 {

223 }

224

225

226

227

228

230}

231

232

233

234

235

238 Size initBlockSize, Size maxBlockSize)

239{

242

243

245

247

248

252

254

255

256

257

260 "ExprContext",

261 minContextSize,

262 initBlockSize,

263 maxBlockSize);

264

267

270

273

276

278

280

281

282

283

284

285

287

289

290 return econtext;

291}

292

293

294

295

296

297

298

299

300

301

302

303

304

305

308{

310}

311

312

313

314

315

316

317

318

319

320

323{

325

327

328

330

331

333

336}

337

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

358{

360

361

363

364

368

370

371

372

373

376 "ExprContext",

378

381

384

387

390

392

394

395 return econtext;

396}

397

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415void

417{

419

420

422

424

426 if (estate)

428 econtext);

429

431}

432

433

434

435

436

437

438

439

440

441

442void

444{

445

447

449}

450

451

452

453

454

455

456

459{

462

464}

465

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484void

486{

488}

489

490

491

492

493

496{

498}

499

500

501

502

505{

507 {

508 if (isfixed)

511 }

512

513 if (isfixed)

514 {

519 else

520 *isfixed = false;

521 }

522

525

527}

528

529

530

531

532

533

534

537{

539 bool isfixed;

540

541 if (nplans <= 0)

542 return NULL;

544 if (!isfixed)

545 return NULL;

546 for (int i = 1; i < nplans; i++)

547 {

549

551 if (!isfixed)

552 return NULL;

553 if (result != thisops)

554 return NULL;

555 }

556 return result;

557}

558

559

560

561

564{

566

570}

571

572

573

574

575

576

577

578

579

580

581

582void

585{

590 planstate,

591 inputDesc);

592}

593

594

595

596

597

598

599

600

601

602void

604 int varno)

605{

608 varno,

609 inputDesc))

610 {

615 }

616 else

617 {

619 {

624 }

626 }

627}

628

629static bool

631{

632 int numattrs = tupdesc->natts;

633 int attrno;

635

636

637 for (attrno = 1; attrno <= numattrs; attrno++)

638 {

640 Var *var;

641

642 if (tlist_item == NULL)

643 return false;

645 if (!var || IsA(var, Var))

646 return false;

647

651 return false;

652 if (att_tup->attisdropped)

653 return false;

654 if (att_tup->atthasmissing)

655 return false;

656

657

658

659

660

661

662

663

664

665

666

667 if (var->vartype != att_tup->atttypid ||

668 (var->vartypmod != att_tup->atttypmod &&

669 var->vartypmod != -1))

670 return false;

671

672 tlist_item = lnext(tlist, tlist_item);

673 }

674

675 if (tlist_item)

676 return false;

677

678 return true;

679}

680

681

682

683

684

685

686

687

688

689

690

691void

693{

695

697}

698

699

700

701

702

703void

707{

710

713

715}

716

717

718

719

720

721

722

723

724

725

726

727

728bool

730{

732}

733

734

735

736

737

738

739

740

743{

745

746

748

749

750

751

752

753

757 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

758 errmsg("materialized view \"%s\" has not been populated",

760 errhint("Use the REFRESH MATERIALIZED VIEW command.")));

761

762 return rel;

763}

764

765

766

767

768

769

770

771

772void

775{

776

778

779

781

782

784

785

786

787

788

789

790

791

793

794

795

796

797

798

801

802

803

804

805

808}

809

810

811

812

813

814

815

816

817

818

819

820

821

822

823

826{

828

829 Assert(rti > 0 && rti <= estate->es_range_table_size);

830

832 elog(ERROR, "trying to open a pruned relation");

833

835 if (rel == NULL)

836 {

837

839

841

843 {

844

845

846

847

848

849

850

854 }

855 else

856 {

857

858

859

860

861

862 rel = table_open(rte->relid, rte->rellockmode);

863 }

864

866 }

867

868 return rel;

869}

870

871

872

873

874

875

876

877

878

879void

882{

884

887 resultRelationDesc,

888 rti,

889 NULL,

891

896

897

898

899

900

903}

904

905

906

907

908

909void

911{

913

914

915

916

917

920}

921

922

923

924

925

926

927

928

929

930

931

932

933

934

935int

937{

938 int pos;

939

940

941 if (location < 0)

942 return 0;

943

944 if (estate == NULL || estate->es_sourceText == NULL)

945 return 0;

946

948

950}

951

952

953

954

955

956

957

958

959

960

961

962void

966{

968

969

973

975 ecxt_callback->arg = arg;

976

977

980}

981

982

983

984

985

986

987

988void

992{

995

997

998 while ((ecxt_callback = *prev_callback) != NULL)

999 {

1001 {

1002 *prev_callback = ecxt_callback->next;

1003 pfree(ecxt_callback);

1004 }

1005 else

1006 prev_callback = &ecxt_callback->next;

1007 }

1008}

1009

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019static void

1021{

1024

1025

1027 return;

1028

1029

1030

1031

1032

1034

1035

1036

1037

1038 while ((ecxt_callback = econtext->ecxt_callbacks) != NULL)

1039 {

1041 if (isCommit)

1042 ecxt_callback->function(ecxt_callback->arg);

1043 pfree(ecxt_callback);

1044 }

1045

1047}

1048

1049

1050

1051

1052

1053

1054

1055

1056

1057

1058

1059

1062{

1065 Oid tupType;

1066 int32 tupTypmod;

1069 int i;

1070

1072 elog(ERROR, "invalid attribute name");

1073

1074 if (isNull == NULL)

1075 elog(ERROR, "a NULL isNull pointer was passed");

1076

1077 if (tuple == NULL)

1078 {

1079

1080 *isNull = true;

1081 return (Datum) 0;

1082 }

1083

1087

1089 for (i = 0; i < tupDesc->natts; i++)

1090 {

1092

1094 {

1095 attrno = att->attnum;

1096 break;

1097 }

1098 }

1099

1102

1103

1104

1105

1106

1107

1111 tmptup.t_data = tuple;

1112

1114 attrno,

1115 tupDesc,

1116 isNull);

1117

1119

1120 return result;

1121}

1122

1126 bool *isNull)

1127{

1129 Oid tupType;

1130 int32 tupTypmod;

1133

1135 elog(ERROR, "invalid attribute number %d", attrno);

1136

1137 if (isNull == NULL)

1138 elog(ERROR, "a NULL isNull pointer was passed");

1139

1140 if (tuple == NULL)

1141 {

1142

1143 *isNull = true;

1144 return (Datum) 0;

1145 }

1146

1150

1151

1152

1153

1154

1155

1159 tmptup.t_data = tuple;

1160

1162 attrno,

1163 tupDesc,

1164 isNull);

1165

1167

1168 return result;

1169}

1170

1171

1172

1173

1174int

1176{

1177

1179}

1180

1181

1182

1183

1184int

1186{

1187 int len = 0;

1189

1190 foreach(tl, targetlist)

1191 {

1193

1194 if (!curTle->resjunk)

1196 }

1197 return len;

1198}

1199

1200

1201

1202

1205{

1207 {

1210

1215

1217 }

1218

1220}

1221

1222

1223

1224

1227{

1229 {

1232

1237

1239 }

1240

1242}

1243

1244

1245

1246

1249{

1251 {

1254

1259

1261 }

1262

1264}

1265

1266

1267

1268

1269

1270

1271

1274{

1276 {

1280

1285

1287

1289 }

1290

1292}

1293

1294

1295

1296

1297

1298

1301{

1302

1304 {

1306

1307 if (rootRelInfo)

1311 else

1313

1315 }

1316

1318}

1319

1320

1321

1322

1323

1324

1327{

1328

1330

1331

1333 {

1340

1341

1342

1343

1344

1345

1348 !childrel->rd_rel->relispartition);

1349 if (attrMap)

1354 }

1355

1357}

1358

1359

1362{

1364

1365 if (perminfo == NULL)

1366 return NULL;

1367

1368

1370 {

1372

1373 if (map)

1375 }

1376

1378}

1379

1380

1383{

1385

1386 if (perminfo == NULL)

1387 return NULL;

1388

1389

1391 {

1393

1394 if (map)

1396 }

1397

1399}

1400

1401

1404{

1405

1409}

1410

1411

1412

1413

1414

1415

1416

1419{

1422

1424

1427

1429

1430 return ret;

1431}

1432

1433

1434

1435

1436

1439{

1443

1445 {

1446

1447

1448

1449

1450

1451

1453 }

1455 {

1456

1457

1458

1460 }

1461 else

1462 {

1463

1464

1465

1466

1467

1468

1469 rti = 0;

1470 }

1471

1472 if (rti > 0)

1473 {

1476 }

1477

1478 return perminfo;

1479}

1480

1481

1482

1483

1484

1485

1486

1487

1490{

1492

1493

1494 if (perminfo == NULL)

1495 elog(ERROR, "no RTEPermissionInfo found for result relation with OID %u",

1497

1499}

AttrMap * build_attrmap_by_name_if_req(TupleDesc indesc, TupleDesc outdesc, bool missing_ok)

#define AttributeNumberIsValid(attributeNumber)

#define InvalidAttrNumber

Bitmapset * bms_intersect(const Bitmapset *a, const Bitmapset *b)

bool bms_is_member(int x, const Bitmapset *a)

Bitmapset * bms_union(const Bitmapset *a, const Bitmapset *b)

Bitmapset * bms_join(Bitmapset *a, Bitmapset *b)

int errhint(const char *fmt,...)

int errcode(int sqlerrcode)

int errmsg(const char *fmt,...)

int errposition(int cursorpos)

#define ereport(elevel,...)

ProjectionInfo * ExecBuildProjectionInfo(List *targetList, ExprContext *econtext, TupleTableSlot *slot, PlanState *parent, TupleDesc inputDesc)

void InitResultRelInfo(ResultRelInfo *resultRelInfo, Relation resultRelationDesc, Index resultRelationIndex, ResultRelInfo *partition_root_rri, int instrument_options)

const TupleTableSlotOps TTSOpsVirtual

void ExecInitResultSlot(PlanState *planstate, const TupleTableSlotOps *tts_ops)

void ExecInitScanTupleSlot(EState *estate, ScanState *scanstate, TupleDesc tupledesc, const TupleTableSlotOps *tts_ops)

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

void ExecSetSlotDescriptor(TupleTableSlot *slot, TupleDesc tupdesc)

TupleTableSlot * ExecStoreAllNullTuple(TupleTableSlot *slot)

TupleDesc ExecGetResultType(PlanState *planstate)

Relation ExecGetRangeTableRelation(EState *estate, Index rti, bool isResultRel)

TupleConversionMap * ExecGetRootToChildMap(ResultRelInfo *resultRelInfo, EState *estate)

Bitmapset * ExecGetExtraUpdatedCols(ResultRelInfo *relinfo, EState *estate)

static void ShutdownExprContext(ExprContext *econtext, bool isCommit)

Bitmapset * ExecGetInsertedCols(ResultRelInfo *relinfo, EState *estate)

TupleTableSlot * ExecGetTriggerNewSlot(EState *estate, ResultRelInfo *relInfo)

void ReScanExprContext(ExprContext *econtext)

ExprContext * CreateExprContext(EState *estate)

static RTEPermissionInfo * GetResultRTEPermissionInfo(ResultRelInfo *relinfo, EState *estate)

TupleConversionMap * ExecGetChildToRootMap(ResultRelInfo *resultRelInfo)

ExprContext * CreateStandaloneExprContext(void)

TupleTableSlot * ExecGetTriggerOldSlot(EState *estate, ResultRelInfo *relInfo)

int executor_errposition(EState *estate, int location)

Datum GetAttributeByNum(HeapTupleHeader tuple, AttrNumber attrno, bool *isNull)

void FreeExprContext(ExprContext *econtext, bool isCommit)

void ExecInitRangeTable(EState *estate, List *rangeTable, List *permInfos, Bitmapset *unpruned_relids)

static bool tlist_matches_tupdesc(PlanState *ps, List *tlist, int varno, TupleDesc tupdesc)

Bitmapset * ExecGetUpdatedCols(ResultRelInfo *relinfo, EState *estate)

const TupleTableSlotOps * ExecGetCommonSlotOps(PlanState **planstates, int nplans)

void ExecInitResultRelation(EState *estate, ResultRelInfo *resultRelInfo, Index rti)

void ExecCreateScanSlotFromOuterPlan(EState *estate, ScanState *scanstate, const TupleTableSlotOps *tts_ops)

void ExecAssignExprContext(EState *estate, PlanState *planstate)

void ExecAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc)

ExprContext * MakePerTupleExprContext(EState *estate)

void UnregisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)

void ExecAssignScanType(ScanState *scanstate, TupleDesc tupDesc)

const TupleTableSlotOps * ExecGetCommonChildSlotOps(PlanState *ps)

void ExecConditionalAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc, int varno)

void RegisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg)

int ExecTargetListLength(List *targetlist)

void FreeExecutorState(EState *estate)

bool ExecRelationIsTargetRelation(EState *estate, Index scanrelid)

static ExprContext * CreateExprContextInternal(EState *estate, Size minContextSize, Size initBlockSize, Size maxBlockSize)

TupleTableSlot * ExecGetAllNullSlot(EState *estate, ResultRelInfo *relInfo)

int ExecCleanTargetListLength(List *targetlist)

ExprContext * CreateWorkExprContext(EState *estate)

void UpdateChangedParamSet(PlanState *node, Bitmapset *newchg)

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

Datum GetAttributeByName(HeapTupleHeader tuple, const char *attname, bool *isNull)

Bitmapset * ExecGetAllUpdatedCols(ResultRelInfo *relinfo, EState *estate)

TupleTableSlot * ExecGetReturningSlot(EState *estate, ResultRelInfo *relInfo)

Relation ExecOpenScanRelation(EState *estate, Index scanrelid, int eflags)

Oid ExecGetResultRelCheckAsUser(ResultRelInfo *relInfo, EState *estate)

EState * CreateExecutorState(void)

void(* ExprContextCallbackFunction)(Datum arg)

#define outerPlanState(node)

#define innerPlanState(node)

#define EXEC_FLAG_WITH_NO_DATA

static RangeTblEntry * exec_rt_fetch(Index rti, EState *estate)

#define GetPerTupleMemoryContext(estate)

#define EXEC_FLAG_EXPLAIN_ONLY

Assert(PointerIsAligned(start, uint64))

static Datum heap_getattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool *isnull)

static int32 HeapTupleHeaderGetTypMod(const HeapTupleHeaderData *tup)

static uint32 HeapTupleHeaderGetDatumLength(const HeapTupleHeaderData *tup)

static Oid HeapTupleHeaderGetTypeId(const HeapTupleHeaderData *tup)

#define IsParallelWorker()

static void ItemPointerSetInvalid(ItemPointerData *pointer)

void jit_release_context(JitContext *context)

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

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

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

bool list_member_int(const List *list, int datum)

bool CheckRelationLockedByMe(Relation relation, LOCKMODE lockmode, bool orstronger)

int pg_mbstrlen_with_len(const char *mbstr, int limit)

void * MemoryContextAlloc(MemoryContext context, Size size)

void MemoryContextReset(MemoryContext context)

void pfree(void *pointer)

void * palloc0(Size size)

MemoryContext CurrentMemoryContext

void MemoryContextDelete(MemoryContext context)

#define AllocSetContextCreate

#define ALLOCSET_DEFAULT_MAXSIZE

#define ALLOCSET_DEFAULT_MINSIZE

#define ALLOCSET_DEFAULT_SIZES

#define ALLOCSET_DEFAULT_INITSIZE

int namestrcmp(Name name, const char *str)

void ExecInitGenerated(ResultRelInfo *resultRelInfo, EState *estate, CmdType cmdtype)

#define IsA(nodeptr, _type_)

static MemoryContext MemoryContextSwitchTo(MemoryContext context)

RTEPermissionInfo * getRTEPermissionInfo(List *rteperminfos, RangeTblEntry *rte)

void DestroyPartitionDirectory(PartitionDirectory pdir)

FormData_pg_attribute * Form_pg_attribute

on_exit_nicely_callback function

#define pg_prevpower2_size_t

#define lfirst_node(type, lc)

static int list_length(const List *l)

static ListCell * list_head(const List *l)

static ListCell * lnext(const List *l, const ListCell *c)

#define RelationGetRelid(relation)

#define RelationIsScannable(relation)

#define RelationGetDescr(relation)

#define RelationGetRelationName(relation)

List * es_part_prune_infos

struct ExecRowMark ** es_rowmarks

int es_parallel_workers_to_launch

List * es_tuple_routing_result_relations

struct JitContext * es_jit

PlannedStmt * es_plannedstmt

QueryEnvironment * es_queryEnv

ResultRelInfo ** es_result_relations

ParamExecData * es_param_exec_vals

uint64 es_total_processed

Bitmapset * es_unpruned_relids

ParamListInfo es_param_list_info

List * es_insert_pending_result_relations

MemoryContext es_query_cxt

ScanDirection es_direction

PartitionDirectory es_partition_directory

List * es_trig_target_relations

List * es_opened_result_relations

bool es_use_parallel_mode

ExprContext * es_per_tuple_exprcontext

int es_parallel_workers_launched

Index es_range_table_size

List * es_insert_pending_modifytables

const char * es_sourceText

List * es_auxmodifytables

JunkFilter * es_junkFilter

Snapshot es_crosscheck_snapshot

struct ExprContext_CB * next

ExprContextCallbackFunction function

ParamListInfo ecxt_param_list_info

MemoryContext ecxt_per_tuple_memory

TupleTableSlot * ecxt_innertuple

ParamExecData * ecxt_param_exec_vals

TupleTableSlot * ecxt_scantuple

MemoryContext ecxt_per_query_memory

ExprContext_CB * ecxt_callbacks

struct EState * ecxt_estate

TupleTableSlot * ecxt_outertuple

const TupleTableSlotOps * resultops

const TupleTableSlotOps * scanops

TupleDesc ps_ResultTupleDesc

ExprContext * ps_ExprContext

TupleTableSlot * ps_ResultTupleSlot

ProjectionInfo * ps_ProjInfo

TupleConversionMap * ri_RootToChildMap

struct ResultRelInfo * ri_RootResultRelInfo

TupleTableSlot * ri_ReturningSlot

bool ri_extraUpdatedCols_valid

bool ri_RootToChildMapValid

TupleTableSlot * ri_AllNullSlot

Bitmapset * ri_extraUpdatedCols

TupleConversionMap * ri_ChildToRootMap

bool ri_ChildToRootMapValid

TupleTableSlot * ri_TrigNewSlot

TupleTableSlot * ri_TrigOldSlot

TupleTableSlot * ss_ScanTupleSlot

const TupleTableSlotOps *const tts_ops

Relation table_open(Oid relationId, LOCKMODE lockmode)

const TupleTableSlotOps * table_slot_callbacks(Relation relation)

TupleConversionMap * convert_tuples_by_name(TupleDesc indesc, TupleDesc outdesc)

TupleConversionMap * convert_tuples_by_name_attrmap(TupleDesc indesc, TupleDesc outdesc, AttrMap *attrMap)

Bitmapset * execute_attr_map_cols(AttrMap *attrMap, Bitmapset *in_cols)

#define ReleaseTupleDesc(tupdesc)

static FormData_pg_attribute * TupleDescAttr(TupleDesc tupdesc, int i)

TupleDesc lookup_rowtype_tupdesc(Oid type_id, int32 typmod)