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

151

153

155

157

159

161

165

167 estate->es_jit = NULL;

168

169

170

171

173

174 return estate;

175}

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192void

194{

195

196

197

198

199

200

202 {

203

204

205

206

208 true);

209

210 }

211

212

214 {

216 estate->es_jit = NULL;

217 }

218

219

221 {

224 }

225

226

227

228

229

231}

232

233

234

235

236

239 Size initBlockSize, Size maxBlockSize)

240{

243

244

246

248

249

253

255

256

257

258

261 "ExprContext",

262 minContextSize,

263 initBlockSize,

264 maxBlockSize);

265

268

271

274

277

279

281

282

283

284

285

286

288

290

291 return econtext;

292}

293

294

295

296

297

298

299

300

301

302

303

304

305

306

309{

311}

312

313

314

315

316

317

318

319

320

321

324{

326

328

329

331

332

334

337}

338

339

340

341

342

343

344

345

346

347

348

349

350

351

352

353

354

355

356

359{

361

362

364

365

369

371

372

373

374

377 "ExprContext",

379

382

385

388

391

393

395

396 return econtext;

397}

398

399

400

401

402

403

404

405

406

407

408

409

410

411

412

413

414

415

416void

418{

420

421

423

425

427 if (estate)

429 econtext);

430

432}

433

434

435

436

437

438

439

440

441

442

443void

445{

446

448

450}

451

452

453

454

455

456

457

460{

463

465}

466

467

468

469

470

471

472

473

474

475

476

477

478

479

480

481

482

483

484

485void

487{

489}

490

491

492

493

494

497{

499}

500

501

502

503

506{

508 {

509 if (isfixed)

512 }

513

514 if (isfixed)

515 {

520 else

521 *isfixed = false;

522 }

523

526

528}

529

530

531

532

533

534

535

538{

540 bool isfixed;

541

542 if (nplans <= 0)

543 return NULL;

545 if (!isfixed)

546 return NULL;

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

548 {

550

552 if (!isfixed)

553 return NULL;

554 if (result != thisops)

555 return NULL;

556 }

557 return result;

558}

559

560

561

562

565{

567

571}

572

573

574

575

576

577

578

579

580

581

582

583void

586{

591 planstate,

592 inputDesc);

593}

594

595

596

597

598

599

600

601

602

603void

605 int varno)

606{

609 varno,

610 inputDesc))

611 {

616 }

617 else

618 {

620 {

625 }

627 }

628}

629

630static bool

632{

633 int numattrs = tupdesc->natts;

634 int attrno;

636

637

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

639 {

641 Var *var;

642

643 if (tlist_item == NULL)

644 return false;

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

647 return false;

648

652 return false;

653 if (att_tup->attisdropped)

654 return false;

655 if (att_tup->atthasmissing)

656 return false;

657

658

659

660

661

662

663

664

665

666

667

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

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

670 var->vartypmod != -1))

671 return false;

672

673 tlist_item = lnext(tlist, tlist_item);

674 }

675

676 if (tlist_item)

677 return false;

678

679 return true;

680}

681

682

683

684

685

686

687

688

689

690

691

692void

694{

696

698}

699

700

701

702

703

704void

708{

711

714

716}

717

718

719

720

721

722

723

724

725

726

727

728

729bool

731{

733}

734

735

736

737

738

739

740

741

744{

746

747

749

750

751

752

753

754

758 (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),

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

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

762

763 return rel;

764}

765

766

767

768

769

770

771

772

773void

776{

777

779

780

782

783

785

786

787

788

789

790

791

792

794

795

796

797

798

799

802

803

804

805

806

809}

810

811

812

813

814

815

816

817

818

819

820

821

822

823

824

827{

829

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

831

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

834

836 if (rel == NULL)

837 {

838

840

842

844 {

845

846

847

848

849

850

851

855 }

856 else

857 {

858

859

860

861

862

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

864 }

865

867 }

868

869 return rel;

870}

871

872

873

874

875

876

877

878

879

880void

883{

885

888 resultRelationDesc,

889 rti,

890 NULL,

892

897

898

899

900

901

904}

905

906

907

908

909

910void

912{

914

915

916

917

918

921}

922

923

924

925

926

927

928

929

930

931

932

933

934

935

936int

938{

939 int pos;

940

941

942 if (location < 0)

943 return 0;

944

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

946 return 0;

947

949

951}

952

953

954

955

956

957

958

959

960

961

962

963void

967{

969

970

974

976 ecxt_callback->arg = arg;

977

978

981}

982

983

984

985

986

987

988

989void

993{

996

998

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

1000 {

1002 {

1003 *prev_callback = ecxt_callback->next;

1004 pfree(ecxt_callback);

1005 }

1006 else

1007 prev_callback = &ecxt_callback->next;

1008 }

1009}

1010

1011

1012

1013

1014

1015

1016

1017

1018

1019

1020static void

1022{

1025

1026

1028 return;

1029

1030

1031

1032

1033

1035

1036

1037

1038

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

1040 {

1042 if (isCommit)

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

1044 pfree(ecxt_callback);

1045 }

1046

1048}

1049

1050

1051

1052

1053

1054

1055

1056

1057

1058

1059

1060

1063{

1066 Oid tupType;

1067 int32 tupTypmod;

1070 int i;

1071

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

1074

1075 if (isNull == NULL)

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

1077

1078 if (tuple == NULL)

1079 {

1080

1081 *isNull = true;

1082 return (Datum) 0;

1083 }

1084

1088

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

1091 {

1093

1095 {

1096 attrno = att->attnum;

1097 break;

1098 }

1099 }

1100

1103

1104

1105

1106

1107

1108

1112 tmptup.t_data = tuple;

1113

1115 attrno,

1116 tupDesc,

1117 isNull);

1118

1120

1121 return result;

1122}

1123

1127 bool *isNull)

1128{

1130 Oid tupType;

1131 int32 tupTypmod;

1134

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

1137

1138 if (isNull == NULL)

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

1140

1141 if (tuple == NULL)

1142 {

1143

1144 *isNull = true;

1145 return (Datum) 0;

1146 }

1147

1151

1152

1153

1154

1155

1156

1160 tmptup.t_data = tuple;

1161

1163 attrno,

1164 tupDesc,

1165 isNull);

1166

1168

1169 return result;

1170}

1171

1172

1173

1174

1175int

1177{

1178

1180}

1181

1182

1183

1184

1185int

1187{

1188 int len = 0;

1190

1191 foreach(tl, targetlist)

1192 {

1194

1195 if (!curTle->resjunk)

1197 }

1198 return len;

1199}

1200

1201

1202

1203

1206{

1208 {

1211

1216

1218 }

1219

1221}

1222

1223

1224

1225

1228{

1230 {

1233

1238

1240 }

1241

1243}

1244

1245

1246

1247

1250{

1252 {

1255

1260

1262 }

1263

1265}

1266

1267

1268

1269

1270

1271

1272

1275{

1277 {

1281

1286

1288

1290 }

1291

1293}

1294

1295

1296

1297

1298

1299

1302{

1303

1305 {

1307

1308 if (rootRelInfo)

1312 else

1314

1316 }

1317

1319}

1320

1321

1322

1323

1324

1325

1328{

1329

1331

1332

1334 {

1341

1342

1343

1344

1345

1346

1349 !childrel->rd_rel->relispartition);

1350 if (attrMap)

1355 }

1356

1358}

1359

1360

1363{

1365

1366 if (perminfo == NULL)

1367 return NULL;

1368

1369

1371 {

1373

1374 if (map)

1376 }

1377

1379}

1380

1381

1384{

1386

1387 if (perminfo == NULL)

1388 return NULL;

1389

1390

1392 {

1394

1395 if (map)

1397 }

1398

1400}

1401

1402

1405{

1406

1410}

1411

1412

1413

1414

1415

1416

1417

1420{

1423

1425

1428

1430

1431 return ret;

1432}

1433

1434

1435

1436

1437

1440{

1444

1446 {

1447

1448

1449

1450

1451

1452

1454 }

1456 {

1457

1458

1459

1461 }

1462 else

1463 {

1464

1465

1466

1467

1468

1469

1470 rti = 0;

1471 }

1472

1473 if (rti > 0)

1474 {

1477 }

1478

1479 return perminfo;

1480}

1481

1482

1483

1484

1485

1486

1487

1488

1491{

1493

1494

1495 if (perminfo == NULL)

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

1498

1500}

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)