PostgreSQL如何构建表达式解析
这篇文章主要介绍PostgreSQL如何构建表达式解析,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
一、数据结构EEO_XXX宏定义
opcode分发器宏定义
/**Macrosforopcodedispatch.*opcode分发器宏定义**EEO_SWITCH-justhidestheswitchifnotinuse.*EEO_SWITCH-如未使用,则隐藏switch**EEO_CASE-labelstheimplementationofnamedexpressionsteptype.*EEO_CASE-标签化已命名的表达式步骤类型的实现**EEO_DISPATCH-jumptotheimplementationofthesteptypefor'op'.*EEO_DISPATCH-跳到'op'指定的步骤类型的实现**EEO_OPCODE-computeopcoderequiredbyusedexpressionevaluationmethod.*-通过请求的表达式解析方法计算opcode**EEO_NEXT-increment'op'andjumptocorrectnextsteptype.*-'op'++并跳转到下一个步骤类型**EEO_JUMP-jumptothespecifiedstepnumberwithinthecurrentexpression.*EEO_JUMP-在当前表达式中跳转到指定的步骤编号*/#ifdefined(EEO_USE_COMPUTED_GOTO)//---------------定义了EEO_USE_COMPUTED_GOTO/*structforjumptarget->opcodelookuptable*///跳转target->opcode搜索表结构体typedefstructExprEvalOpLookup{constvoid*opcode;ExprEvalOpop;}ExprEvalOpLookup;/*tomakedispatch_tableaccessibleoutsideExecInterpExpr()*/staticconstvoid**dispatch_table=NULL;/*jumptarget->opcodelookuptable*/staticExprEvalOpLookupreverse_dispatch_table[EEOP_LAST];#defineEEO_SWITCH()#defineEEO_CASE(name)CASE_##name:#defineEEO_DISPATCH()goto*((void*)op->opcode)#defineEEO_OPCODE(opcode)((intptr_t)dispatch_table[opcode])#else/*!EEO_USE_COMPUTED_GOTO*///---------------没有定义EEO_USE_COMPUTED_GOTO#defineEEO_SWITCH()starteval:switch((ExprEvalOp)op->opcode)#defineEEO_CASE(name)casename:#defineEEO_DISPATCH()gotostarteval#defineEEO_OPCODE(opcode)(opcode)#endif/*EEO_USE_COMPUTED_GOTO*/#defineEEO_NEXT()\do{\op++;\EEO_DISPATCH();\}while(0)#defineEEO_JUMP(stepno)\do{\op=&state->steps[stepno];\EEO_DISPATCH();\}while(0)
ExprState
解析表达式中运行期状态节点
/*BitsinExprState->flags(seealsoexecExpr.hforprivateflagbits):*//*expressionisforusewithExecQual()*/#defineEEO_FLAG_IS_QUAL(1<<0)typedefstructExprState{//节点tagNodetag;//EEO_FLAG_IS_QUALuint8flags;/*bitmaskofEEO_FLAG_*bits,seeabove*//**Storageforresultvalueofascalarexpression,orforindividual*columnresultswithinexpressionsbuiltbyExecBuildProjectionInfo().*存储scalarexpression表达式*和通过ExecBuildProjectionInfo()函数创建的expressions单列的结果.*/#defineFIELDNO_EXPRSTATE_RESNULL2boolresnull;#defineFIELDNO_EXPRSTATE_RESVALUE3Datumresvalue;/**Ifprojectingatupleresult,thisslotholdstheresult;elseNULL.*如果投影元组结果,该slot存储结果,或者为NULL.*/#defineFIELDNO_EXPRSTATE_RESULTSLOT4TupleTableSlot*resultslot;/**Instructionstocomputeexpression'sreturnvalue.*计算表达式返回结果的基础"架构"*/structExprEvalStep*steps;/**Functionthatactuallyevaluatestheexpression.Thiscanbesetto*differentvaluesdependingonthecomplexityoftheexpression.*实际解析表达式的函数.*根据表达式的复杂程度,可以设置为不同的值.*/ExprStateEvalFuncevalfunc;/*originalexpressiontree,fordebuggingonly*///原始的表达式树,仅用于debuggingExpr*expr;/*privatestateforanevalfunc*///evalfunc的私有状态void*evalfunc_private;/**XXX:followingfieldsonlyneededduring"compilation"(ExecInitExpr);*couldbethrownawayafterwards.*XXX:接下来的字段在"compilation"(ExecInitExpr)期间需要,之后可被"扔掉".*///当前的步数intsteps_len;/*numberofstepscurrently*///steps数组已分配的长度intsteps_alloc;/*allocatedlengthofstepsarray*///父PlanState节点(如存在)structPlanState*parent;/*parentPlanStatenode,ifany*///用于编译PARAM_EXTERN节点ParamListInfoext_params;/*forcompilingPARAM_EXTERNnodes*///Datum*innermost_caseval;bool*innermost_casenull;Datum*innermost_domainval;bool*innermost_domainnull;}ExprState;
ExprEvalStep
表达式解析步骤结构体
typedefstructExprEvalStep{/**Instructiontobeexecuted.Duringinstructionpreparationthisisan*enumExprEvalOp,butlateritcanbechangedtosomeothertype,e.g.a*pointerforcomputedgoto(that'swhyit'sanintptr_t).*待执行指令.*在指令准备期间这是枚举型的ExprEvalOp,*但后续会被改变为某些其他类型,比如用于goto的指针,因此被定义为intprt_t类型*/intptr_topcode;/*wheretostoretheresultofthisstep*///存储该步骤的结果Datum*resvalue;bool*resnull;/**Inlinedatafortheoperation.Inlinedataisfastertoaccess,but*alsobloatsthesizeofallinstructions.Theunionshouldbekeptto*nomorethan40byteson64-bitsystems(sothattheentirestructis*nomorethan64bytes,asinglecachelineoncommonsystems).*操作的内联数据.*内联数据用于更快的访问,但同时会导致指令的盘膨胀.*联合体在64-bit系统上应保持在40字节范围内*(因此整个结构体不应大于64字节,普通系统上的单个缓存线大小)*/union{/*forEEOP_INNER/OUTER/SCAN_FETCHSOME*///用于EEOP_INNER/OUTER/SCAN_FETCHSOMEstruct{/*attributenumberuptowhichtofetch(inclusive)*///获取到的属性编号intlast_var;TupleDescknown_desc;}fetch;/*forEEOP_INNER/OUTER/SCAN_[SYS]VAR[_FIRST]*/struct{/*attnumisattrnumber-1forregularVAR...*///attnum是常规VAR的attrnumber-1/*butit'sjustthenormal(negative)attrnumberforSYSVAR*///对于SYSVAR,该值是常规的attrnumberintattnum;Oidvartype;/*typeOIDofvariable*/}var;/*forEEOP_WHOLEROW*/struct{Var*var;/*originalVarnodeinplantree*/boolfirst;/*firsttimethrough,needtoinitialize?*/boolslow;/*needruntimecheckfornulls?*/TupleDesctupdesc;/*descriptorforresultingtuples*/JunkFilter*junkFilter;/*JunkFiltertoremoveresjunkcols*/}wholerow;/*forEEOP_ASSIGN_*_VAR*/struct{/*targetindexinExprState->resultslot->tts_values/nulls*/intresultnum;/*sourceattributenumber-1*/intattnum;}assign_var;/*forEEOP_ASSIGN_TMP[_MAKE_RO]*/struct{/*targetindexinExprState->resultslot->tts_values/nulls*/intresultnum;}assign_tmp;/*forEEOP_CONST*/struct{/*constant'svalue*/Datumvalue;boolisnull;}constval;/*forEEOP_FUNCEXPR_*/NULLIF/DISTINCT*///对于EEOP_FUNCEXPR_*/NULLIF/DISTINCTstruct{//函数的检索数据FmgrInfo*finfo;/*function'slookupdata*///参数信息等FunctionCallInfofcinfo_data;/*argumentsetc*//*fastertoaccesswithoutadditionalindirection:*///无需额外的指向,更快速的访问PGFunctionfn_addr;/*actualcalladdress*/intnargs;/*numberofarguments*/}func;/*forEEOP_BOOL_*_STEP*/struct{bool*anynull;/*trackifanyinputwasNULL*/intjumpdone;/*jumphereifresultdetermined*/}boolexpr;/*forEEOP_QUAL*/struct{intjumpdone;/*jumphereonfalseornull*/}qualexpr;/*forEEOP_JUMP[_CONDITION]*/struct{intjumpdone;/*targetinstruction'sindex*/}jump;/*forEEOP_NULLTEST_ROWIS[NOT]NULL*/struct{/*cachedtupdescpointer-filledatruntime*/TupleDescargdesc;}nulltest_row;/*forEEOP_PARAM_EXEC/EXTERN*/struct{intparamid;/*numericIDforparameter*/Oidparamtype;/*OIDofparameter'sdatatype*/}param;/*forEEOP_PARAM_CALLBACK*/struct{ExecEvalSubroutineparamfunc;/*add-onevaluationsubroutine*/void*paramarg;/*privatedataforsame*/intparamid;/*numericIDforparameter*/Oidparamtype;/*OIDofparameter'sdatatype*/}cparam;/*forEEOP_CASE_TESTVAL/DOMAIN_TESTVAL*/struct{Datum*value;/*valuetoreturn*/bool*isnull;}casetest;/*forEEOP_MAKE_READONLY*/struct{Datum*value;/*valuetocoercetoread-only*/bool*isnull;}make_readonly;/*forEEOP_IOCOERCE*/struct{/*lookupandcallinfoforsourcetype'soutputfunction*/FmgrInfo*finfo_out;FunctionCallInfofcinfo_data_out;/*lookupandcallinfoforresulttype'sinputfunction*/FmgrInfo*finfo_in;FunctionCallInfofcinfo_data_in;}iocoerce;/*forEEOP_SQLVALUEFUNCTION*/struct{SQLValueFunction*svf;}sqlvaluefunction;/*forEEOP_NEXTVALUEEXPR*///EEOP_NEXTVALUEEXPRstruct{Oidseqid;Oidseqtypid;}nextvalueexpr;/*forEEOP_ARRAYEXPR*/struct{Datum*elemvalues;/*elementvaluesgetstoredhere*/bool*elemnulls;intnelems;/*lengthoftheabovearrays*/Oidelemtype;/*arrayelementtype*/int16elemlength;/*typlenofthearrayelementtype*/boolelembyval;/*istheelementtypepass-by-value?*/charelemalign;/*typalignoftheelementtype*/boolmultidims;/*isarrayexpressionmulti-D?*/}arrayexpr;/*forEEOP_ARRAYCOERCE*/struct{ExprState*elemexprstate;/*nullifnoper-elementwork*/Oidresultelemtype;/*elementtypeofresultarray*/structArrayMapState*amstate;/*workspaceforarray_map*/}arraycoerce;/*forEEOP_ROW*/struct{TupleDesctupdesc;/*descriptorforresulttuples*//*workspaceforthevaluesconstitutingtherow:*/Datum*elemvalues;bool*elemnulls;}row;/*forEEOP_ROWCOMPARE_STEP*/struct{/*lookupandcalldataforcolumncomparisonfunction*/FmgrInfo*finfo;FunctionCallInfofcinfo_data;PGFunctionfn_addr;/*targetforcomparisonresultinginNULL*/intjumpnull;/*targetforcomparisonyieldinginequality*/intjumpdone;}rowcompare_step;/*forEEOP_ROWCOMPARE_FINAL*/struct{RowCompareTyperctype;}rowcompare_final;/*forEEOP_MINMAX*/struct{/*workspaceforargumentvalues*/Datum*values;bool*nulls;intnelems;/*isitGREATESTorLEAST?*/MinMaxOpop;/*lookupandcalldataforcomparisonfunction*/FmgrInfo*finfo;FunctionCallInfofcinfo_data;}minmax;/*forEEOP_FIELDSELECT*/struct{AttrNumberfieldnum;/*fieldnumbertoextract*/Oidresulttype;/*field'stype*//*cachedtupdescpointer-filledatruntime*/TupleDescargdesc;}fieldselect;/*forEEOP_FIELDSTORE_DEFORM/FIELDSTORE_FORM*/struct{/*originalexpressionnode*/FieldStore*fstore;/*cachedtupdescpointer-filledatruntime*//*notethataDEFORMandFORMpairsharethesametupdesc*/TupleDesc*argdesc;/*workspaceforcolumnvalues*/Datum*values;bool*nulls;intncolumns;}fieldstore;/*forEEOP_ARRAYREF_SUBSCRIPT*/struct{/*toobigtohaveinline*/structArrayRefState*state;intoff;/*0-basedindexofthissubscript*/boolisupper;/*isitupperorlowersubscript?*/intjumpdone;/*jumphereonnull*/}arrayref_subscript;/*forEEOP_ARRAYREF_OLD/ASSIGN/FETCH*/struct{/*toobigtohaveinline*/structArrayRefState*state;}arrayref;/*forEEOP_DOMAIN_NOTNULL/DOMAIN_CHECK*/struct{/*nameofconstraint*/char*constraintname;/*wheretheresultofaCHECKconstraintwillbestored*/Datum*checkvalue;bool*checknull;/*OIDofdomaintype*/Oidresulttype;}domaincheck;/*forEEOP_CONVERT_ROWTYPE*/struct{ConvertRowtypeExpr*convert;/*originalexpression*//*thesethreefieldsarefilledatruntime:*/TupleDescindesc;/*tupdescforinputtype*/TupleDescoutdesc;/*tupdescforoutputtype*/TupleConversionMap*map;/*columnmapping*/boolinitialized;/*initializedforcurrenttypes?*/}convert_rowtype;/*forEEOP_SCALARARRAYOP*/struct{/*element_type/typlen/typbyval/typalignarefilledatruntime*/Oidelement_type;/*InvalidOidifnotyetfilled*/booluseOr;/*useORorANDsemantics?*/int16typlen;/*arrayelementtypestorageinfo*/booltypbyval;chartypalign;FmgrInfo*finfo;/*function'slookupdata*/FunctionCallInfofcinfo_data;/*argumentsetc*//*fastertoaccesswithoutadditionalindirection:*/PGFunctionfn_addr;/*actualcalladdress*/}scalararrayop;/*forEEOP_XMLEXPR*/struct{XmlExpr*xexpr;/*originalexpressionnode*//*workspaceforevaluatingnamedargs,ifany*/Datum*named_argvalue;bool*named_argnull;/*workspaceforevaluatingunnamedargs,ifany*/Datum*argvalue;bool*argnull;}xmlexpr;/*forEEOP_AGGREF*/struct{/*out-of-linestate,modifiedbynodeAgg.c*/AggrefExprState*astate;}aggref;/*forEEOP_GROUPING_FUNC*/struct{AggState*parent;/*parentAgg*/List*clauses;/*integerlistofcolumnnumbers*/}grouping_func;/*forEEOP_WINDOW_FUNC*/struct{/*out-of-linestate,modifiedbynodeWindowFunc.c*/WindowFuncExprState*wfstate;}window_func;/*forEEOP_SUBPLAN*/struct{/*out-of-linestate,createdbynodeSubplan.c*/SubPlanState*sstate;}subplan;/*forEEOP_ALTERNATIVE_SUBPLAN*/struct{/*out-of-linestate,createdbynodeSubplan.c*/AlternativeSubPlanState*asstate;}alternative_subplan;/*forEEOP_AGG_*DESERIALIZE*/struct{AggState*aggstate;FunctionCallInfofcinfo_data;intjumpnull;}agg_deserialize;/*forEEOP_AGG_STRICT_INPUT_CHECK*/struct{bool*nulls;intnargs;intjumpnull;}agg_strict_input_check;/*forEEOP_AGG_INIT_TRANS*/struct{AggState*aggstate;AggStatePerTranspertrans;ExprContext*aggcontext;intsetno;inttransno;intsetoff;intjumpnull;}agg_init_trans;/*forEEOP_AGG_STRICT_TRANS_CHECK*/struct{AggState*aggstate;intsetno;inttransno;intsetoff;intjumpnull;}agg_strict_trans_check;/*forEEOP_AGG_{PLAIN,ORDERED}_TRANS**/struct{AggState*aggstate;AggStatePerTranspertrans;ExprContext*aggcontext;intsetno;inttransno;intsetoff;}agg_trans;}d;}ExprEvalStep;
ExprEvalOp
ExprEvalSteps的鉴频器,定义哪个操作将被执行并且联合体ExprEvalStep->d中的哪个struct将被使用.
/**DiscriminatorforExprEvalSteps.*ExprEvalSteps的鉴频器**Identifiestheoperationtobeexecutedandwhichmemberinthe*ExprEvalStep->dunionisvalid.*定义哪个操作将被执行并且联合体ExprEvalStep->d中的哪个struct将被使用.**Theorderofentriesneedstobekeptinsyncwiththedispatch_table[]*arrayinexecExprInterp.c:ExecInterpExpr().*条目的排序需要与execExprInterp.c:ExecInterpExpr()中dispatch_table[]数组的元素保持一致*/typedefenumExprEvalOp{/*entireexpressionhasbeenevaluatedcompletely,return*///整个表达式已被解析,返回EEOP_DONE,/*applyslot_getsomeattrsoncorrespondingtupleslot*///在相应的元组slot上应用了slot_getsomeattrs方法EEOP_INNER_FETCHSOME,EEOP_OUTER_FETCHSOME,EEOP_SCAN_FETCHSOME,/*computenon-systemVarvalue*///计算非系统Var变量值EEOP_INNER_VAR,EEOP_OUTER_VAR,EEOP_SCAN_VAR,/*computesystemVarvalue*///计算系统Var变量值EEOP_INNER_SYSVAR,EEOP_OUTER_SYSVAR,EEOP_SCAN_SYSVAR,/*computewholerowVar*///计算整行VarEEOP_WHOLEROW,/**Computenon-systemVarvalue,assignitintoExprState'sresultslot.*ThesearenotusedifaCheckVarSlotCompatibility()checkwouldbe*needed.*计算非系统Var值,分配到ExprState's的resultslot字段中.*如果CheckVarSlotCompatibility()需要时,这些都不需要.*/EEOP_ASSIGN_INNER_VAR,EEOP_ASSIGN_OUTER_VAR,EEOP_ASSIGN_SCAN_VAR,/*assignExprState'sresvalue/resnulltoacolumnofitsresultslot*///分配ExprState'sresvalue/resnull到该列的resultslot中EEOP_ASSIGN_TMP,/*ditto,applyingMakeExpandedObjectReadOnly()*///同上,应用MakeExpandedObjectReadOnly()EEOP_ASSIGN_TMP_MAKE_RO,/*evaluateConstvalue*///解析常量值EEOP_CONST,/**Evaluatefunctioncall(includingOpExprsetc).Forspeed,we*distinguishintheopcodewhetherthefunctionisstrictand/or*requiresusagestatstracking.*解析函数调用(包括OpExprs等等).*出于性能的考虑,需要区分opcode是strict函数还是非strict函数,以及是否需要统计跟踪.*/EEOP_FUNCEXPR,EEOP_FUNCEXPR_STRICT,EEOP_FUNCEXPR_FUSAGE,EEOP_FUNCEXPR_STRICT_FUSAGE,/**EvaluatebooleanANDexpression,onesteppersubexpression.FIRST/LAST*subexpressionsarespecial-casedforperformance.SinceANDalwayshas*atleasttwosubexpressions,FIRSTandLASTneverapplytothesame*subexpression.*解析布尔AND表达式,每一个子表达式一个步骤.*FIRST/LAST子表达式是性能上的特例.*由于AND通常至少有两个子表达式,FIRST和LAST永远都不会应用在同一个子表达式上.*/EEOP_BOOL_AND_STEP_FIRST,EEOP_BOOL_AND_STEP,EEOP_BOOL_AND_STEP_LAST,/*similarlyforbooleanORexpression*///与布尔OR表达式类似EEOP_BOOL_OR_STEP_FIRST,EEOP_BOOL_OR_STEP,EEOP_BOOL_OR_STEP_LAST,/*evaluatebooleanNOTexpression*///解析布尔NOT表达式EEOP_BOOL_NOT_STEP,/*simplifiedversionofBOOL_AND_STEPforusebyExecQual()*///用于ExecQual()中的BOOL_AND_STEP简化版本EEOP_QUAL,/*unconditionaljumptoanotherstep*///无条件跳转到另外一个步骤EEOP_JUMP,/*conditionaljumpsbasedoncurrentresultvalue*///基于当前结果值的条件跳转EEOP_JUMP_IF_NULL,EEOP_JUMP_IF_NOT_NULL,EEOP_JUMP_IF_NOT_TRUE,/*performNULLtestsforscalarvalues*///为scalar值执行NULL测试EEOP_NULLTEST_ISNULL,EEOP_NULLTEST_ISNOTNULL,/*performNULLtestsforrowvalues*///为行值执行NULL测试EEOP_NULLTEST_ROWISNULL,EEOP_NULLTEST_ROWISNOTNULL,/*evaluateaBooleanTestexpression*///解析BooleanTest表达式EEOP_BOOLTEST_IS_TRUE,EEOP_BOOLTEST_IS_NOT_TRUE,EEOP_BOOLTEST_IS_FALSE,EEOP_BOOLTEST_IS_NOT_FALSE,/*evaluatePARAM_EXEC/EXTERNparameters*///解析PARAM_EXEC/EXTERN参数EEOP_PARAM_EXEC,EEOP_PARAM_EXTERN,EEOP_PARAM_CALLBACK,/*returnCaseTestExprvalue*///返回CaseTestExpr值EEOP_CASE_TESTVAL,/*applyMakeExpandedObjectReadOnly()totargetvalue*///对目标值应用MakeExpandedObjectReadOnly()EEOP_MAKE_READONLY,/*evaluateassortedspecial-purposeexpressiontypes*///解析各种特殊用途的表达式类型EEOP_IOCOERCE,EEOP_DISTINCT,EEOP_NOT_DISTINCT,EEOP_NULLIF,EEOP_SQLVALUEFUNCTION,EEOP_CURRENTOFEXPR,EEOP_NEXTVALUEEXPR,EEOP_ARRAYEXPR,EEOP_ARRAYCOERCE,EEOP_ROW,/**ComparetwoindividualelementsofeachoftwocomparedROW()*expressions.SkiptoROWCOMPARE_FINALifelementsarenotequal.*给出两个需要对比的ROW()表达式,两两比较行中的元素.*如果元素不相等,则跳转到ROWCOMPARE_FINAL*/EEOP_ROWCOMPARE_STEP,/*evaluatebooleanvaluebasedonpreviousROWCOMPARE_STEPoperations*///基于上一步的ROWCOMPARE_STEP操作解析布尔值EEOP_ROWCOMPARE_FINAL,/*evaluateGREATEST()orLEAST()*///解析GREATEST()和LEAST()EEOP_MINMAX,/*evaluateFieldSelectexpression*///解析FieldSelect表达式EEOP_FIELDSELECT,/**Deformtuplebeforeevaluatingnewvaluesforindividualfieldsina*FieldStoreexpression.*在解析FieldStore表达式中的独立列新值前重构元组*/EEOP_FIELDSTORE_DEFORM,/**FormthenewtupleforaFieldStoreexpression.Individualfieldswill*havebeenevaluatedintocolumnsofthetupledeformedbythepreceding*DEFORMstep.*为FieldStore表达式构成新元组.*单独的字段会解析到元组的列中(行已被上一个步骤EEOP_FIELDSTORE_DEFORM析构)*/EEOP_FIELDSTORE_FORM,/*Processanarraysubscript;short-circuitexpressiontoNULLifNULL*///处理数组子脚本.如为NULL则短路表达式为NULLEEOP_ARRAYREF_SUBSCRIPT,/**Computeoldarrayelement/slicewhenanArrayRefassignmentexpression*containsArrayRef/FieldStoresubexpressions.Valueisaccessedusing*theCaseTestmechanism.*在ArrayRef分配表达式包含ArrayRef/FieldStore子表达式时计算旧的数组元素/片.*通过CaseTest机制访问Value*/EEOP_ARRAYREF_OLD,/*computenewvalueforArrayRefassignmentexpression*///为ArrayRef分配118EEOP_ARRAYREF_ASSIGN,/*computeelement/sliceforArrayReffetchexpression*///为ArrayRef提取表达式计算element/sliceEEOP_ARRAYREF_FETCH,/*evaluatevalueforCoerceToDomainValue*///为CoerceToDomainValue解析值EEOP_DOMAIN_TESTVAL,/*evaluateadomain'sNOTNULLconstraint*///解析域NOTNULL约束EEOP_DOMAIN_NOTNULL,/*evaluateasingledomainCHECKconstraint*///解析单个域CHECK约束EEOP_DOMAIN_CHECK,/*evaluateassortedspecial-purposeexpressiontypes*///解析特殊目的的表达式类型EEOP_CONVERT_ROWTYPE,EEOP_SCALARARRAYOP,EEOP_XMLEXPR,EEOP_AGGREF,EEOP_GROUPING_FUNC,EEOP_WINDOW_FUNC,EEOP_SUBPLAN,EEOP_ALTERNATIVE_SUBPLAN,/*aggregationrelatednodes*///聚合相关节点EEOP_AGG_STRICT_DESERIALIZE,EEOP_AGG_DESERIALIZE,EEOP_AGG_STRICT_INPUT_CHECK,EEOP_AGG_INIT_TRANS,EEOP_AGG_STRICT_TRANS_CHECK,EEOP_AGG_PLAIN_TRANS_BYVAL,EEOP_AGG_PLAIN_TRANS,EEOP_AGG_ORDERED_TRANS_DATUM,EEOP_AGG_ORDERED_TRANS_TUPLE,/*non-existentoperation,usede.g.tocheckarraylengths*///不存在的操作,比如用于检测数组长度EEOP_LAST}ExprEvalOp;二、源码解读
ExecInitIndexScan
初始化Index Scan运行期状态信息,调用ExecAssignScanProjectionInfo->…->ExecBuildProjectionInfo函数构建投影信息.
/*----------------------------------------------------------------*ExecInitIndexScan**Initializestheindexscan'sstateinformation,creates*scankeys,andopensthebaseandindexrelations.**Note:indexscanshave2setsofstateinformationbecause*wehavetokeeptrackofthebaserelationandthe*indexrelation.*----------------------------------------------------------------*/IndexScanState*ExecInitIndexScan(IndexScan*node,EState*estate,inteflags){.../**Initializeresultslot,typeandprojection.*初始化结果slot,类型和投影*/ExecInitResultTupleSlotTL(estate,&indexstate->ss.ps);ExecAssignScanProjectionInfo(&indexstate->ss);...}
ExecBuildProjectionInfo
为给定的econtext中的tlist构建ProjectionInfo,并把结果存储在tuple slot中.(调用者必须确保元组slot与此tlist匹配)
其主要逻辑是:
1.初始化
2.如需要,插入EEOP*_FETCHSOME步骤(调用ExecInitExprSlots)
3.遍历targetList,处理targetList(目标列)中的每一个列
3.1.对于”安全”Var则只需要生成EEOP_ASSIGN*_VAR步骤
3.2对于非”安全”VAr,使用常规办法处理列表达式,调用ExecInitExprRec函数处理,并通过ExprEvalPushStep压步骤
4.压入EEOP_DONE步骤
/*
* ExecAssignScanProjectionInfo
* Set up projection info for a scan node, if necessary.
* ExecAssignScanProjectionInfo
* 为扫描节点配置投影信息.
*
* We can avoid a projection step if the requested tlist exactly matches
* the underlying tuple type. If so, we just set ps_ProjInfo to NULL.
* Note that this case occurs not only for simple "SELECT * FROM ...", but
* also in most cases where there are joins or other processing nodes above
* the scan node, because the planner will preferentially generate a matching
* tlist.
* 如果请求的tlist刚好与潜在的tuple类型相匹配,则可以避免投影这一步骤.
* 因此,只需要简单的把ps_ProjInfo设置为NULL即可.
* 注意这种情况不单在"SELECT * FROM ..."时会出现,
* 而且在存在连接或者其他处理节点在扫描节点的上层时也会发生,
* 因为规划器会优先生成匹配的tlist.
*
* The scan slot's descriptor must have been set already.
* 扫描slot的描述符必须已设置.
*/
void
ExecAssignScanProjectionInfo(ScanState *node)
{
//扫描节点
Scan *scan = (Scan *) node->ps.plan;
//元组描述符
TupleDesc tupdesc = node->ss_ScanTupleSlot->tts_tupleDescriptor;
//执行ExecConditionalAssignProjectionInfo
ExecConditionalAssignProjectionInfo(&node->ps, tupdesc, scan->scanrelid);
}
/* ----------------
* ExecConditionalAssignProjectionInfo
*
* as ExecAssignProjectionInfo, but store NULL rather than building projection
* info if no projection is required
* 与ExecAssignProjectionInfo类似,但在不需要投影操作时只需要存储NULL而不是构建投影信息
* ----------------
*/
void
ExecConditionalAssignProjectionInfo(PlanState *planstate, TupleDesc inputDesc,
Index varno)
{
//正好匹配元组类型,则设计为NULL
if (tlist_matches_tupdesc(planstate,
planstate->plan->targetlist,
varno,
inputDesc))
planstate->ps_ProjInfo = NULL;
else
//否则执行ExecAssignProjectionInfo
ExecAssignProjectionInfo(planstate, inputDesc);
}
/* ----------------
* ExecAssignProjectionInfo
*
* forms the projection information from the node's targetlist
* 通过节点的targetlist构造投影信息.
*
* Notes for inputDesc are same as for ExecBuildProjectionInfo: supply it
* for a relation-scan node, can pass NULL for upper-level nodes
* 注意inputDesc与ExecBuildProjectionInfo的一样:
* 为relation-scan节点提供该描述符,可能为高层的节点传递NULL值
* ----------------
*/
void
ExecAssignProjectionInfo(PlanState *planstate,
TupleDesc inputDesc)
{
//直接调用ExecBuildProjectionInfo
planstate->ps_ProjInfo =
ExecBuildProjectionInfo(planstate->plan->targetlist,
planstate->ps_ExprContext,
planstate->ps_ResultTupleSlot,
planstate,
inputDesc);
}
/*
* ExecBuildProjectionInfo
*
* Build a ProjectionInfo node for evaluating the given tlist in the given
* econtext, and storing the result into the tuple slot. (Caller must have
* ensured that tuple slot has a descriptor matching the tlist!)
* 为给定的econtext中的tlist构建ProjectionInfo,并把结果存储在tuple slot中.
* (调用者必须确保元组slot与此tlist匹配)
*
* inputDesc can be NULL, but if it is not, we check to see whether simple
* Vars in the tlist match the descriptor. It is important to provide
* inputDesc for relation-scan plan nodes, as a cross check that the relation
* hasn't been changed since the plan was made. At higher levels of a plan,
* there is no need to recheck.
* inputDesc可以为NULL,但如果不是,检查tlist中的简单Vars是否与描述符匹配.
* 对于relation-scan节点来说,提供inputDesc是十分重要的,
* 交叉检查在plan已生成的情况下relation没有出现变化.
* 而plan更高的层次,则不需要重新检查.
*
* This is implemented by internally building an ExprState that performs the
* whole projection in one go.
* 通过内部构造ExprState(在一轮执行中完成整个投影操作)来实现.
*
* Caution: before PG v10, the targetList was a list of ExprStates; now it
* should be the planner-created targetlist, since we do the compilation here.
* 注意:在PG v10前,targetlist是ExprState链表,现在tlist应该是planner创建的targetlist,
* 如不是则需报错.
*/
ProjectionInfo *
ExecBuildProjectionInfo(List *targetList,
ExprContext *econtext,
TupleTableSlot *slot,
PlanState *parent,
TupleDesc inputDesc)
{
//生成ProjectionInfo节点
ProjectionInfo *projInfo = makeNode(ProjectionInfo);
//表达式状态节点
ExprState *state;
//表达式解析步骤
ExprEvalStep scratch = {0};
//临时变量
ListCell *lc;
//expr上下文
projInfo->pi_exprContext = econtext;
/* We embed ExprState into ProjectionInfo instead of doing extra palloc */
//集成ExprState到ProjectionInfo中,而不需要另外的palloc
projInfo->pi_state.tag.type = T_ExprState;
state = &projInfo->pi_state;
state->expr = (Expr *) targetList;
state->parent = parent;
state->ext_params = NULL;
state->resultslot = slot;
/* Insert EEOP_*_FETCHSOME steps as needed */
//如需要,插入EEOP_*_FETCHSOME步骤
ExecInitExprSlots(state, (Node *) targetList);
/* Now compile each tlist column */
//现在"编译"tlist中的每一个列
foreach(lc, targetList)
{
TargetEntry *tle = lfirst_node(TargetEntry, lc);
Var *variable = NULL;
AttrNumber attnum = 0;
bool isSafeVar = false;
/*
* If tlist expression is a safe non-system Var, use the fast-path
* ASSIGN_*_VAR opcodes. "Safe" means that we don't need to apply
* CheckVarSlotCompatibility() during plan startup. If a source slot
* was provided, we make the equivalent tests here; if a slot was not
* provided, we assume that no check is needed because we're dealing
* with a non-relation-scan-level expression.
* 如果tlist表达式是安全的非系统Var,使用快速路径ASSIGN_*_VAR opcodes.
* "Safe"的意思是在计划启动执行时我们不需要应用CheckVarSlotCompatibility().
* 如果提供了源slot,假定不需要再做检查,因为我们正在处理的是非关系扫描级别的表达式.
*/
if (tle->expr != NULL &&
IsA(tle->expr, Var) &&
((Var *) tle->expr)->varattno > 0)
{
/* Non-system Var, but how safe is it? */
//非系统Var,但有多安全呢?
variable = (Var *) tle->expr;
attnum = variable->varattno;
if (inputDesc == NULL)
//无法检查,假定是OK的.
isSafeVar = true; /* can't check, just assume OK */
else if (attnum <= inputDesc->natts)
{
//---- 属性编号小于输入的属性个数
Form_pg_attribute attr = TupleDescAttr(inputDesc, attnum - 1);
/*
* If user attribute is dropped or has a type mismatch, don't
* use ASSIGN_*_VAR. Instead let the normal expression
* machinery handle it (which'll possibly error out).
* 如果用户属性已被清除或者有类型不匹配,不要使用ASSIGN_*_VAR.
* 让常规的表达式匹配处理这周情况(可能会出现错误)
*/
if (!attr->attisdropped && variable->vartype == attr->atttypid)
{
isSafeVar = true;
}
}
}
if (isSafeVar)
{
//--- 如为安全的Var
/* Fast-path: just generate an EEOP_ASSIGN_*_VAR step */
//Fast-path: 只需要生成EEOP_ASSIGN_*_VAR步骤即可
switch (variable->varno)
{
case INNER_VAR:
/* get the tuple from the inner node */
//内关系VAR,从inner节点获取元组
scratch.opcode = EEOP_ASSIGN_INNER_VAR;
break;
case OUTER_VAR:
/* get the tuple from the outer node */
//从外关系获取元组
scratch.opcode = EEOP_ASSIGN_OUTER_VAR;
break;
/* INDEX_VAR is handled by default case */
//默认: INDEX_VAR
default:
/* get the tuple from the relation being scanned */
//从正在扫描的关系中获取元组
scratch.opcode = EEOP_ASSIGN_SCAN_VAR;
break;
}
//EEOP_ASSIGN_*_VAR
scratch.d.assign_var.attnum = attnum - 1;
scratch.d.assign_var.resultnum = tle->resno - 1;
ExprEvalPushStep(state, &scratch);
}
else
{
/*
* Otherwise, compile the column expression normally.
* 否则的话,使用常规办法"编译"列表达式
*
* We can't tell the expression to evaluate directly into the
* result slot, as the result slot (and the exprstate for that
* matter) can change between executions. We instead evaluate
* into the ExprState's resvalue/resnull and then move.
* 我们不能够直接告知表达式进行解析到结果slot中,
* 因为结果slot(以及这种情况下的exprstate)在执行期间会出现变化.
* 我们只需要解析到ExprState's的resvalue/resnull中并进行移动即可.
*/
ExecInitExprRec(tle->expr, state,
&state->resvalue, &state->resnull);
/*
* Column might be referenced multiple times in upper nodes, so
* force value to R/O - but only if it could be an expanded datum.
* 列可能在高层节点被依赖多次,因此强制值为R/O - 只在可扩展datum时才这样处理
*/
//d.assign_tmp.resultnum/attnum
if (get_typlen(exprType((Node *) tle->expr)) == -1)
scratch.opcode = EEOP_ASSIGN_TMP_MAKE_RO;
else
scratch.opcode = EEOP_ASSIGN_TMP;
scratch.d.assign_tmp.resultnum = tle->resno - 1;
ExprEvalPushStep(state, &scratch);
}
}
scratch.opcode = EEOP_DONE;
ExprEvalPushStep(state, &scratch);
ExecReadyExpr(state);
//返回投影信息.
return projInfo;
}
三、跟踪分析
测试脚本
testdb=# select 1+id,c2 from t_expr where id < 3;
调用栈
(gdb) bt
#0 ExecBuildProjectionInfo (targetList=0x1cc7550, econtext=0x1c8f408, slot=0x1c8f710, parent=0x1c8f1f0,
inputDesc=0x7f8386bb6ab8) at execExpr.c:355
#1 0x00000000006e60d5 in ExecAssignProjectionInfo (planstate=0x1c8f1f0, inputDesc=0x7f8386bb6ab8) at execUtils.c:468
#2 0x00000000006e613c in ExecConditionalAssignProjectionInfo (planstate=0x1c8f1f0, inputDesc=0x7f8386bb6ab8, varno=1)
at execUtils.c:493
#3 0x00000000006e23f5 in ExecAssignScanProjectionInfo (node=0x1c8f1f0) at execScan.c:240
#4 0x0000000000700afc in ExecInitIndexScan (node=0x1ba8a18, estate=0x1c8efd8, eflags=16) at nodeIndexscan.c:962
#5 0x00000000006e00cc in ExecInitNode (node=0x1ba8a18, estate=0x1c8efd8, eflags=16) at execProcnode.c:217
#6 0x00000000006d6abe in InitPlan (queryDesc=0x1c94aa8, eflags=16) at execMain.c:1046
#7 0x00000000006d58ad in standard_ExecutorStart (queryDesc=0x1c94aa8, eflags=16) at execMain.c:265
#8 0x00000000006d5649 in ExecutorStart (queryDesc=0x1c94aa8, eflags=0) at execMain.c:147
#9 0x00000000008c18d6 in PortalStart (portal=0x1c15608, params=0x0, eflags=0, snapshot=0x0) at pquery.c:520
#10 0x00000000008bbe1b in exec_simple_query (query_string=0x1ba6d78 "select 1+id,c2 from t_expr where id < 3;")
at postgres.c:1106
#11 0x00000000008c0191 in PostgresMain (argc=1, argv=0x1bd4cb8, dbname=0x1bd4b20 "testdb", username=0x1ba3a98 "xdb")
at postgres.c:4182
#12 0x000000000081e06c in BackendRun (port=0x1bc8ae0) at postmaster.c:4361
#13 0x000000000081d7df in BackendStartup (port=0x1bc8ae0) at postmaster.c:4033
#14 0x0000000000819bd9 in ServerLoop () at postmaster.c:1706
#15 0x000000000081948f in PostmasterMain (argc=1, argv=0x1ba1a50) at postmaster.c:1379
#16 0x0000000000742931 in main (argc=1, argv=0x1ba1a50) at main.c:228
执行跟踪,进入函数ExecBuildProjectionInfo
(gdb) b ExecBuildProjectionInfo
Breakpoint 1 at 0x6c5377: file execExpr.c, line 355.
(gdb) c
Continuing.
Breakpoint 1, ExecBuildProjectionInfo (targetList=0x1c93498, econtext=0x1c883a8, slot=0x1c887c8, parent=0x1c88190,
inputDesc=0x1c884a0) at execExpr.c:355
355 ProjectionInfo *projInfo = makeNode(ProjectionInfo);
(gdb)
1.初始化
(gdb) n
357 ExprEvalStep scratch = {0};
(gdb)
360 projInfo->pi_exprContext = econtext;
(gdb)
362 projInfo->pi_state.tag.type = T_ExprState;
(gdb)
363 state = &projInfo->pi_state;
(gdb)
364 state->expr = (Expr *) targetList;
(gdb)
365 state->parent = parent;
(gdb)
366 state->ext_params = NULL;
(gdb)
368 state->resultslot = slot;
(gdb)
查看相关变量
(gdb) p *state
$1 = {tag = {type = T_ExprState}, flags = 0 '\000', resnull = false, resvalue = 0, resultslot = 0x1c8f710, steps = 0x0,
evalfunc = 0x0, expr = 0x1cc7550, evalfunc_private = 0x0, steps_len = 0, steps_alloc = 0, parent = 0x1c8f1f0,
ext_params = 0x0, innermost_caseval = 0x0, innermost_casenull = 0x0, innermost_domainval = 0x0,
innermost_domainnull = 0x0}
目标列链表
(gdb) p targetList
$2 = (List *) 0x1cc7550
(gdb) p *targetList
$3 = {type = T_List, length = 2, head = 0x1cc7528, tail = 0x1cc75e0}
第一个元素是1+id,第二个元素是c2
(gdb) p *(TargetEntry *)targetList->head->data.ptr_value
$7 = {xpr = {type = T_TargetEntry}, expr = 0x1c9a930, resno = 1, resname = 0xbcf498 "?column?", ressortgroupref = 0,
resorigtbl = 0, resorigcol = 0, resjunk = false}
(gdb) p *(OpExpr *)((TargetEntry *)targetList->head->data.ptr_value)->expr
$9 = {xpr = {type = T_OpExpr}, opno = 551, opfuncid = 177, opresulttype = 23, opretset = false, opcollid = 0,
inputcollid = 0, args = 0x1c9a878, location = 8}
(gdb) p *(Node *)targetList->head->next->data.ptr_value
$10 = {type = T_TargetEntry}
(gdb) p *(TargetEntry *)targetList->head->next->data.ptr_value
$11 = {xpr = {type = T_TargetEntry}, expr = 0x1c9aa40, resno = 2, resname = 0x1ba7a40 "c2", ressortgroupref = 0,
resorigtbl = 237600, resorigcol = 2, resjunk = false}
2.如需要,插入EEOP_*_FETCHSOME步骤(调用ExecInitExprSlots)
(gdb)
371 ExecInitExprSlots(state, (Node *) targetList);
第一个步骤,opcode = 3,即EEOP_SCAN_FETCHSOME
(gdb) n
374 foreach(lc, targetList)
(gdb) p *state
$13 = {tag = {type = T_ExprState}, flags = 0 '\000', resnull = false, resvalue = 0, resultslot = 0x1c8f710,
steps = 0x1c8f868, evalfunc = 0x0, expr = 0x1cc7550, evalfunc_private = 0x0, steps_len = 1, steps_alloc = 16,
parent = 0x1c8f1f0, ext_params = 0x0, innermost_caseval = 0x0, innermost_casenull = 0x0, innermost_domainval = 0x0,
innermost_domainnull = 0x0}
(gdb) p state->steps[0]
$14 = {opcode = 3, resvalue = 0x0, resnull = 0x0, d = {fetch = {last_var = 2, known_desc = 0x0}, var = {attnum = 2,
vartype = 0}, wholerow = {var = 0x2, first = false, slow = false, tupdesc = 0x0, junkFilter = 0x0}, assign_var = {
resultnum = 2, attnum = 0}, assign_tmp = {resultnum = 2}, constval = {value = 2, isnull = false}, func = {
finfo = 0x2, fcinfo_data = 0x0, fn_addr = 0x0, nargs = 0}, boolexpr = {anynull = 0x2, jumpdone = 0}, qualexpr = {
jumpdone = 2}, jump = {jumpdone = 2}, nulltest_row = {argdesc = 0x2}, param = {paramid = 2, paramtype = 0}, cparam = {
paramfunc = 0x2, paramarg = 0x0, paramid = 0, paramtype = 0}, casetest = {value = 0x2, isnull = 0x0},
make_readonly = {value = 0x2, isnull = 0x0}, iocoerce = {finfo_out = 0x2, fcinfo_data_out = 0x0, finfo_in = 0x0,
fcinfo_data_in = 0x0}, sqlvaluefunction = {svf = 0x2}, nextvalueexpr = {seqid = 2, seqtypid = 0}, arrayexpr = {
elemvalues = 0x2, elemnulls = 0x0, nelems = 0, elemtype = 0, elemlength = 0, elembyval = false, elemalign = 0 '\000',
multidims = false}, arraycoerce = {elemexprstate = 0x2, resultelemtype = 0, amstate = 0x0}, row = {tupdesc = 0x2,
elemvalues = 0x0, elemnulls = 0x0}, rowcompare_step = {finfo = 0x2, fcinfo_data = 0x0, fn_addr = 0x0, jumpnull = 0,
jumpdone = 0}, rowcompare_final = {rctype = ROWCOMPARE_LE}, minmax = {values = 0x2, nulls = 0x0, nelems = 0,
op = IS_GREATEST, finfo = 0x0, fcinfo_data = 0x0}, fieldselect = {fieldnum = 2, resulttype = 0, argdesc = 0x0},
fieldstore = {fstore = 0x2, argdesc = 0x0, values = 0x0, nulls = 0x0, ncolumns = 0}, arrayref_subscript = {state = 0x2,
off = 0, isupper = false, jumpdone = 0}, arrayref = {state = 0x2}, domaincheck = {
constraintname = 0x2 <Address 0x2 out of bounds>, checkvalue = 0x0, checknull = 0x0, resulttype = 0},
convert_rowtype = {convert = 0x2, indesc = 0x0, outdesc = 0x0, map = 0x0, initialized = false}, scalararrayop = {
element_type = 2, useOr = false, typlen = 0, typbyval = false, typalign = 0 '\000', finfo = 0x0, fcinfo_data = 0x0,
fn_addr = 0x0}, xmlexpr = {xexpr = 0x2, named_argvalue = 0x0, named_argnull = 0x0, argvalue = 0x0, argnull = 0x0},
aggref = {astate = 0x2}, grouping_func = {parent = 0x2, clauses = 0x0}, window_func = {wfstate = 0x2}, subplan = {
sstate = 0x2}, alternative_subplan = {asstate = 0x2}, agg_deserialize = {aggstate = 0x2, fcinfo_data = 0x0,
jumpnull = 0}, agg_strict_input_check = {nulls = 0x2, nargs = 0, jumpnull = 0}, agg_init_trans = {aggstate = 0x2,
pertrans = 0x0, aggcontext = 0x0, setno = 0, transno = 0, setoff = 0, jumpnull = 0}, agg_strict_trans_check = {
aggstate = 0x2, setno = 0, transno = 0, setoff = 0, jumpnull = 0}, agg_trans = {aggstate = 0x2, pertrans = 0x0,
aggcontext = 0x0, setno = 0, transno = 0, setoff = 0}}}
(gdb)
3.遍历targetList,处理targetList(目标列)中的每一个列
3.1.对于”安全”Var则只需要生成EEOPASSIGN*_VAR步骤
3.2.对于非”安全”VAr,使用常规办法处理列表达式,调用ExecInitExprRec函数处理,并通过ExprEvalPushStep压步骤
(gdb) n
376 TargetEntry *tle = lfirst_node(TargetEntry, lc);
(gdb)
377 Var *variable = NULL;
(gdb)
378 AttrNumber attnum = 0;
(gdb)
379 bool isSafeVar = false;
(gdb)
389 if (tle->expr != NULL &&
(gdb)
390 IsA(tle->expr, Var) &&
(gdb)
389 if (tle->expr != NULL &&
(gdb)
415 if (isSafeVar)
(gdb) p *tle
$15 = {xpr = {type = T_TargetEntry}, expr = 0x1c9a930, resno = 1, resname = 0xbcf498 "?column?", ressortgroupref = 0,
resorigtbl = 0, resorigcol = 0, resjunk = false}
(gdb) n
452 ExecInitExprRec(tle->expr, state,
(gdb)
进入ExecInitExprRec,Node节点为OpExpr,执行ExprEvalPushStep压入步骤中
(gdb) step
ExecInitExprRec (node=0x1c9a930, state=0x1c8f7d8, resv=0x1c8f7e0, resnull=0x1c8f7dd) at execExpr.c:645
645 ExprEvalStep scratch = {0};
(gdb) n
648 check_stack_depth();
(gdb)
651 Assert(resv != NULL && resnull != NULL);
(gdb)
652 scratch.resvalue = resv;
(gdb)
653 scratch.resnull = resnull;
(gdb)
656 switch (nodeTag(node))
(gdb)
891 OpExpr *op = (OpExpr *) node;
(gdb) p *node
$16 = {type = T_OpExpr}
(gdb) n
893 ExecInitFunc(&scratch, node,
(gdb)
896 ExprEvalPushStep(state, &scratch);
(gdb)
897 break;
(gdb)
2122 }
(gdb)
ExecBuildProjectionInfo (targetList=0x1cc7550, econtext=0x1c8f408, slot=0x1c8f710, parent=0x1c8f1f0,
inputDesc=0x7f8386bb6ab8) at execExpr.c:459
459 if (get_typlen(exprType((Node *) tle->expr)) == -1)
(gdb)
462 scratch.opcode = EEOP_ASSIGN_TMP;
(gdb)
ExecInitExprRec调用完毕,增加了2个步骤,分别是:
1.opcode = 6,即EEOP_SCAN_VAR
2.opcode = 18,即EEOP_FUNCEXPR_STRICT
(gdb) p *state
$17 = {tag = {type = T_ExprState}, flags = 0 '\000', resnull = false, resvalue = 0, resultslot = 0x1c8f710,
steps = 0x1c8f868, evalfunc = 0x0, expr = 0x1cc7550, evalfunc_private = 0x0, steps_len = 3, steps_alloc = 16,
parent = 0x1c8f1f0, ext_params = 0x0, innermost_caseval = 0x0, innermost_casenull = 0x0, innermost_domainval = 0x0,
innermost_domainnull = 0x0}
(gdb) p state->steps[1]
$18 = {opcode = 6, resvalue = 0x1c8fd00, resnull = 0x1c90019, d = {fetch = {last_var = 0, known_desc = 0x0}, var = {
attnum = 0, vartype = 23}, wholerow = {var = 0x1700000000, first = false, slow = false, tupdesc = 0x0,
junkFilter = 0x0}, assign_var = {resultnum = 0, attnum = 23}, assign_tmp = {resultnum = 0}, constval = {
value = 98784247808, isnull = false}, func = {finfo = 0x1700000000, fcinfo_data = 0x0, fn_addr = 0x0, nargs = 0},
boolexpr = {anynull = 0x1700000000, jumpdone = 0}, qualexpr = {jumpdone = 0}, jump = {jumpdone = 0}, nulltest_row = {
argdesc = 0x1700000000}, param = {paramid = 0, paramtype = 23}, cparam = {paramfunc = 0x1700000000, paramarg = 0x0,
paramid = 0, paramtype = 0}, casetest = {value = 0x1700000000, isnull = 0x0}, make_readonly = {value = 0x1700000000,
isnull = 0x0}, iocoerce = {finfo_out = 0x1700000000, fcinfo_data_out = 0x0, finfo_in = 0x0, fcinfo_data_in = 0x0},
sqlvaluefunction = {svf = 0x1700000000}, nextvalueexpr = {seqid = 0, seqtypid = 23}, arrayexpr = {
elemvalues = 0x1700000000, elemnulls = 0x0, nelems = 0, elemtype = 0, elemlength = 0, elembyval = false,
elemalign = 0 '\000', multidims = false}, arraycoerce = {elemexprstate = 0x1700000000, resultelemtype = 0,
amstate = 0x0}, row = {tupdesc = 0x1700000000, elemvalues = 0x0, elemnulls = 0x0}, rowcompare_step = {
finfo = 0x1700000000, fcinfo_data = 0x0, fn_addr = 0x0, jumpnull = 0, jumpdone = 0}, rowcompare_final = {rctype = 0},
minmax = {values = 0x1700000000, nulls = 0x0, nelems = 0, op = IS_GREATEST, finfo = 0x0, fcinfo_data = 0x0},
fieldselect = {fieldnum = 0, resulttype = 23, argdesc = 0x0}, fieldstore = {fstore = 0x1700000000, argdesc = 0x0,
values = 0x0, nulls = 0x0, ncolumns = 0}, arrayref_subscript = {state = 0x1700000000, off = 0, isupper = false,
jumpdone = 0}, arrayref = {state = 0x1700000000}, domaincheck = {
constraintname = 0x1700000000 <Address 0x1700000000 out of bounds>, checkvalue = 0x0, checknull = 0x0,
resulttype = 0}, convert_rowtype = {convert = 0x1700000000, indesc = 0x0, outdesc = 0x0, map = 0x0,
initialized = false}, scalararrayop = {element_type = 0, useOr = 23, typlen = 0, typbyval = false,
typalign = 0 '\000', finfo = 0x0, fcinfo_data = 0x0, fn_addr = 0x0}, xmlexpr = {xexpr = 0x1700000000,
named_argvalue = 0x0, named_argnull = 0x0, argvalue = 0x0, argnull = 0x0}, aggref = {astate = 0x1700000000},
grouping_func = {parent = 0x1700000000, clauses = 0x0}, window_func = {wfstate = 0x1700000000}, subplan = {
sstate = 0x1700000000}, alternative_subplan = {asstate = 0x1700000000}, agg_deserialize = {aggstate = 0x1700000000,
fcinfo_data = 0x0, jumpnull = 0}, agg_strict_input_check = {nulls = 0x1700000000, nargs = 0, jumpnull = 0},
agg_init_trans = {aggstate = 0x1700000000, pertrans = 0x0, aggcontext = 0x0, setno = 0, transno = 0, setoff = 0,
jumpnull = 0}, agg_strict_trans_check = {aggstate = 0x1700000000, setno = 0, transno = 0, setoff = 0, jumpnull = 0},
---Type <return> to continue, or q <return> to quit---
agg_trans = {aggstate = 0x1700000000, pertrans = 0x0, aggcontext = 0x0, setno = 0, transno = 0, setoff = 0}}}
(gdb) p state->steps[2]
$19 = {opcode = 18, resvalue = 0x1c8f7e0, resnull = 0x1c8f7dd, d = {fetch = {last_var = 29949056, known_desc = 0x1c8fcd8},
var = {attnum = 29949056, vartype = 0}, wholerow = {var = 0x1c8fc80, first = 216, slow = 252,
tupdesc = 0x93d60c <int4pl>, junkFilter = 0x2}, assign_var = {resultnum = 29949056, attnum = 0}, assign_tmp = {
resultnum = 29949056}, constval = {value = 29949056, isnull = 216}, func = {finfo = 0x1c8fc80,
fcinfo_data = 0x1c8fcd8, fn_addr = 0x93d60c <int4pl>, nargs = 2}, boolexpr = {anynull = 0x1c8fc80,
jumpdone = 29949144}, qualexpr = {jumpdone = 29949056}, jump = {jumpdone = 29949056}, nulltest_row = {
argdesc = 0x1c8fc80}, param = {paramid = 29949056, paramtype = 0}, cparam = {paramfunc = 0x1c8fc80,
paramarg = 0x1c8fcd8, paramid = 9688588, paramtype = 0}, casetest = {value = 0x1c8fc80, isnull = 0x1c8fcd8},
make_readonly = {value = 0x1c8fc80, isnull = 0x1c8fcd8}, iocoerce = {finfo_out = 0x1c8fc80,
fcinfo_data_out = 0x1c8fcd8, finfo_in = 0x93d60c <int4pl>, fcinfo_data_in = 0x2}, sqlvaluefunction = {
svf = 0x1c8fc80}, nextvalueexpr = {seqid = 29949056, seqtypid = 0}, arrayexpr = {elemvalues = 0x1c8fc80,
elemnulls = 0x1c8fcd8, nelems = 9688588, elemtype = 0, elemlength = 2, elembyval = false, elemalign = 0 '\000',
multidims = false}, arraycoerce = {elemexprstate = 0x1c8fc80, resultelemtype = 29949144,
amstate = 0x93d60c <int4pl>}, row = {tupdesc = 0x1c8fc80, elemvalues = 0x1c8fcd8, elemnulls = 0x93d60c <int4pl>},
rowcompare_step = {finfo = 0x1c8fc80, fcinfo_data = 0x1c8fcd8, fn_addr = 0x93d60c <int4pl>, jumpnull = 2,
jumpdone = 0}, rowcompare_final = {rctype = 29949056}, minmax = {values = 0x1c8fc80, nulls = 0x1c8fcd8,
nelems = 9688588, op = IS_GREATEST, finfo = 0x2, fcinfo_data = 0x0}, fieldselect = {fieldnum = -896, resulttype = 0,
argdesc = 0x1c8fcd8}, fieldstore = {fstore = 0x1c8fc80, argdesc = 0x1c8fcd8, values = 0x93d60c <int4pl>, nulls = 0x2,
ncolumns = 0}, arrayref_subscript = {state = 0x1c8fc80, off = 29949144, isupper = false, jumpdone = 9688588},
arrayref = {state = 0x1c8fc80}, domaincheck = {constraintname = 0x1c8fc80 "\f֓", checkvalue = 0x1c8fcd8,
checknull = 0x93d60c <int4pl>, resulttype = 2}, convert_rowtype = {convert = 0x1c8fc80, indesc = 0x1c8fcd8,
outdesc = 0x93d60c <int4pl>, map = 0x2, initialized = false}, scalararrayop = {element_type = 29949056,
useOr = false, typlen = 0, typbyval = 216, typalign = -4 '\374', finfo = 0x93d60c <int4pl>, fcinfo_data = 0x2,
fn_addr = 0x0}, xmlexpr = {xexpr = 0x1c8fc80, named_argvalue = 0x1c8fcd8, named_argnull = 0x93d60c <int4pl>,
argvalue = 0x2, argnull = 0x0}, aggref = {astate = 0x1c8fc80}, grouping_func = {parent = 0x1c8fc80,
clauses = 0x1c8fcd8}, window_func = {wfstate = 0x1c8fc80}, subplan = {sstate = 0x1c8fc80}, alternative_subplan = {
asstate = 0x1c8fc80}, agg_deserialize = {aggstate = 0x1c8fc80, fcinfo_data = 0x1c8fcd8, jumpnull = 9688588},
---Type <return> to continue, or q <return> to quit---
agg_strict_input_check = {nulls = 0x1c8fc80, nargs = 29949144, jumpnull = 0}, agg_init_trans = {aggstate = 0x1c8fc80,
pertrans = 0x1c8fcd8, aggcontext = 0x93d60c <int4pl>, setno = 2, transno = 0, setoff = 0, jumpnull = 0},
agg_strict_trans_check = {aggstate = 0x1c8fc80, setno = 29949144, transno = 0, setoff = 9688588, jumpnull = 0},
agg_trans = {aggstate = 0x1c8fc80, pertrans = 0x1c8fcd8, aggcontext = 0x93d60c <int4pl>, setno = 2, transno = 0,
setoff = 0}}}
(gdb)
压入对应该表达式列的编号,opcode = 14,即EEOP_ASSIGN_TMP
(gdb) n
463 scratch.d.assign_tmp.resultnum = tle->resno - 1;
(gdb)
464 ExprEvalPushStep(state, &scratch);
(gdb)
(gdb)
374 foreach(lc, targetList)
(gdb) p *state
$20 = {tag = {type = T_ExprState}, flags = 0 '\000', resnull = false, resvalue = 0, resultslot = 0x1c8f710,
steps = 0x1c8f868, evalfunc = 0x0, expr = 0x1cc7550, evalfunc_private = 0x0, steps_len = 4, steps_alloc = 16,
parent = 0x1c8f1f0, ext_params = 0x0, innermost_caseval = 0x0, innermost_casenull = 0x0, innermost_domainval = 0x0,
innermost_domainnull = 0x0}
(gdb) p state->steps[3]
$21 = {opcode = 14, resvalue = 0x0, resnull = 0x0, d = {fetch = {last_var = 0, known_desc = 0x0}, var = {attnum = 0,
vartype = 0}, wholerow = {var = 0x0, first = false, slow = false, tupdesc = 0x0, junkFilter = 0x0}, assign_var = {
resultnum = 0, attnum = 0}, assign_tmp = {resultnum = 0}, constval = {value = 0, isnull = false}, func = {
finfo = 0x0, fcinfo_data = 0x0, fn_addr = 0x0, nargs = 0}, boolexpr = {anynull = 0x0, jumpdone = 0}, qualexpr = {
jumpdone = 0}, jump = {jumpdone = 0}, nulltest_row = {argdesc = 0x0}, param = {paramid = 0, paramtype = 0}, cparam = {
paramfunc = 0x0, paramarg = 0x0, paramid = 0, paramtype = 0}, casetest = {value = 0x0, isnull = 0x0},
make_readonly = {value = 0x0, isnull = 0x0}, iocoerce = {finfo_out = 0x0, fcinfo_data_out = 0x0, finfo_in = 0x0,
fcinfo_data_in = 0x0}, sqlvaluefunction = {svf = 0x0}, nextvalueexpr = {seqid = 0, seqtypid = 0}, arrayexpr = {
elemvalues = 0x0, elemnulls = 0x0, nelems = 0, elemtype = 0, elemlength = 0, elembyval = false, elemalign = 0 '\000',
multidims = false}, arraycoerce = {elemexprstate = 0x0, resultelemtype = 0, amstate = 0x0}, row = {tupdesc = 0x0,
elemvalues = 0x0, elemnulls = 0x0}, rowcompare_step = {finfo = 0x0, fcinfo_data = 0x0, fn_addr = 0x0, jumpnull = 0,
jumpdone = 0}, rowcompare_final = {rctype = 0}, minmax = {values = 0x0, nulls = 0x0, nelems = 0, op = IS_GREATEST,
finfo = 0x0, fcinfo_data = 0x0}, fieldselect = {fieldnum = 0, resulttype = 0, argdesc = 0x0}, fieldstore = {
fstore = 0x0, argdesc = 0x0, values = 0x0, nulls = 0x0, ncolumns = 0}, arrayref_subscript = {state = 0x0, off = 0,
isupper = false, jumpdone = 0}, arrayref = {state = 0x0}, domaincheck = {constraintname = 0x0, checkvalue = 0x0,
checknull = 0x0, resulttype = 0}, convert_rowtype = {convert = 0x0, indesc = 0x0, outdesc = 0x0, map = 0x0,
initialized = false}, scalararrayop = {element_type = 0, useOr = false, typlen = 0, typbyval = false,
typalign = 0 '\000', finfo = 0x0, fcinfo_data = 0x0, fn_addr = 0x0}, xmlexpr = {xexpr = 0x0, named_argvalue = 0x0,
named_argnull = 0x0, argvalue = 0x0, argnull = 0x0}, aggref = {astate = 0x0}, grouping_func = {parent = 0x0,
clauses = 0x0}, window_func = {wfstate = 0x0}, subplan = {sstate = 0x0}, alternative_subplan = {asstate = 0x0},
agg_deserialize = {aggstate = 0x0, fcinfo_data = 0x0, jumpnull = 0}, agg_strict_input_check = {nulls = 0x0, nargs = 0,
jumpnull = 0}, agg_init_trans = {aggstate = 0x0, pertrans = 0x0, aggcontext = 0x0, setno = 0, transno = 0,
setoff = 0, jumpnull = 0}, agg_strict_trans_check = {aggstate = 0x0, setno = 0, transno = 0, setoff = 0,
jumpnull = 0}, agg_trans = {aggstate = 0x0, pertrans = 0x0, aggcontext = 0x0, setno = 0, transno = 0, setoff = 0}}}
(gdb)
继续处理下一个列,这是一个”安全”列,压入EEOP_ASSIGN_SCAN_VAR步骤
(gdb) n
376 TargetEntry *tle = lfirst_node(TargetEntry, lc);
(gdb)
377 Var *variable = NULL;
(gdb) p *tle
$22 = {xpr = {type = T_TargetEntry}, expr = 0x1c9aa40, resno = 2, resname = 0x1ba7a40 "c2", ressortgroupref = 0,
resorigtbl = 237600, resorigcol = 2, resjunk = false}
(gdb) n
378 AttrNumber attnum = 0;
(gdb)
379 bool isSafeVar = false;
(gdb)
389 if (tle->expr != NULL &&
(gdb)
390 IsA(tle->expr, Var) &&
(gdb)
389 if (tle->expr != NULL &&
(gdb)
391 ((Var *) tle->expr)->varattno > 0)
(gdb)
390 IsA(tle->expr, Var) &&
(gdb)
394 variable = (Var *) tle->expr;
(gdb)
395 attnum = variable->varattno;
(gdb)
397 if (inputDesc == NULL)
(gdb)
399 else if (attnum <= inputDesc->natts)
(gdb)
401 Form_pg_attribute attr = TupleDescAttr(inputDesc, attnum - 1);
(gdb)
408 if (!attr->attisdropped && variable->vartype == attr->atttypid)
(gdb)
410 isSafeVar = true;
(gdb)
415 if (isSafeVar)
(gdb)
418 switch (variable->varno)
(gdb)
434 scratch.opcode = EEOP_ASSIGN_SCAN_VAR;
(gdb)
435 break;
(gdb)
438 scratch.d.assign_var.attnum = attnum - 1;
(gdb)
439 scratch.d.assign_var.resultnum = tle->resno - 1;
(gdb)
440 ExprEvalPushStep(state, &scratch);
(gdb) p *state
$23 = {tag = {type = T_ExprState}, flags = 0 '\000', resnull = false, resvalue = 0, resultslot = 0x1c8f710,
steps = 0x1c8f868, evalfunc = 0x0, expr = 0x1cc7550, evalfunc_private = 0x0, steps_len = 4, steps_alloc = 16,
parent = 0x1c8f1f0, ext_params = 0x0, innermost_caseval = 0x0, innermost_casenull = 0x0, innermost_domainval = 0x0,
innermost_domainnull = 0x0}
(gdb) n
374 foreach(lc, targetList)
(gdb) p *state
$24 = {tag = {type = T_ExprState}, flags = 0 '\000', resnull = false, resvalue = 0, resultslot = 0x1c8f710,
steps = 0x1c8f868, evalfunc = 0x0, expr = 0x1cc7550, evalfunc_private = 0x0, steps_len = 5, steps_alloc = 16,
parent = 0x1c8f1f0, ext_params = 0x0, innermost_caseval = 0x0, innermost_casenull = 0x0, innermost_domainval = 0x0,
innermost_domainnull = 0x0}
(gdb) p state->steps[4]
$25 = {opcode = 13, resvalue = 0x0, resnull = 0x0, d = {fetch = {last_var = 1, known_desc = 0x0}, var = {attnum = 1,
vartype = 1}, wholerow = {var = 0x100000001, first = false, slow = false, tupdesc = 0x0, junkFilter = 0x0},
assign_var = {resultnum = 1, attnum = 1}, assign_tmp = {resultnum = 1}, constval = {value = 4294967297,
isnull = false}, func = {finfo = 0x100000001, fcinfo_data = 0x0, fn_addr = 0x0, nargs = 0}, boolexpr = {
anynull = 0x100000001, jumpdone = 0}, qualexpr = {jumpdone = 1}, jump = {jumpdone = 1}, nulltest_row = {
argdesc = 0x100000001}, param = {paramid = 1, paramtype = 1}, cparam = {paramfunc = 0x100000001, paramarg = 0x0,
paramid = 0, paramtype = 0}, casetest = {value = 0x100000001, isnull = 0x0}, make_readonly = {value = 0x100000001,
isnull = 0x0}, iocoerce = {finfo_out = 0x100000001, fcinfo_data_out = 0x0, finfo_in = 0x0, fcinfo_data_in = 0x0},
sqlvaluefunction = {svf = 0x100000001}, nextvalueexpr = {seqid = 1, seqtypid = 1}, arrayexpr = {
elemvalues = 0x100000001, elemnulls = 0x0, nelems = 0, elemtype = 0, elemlength = 0, elembyval = false,
elemalign = 0 '\000', multidims = false}, arraycoerce = {elemexprstate = 0x100000001, resultelemtype = 0,
amstate = 0x0}, row = {tupdesc = 0x100000001, elemvalues = 0x0, elemnulls = 0x0}, rowcompare_step = {
finfo = 0x100000001, fcinfo_data = 0x0, fn_addr = 0x0, jumpnull = 0, jumpdone = 0}, rowcompare_final = {
rctype = ROWCOMPARE_LT}, minmax = {values = 0x100000001, nulls = 0x0, nelems = 0, op = IS_GREATEST, finfo = 0x0,
fcinfo_data = 0x0}, fieldselect = {fieldnum = 1, resulttype = 1, argdesc = 0x0}, fieldstore = {fstore = 0x100000001,
argdesc = 0x0, values = 0x0, nulls = 0x0, ncolumns = 0}, arrayref_subscript = {state = 0x100000001, off = 0,
isupper = false, jumpdone = 0}, arrayref = {state = 0x100000001}, domaincheck = {
constraintname = 0x100000001 <Address 0x100000001 out of bounds>, checkvalue = 0x0, checknull = 0x0, resulttype = 0},
convert_rowtype = {convert = 0x100000001, indesc = 0x0, outdesc = 0x0, map = 0x0, initialized = false},
scalararrayop = {element_type = 1, useOr = true, typlen = 0, typbyval = false, typalign = 0 '\000', finfo = 0x0,
fcinfo_data = 0x0, fn_addr = 0x0}, xmlexpr = {xexpr = 0x100000001, named_argvalue = 0x0, named_argnull = 0x0,
argvalue = 0x0, argnull = 0x0}, aggref = {astate = 0x100000001}, grouping_func = {parent = 0x100000001,
clauses = 0x0}, window_func = {wfstate = 0x100000001}, subplan = {sstate = 0x100000001}, alternative_subplan = {
asstate = 0x100000001}, agg_deserialize = {aggstate = 0x100000001, fcinfo_data = 0x0, jumpnull = 0},
agg_strict_input_check = {nulls = 0x100000001, nargs = 0, jumpnull = 0}, agg_init_trans = {aggstate = 0x100000001,
pertrans = 0x0, aggcontext = 0x0, setno = 0, transno = 0, setoff = 0, jumpnull = 0}, agg_strict_trans_check = {
aggstate = 0x100000001, setno = 0, transno = 0, setoff = 0, jumpnull = 0}, agg_trans = {aggstate = 0x100000001,
---Type <return> to continue, or q <return> to quit---
pertrans = 0x0, aggcontext = 0x0, setno = 0, transno = 0, setoff = 0}}}
(gdb)
4.压入EEOP_DONE步骤
(gdb) n
468 scratch.opcode = EEOP_DONE;
(gdb)
469 ExprEvalPushStep(state, &scratch);
(gdb)
471 ExecReadyExpr(state);
(gdb) p state->steps[5]
$26 = {opcode = 0, resvalue = 0x0, resnull = 0x0, d = {fetch = {last_var = 1, known_desc = 0x0}, var = {attnum = 1,
vartype = 1}, wholerow = {var = 0x100000001, first = false, slow = false, tupdesc = 0x0, junkFilter = 0x0},
assign_var = {resultnum = 1, attnum = 1}, assign_tmp = {resultnum = 1}, constval = {value = 4294967297,
isnull = false}, func = {finfo = 0x100000001, fcinfo_data = 0x0, fn_addr = 0x0, nargs = 0}, boolexpr = {
anynull = 0x100000001, jumpdone = 0}, qualexpr = {jumpdone = 1}, jump = {jumpdone = 1}, nulltest_row = {
argdesc = 0x100000001}, param = {paramid = 1, paramtype = 1}, cparam = {paramfunc = 0x100000001, paramarg = 0x0,
paramid = 0, paramtype = 0}, casetest = {value = 0x100000001, isnull = 0x0}, make_readonly = {value = 0x100000001,
isnull = 0x0}, iocoerce = {finfo_out = 0x100000001, fcinfo_data_out = 0x0, finfo_in = 0x0, fcinfo_data_in = 0x0},
sqlvaluefunction = {svf = 0x100000001}, nextvalueexpr = {seqid = 1, seqtypid = 1}, arrayexpr = {
elemvalues = 0x100000001, elemnulls = 0x0, nelems = 0, elemtype = 0, elemlength = 0, elembyval = false,
elemalign = 0 '\000', multidims = false}, arraycoerce = {elemexprstate = 0x100000001, resultelemtype = 0,
amstate = 0x0}, row = {tupdesc = 0x100000001, elemvalues = 0x0, elemnulls = 0x0}, rowcompare_step = {
finfo = 0x100000001, fcinfo_data = 0x0, fn_addr = 0x0, jumpnull = 0, jumpdone = 0}, rowcompare_final = {
rctype = ROWCOMPARE_LT}, minmax = {values = 0x100000001, nulls = 0x0, nelems = 0, op = IS_GREATEST, finfo = 0x0,
fcinfo_data = 0x0}, fieldselect = {fieldnum = 1, resulttype = 1, argdesc = 0x0}, fieldstore = {fstore = 0x100000001,
argdesc = 0x0, values = 0x0, nulls = 0x0, ncolumns = 0}, arrayref_subscript = {state = 0x100000001, off = 0,
isupper = false, jumpdone = 0}, arrayref = {state = 0x100000001}, domaincheck = {
constraintname = 0x100000001 <Address 0x100000001 out of bounds>, checkvalue = 0x0, checknull = 0x0, resulttype = 0},
convert_rowtype = {convert = 0x100000001, indesc = 0x0, outdesc = 0x0, map = 0x0, initialized = false},
scalararrayop = {element_type = 1, useOr = true, typlen = 0, typbyval = false, typalign = 0 '\000', finfo = 0x0,
fcinfo_data = 0x0, fn_addr = 0x0}, xmlexpr = {xexpr = 0x100000001, named_argvalue = 0x0, named_argnull = 0x0,
argvalue = 0x0, argnull = 0x0}, aggref = {astate = 0x100000001}, grouping_func = {parent = 0x100000001,
clauses = 0x0}, window_func = {wfstate = 0x100000001}, subplan = {sstate = 0x100000001}, alternative_subplan = {
asstate = 0x100000001}, agg_deserialize = {aggstate = 0x100000001, fcinfo_data = 0x0, jumpnull = 0},
agg_strict_input_check = {nulls = 0x100000001, nargs = 0, jumpnull = 0}, agg_init_trans = {aggstate = 0x100000001,
pertrans = 0x0, aggcontext = 0x0, setno = 0, transno = 0, setoff = 0, jumpnull = 0}, agg_strict_trans_check = {
aggstate = 0x100000001, setno = 0, transno = 0, setoff = 0, jumpnull = 0}, agg_trans = {aggstate = 0x100000001,
---Type <return> to continue, or q <return> to quit---
pertrans = 0x0, aggcontext = 0x0, setno = 0, transno = 0, setoff = 0}}}
(gdb)
结束调用
(gdb) n
473 return projInfo;
(gdb)
474 }
(gdb)
ExecAssignProjectionInfo (planstate=0x1c8f1f0, inputDesc=0x7f8386bb6ab8) at execUtils.c:467
467 planstate->ps_ProjInfo =
(gdb)
以上是“PostgreSQL如何构建表达式解析”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注亿速云行业资讯频道!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。