Skip to content

Commit e2c0070

Browse files
committed
Back out cleanup patch. Got old version and needs work.
Neil Conway
1 parent ed275ae commit e2c0070

File tree

13 files changed

+98
-125
lines changed

13 files changed

+98
-125
lines changed

src/backend/executor/execMain.c

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*
2828
*
2929
* IDENTIFICATION
30-
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.166 2002/06/25 17:27:20 momjian Exp $
30+
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.167 2002/06/25 17:58:10 momjian Exp $
3131
*
3232
*-------------------------------------------------------------------------
3333
*/
@@ -62,14 +62,14 @@ static TupleTableSlot *ExecutePlan(EState *estate, Plan *plan,
6262
long numberTuples,
6363
ScanDirection direction,
6464
DestReceiver *destfunc);
65-
static void ExecSelect(TupleTableSlot *slot,
65+
static void ExecRetrieve(TupleTableSlot *slot,
6666
DestReceiver *destfunc,
6767
EState *estate);
68-
static void ExecInsert(TupleTableSlot *slot, ItemPointer tupleid,
68+
static void ExecAppend(TupleTableSlot *slot, ItemPointer tupleid,
6969
EState *estate);
7070
static void ExecDelete(TupleTableSlot *slot, ItemPointer tupleid,
7171
EState *estate);
72-
static void ExecUpdate(TupleTableSlot *slot, ItemPointer tupleid,
72+
static void ExecReplace(TupleTableSlot *slot, ItemPointer tupleid,
7373
EState *estate);
7474
static TupleTableSlot *EvalPlanQualNext(EState *estate);
7575
static void EndEvalPlanQual(EState *estate);
@@ -251,7 +251,7 @@ ExecCheckQueryPerms(CmdType operation, Query *parseTree, Plan *plan)
251251
ExecCheckRTPerms(parseTree->rtable, operation);
252252

253253
/*
254-
* Search for subplans and INSERT nodes to check their rangetables.
254+
* Search for subplans and APPEND nodes to check their rangetables.
255255
*/
256256
ExecCheckPlanPerms(plan, parseTree->rtable, operation);
257257
}
@@ -583,7 +583,7 @@ InitPlan(CmdType operation, Query *parseTree, Plan *plan, EState *estate)
583583
/*
584584
* Get the tuple descriptor describing the type of tuples to return.
585585
* (this is especially important if we are creating a relation with
586-
* "SELECT INTO")
586+
* "retrieve into")
587587
*/
588588
tupType = ExecGetTupType(plan); /* tuple descriptor */
589589

@@ -892,7 +892,7 @@ EndPlan(Plan *plan, EState *estate)
892892
* Retrieves all tuples if numberTuples is 0
893893
*
894894
* result is either a slot containing the last tuple in the case
895-
* of a SELECT or NULL otherwise.
895+
* of a RETRIEVE or NULL otherwise.
896896
*
897897
* Note: the ctid attribute is a 'junk' attribute that is removed before the
898898
* user can see it
@@ -1068,26 +1068,29 @@ lnext: ;
10681068

10691069
slot = ExecStoreTuple(newTuple, /* tuple to store */
10701070
junkfilter->jf_resultSlot, /* dest slot */
1071-
InvalidBuffer, /* this tuple has no buffer */
1071+
InvalidBuffer, /* this tuple has no
1072+
* buffer */
10721073
true); /* tuple should be pfreed */
1073-
}
1074+
} /* if (junkfilter... */
10741075

10751076
/*
10761077
* now that we have a tuple, do the appropriate thing with it..
10771078
* either return it to the user, add it to a relation someplace,
10781079
* delete it from a relation, or modify some of its attributes.
10791080
*/
1081+
10801082
switch (operation)
10811083
{
10821084
case CMD_SELECT:
1083-
ExecSelect(slot, /* slot containing tuple */
1084-
destfunc, /* destination's tuple-receiver obj */
1085-
estate);
1085+
ExecRetrieve(slot, /* slot containing tuple */
1086+
destfunc, /* destination's tuple-receiver
1087+
* obj */
1088+
estate); /* */
10861089
result = slot;
10871090
break;
10881091

10891092
case CMD_INSERT:
1090-
ExecInsert(slot, tupleid, estate);
1093+
ExecAppend(slot, tupleid, estate);
10911094
result = NULL;
10921095
break;
10931096

@@ -1097,7 +1100,7 @@ lnext: ;
10971100
break;
10981101

10991102
case CMD_UPDATE:
1100-
ExecUpdate(slot, tupleid, estate);
1103+
ExecReplace(slot, tupleid, estate);
11011104
result = NULL;
11021105
break;
11031106

@@ -1118,25 +1121,25 @@ lnext: ;
11181121

11191122
/*
11201123
* here, result is either a slot containing a tuple in the case of a
1121-
* SELECT or NULL otherwise.
1124+
* RETRIEVE or NULL otherwise.
11221125
*/
11231126
return result;
11241127
}
11251128

11261129
/* ----------------------------------------------------------------
1127-
* ExecSelect
1130+
* ExecRetrieve
11281131
*
1129-
* SELECTs are easy.. we just pass the tuple to the appropriate
1132+
* RETRIEVEs are easy.. we just pass the tuple to the appropriate
11301133
* print function. The only complexity is when we do a
1131-
* "SELECT INTO", in which case we insert the tuple into
1134+
* "retrieve into", in which case we insert the tuple into
11321135
* the appropriate relation (note: this is a newly created relation
11331136
* so we don't need to worry about indices or locks.)
11341137
* ----------------------------------------------------------------
11351138
*/
11361139
static void
1137-
ExecSelect(TupleTableSlot *slot,
1138-
DestReceiver *destfunc,
1139-
EState *estate)
1140+
ExecRetrieve(TupleTableSlot *slot,
1141+
DestReceiver *destfunc,
1142+
EState *estate)
11401143
{
11411144
HeapTuple tuple;
11421145
TupleDesc attrtype;
@@ -1166,15 +1169,16 @@ ExecSelect(TupleTableSlot *slot,
11661169
}
11671170

11681171
/* ----------------------------------------------------------------
1169-
* ExecInsert
1172+
* ExecAppend
11701173
*
1171-
* INSERTs are trickier.. we have to insert the tuple into
1174+
* APPENDs are trickier.. we have to insert the tuple into
11721175
* the base relation and insert appropriate tuples into the
11731176
* index relations.
11741177
* ----------------------------------------------------------------
11751178
*/
1179+
11761180
static void
1177-
ExecInsert(TupleTableSlot *slot,
1181+
ExecAppend(TupleTableSlot *slot,
11781182
ItemPointer tupleid,
11791183
EState *estate)
11801184
{
@@ -1223,7 +1227,7 @@ ExecInsert(TupleTableSlot *slot,
12231227
* Check the constraints of the tuple
12241228
*/
12251229
if (resultRelationDesc->rd_att->constr)
1226-
ExecConstraints("ExecInsert", resultRelInfo, slot, estate);
1230+
ExecConstraints("ExecAppend", resultRelInfo, slot, estate);
12271231

12281232
/*
12291233
* insert the tuple
@@ -1255,7 +1259,7 @@ ExecInsert(TupleTableSlot *slot,
12551259
/* ----------------------------------------------------------------
12561260
* ExecDelete
12571261
*
1258-
* DELETE is like UPDATE, we delete the tuple and its
1262+
* DELETE is like append, we delete the tuple and its
12591263
* index tuples.
12601264
* ----------------------------------------------------------------
12611265
*/
@@ -1342,18 +1346,18 @@ ldelete:;
13421346
}
13431347

13441348
/* ----------------------------------------------------------------
1345-
* ExecUpdate
1349+
* ExecReplace
13461350
*
1347-
* note: we can't run UPDATE queries with transactions
1348-
* off because UPDATEs are actually INSERTs and our
1349-
* scan will mistakenly loop forever, updating the tuple
1350-
* it just inserted.. This should be fixed but until it
1351+
* note: we can't run replace queries with transactions
1352+
* off because replaces are actually appends and our
1353+
* scan will mistakenly loop forever, replacing the tuple
1354+
* it just appended.. This should be fixed but until it
13511355
* is, we don't want to get stuck in an infinite loop
13521356
* which corrupts your database..
13531357
* ----------------------------------------------------------------
13541358
*/
13551359
static void
1356-
ExecUpdate(TupleTableSlot *slot,
1360+
ExecReplace(TupleTableSlot *slot,
13571361
ItemPointer tupleid,
13581362
EState *estate)
13591363
{
@@ -1369,7 +1373,7 @@ ExecUpdate(TupleTableSlot *slot,
13691373
*/
13701374
if (IsBootstrapProcessingMode())
13711375
{
1372-
elog(WARNING, "ExecUpdate: UPDATE can't run without transactions");
1376+
elog(WARNING, "ExecReplace: replace can't run without transactions");
13731377
return;
13741378
}
13751379

@@ -1420,7 +1424,7 @@ ExecUpdate(TupleTableSlot *slot,
14201424
*/
14211425
lreplace:;
14221426
if (resultRelationDesc->rd_att->constr)
1423-
ExecConstraints("ExecUpdate", resultRelInfo, slot, estate);
1427+
ExecConstraints("ExecReplace", resultRelInfo, slot, estate);
14241428

14251429
/*
14261430
* replace the heap tuple
@@ -1468,7 +1472,7 @@ lreplace:;
14681472
/*
14691473
* Note: instead of having to update the old index tuples associated
14701474
* with the heap tuple, all we do is form and insert new index tuples.
1471-
* This is because UPDATEs are actually DELETEs and INSERTs and index
1475+
* This is because replaces are actually deletes and inserts and index
14721476
* tuple deletion is done automagically by the vacuum daemon. All we
14731477
* do is insert new index tuples. -cim 9/27/89
14741478
*/
@@ -1477,7 +1481,7 @@ lreplace:;
14771481
* process indices
14781482
*
14791483
* heap_update updates a tuple in the base relation by invalidating it
1480-
* and then inserting a new tuple to the relation. As a side effect,
1484+
* and then appending a new tuple to the relation. As a side effect,
14811485
* the tupleid of the new tuple is placed in the new tuple's t_ctid
14821486
* field. So we now insert index tuples using the new tupleid stored
14831487
* there.
@@ -1550,7 +1554,7 @@ ExecRelCheck(ResultRelInfo *resultRelInfo,
15501554
}
15511555

15521556
void
1553-
ExecConstraints(const char *caller, ResultRelInfo *resultRelInfo,
1557+
ExecConstraints(char *caller, ResultRelInfo *resultRelInfo,
15541558
TupleTableSlot *slot, EState *estate)
15551559
{
15561560
Relation rel = resultRelInfo->ri_RelationDesc;

src/backend/executor/execUtils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.84 2002/06/25 17:27:20 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.85 2002/06/25 17:58:10 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -18,7 +18,7 @@
1818
*
1919
* ExecOpenIndices \
2020
* ExecCloseIndices | referenced by InitPlan, EndPlan,
21-
* ExecInsertIndexTuples / ExecInsert, ExecUpdate
21+
* ExecInsertIndexTuples / ExecAppend, ExecReplace
2222
*
2323
* RegisterExprContextCallback Register function shutdown callback
2424
* UnregisterExprContextCallback Deregister function shutdown callback

src/backend/optimizer/path/costsize.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
* Portions Copyright (c) 1994, Regents of the University of California
4343
*
4444
* IDENTIFICATION
45-
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.86 2002/06/25 17:27:20 momjian Exp $
45+
* $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.87 2002/06/25 17:58:10 momjian Exp $
4646
*
4747
*-------------------------------------------------------------------------
4848
*/
@@ -154,11 +154,11 @@ cost_seqscan(Path *path, Query *root,
154154
*
155155
* Given a guesstimated cache size, we estimate the actual I/O cost per page
156156
* with the entirely ad-hoc equations:
157-
* if relpages >= effective_cache_size:
158-
* random_page_cost * (1 - (effective_cache_size/relpages)/2)
159-
* if relpages < effective_cache_size:
160-
* 1 + (random_page_cost/2-1) * (relpages/effective_cache_size) ** 2
161-
* These give the right asymptotic behavior (=> 1.0 as relpages becomes
157+
* for rel_size <= effective_cache_size:
158+
* 1 + (random_page_cost/2-1) * (rel_size/effective_cache_size) ** 2
159+
* for rel_size >= effective_cache_size:
160+
* random_page_cost * (1 - (effective_cache_size/rel_size)/2)
161+
* These give the right asymptotic behavior (=> 1.0 as rel_size becomes
162162
* small, => random_page_cost as it becomes large) and meet in the middle
163163
* with the estimate that the cache is about 50% effective for a relation
164164
* of the same size as effective_cache_size. (XXX this is probably all

src/backend/optimizer/prep/_deadcode/prepkeyset.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*-------------------------------------------------------------------------
22
*
33
* prepkeyset.c
4-
* Special preparation for keyset queries (KSQO).
4+
* Special preperation for keyset queries.
55
*
66
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
@@ -14,6 +14,12 @@
1414
#include "postgres.h"
1515
#include "optimizer/planmain.h"
1616

17+
/*
18+
* Node_Copy
19+
* a macro to simplify calling of copyObject on the specified field
20+
*/
21+
#define Node_Copy(from, newnode, field) newnode->field = copyObject(from->field)
22+
1723
bool _use_keyset_query_optimizer = FALSE;
1824

1925
#ifdef ENABLE_KEY_SET_QUERY
@@ -49,20 +55,13 @@ static int TotalExpr;
4955
* a HAVING, or a GROUP BY. It must be a single table and have KSQO
5056
* set to 'on'.
5157
*
52-
* The primary use of this transformation is to avoid the exponential
58+
* The primary use of this transformation is to avoid the exponrntial
5359
* memory consumption of cnfify() and to make use of index access
5460
* methods.
5561
*
5662
* daveh@insightdist.com 1998-08-31
5763
*
5864
* May want to also prune out duplicate terms.
59-
*
60-
* XXX: this code is currently not compiled because it has not been
61-
* updated to work with the re-implementation of UNION/INTERSECT/EXCEPT
62-
* in PostgreSQL 7.1. However, it is of questionable value in any
63-
* case, because it changes the semantics of the original query:
64-
* UNION will add an implicit SELECT DISTINCT, which might change
65-
* the results that are returned.
6665
**********************************************************************/
6766
void
6867
transformKeySetQuery(Query *origNode)

src/include/executor/executor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: executor.h,v 1.67 2002/06/25 17:27:20 momjian Exp $
10+
* $Id: executor.h,v 1.68 2002/06/25 17:58:10 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -52,7 +52,7 @@ extern TupleDesc ExecutorStart(QueryDesc *queryDesc, EState *estate);
5252
extern TupleTableSlot *ExecutorRun(QueryDesc *queryDesc, EState *estate,
5353
ScanDirection direction, long count);
5454
extern void ExecutorEnd(QueryDesc *queryDesc, EState *estate);
55-
extern void ExecConstraints(const char *caller, ResultRelInfo *resultRelInfo,
55+
extern void ExecConstraints(char *caller, ResultRelInfo *resultRelInfo,
5656
TupleTableSlot *slot, EState *estate);
5757
extern TupleTableSlot *EvalPlanQual(EState *estate, Index rti,
5858
ItemPointer tid);

0 commit comments

Comments
 (0)