Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee33b95

Browse files
committed
Improve the plan cache invalidation mechanism to make it invalidate plans
when user-defined functions used in a plan are modified. Also invalidateplans when schemas, operators, or operator classes are modified; but for thesecases we just invalidate everything rather than tracking exact dependencies,since these types of objects seldom change in a production database.Tom Lane; loosely based on a patch by Martin Pihlak.
1 parentc06629c commitee33b95

File tree

18 files changed

+521
-274
lines changed

18 files changed

+521
-274
lines changed

‎src/backend/catalog/namespace.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
1515
* IDENTIFICATION
16-
* $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.111 2008/09/01 20:42:43 tgl Exp $
16+
* $PostgreSQL: pgsql/src/backend/catalog/namespace.c,v 1.112 2008/09/09 18:58:08 tgl Exp $
1717
*
1818
*-------------------------------------------------------------------------
1919
*/
@@ -187,7 +187,7 @@ static void recomputeNamespacePath(void);
187187
staticvoidInitTempTableNamespace(void);
188188
staticvoidRemoveTempRelations(OidtempNamespaceId);
189189
staticvoidRemoveTempRelationsCallback(intcode,Datumarg);
190-
staticvoidNamespaceCallback(Datumarg,Oidrelid);
190+
staticvoidNamespaceCallback(Datumarg,intcacheid,ItemPointertuplePtr);
191191

192192
/* These don't really need to appear in any header file */
193193
Datumpg_table_is_visible(PG_FUNCTION_ARGS);
@@ -3094,7 +3094,7 @@ InitializeSearchPath(void)
30943094
*Syscache inval callback function
30953095
*/
30963096
staticvoid
3097-
NamespaceCallback(Datumarg,Oidrelid)
3097+
NamespaceCallback(Datumarg,intcacheid,ItemPointertuplePtr)
30983098
{
30993099
/* Force search path to be recomputed on next use */
31003100
baseSearchPathValid= false;

‎src/backend/nodes/copyfuncs.c

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* Portions Copyright (c) 1994, Regents of the University of California
1616
*
1717
* IDENTIFICATION
18-
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.404 2008/09/01 20:42:44 tgl Exp $
18+
* $PostgreSQL: pgsql/src/backend/nodes/copyfuncs.c,v 1.405 2008/09/09 18:58:08 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -88,6 +88,7 @@ _copyPlannedStmt(PlannedStmt *from)
8888
COPY_NODE_FIELD(returningLists);
8989
COPY_NODE_FIELD(rowMarks);
9090
COPY_NODE_FIELD(relationOids);
91+
COPY_NODE_FIELD(invalItems);
9192
COPY_SCALAR_FIELD(nParamExec);
9293

9394
returnnewnode;
@@ -689,6 +690,21 @@ _copyLimit(Limit *from)
689690
returnnewnode;
690691
}
691692

693+
/*
694+
* _copyPlanInvalItem
695+
*/
696+
staticPlanInvalItem*
697+
_copyPlanInvalItem(PlanInvalItem*from)
698+
{
699+
PlanInvalItem*newnode=makeNode(PlanInvalItem);
700+
701+
COPY_SCALAR_FIELD(cacheId);
702+
/* tupleId isn't really a "scalar", but this works anyway */
703+
COPY_SCALAR_FIELD(tupleId);
704+
705+
returnnewnode;
706+
}
707+
692708
/* ****************************************************************
693709
* primnodes.h copy functions
694710
* ****************************************************************
@@ -3157,6 +3173,9 @@ copyObject(void *from)
31573173
caseT_Limit:
31583174
retval=_copyLimit(from);
31593175
break;
3176+
caseT_PlanInvalItem:
3177+
retval=_copyPlanInvalItem(from);
3178+
break;
31603179

31613180
/*
31623181
* PRIMITIVE NODES

‎src/backend/nodes/outfuncs.c

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.338 2008/09/01 20:42:44 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/nodes/outfuncs.c,v 1.339 2008/09/09 18:58:08 tgl Exp $
1212
*
1313
* NOTES
1414
* Every node type that can appear in stored rules' parsetrees *must*
@@ -255,6 +255,7 @@ _outPlannedStmt(StringInfo str, PlannedStmt *node)
255255
WRITE_NODE_FIELD(returningLists);
256256
WRITE_NODE_FIELD(rowMarks);
257257
WRITE_NODE_FIELD(relationOids);
258+
WRITE_NODE_FIELD(invalItems);
258259
WRITE_INT_FIELD(nParamExec);
259260
}
260261

@@ -593,6 +594,14 @@ _outUnique(StringInfo str, Unique *node)
593594
appendStringInfo(str," %u",node->uniqOperators[i]);
594595
}
595596

597+
staticvoid
598+
_outHash(StringInfostr,Hash*node)
599+
{
600+
WRITE_NODE_TYPE("HASH");
601+
602+
_outPlanInfo(str, (Plan*)node);
603+
}
604+
596605
staticvoid
597606
_outSetOp(StringInfostr,SetOp*node)
598607
{
@@ -631,11 +640,14 @@ _outLimit(StringInfo str, Limit *node)
631640
}
632641

633642
staticvoid
634-
_outHash(StringInfostr,Hash*node)
643+
_outPlanInvalItem(StringInfostr,PlanInvalItem*node)
635644
{
636-
WRITE_NODE_TYPE("HASH");
645+
WRITE_NODE_TYPE("PLANINVALITEM");
637646

638-
_outPlanInfo(str, (Plan*)node);
647+
WRITE_INT_FIELD(cacheId);
648+
appendStringInfo(str," :tupleId (%u,%u)",
649+
ItemPointerGetBlockNumber(&node->tupleId),
650+
ItemPointerGetOffsetNumber(&node->tupleId));
639651
}
640652

641653
/*****************************************************************************
@@ -1354,6 +1366,7 @@ _outPlannerGlobal(StringInfo str, PlannerGlobal *node)
13541366
WRITE_BITMAPSET_FIELD(rewindPlanIDs);
13551367
WRITE_NODE_FIELD(finalrtable);
13561368
WRITE_NODE_FIELD(relationOids);
1369+
WRITE_NODE_FIELD(invalItems);
13571370
}
13581371

13591372
staticvoid
@@ -2206,14 +2219,17 @@ _outNode(StringInfo str, void *obj)
22062219
caseT_Unique:
22072220
_outUnique(str,obj);
22082221
break;
2222+
caseT_Hash:
2223+
_outHash(str,obj);
2224+
break;
22092225
caseT_SetOp:
22102226
_outSetOp(str,obj);
22112227
break;
22122228
caseT_Limit:
22132229
_outLimit(str,obj);
22142230
break;
2215-
caseT_Hash:
2216-
_outHash(str,obj);
2231+
caseT_PlanInvalItem:
2232+
_outPlanInvalItem(str,obj);
22172233
break;
22182234
caseT_Alias:
22192235
_outAlias(str,obj);

‎src/backend/optimizer/plan/planner.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.242 2008/08/17 01:19:59 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/optimizer/plan/planner.c,v 1.243 2008/09/09 18:58:08 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -140,6 +140,7 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
140140
glob->rewindPlanIDs=NULL;
141141
glob->finalrtable=NIL;
142142
glob->relationOids=NIL;
143+
glob->invalItems=NIL;
143144
glob->transientPlan= false;
144145

145146
/* Determine what fraction of the plan is likely to be scanned */
@@ -213,6 +214,7 @@ standard_planner(Query *parse, int cursorOptions, ParamListInfo boundParams)
213214
result->returningLists=root->returningLists;
214215
result->rowMarks=parse->rowMarks;
215216
result->relationOids=glob->relationOids;
217+
result->invalItems=glob->invalItems;
216218
result->nParamExec=list_length(glob->paramlist);
217219

218220
returnresult;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp