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

Commitef590e1

Browse files
Jan WieckJan Wieck
Jan Wieck
authored and
Jan Wieck
committed
Changed ExecConstraints() and ExecRelCheck() to cache the constraints
qualification expression trees in the execution state. Prevents frommemory exhaustion on INSERT, UPDATE or COPY to tables that have CHECKconstraints. Speedup against the variant using freeObject() is more thanfactor 2.Jan
1 parentdd4a357 commitef590e1

File tree

4 files changed

+27
-14
lines changed

4 files changed

+27
-14
lines changed

‎src/backend/commands/copy.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.71 1999/02/03 21:16:03 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.72 1999/02/0716:17:10 wieck Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -505,6 +505,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
505505
Node**indexPred=NULL;
506506
TupleDescrtupdesc;
507507
ExprContext*econtext=NULL;
508+
EState*estate=makeNode(EState);/* for ExecConstraints() */
508509

509510
#ifndefOMIT_PARTIAL_INDEX
510511
TupleTabletupleTable;
@@ -805,7 +806,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
805806
*/
806807

807808
if (rel->rd_att->constr)
808-
ExecConstraints("CopyFrom",rel,tuple);
809+
ExecConstraints("CopyFrom",rel,tuple,estate);
809810

810811
heap_insert(rel,tuple);
811812

‎src/backend/executor/execMain.c

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
*
2727
*
2828
* IDENTIFICATION
29-
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.74 1999/02/0714:20:11 wieck Exp $
29+
* $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.75 1999/02/0716:17:11 wieck Exp $
3030
*
3131
*-------------------------------------------------------------------------
3232
*/
@@ -1124,7 +1124,7 @@ ExecAppend(TupleTableSlot *slot,
11241124

11251125
if (resultRelationDesc->rd_att->constr)
11261126
{
1127-
ExecConstraints("ExecAppend",resultRelationDesc,tuple);
1127+
ExecConstraints("ExecAppend",resultRelationDesc,tuple,estate);
11281128
}
11291129

11301130
/******************
@@ -1327,7 +1327,7 @@ ExecReplace(TupleTableSlot *slot,
13271327

13281328
if (resultRelationDesc->rd_att->constr)
13291329
{
1330-
ExecConstraints("ExecReplace",resultRelationDesc,tuple);
1330+
ExecConstraints("ExecReplace",resultRelationDesc,tuple,estate);
13311331
}
13321332

13331333
/*
@@ -1472,7 +1472,7 @@ ExecAttrDefault(Relation rel, HeapTuple tuple)
14721472
#endif
14731473

14741474
staticchar*
1475-
ExecRelCheck(Relationrel,HeapTupletuple)
1475+
ExecRelCheck(Relationrel,HeapTupletuple,EState*estate)
14761476
{
14771477
intncheck=rel->rd_att->constr->num_check;
14781478
ConstrCheck*check=rel->rd_att->constr->check;
@@ -1505,14 +1505,24 @@ ExecRelCheck(Relation rel, HeapTuple tuple)
15051505
econtext->ecxt_param_exec_vals=NULL;/* exec param values */
15061506
econtext->ecxt_range_table=rtlist;/* range table */
15071507

1508+
if (estate->es_result_relation_constraints==NULL)
1509+
{
1510+
estate->es_result_relation_constraints=
1511+
(List**)palloc(ncheck*sizeof(List*));
1512+
1513+
for (i=0;i<ncheck;i++)
1514+
{
1515+
qual= (List*)stringToNode(check[i].ccbin);
1516+
estate->es_result_relation_constraints[i]=qual;
1517+
}
1518+
}
1519+
15081520
for (i=0;i<ncheck;i++)
15091521
{
1510-
qual=(List*)stringToNode(check[i].ccbin);
1522+
qual=estate->es_result_relation_constraints[i];
15111523

15121524
res=ExecQual(qual,econtext);
15131525

1514-
freeObject(qual);
1515-
15161526
if (!res)
15171527
returncheck[i].ccname;
15181528
}
@@ -1528,7 +1538,7 @@ ExecRelCheck(Relation rel, HeapTuple tuple)
15281538
}
15291539

15301540
void
1531-
ExecConstraints(char*caller,Relationrel,HeapTupletuple)
1541+
ExecConstraints(char*caller,Relationrel,HeapTupletuple,EState*estate)
15321542
{
15331543

15341544
Assert(rel->rd_att->constr);
@@ -1549,7 +1559,7 @@ ExecConstraints(char *caller, Relation rel, HeapTuple tuple)
15491559
{
15501560
char*failed;
15511561

1552-
if ((failed=ExecRelCheck(rel,tuple))!=NULL)
1562+
if ((failed=ExecRelCheck(rel,tuple,estate))!=NULL)
15531563
elog(ERROR,"%s: rejected due to CHECK constraint %s",caller,failed);
15541564
}
15551565

‎src/include/executor/executor.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: executor.h,v 1.28 1998/11/27 19:33:32 vadim Exp $
9+
* $Id: executor.h,v 1.29 1999/02/07 16:17:12 wieck Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -85,7 +85,8 @@ extern HeapTuple ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot);
8585
externTupleDescExecutorStart(QueryDesc*queryDesc,EState*estate);
8686
externTupleTableSlot*ExecutorRun(QueryDesc*queryDesc,EState*estate,intfeature,intcount);
8787
externvoidExecutorEnd(QueryDesc*queryDesc,EState*estate);
88-
externvoidExecConstraints(char*caller,Relationrel,HeapTupletuple);
88+
externvoidExecConstraints(char*caller,Relationrel,HeapTupletuple,
89+
EState*estate);
8990
#ifdefQUERY_LIMIT
9091
externintExecutorLimit(intlimit);
9192
externintExecutorGetLimit(void);

‎src/include/nodes/execnodes.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* Copyright (c) 1994, Regents of the University of California
88
*
9-
* $Id: execnodes.h,v 1.22 1999/01/29 09:23:13 vadim Exp $
9+
* $Id: execnodes.h,v 1.23 1999/02/07 16:17:14 wieck Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -199,6 +199,7 @@ typedef struct EState
199199
Snapshotes_snapshot;
200200
List*es_range_table;
201201
RelationInfo*es_result_relation_info;
202+
List**es_result_relation_constraints;
202203
Relationes_into_relation_descriptor;
203204
ParamListInfoes_param_list_info;
204205
ParamExecData*es_param_exec_vals;/* this is for subselects */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp