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

Commit4a2c34d

Browse files
committed
Use makeNode() to allocate structures that have to be cast to Node *,
rather than allocating them on the stack.Fixes complaint from gcc 3.3.1.
1 parent037468e commit4a2c34d

File tree

3 files changed

+46
-44
lines changed

3 files changed

+46
-44
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.88 2003/10/11 18:04:25 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.89 2003/10/12 23:19:21 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -3449,6 +3449,7 @@ validateForeignKeyConstraint(FkConstraint *fkconstraint,
34493449
Relationpkrel)
34503450
{
34513451
HeapScanDescscan;
3452+
TriggerData*trigdata=makeNode(TriggerData);/* must be Node aligned */
34523453
HeapTupletuple;
34533454
Triggertrig;
34543455
List*list;
@@ -3506,7 +3507,6 @@ validateForeignKeyConstraint(FkConstraint *fkconstraint,
35063507
while ((tuple=heap_getnext(scan,ForwardScanDirection))!=NULL)
35073508
{
35083509
FunctionCallInfoDatafcinfo;
3509-
TriggerDatatrigdata;
35103510

35113511
/*
35123512
* Make a call to the trigger function
@@ -3518,20 +3518,21 @@ validateForeignKeyConstraint(FkConstraint *fkconstraint,
35183518
/*
35193519
* We assume RI_FKey_check_ins won't look at flinfo...
35203520
*/
3521-
trigdata.type=T_TriggerData;
3522-
trigdata.tg_event=TRIGGER_EVENT_INSERT |TRIGGER_EVENT_ROW;
3523-
trigdata.tg_relation=rel;
3524-
trigdata.tg_trigtuple=tuple;
3525-
trigdata.tg_newtuple=NULL;
3526-
trigdata.tg_trigger=&trig;
3521+
trigdata->type=T_TriggerData;
3522+
trigdata->tg_event=TRIGGER_EVENT_INSERT |TRIGGER_EVENT_ROW;
3523+
trigdata->tg_relation=rel;
3524+
trigdata->tg_trigtuple=tuple;
3525+
trigdata->tg_newtuple=NULL;
3526+
trigdata->tg_trigger=&trig;
35273527

3528-
fcinfo.context= (Node*)&trigdata;
3528+
fcinfo.context= (Node*)trigdata;
35293529

35303530
RI_FKey_check_ins(&fcinfo);
35313531
}
35323532

35333533
heap_endscan(scan);
35343534

3535+
pfree(trigdata);
35353536
pfree(trig.tgargs);
35363537
}
35373538

‎src/backend/executor/execQual.c

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.148 2003/10/11 18:04:25 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.149 2003/10/12 23:19:21 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -699,7 +699,8 @@ ExecMakeFunctionResult(FuncExprState *fcache,
699699
List*arguments=fcache->args;
700700
Datumresult;
701701
FunctionCallInfoDatafcinfo;
702-
ReturnSetInforsinfo;/* for functions returning sets */
702+
/* for functions returning sets, must be aligned as Node, so use makeNode */
703+
ReturnSetInfo*rsinfo=makeNode(ReturnSetInfo);
703704
ExprDoneCondargDone;
704705
boolhasSetArg;
705706
inti;
@@ -746,15 +747,15 @@ ExecMakeFunctionResult(FuncExprState *fcache,
746747
*/
747748
if (fcache->func.fn_retset)
748749
{
749-
fcinfo.resultinfo= (Node*)&rsinfo;
750-
rsinfo.type=T_ReturnSetInfo;
751-
rsinfo.econtext=econtext;
752-
rsinfo.expectedDesc=NULL;
753-
rsinfo.allowedModes= (int)SFRM_ValuePerCall;
754-
rsinfo.returnMode=SFRM_ValuePerCall;
750+
fcinfo.resultinfo= (Node*)rsinfo;
751+
rsinfo->type=T_ReturnSetInfo;
752+
rsinfo->econtext=econtext;
753+
rsinfo->expectedDesc=NULL;
754+
rsinfo->allowedModes= (int)SFRM_ValuePerCall;
755+
rsinfo->returnMode=SFRM_ValuePerCall;
755756
/* isDone is filled below */
756-
rsinfo.setResult=NULL;
757-
rsinfo.setDesc=NULL;
757+
rsinfo->setResult=NULL;
758+
rsinfo->setDesc=NULL;
758759
}
759760

760761
/*
@@ -803,10 +804,10 @@ ExecMakeFunctionResult(FuncExprState *fcache,
803804
if (callit)
804805
{
805806
fcinfo.isnull= false;
806-
rsinfo.isDone=ExprSingleResult;
807+
rsinfo->isDone=ExprSingleResult;
807808
result=FunctionCallInvoke(&fcinfo);
808809
*isNull=fcinfo.isnull;
809-
*isDone=rsinfo.isDone;
810+
*isDone=rsinfo->isDone;
810811
}
811812
else
812813
{
@@ -903,7 +904,7 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
903904
TupleDesctupdesc=NULL;
904905
Oidfuncrettype;
905906
FunctionCallInfoDatafcinfo;
906-
ReturnSetInforsinfo;
907+
ReturnSetInfo*rsinfo=makeNode(ReturnSetInfo);/* must be Node aligned */
907908
MemoryContextcallerContext;
908909
MemoryContextoldcontext;
909910
TupleTableSlot*slot;
@@ -992,15 +993,15 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
992993
* doesn't actually get to see the resultinfo, but set it up anyway
993994
* because we use some of the fields as our own state variables.
994995
*/
995-
fcinfo.resultinfo= (Node*)&rsinfo;
996-
rsinfo.type=T_ReturnSetInfo;
997-
rsinfo.econtext=econtext;
998-
rsinfo.expectedDesc=expectedDesc;
999-
rsinfo.allowedModes= (int) (SFRM_ValuePerCall |SFRM_Materialize);
1000-
rsinfo.returnMode=SFRM_ValuePerCall;
996+
fcinfo.resultinfo= (Node*)rsinfo;
997+
rsinfo->type=T_ReturnSetInfo;
998+
rsinfo->econtext=econtext;
999+
rsinfo->expectedDesc=expectedDesc;
1000+
rsinfo->allowedModes= (int) (SFRM_ValuePerCall |SFRM_Materialize);
1001+
rsinfo->returnMode=SFRM_ValuePerCall;
10011002
/* isDone is filled below */
1002-
rsinfo.setResult=NULL;
1003-
rsinfo.setDesc=NULL;
1003+
rsinfo->setResult=NULL;
1004+
rsinfo->setDesc=NULL;
10041005

10051006
/*
10061007
* Switch to short-lived context for calling the function or
@@ -1028,17 +1029,17 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
10281029
if (direct_function_call)
10291030
{
10301031
fcinfo.isnull= false;
1031-
rsinfo.isDone=ExprSingleResult;
1032+
rsinfo->isDone=ExprSingleResult;
10321033
result=FunctionCallInvoke(&fcinfo);
10331034
}
10341035
else
10351036
{
10361037
result=ExecEvalExpr(funcexpr,econtext,
1037-
&fcinfo.isnull,&rsinfo.isDone);
1038+
&fcinfo.isnull,&rsinfo->isDone);
10381039
}
10391040

10401041
/* Which protocol does function want to use? */
1041-
if (rsinfo.returnMode==SFRM_ValuePerCall)
1042+
if (rsinfo->returnMode==SFRM_ValuePerCall)
10421043
{
10431044
/*
10441045
* Check for end of result set.
@@ -1047,7 +1048,7 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
10471048
* tupdesc or tuplestore (since we can't get a tupdesc in the
10481049
* function-returning-tuple case)
10491050
*/
1050-
if (rsinfo.isDone==ExprEndResult)
1051+
if (rsinfo->isDone==ExprEndResult)
10511052
break;
10521053

10531054
/*
@@ -1093,8 +1094,8 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
10931094
}
10941095
tupstore=tuplestore_begin_heap(true, false,SortMem);
10951096
MemoryContextSwitchTo(oldcontext);
1096-
rsinfo.setResult=tupstore;
1097-
rsinfo.setDesc=tupdesc;
1097+
rsinfo->setResult=tupstore;
1098+
rsinfo->setDesc=tupdesc;
10981099
}
10991100

11001101
/*
@@ -1127,13 +1128,13 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
11271128
/*
11281129
* Are we done?
11291130
*/
1130-
if (rsinfo.isDone!=ExprMultipleResult)
1131+
if (rsinfo->isDone!=ExprMultipleResult)
11311132
break;
11321133
}
1133-
elseif (rsinfo.returnMode==SFRM_Materialize)
1134+
elseif (rsinfo->returnMode==SFRM_Materialize)
11341135
{
11351136
/* check we're on the same page as the function author */
1136-
if (!first_time||rsinfo.isDone!=ExprSingleResult)
1137+
if (!first_time||rsinfo->isDone!=ExprSingleResult)
11371138
ereport(ERROR,
11381139
(errcode(ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED),
11391140
errmsg("table-function protocol for materialize mode was not followed")));
@@ -1144,16 +1145,16 @@ ExecMakeTableFunctionResult(ExprState *funcexpr,
11441145
ereport(ERROR,
11451146
(errcode(ERRCODE_E_R_I_E_SRF_PROTOCOL_VIOLATED),
11461147
errmsg("unrecognized table-function returnMode: %d",
1147-
(int)rsinfo.returnMode)));
1148+
(int)rsinfo->returnMode)));
11481149

11491150
first_time= false;
11501151
}
11511152

11521153
MemoryContextSwitchTo(callerContext);
11531154

11541155
/* The returned pointers are those in rsinfo */
1155-
*returnDesc=rsinfo.setDesc;
1156-
returnrsinfo.setResult;
1156+
*returnDesc=rsinfo->setDesc;
1157+
returnrsinfo->setResult;
11571158
}
11581159

11591160

‎src/backend/port/sysv_shmem.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
* Portions Copyright (c) 1994, Regents of the University of California
1111
*
1212
* IDENTIFICATION
13-
* $Header: /cvsroot/pgsql/src/backend/port/sysv_shmem.c,v 1.19 2003/10/11 18:04:25 momjian Exp $
13+
* $Header: /cvsroot/pgsql/src/backend/port/sysv_shmem.c,v 1.20 2003/10/12 23:19:21 momjian Exp $
1414
*
1515
*-------------------------------------------------------------------------
1616
*/
@@ -365,7 +365,7 @@ PGSharedMemoryAttach(IpcMemoryKey key, IpcMemoryId *shmid)
365365

366366
if (hdr->magic!=PGShmemMagic)
367367
{
368-
shmdt(hdr);
368+
shmdt((void*)hdr);
369369
returnNULL;/* segment belongs to a non-Postgres app */
370370
}
371371

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp