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

Commitd4bbce6

Browse files
amitlanpull[bot]
authored andcommitted
Revert "Add soft error handling to some expression nodes"
This reverts commit7fbc75b.Looks like the LLVM additions may not be totally correct.
1 parentfb16c8e commitd4bbce6

File tree

9 files changed

+69
-96
lines changed

9 files changed

+69
-96
lines changed

‎src/backend/executor/execExpr.c

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,6 @@ ExecInitExpr(Expr *node, PlanState *parent)
139139
state->expr=node;
140140
state->parent=parent;
141141
state->ext_params=NULL;
142-
state->escontext=NULL;
143142

144143
/* Insert setup steps as needed */
145144
ExecCreateExprSetupSteps(state, (Node*)node);
@@ -177,7 +176,6 @@ ExecInitExprWithParams(Expr *node, ParamListInfo ext_params)
177176
state->expr=node;
178177
state->parent=NULL;
179178
state->ext_params=ext_params;
180-
state->escontext=NULL;
181179

182180
/* Insert setup steps as needed */
183181
ExecCreateExprSetupSteps(state, (Node*)node);
@@ -230,7 +228,6 @@ ExecInitQual(List *qual, PlanState *parent)
230228
state->expr= (Expr*)qual;
231229
state->parent=parent;
232230
state->ext_params=NULL;
233-
state->escontext=NULL;
234231

235232
/* mark expression as to be used with ExecQual() */
236233
state->flags=EEO_FLAG_IS_QUAL;
@@ -376,7 +373,6 @@ ExecBuildProjectionInfo(List *targetList,
376373
state->expr= (Expr*)targetList;
377374
state->parent=parent;
378375
state->ext_params=NULL;
379-
state->escontext=NULL;
380376

381377
state->resultslot=slot;
382378

@@ -548,7 +544,6 @@ ExecBuildUpdateProjection(List *targetList,
548544
state->expr=NULL;/* not used */
549545
state->parent=parent;
550546
state->ext_params=NULL;
551-
state->escontext=NULL;
552547

553548
state->resultslot=slot;
554549

@@ -1554,6 +1549,8 @@ ExecInitExprRec(Expr *node, ExprState *state,
15541549
CoerceViaIO*iocoerce= (CoerceViaIO*)node;
15551550
Oidiofunc;
15561551
booltypisvarlena;
1552+
Oidtypioparam;
1553+
FunctionCallInfofcinfo_in;
15571554

15581555
/* evaluate argument into step's result area */
15591556
ExecInitExprRec(iocoerce->arg,state,resv,resnull);
@@ -1582,13 +1579,25 @@ ExecInitExprRec(Expr *node, ExprState *state,
15821579

15831580
/* lookup the result type's input function */
15841581
scratch.d.iocoerce.finfo_in=palloc0(sizeof(FmgrInfo));
1582+
scratch.d.iocoerce.fcinfo_data_in=palloc0(SizeForFunctionCallInfo(3));
1583+
15851584
getTypeInputInfo(iocoerce->resulttype,
1586-
&iofunc,&scratch.d.iocoerce.typioparam);
1585+
&iofunc,&typioparam);
15871586
fmgr_info(iofunc,scratch.d.iocoerce.finfo_in);
15881587
fmgr_info_set_expr((Node*)node,scratch.d.iocoerce.finfo_in);
1588+
InitFunctionCallInfoData(*scratch.d.iocoerce.fcinfo_data_in,
1589+
scratch.d.iocoerce.finfo_in,
1590+
3,InvalidOid,NULL,NULL);
15891591

1590-
/* Set ErrorSaveContext if passed by the caller. */
1591-
scratch.d.iocoerce.escontext=state->escontext;
1592+
/*
1593+
* We can preload the second and third arguments for the input
1594+
* function, since they're constants.
1595+
*/
1596+
fcinfo_in=scratch.d.iocoerce.fcinfo_data_in;
1597+
fcinfo_in->args[1].value=ObjectIdGetDatum(typioparam);
1598+
fcinfo_in->args[1].isnull= false;
1599+
fcinfo_in->args[2].value=Int32GetDatum(-1);
1600+
fcinfo_in->args[2].isnull= false;
15921601

15931602
ExprEvalPushStep(state,&scratch);
15941603
break;
@@ -1619,7 +1628,6 @@ ExecInitExprRec(Expr *node, ExprState *state,
16191628
elemstate->expr=acoerce->elemexpr;
16201629
elemstate->parent=state->parent;
16211630
elemstate->ext_params=state->ext_params;
1622-
state->escontext=NULL;
16231631

16241632
elemstate->innermost_caseval= (Datum*)palloc(sizeof(Datum));
16251633
elemstate->innermost_casenull= (bool*)palloc(sizeof(bool));
@@ -3298,8 +3306,6 @@ ExecInitCoerceToDomain(ExprEvalStep *scratch, CoerceToDomain *ctest,
32983306
/* we'll allocate workspace only if needed */
32993307
scratch->d.domaincheck.checkvalue=NULL;
33003308
scratch->d.domaincheck.checknull=NULL;
3301-
/* Set ErrorSaveContext if passed by the caller. */
3302-
scratch->d.domaincheck.escontext=state->escontext;
33033309

33043310
/*
33053311
* Evaluate argument - it's fine to directly store it into resv/resnull,

‎src/backend/executor/execExprInterp.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,27 +1177,29 @@ ExecInterpExpr(ExprState *state, ExprContext *econtext, bool *isnull)
11771177
/* call input function (similar to InputFunctionCall) */
11781178
if (!op->d.iocoerce.finfo_in->fn_strict||str!=NULL)
11791179
{
1180-
boolerror;
1180+
FunctionCallInfofcinfo_in;
1181+
Datumd;
11811182

1182-
/*
1183-
* InputFunctionCallSafe() writes directly into *op->resvalue.
1184-
* Return NULL if an error is reported.
1185-
*/
1186-
error= !InputFunctionCallSafe(op->d.iocoerce.finfo_in,str,
1187-
op->d.iocoerce.typioparam,-1,
1188-
(Node*)op->d.iocoerce.escontext,
1189-
op->resvalue);
1190-
if (error)
1191-
*op->resnull= true;
1183+
fcinfo_in=op->d.iocoerce.fcinfo_data_in;
1184+
fcinfo_in->args[0].value=PointerGetDatum(str);
1185+
fcinfo_in->args[0].isnull=*op->resnull;
1186+
/* second and third arguments are already set up */
11921187

1193-
/*
1194-
* Should get null result if and only if str is NULL or if we
1195-
* got an error above.
1196-
*/
1197-
if (str==NULL||error)
1188+
fcinfo_in->isnull= false;
1189+
d=FunctionCallInvoke(fcinfo_in);
1190+
*op->resvalue=d;
1191+
1192+
/* Should get null result if and only if str is NULL */
1193+
if (str==NULL)
1194+
{
11981195
Assert(*op->resnull);
1196+
Assert(fcinfo_in->isnull);
1197+
}
11991198
else
1199+
{
12001200
Assert(!*op->resnull);
1201+
Assert(!fcinfo_in->isnull);
1202+
}
12011203
}
12021204

12031205
EEO_NEXT();
@@ -3743,7 +3745,7 @@ ExecEvalConstraintCheck(ExprState *state, ExprEvalStep *op)
37433745
{
37443746
if (!*op->d.domaincheck.checknull&&
37453747
!DatumGetBool(*op->d.domaincheck.checkvalue))
3746-
errsave((Node*)op->d.domaincheck.escontext,
3748+
ereport(ERROR,
37473749
(errcode(ERRCODE_CHECK_VIOLATION),
37483750
errmsg("value for domain %s violates check constraint \"%s\"",
37493751
format_type_be(op->d.domaincheck.resulttype),

‎src/backend/jit/llvm/llvmjit.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,12 @@ LLVMTypeRef StructHeapTupleTableSlot;
7070
LLVMTypeRefStructMinimalTupleTableSlot;
7171
LLVMTypeRefStructMemoryContextData;
7272
LLVMTypeRefStructFunctionCallInfoData;
73-
LLVMTypeRefStructFmgrInfo;
7473
LLVMTypeRefStructExprContext;
7574
LLVMTypeRefStructExprEvalStep;
7675
LLVMTypeRefStructExprState;
7776
LLVMTypeRefStructAggState;
7877
LLVMTypeRefStructAggStatePerGroupData;
7978
LLVMTypeRefStructAggStatePerTransData;
80-
LLVMTypeRefStructErrorSaveContext;
8179

8280
LLVMValueRefAttributeTemplate;
8381

@@ -1120,7 +1118,6 @@ llvm_create_types(void)
11201118
StructExprEvalStep=llvm_pg_var_type("StructExprEvalStep");
11211119
StructExprState=llvm_pg_var_type("StructExprState");
11221120
StructFunctionCallInfoData=llvm_pg_var_type("StructFunctionCallInfoData");
1123-
StructFmgrInfo=llvm_pg_var_type("StructFmgrInfo");
11241121
StructMemoryContextData=llvm_pg_var_type("StructMemoryContextData");
11251122
StructTupleTableSlot=llvm_pg_var_type("StructTupleTableSlot");
11261123
StructHeapTupleTableSlot=llvm_pg_var_type("StructHeapTupleTableSlot");
@@ -1130,7 +1127,6 @@ llvm_create_types(void)
11301127
StructAggState=llvm_pg_var_type("StructAggState");
11311128
StructAggStatePerGroupData=llvm_pg_var_type("StructAggStatePerGroupData");
11321129
StructAggStatePerTransData=llvm_pg_var_type("StructAggStatePerTransData");
1133-
StructErrorSaveContext=llvm_pg_var_type("StructErrorSaveContext");
11341130

11351131
AttributeTemplate=LLVMGetNamedFunction(llvm_types_module,"AttributeTemplate");
11361132
}

‎src/backend/jit/llvm/llvmjit_expr.c

Lines changed: 32 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,9 +1251,14 @@ llvm_compile_expr(ExprState *state)
12511251

12521252
caseEEOP_IOCOERCE:
12531253
{
1254-
FunctionCallInfofcinfo_out;
1255-
LLVMValueRefv_fn_out;
1256-
LLVMValueRefv_fcinfo_out;
1254+
FunctionCallInfofcinfo_out,
1255+
fcinfo_in;
1256+
LLVMValueRefv_fn_out,
1257+
v_fn_in;
1258+
LLVMValueRefv_fcinfo_out,
1259+
v_fcinfo_in;
1260+
LLVMValueRefv_fcinfo_in_isnullp;
1261+
LLVMValueRefv_retval;
12571262
LLVMValueRefv_resvalue;
12581263
LLVMValueRefv_resnull;
12591264

@@ -1266,6 +1271,7 @@ llvm_compile_expr(ExprState *state)
12661271
LLVMBasicBlockRefb_inputcall;
12671272

12681273
fcinfo_out=op->d.iocoerce.fcinfo_data_out;
1274+
fcinfo_in=op->d.iocoerce.fcinfo_data_in;
12691275

12701276
b_skipoutput=l_bb_before_v(opblocks[opno+1],
12711277
"op.%d.skipoutputnull",opno);
@@ -1277,7 +1283,14 @@ llvm_compile_expr(ExprState *state)
12771283
"op.%d.inputcall",opno);
12781284

12791285
v_fn_out=llvm_function_reference(context,b,mod,fcinfo_out);
1286+
v_fn_in=llvm_function_reference(context,b,mod,fcinfo_in);
12801287
v_fcinfo_out=l_ptr_const(fcinfo_out,l_ptr(StructFunctionCallInfoData));
1288+
v_fcinfo_in=l_ptr_const(fcinfo_in,l_ptr(StructFunctionCallInfoData));
1289+
1290+
v_fcinfo_in_isnullp=
1291+
LLVMBuildStructGEP(b,v_fcinfo_in,
1292+
FIELDNO_FUNCTIONCALLINFODATA_ISNULL,
1293+
"v_fcinfo_in_isnull");
12811294

12821295
/* output functions are not called on nulls */
12831296
v_resnull=LLVMBuildLoad(b,v_resnullp,"");
@@ -1343,44 +1356,24 @@ llvm_compile_expr(ExprState *state)
13431356
LLVMBuildBr(b,b_inputcall);
13441357
}
13451358

1346-
/*
1347-
* Call the input function.
1348-
*
1349-
* If op->d.iocoerce.escontext references an
1350-
* ErrorSaveContext, InputFunctionCallSafe() would return
1351-
* false upon encountering an error.
1352-
*/
13531359
LLVMPositionBuilderAtEnd(b,b_inputcall);
1354-
{
1355-
Oidioparam=op->d.iocoerce.typioparam;
1356-
LLVMValueRefv_params[6];
1357-
LLVMValueRefv_success;
1358-
1359-
v_params[0]=l_ptr_const(op->d.iocoerce.finfo_in,
1360-
l_ptr(StructFmgrInfo));
1361-
v_params[1]=v_output;
1362-
v_params[2]=l_oid_const(lc,ioparam);
1363-
v_params[3]=l_int32_const(lc,-1);
1364-
v_params[4]=l_ptr_const(op->d.iocoerce.escontext,
1365-
l_ptr(StructErrorSaveContext));
1360+
/* set arguments */
1361+
/* arg0: output */
1362+
LLVMBuildStore(b,v_output,
1363+
l_funcvaluep(b,v_fcinfo_in,0));
1364+
LLVMBuildStore(b,v_resnull,
1365+
l_funcnullp(b,v_fcinfo_in,0));
1366+
1367+
/* arg1: ioparam: preset in execExpr.c */
1368+
/* arg2: typmod: preset in execExpr.c */
1369+
1370+
/* reset fcinfo_in->isnull */
1371+
LLVMBuildStore(b,l_sbool_const(0),v_fcinfo_in_isnullp);
1372+
/* and call function */
1373+
v_retval=LLVMBuildCall(b,v_fn_in,&v_fcinfo_in,1,
1374+
"funccall_iocoerce_in");
13661375

1367-
/*
1368-
* InputFunctionCallSafe() will write directly into
1369-
* *op->resvalue.
1370-
*/
1371-
v_params[5]=v_resvaluep;
1372-
1373-
v_success=LLVMBuildCall(b,llvm_pg_func(mod,"InputFunctionCallSafe"),
1374-
v_params,lengthof(v_params),
1375-
"funccall_iocoerce_in_safe");
1376-
1377-
/*
1378-
* Return null if InputFunctionCallSafe() encountered
1379-
* an error.
1380-
*/
1381-
v_resnullp=LLVMBuildICmp(b,LLVMIntEQ,v_success,
1382-
l_sbool_const(0),"");
1383-
}
1376+
LLVMBuildStore(b,v_retval,v_resvaluep);
13841377

13851378
LLVMBuildBr(b,opblocks[opno+1]);
13861379
break;

‎src/backend/jit/llvm/llvmjit_types.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,13 @@ AggStatePerTransData StructAggStatePerTransData;
5959
ExprContextStructExprContext;
6060
ExprEvalStepStructExprEvalStep;
6161
ExprStateStructExprState;
62-
FmgrInfoStructFmgrInfo;
6362
FunctionCallInfoBaseDataStructFunctionCallInfoData;
6463
HeapTupleDataStructHeapTupleData;
6564
MemoryContextDataStructMemoryContextData;
6665
TupleTableSlotStructTupleTableSlot;
6766
HeapTupleTableSlotStructHeapTupleTableSlot;
6867
MinimalTupleTableSlotStructMinimalTupleTableSlot;
6968
TupleDescDataStructTupleDescData;
70-
ErrorSaveContextStructErrorSaveContext;
7169

7270

7371
/*
@@ -138,7 +136,6 @@ void *referenced_functions[] =
138136
ExecEvalJsonConstructor,
139137
ExecEvalJsonIsPredicate,
140138
MakeExpandedObjectReadOnlyInternal,
141-
InputFunctionCallSafe,
142139
slot_getmissingattrs,
143140
slot_getsomeattrs_int,
144141
strlen,

‎src/include/executor/execExpr.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
#include"executor/nodeAgg.h"
1818
#include"nodes/execnodes.h"
19-
#include"nodes/miscnodes.h"
2019

2120
/* forward references to avoid circularity */
2221
structExprEvalStep;
@@ -417,8 +416,7 @@ typedef struct ExprEvalStep
417416
FunctionCallInfofcinfo_data_out;
418417
/* lookup and call info for result type's input function */
419418
FmgrInfo*finfo_in;
420-
Oidtypioparam;
421-
ErrorSaveContext*escontext;
419+
FunctionCallInfofcinfo_data_in;
422420
}iocoerce;
423421

424422
/* for EEOP_SQLVALUEFUNCTION */
@@ -549,7 +547,6 @@ typedef struct ExprEvalStep
549547
bool*checknull;
550548
/* OID of domain type */
551549
Oidresulttype;
552-
ErrorSaveContext*escontext;
553550
}domaincheck;
554551

555552
/* for EEOP_CONVERT_ROWTYPE */

‎src/include/jit/llvmjit.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,13 @@ extern PGDLLIMPORT LLVMTypeRef StructTupleTableSlot;
7575
externPGDLLIMPORTLLVMTypeRefStructHeapTupleTableSlot;
7676
externPGDLLIMPORTLLVMTypeRefStructMinimalTupleTableSlot;
7777
externPGDLLIMPORTLLVMTypeRefStructMemoryContextData;
78-
externPGDLLIMPORTLLVMTypeRefStructFmgrInfo;
7978
externPGDLLIMPORTLLVMTypeRefStructFunctionCallInfoData;
8079
externPGDLLIMPORTLLVMTypeRefStructExprContext;
8180
externPGDLLIMPORTLLVMTypeRefStructExprEvalStep;
8281
externPGDLLIMPORTLLVMTypeRefStructExprState;
8382
externPGDLLIMPORTLLVMTypeRefStructAggState;
8483
externPGDLLIMPORTLLVMTypeRefStructAggStatePerTransData;
8584
externPGDLLIMPORTLLVMTypeRefStructAggStatePerGroupData;
86-
externPGDLLIMPORTLLVMTypeRefStructErrorSaveContext;
8785

8886
externPGDLLIMPORTLLVMValueRefAttributeTemplate;
8987

‎src/include/jit/llvmjit_emit.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,15 +85,6 @@ l_sizet_const(size_t i)
8585
returnLLVMConstInt(TypeSizeT,i, false);
8686
}
8787

88-
/*
89-
* Emit constant oid.
90-
*/
91-
staticinlineLLVMValueRef
92-
l_oid_const(LLVMContextReflc,Oidi)
93-
{
94-
returnLLVMConstInt(LLVMInt32TypeInContext(lc),i, false);
95-
}
96-
9788
/*
9889
* Emit constant boolean, as used for storage (e.g. global vars, structs).
9990
*/

‎src/include/nodes/execnodes.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include"fmgr.h"
3535
#include"lib/ilist.h"
3636
#include"lib/pairingheap.h"
37-
#include"nodes/miscnodes.h"
3837
#include"nodes/params.h"
3938
#include"nodes/plannodes.h"
4039
#include"nodes/tidbitmap.h"
@@ -130,12 +129,6 @@ typedef struct ExprState
130129

131130
Datum*innermost_domainval;
132131
bool*innermost_domainnull;
133-
134-
/*
135-
* For expression nodes that support soft errors. Should be set to NULL
136-
* before calling ExecInitExprRec() if the caller wants errors thrown.
137-
*/
138-
ErrorSaveContext*escontext;
139132
}ExprState;
140133

141134

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp