=== Applying patches on top of PostgreSQL commit ID 53a49365052026907afff7613929710d1e7f0da0 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Sat Feb 1 01:02:29 UTC 2025 On branch cf/4759 nothing to commit, working tree clean === applying patch ./v10-0001-shared-detoast-datum.patch Applied patch to 'src/backend/access/common/detoast.c' with conflicts. Applied patch to 'src/backend/access/common/toast_compression.c' cleanly. Applied patch to 'src/backend/executor/execExpr.c' with conflicts. Applied patch to 'src/backend/executor/execExprInterp.c' with conflicts. Applied patch to 'src/backend/executor/execTuples.c' cleanly. Applied patch to 'src/backend/executor/execUtils.c' cleanly. Applied patch to 'src/backend/executor/nodeHashjoin.c' cleanly. Applied patch to 'src/backend/executor/nodeMergejoin.c' cleanly. Applied patch to 'src/backend/executor/nodeNestloop.c' cleanly. Falling back to direct application... Applied patch to 'src/backend/jit/llvm/llvmjit_expr.c' with conflicts. Applied patch to 'src/backend/jit/llvm/llvmjit_types.c' cleanly. Applied patch to 'src/backend/optimizer/plan/createplan.c' cleanly. Applied patch to 'src/backend/optimizer/plan/setrefs.c' with conflicts. Applied patch to 'src/include/access/detoast.h' cleanly. Applied patch to 'src/include/access/toast_compression.h' cleanly. Applied patch to 'src/include/executor/execExpr.h' cleanly. Applied patch to 'src/include/executor/tuptable.h' cleanly. Applied patch to 'src/include/nodes/execnodes.h' cleanly. Applied patch to 'src/include/nodes/plannodes.h' cleanly. Applied patch to 'src/tools/pgindent/typedefs.list' with conflicts. U src/backend/access/common/detoast.c U src/backend/executor/execExpr.c U src/backend/executor/execExprInterp.c U src/backend/jit/llvm/llvmjit_expr.c U src/backend/optimizer/plan/setrefs.c U src/tools/pgindent/typedefs.list diff --cc src/backend/access/common/detoast.c index 6265178774,acc9644689..0000000000 --- a/src/backend/access/common/detoast.c +++ b/src/backend/access/common/detoast.c @@@ -87,8 -87,8 +87,13 @@@ detoast_external_attr_ext(struct varlen eoh = DatumGetEOHP(PointerGetDatum(attr)); resultsize = EOH_get_flat_size(eoh); ++<<<<<<< ours + result = (struct varlena *) palloc(resultsize); + EOH_flatten_into(eoh, result, resultsize); ++======= + result = (struct varlena *) MemoryContextAlloc(ctx, resultsize); + EOH_flatten_into(eoh, (void *) result, resultsize); ++>>>>>>> theirs } else { diff --cc src/backend/executor/execExpr.c index 03566c4d18,7b4742bf8e..0000000000 --- a/src/backend/executor/execExpr.c +++ b/src/backend/executor/execExpr.c @@@ -981,7 -944,8 +984,12 @@@ ExecInitExprRec(Expr *node, ExprState * /* regular user column */ scratch.d.var.attnum = variable->varattno - 1; scratch.d.var.vartype = variable->vartype; ++<<<<<<< ours + scratch.d.var.varreturningtype = variable->varreturningtype; ++======= + attnum = scratch.d.var.attnum; + ++>>>>>>> theirs switch (variable->varno) { case INNER_VAR: @@@ -994,20 -991,23 +1035,40 @@@ /* INDEX_VAR is handled by default case */ default: ++<<<<<<< ours + switch (variable->varreturningtype) + { + case VAR_RETURNING_DEFAULT: + scratch.opcode = EEOP_SCAN_VAR; + break; + case VAR_RETURNING_OLD: + scratch.opcode = EEOP_OLD_VAR; + state->flags |= EEO_FLAG_HAS_OLD; + break; + case VAR_RETURNING_NEW: + scratch.opcode = EEOP_NEW_VAR; + state->flags |= EEO_FLAG_HAS_NEW; + break; + } ++======= + if (is_scan_plan(plan) && bms_is_member( + attnum, + ((ScanState *) state->parent)->scan_pre_detoast_attrs)) + { + scratch.opcode = EEOP_SCAN_VAR_TOAST; + #ifdef DEBUG_PRE_DETOAST_DATUM + elog(INFO, + "EEOP_SCAN_VAR_TOAST: flags = %u costs=%.2f..%.2f, scanId: %d, attnum: %d", + state->flags, + plan->startup_cost, + plan->total_cost, + ((Scan *) plan)->scanrelid, + attnum); + #endif + } + else + scratch.opcode = EEOP_SCAN_VAR; ++>>>>>>> theirs break; } } diff --cc src/backend/executor/execExprInterp.c index 09f6a5f14c,df932dc7c1..0000000000 --- a/src/backend/executor/execExprInterp.c +++ b/src/backend/executor/execExprInterp.c @@@ -343,9 -336,27 +386,27 @@@ ExecReadyInterpretedExpr(ExprState *sta else if (step0 == EEOP_SCAN_FETCHSOME && step1 == EEOP_SCAN_VAR) { - state->evalfunc_private = (void *) ExecJustScanVar; + state->evalfunc_private = ExecJustScanVar; return; } + if (step0 == EEOP_INNER_FETCHSOME && + step1 == EEOP_INNER_VAR_TOAST) + { + state->evalfunc_private = (void *) ExecJustInnerVarToast; + return; + } + else if (step0 == EEOP_OUTER_FETCHSOME && + step1 == EEOP_OUTER_VAR_TOAST) + { + state->evalfunc_private = (void *) ExecJustOuterVarToast; + return; + } + else if (step0 == EEOP_SCAN_FETCHSOME && + step1 == EEOP_SCAN_VAR_TOAST) + { + state->evalfunc_private = (void *) ExecJustScanVarToast; + return; + } else if (step0 == EEOP_INNER_FETCHSOME && step1 == EEOP_ASSIGN_INNER_VAR) { @@@ -404,12 -404,27 +465,27 @@@ } else if (step0 == EEOP_SCAN_VAR) { - state->evalfunc_private = (void *) ExecJustScanVarVirt; + state->evalfunc_private = ExecJustScanVarVirt; return; } + else if (step0 == EEOP_INNER_VAR_TOAST) + { + state->evalfunc_private = (void *) ExecJustInnerVarVirtToast; + return; + } + else if (step0 == EEOP_OUTER_VAR_TOAST) + { + state->evalfunc_private = (void *) ExecJustOuterVarVirtToast; + return; + } + else if (step0 == EEOP_SCAN_VAR_TOAST) + { + state->evalfunc_private = (void *) ExecJustScanVarVirtToast; + return; + } else if (step0 == EEOP_ASSIGN_INNER_VAR) { - state->evalfunc_private = (void *) ExecJustAssignInnerVarVirt; + state->evalfunc_private = ExecJustAssignInnerVarVirt; return; } else if (step0 == EEOP_ASSIGN_OUTER_VAR) @@@ -478,8 -489,9 +554,14 @@@ ExecInterpExpr(ExprState *state, ExprCo &&CASE_EEOP_INNER_VAR, &&CASE_EEOP_OUTER_VAR, &&CASE_EEOP_SCAN_VAR, ++<<<<<<< ours + &&CASE_EEOP_OLD_VAR, + &&CASE_EEOP_NEW_VAR, ++======= + &&CASE_EEOP_INNER_VAR_TOAST, + &&CASE_EEOP_OUTER_VAR_TOAST, + &&CASE_EEOP_SCAN_VAR_TOAST, ++>>>>>>> theirs &&CASE_EEOP_INNER_SYSVAR, &&CASE_EEOP_OUTER_SYSVAR, &&CASE_EEOP_SCAN_SYSVAR, diff --cc src/backend/jit/llvm/llvmjit_expr.c index f0f5c3bd49,4ed7ed8c67..0000000000 --- a/src/backend/jit/llvm/llvmjit_expr.c +++ b/src/backend/jit/llvm/llvmjit_expr.c @@@ -438,8 -396,9 +438,14 @@@ llvm_compile_expr(ExprState *state case EEOP_INNER_VAR: case EEOP_OUTER_VAR: case EEOP_SCAN_VAR: ++<<<<<<< ours + case EEOP_OLD_VAR: + case EEOP_NEW_VAR: ++======= + case EEOP_INNER_VAR_TOAST: + case EEOP_OUTER_VAR_TOAST: + case EEOP_SCAN_VAR_TOAST: ++>>>>>>> theirs { LLVMValueRef value, isnull; @@@ -457,23 -419,29 +466,39 @@@ v_values = v_outervalues; v_nulls = v_outernulls; } - else + else if (opcode == EEOP_SCAN_VAR) { + v_slot = v_scanslot; v_values = v_scanvalues; v_nulls = v_scannulls; } + else if (opcode == EEOP_OLD_VAR) + { + v_values = v_oldvalues; + v_nulls = v_oldnulls; + } + else + { + v_values = v_newvalues; + v_nulls = v_newnulls; + } v_attnum = l_int32_const(lc, op->d.var.attnum); + + if (opcode == EEOP_INNER_VAR_TOAST || + opcode == EEOP_OUTER_VAR_TOAST || + opcode == EEOP_SCAN_VAR_TOAST) + { + LLVMValueRef params[2]; + + params[0] = v_slot; + params[1] = l_int32_const(lc, op->d.var.attnum); + l_call(b, + llvm_pg_var_func_type("ExecSlotDetoastDatumExternal"), + llvm_pg_func(mod, "ExecSlotDetoastDatumExternal"), + params, lengthof(params), ""); + } + value = l_load_gep1(b, TypeSizeT, v_values, v_attnum, ""); isnull = l_load_gep1(b, TypeStorageBool, v_nulls, v_attnum, ""); LLVMBuildStore(b, value, v_resvaluep); diff --cc src/backend/optimizer/plan/setrefs.c index 0868249be9,3b609a8796..0000000000 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@@ -26,8 -26,9 +26,10 @@@ #include "optimizer/subselect.h" #include "optimizer/tlist.h" #include "parser/parse_relation.h" +#include "rewrite/rewriteManip.h" #include "tcop/utility.h" + #include "utils/fmgroids.h" + #include "utils/lsyscache.h" #include "utils/syscache.h" @@@ -2265,15 -2490,25 +2522,29 @@@ fix_scan_expr_mutator(Node *node, fix_s PlaceHolderVar *phv = (PlaceHolderVar *) node; /* XXX can we assert something about phnullingrels? */ - return fix_scan_expr_mutator((Node *) phv->phexpr, context); + Node *n2 = fix_scan_expr_mutator((Node *) phv->phexpr, context); + + decreased_level_for_pre_detoast(&context->level_ctx); + return n2; } if (IsA(node, AlternativeSubPlan)) - return fix_scan_expr_mutator(fix_alternative_subplan(context->root, - (AlternativeSubPlan *) node, - context->num_exec), - context); + { + Node *n2 = fix_scan_expr_mutator(fix_alternative_subplan(context->root, + (AlternativeSubPlan *) node, + context->num_exec), + context); + + decreased_level_for_pre_detoast(&context->level_ctx); + return n2; + } fix_expr_common(context->root, node); ++<<<<<<< ours + return expression_tree_mutator(node, fix_scan_expr_mutator, context); ++======= + n = expression_tree_mutator(node, fix_scan_expr_mutator, (void *) context); + decreased_level_for_pre_detoast(&context->level_ctx); + return n; ++>>>>>>> theirs } static bool @@@ -2285,7 -2531,11 +2567,15 @@@ fix_scan_expr_walker(Node *node, fix_sc Assert(!IsA(node, PlaceHolderVar)); Assert(!IsA(node, AlternativeSubPlan)); fix_expr_common(context->root, node); ++<<<<<<< ours + return expression_tree_walker(node, fix_scan_expr_walker, context); ++======= + ret = expression_tree_walker(node, fix_scan_expr_walker, + (void *) context); + + decreased_level_for_pre_detoast(&context->level_ctx); + return ret; ++>>>>>>> theirs } /* @@@ -3200,14 -3495,26 +3571,30 @@@ fix_join_expr_mutator(Node *node, fix_j } /* Special cases (apply only AFTER failing to match to lower tlist) */ if (IsA(node, Param)) - return fix_param_node(context->root, (Param *) node); + { + ret_node = fix_param_node(context->root, (Param *) node); + decreased_level_for_pre_detoast(&context->level_ctx); + return ret_node; + } if (IsA(node, AlternativeSubPlan)) - return fix_join_expr_mutator(fix_alternative_subplan(context->root, - (AlternativeSubPlan *) node, - context->num_exec), - context); + { + ret_node = fix_join_expr_mutator(fix_alternative_subplan(context->root, + (AlternativeSubPlan *) node, + context->num_exec), + context); + decreased_level_for_pre_detoast(&context->level_ctx); + return ret_node; + } fix_expr_common(context->root, node); ++<<<<<<< ours + return expression_tree_mutator(node, fix_join_expr_mutator, context); ++======= + ret_node = expression_tree_mutator(node, + fix_join_expr_mutator, + (void *) context); + decreased_level_for_pre_detoast(&context->level_ctx); + return ret_node; ++>>>>>>> theirs } /* diff --cc src/tools/pgindent/typedefs.list index a2644a2e65,8d18fe2472..0000000000 --- a/src/tools/pgindent/typedefs.list +++ b/src/tools/pgindent/typedefs.list @@@ -4210,3 -4085,37 +4210,40 @@@ yyscan_ z_stream z_streamp zic_t ++<<<<<<< ours ++======= + BlockRefTable + BlockRefTableBuffer + BlockRefTableEntry + BlockRefTableKey + BlockRefTableReader + BlockRefTableSerializedEntry + BlockRefTableWriter + SummarizerReadLocalXLogPrivate + SysloggerStartupData + WalSummarizerData + WalSummaryFile + WalSummaryIO + FileBackupMethod + IncrementalBackupInfo + UploadManifestCmd + backup_file_entry + backup_wal_range + cb_cleanup_dir + cb_options + cb_tablespace + cb_tablespace_mapping + intermediate_var_ref_context + intermediate_level_context + manifest_data + manifest_writer + rfile + ws_options + ws_file_info + PathKeyInfo + TidStore + TidStoreIter + TidStoreIterResult + BlocktableEntry + ItemArray ++>>>>>>> theirs