=== Applying patches on top of PostgreSQL commit ID 06473f5a344df8c9594ead90a609b86f6724cff8 === /etc/rc.d/jail: WARNING: Per-jail configuration via jail_* variables is obsolete. Please consider migrating to /etc/jail.conf. Tue Sep 9 02:31:23 UTC 2025 On branch cf/5623 nothing to commit, working tree clean === using 'git am' to apply patch ./numericvar_access.patch === Patch format detection failed. === using patch(1) to apply patch ./numericvar_access.patch === patching file src/backend/utils/adt/numeric.c Hunk #1 succeeded at 46 (offset 1 line). Hunk #2 succeeded at 199 (offset 1 line). Hunk #3 succeeded at 360 (offset -8 lines). Hunk #4 succeeded at 369 (offset -8 lines). Hunk #5 succeeded at 377 (offset -8 lines). Hunk #6 FAILED at 392. Hunk #7 succeeded at 544 (offset -11 lines). Hunk #8 FAILED at 655. Hunk #9 succeeded at 981 (offset -17 lines). Hunk #10 succeeded at 992 (offset -17 lines). Hunk #11 succeeded at 1164 (offset -17 lines). Hunk #12 succeeded at 1366 (offset -17 lines). Hunk #13 succeeded at 1430 (offset -17 lines). Hunk #14 succeeded at 1482 (offset -17 lines). Hunk #15 succeeded at 1510 (offset -17 lines). Hunk #16 succeeded at 1538 (offset -17 lines). Hunk #17 succeeded at 1662 (offset -17 lines). Hunk #18 succeeded at 2760 (offset -103 lines). Hunk #19 FAILED at 2894. Hunk #20 succeeded at 2836 (offset -105 lines). Hunk #21 FAILED at 2972. Hunk #22 succeeded at 2912 (offset -107 lines). Hunk #23 succeeded at 2931 (offset -107 lines). Hunk #24 succeeded at 2945 (offset -107 lines). Hunk #25 succeeded at 2957 (offset -107 lines). Hunk #26 FAILED at 3093. Hunk #27 succeeded at 3032 (offset -112 lines). Hunk #28 succeeded at 3042 with fuzz 2 (offset -120 lines). Hunk #29 succeeded at 3057 with fuzz 2 (offset -128 lines). Hunk #30 succeeded at 3070 (offset -128 lines). Hunk #31 FAILED at 3228. Hunk #32 succeeded at 3129 (offset -128 lines). Hunk #33 succeeded at 3142 (offset -128 lines). Hunk #34 succeeded at 3160 (offset -128 lines). Hunk #35 succeeded at 3173 (offset -128 lines). Hunk #36 succeeded at 3189 (offset -128 lines). Hunk #37 succeeded at 3236 (offset -133 lines). Hunk #38 succeeded at 3243 with fuzz 2 (offset -141 lines). Hunk #39 FAILED at 3406. Hunk #40 succeeded at 3298 (offset -141 lines). Hunk #41 succeeded at 3377 (offset -141 lines). Hunk #42 succeeded at 3392 (offset -141 lines). Hunk #43 succeeded at 3420 (offset -141 lines). Hunk #44 succeeded at 3452 (offset -141 lines). Hunk #45 succeeded at 3479 (offset -141 lines). Hunk #46 succeeded at 3503 (offset -141 lines). Hunk #47 succeeded at 3576 (offset -141 lines). Hunk #48 succeeded at 3606 (offset -141 lines). Hunk #49 succeeded at 3643 (offset -141 lines). Hunk #50 succeeded at 3692 (offset -141 lines). Hunk #51 succeeded at 3724 (offset -141 lines). Hunk #52 succeeded at 3741 (offset -141 lines). Hunk #53 succeeded at 3763 (offset -141 lines). Hunk #54 succeeded at 3804 (offset -141 lines). Hunk #55 succeeded at 3814 (offset -141 lines). Hunk #56 succeeded at 3839 (offset -141 lines). Hunk #57 succeeded at 3855 (offset -141 lines). Hunk #58 succeeded at 3878 (offset -141 lines). Hunk #59 succeeded at 3896 (offset -141 lines). Hunk #60 succeeded at 3909 (offset -141 lines). Hunk #61 succeeded at 3918 (offset -141 lines). Hunk #62 succeeded at 3951 (offset -141 lines). Hunk #63 succeeded at 4060 (offset -141 lines). Hunk #64 succeeded at 4109 (offset -141 lines). Hunk #65 succeeded at 4134 (offset -141 lines). Hunk #66 succeeded at 4211 (offset -153 lines). Hunk #67 succeeded at 4396 (offset -189 lines). Hunk #68 succeeded at 4413 (offset -189 lines). Hunk #69 succeeded at 4490 (offset -189 lines). Hunk #70 succeeded at 4507 (offset -189 lines). Hunk #71 succeeded at 5750 (offset -320 lines). Hunk #72 succeeded at 5776 (offset -324 lines). Hunk #73 succeeded at 5798 (offset -327 lines). Hunk #74 succeeded at 5832 (offset -327 lines). Hunk #75 succeeded at 5898 (offset -327 lines). Hunk #76 succeeded at 5922 (offset -327 lines). Hunk #77 succeeded at 5935 (offset -327 lines). Hunk #78 succeeded at 6548 (offset -387 lines). Hunk #79 succeeded at 6564 (offset -387 lines). Hunk #80 succeeded at 6580 (offset -387 lines). Hunk #81 succeeded at 6702 (offset -387 lines). Hunk #82 succeeded at 7015 (offset -387 lines). Hunk #83 succeeded at 7046 (offset -387 lines). Hunk #84 succeeded at 7063 (offset -387 lines). Hunk #85 FAILED at 7756. Hunk #86 FAILED at 7764. Hunk #87 succeeded at 7402 (offset -393 lines). Hunk #88 FAILED at 7863. 10 out of 88 hunks FAILED -- saving rejects to file src/backend/utils/adt/numeric.c.rej patching file src/include/utils/numeric.h Hunk #1 succeeded at 45 (offset 3 lines). Hunk #2 succeeded at 105 (offset 3 lines). Hunk #3 succeeded at 213 (offset 3 lines). Unstaged changes after reset: M src/backend/utils/adt/numeric.c M src/include/utils/numeric.h Removing src/backend/utils/adt/numeric.c.rej === using 'git apply' to apply patch ./numericvar_access.patch === Applied patch to 'src/backend/utils/adt/numeric.c' with conflicts. Applied patch to 'src/include/utils/numeric.h' cleanly. U src/backend/utils/adt/numeric.c diff --cc src/backend/utils/adt/numeric.c index 76269918593,ec5e4b5ee32..00000000000 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@@ -516,8 -392,6 +384,11 @@@ static void numericvar_serialize(String static void numericvar_deserialize(StringInfo buf, NumericVar *var); static Numeric duplicate_numeric(Numeric num); ++<<<<<<< ours +static Numeric make_result(const NumericVar *var); +static Numeric make_result_safe(const NumericVar *var, Node *escontext); ++======= ++>>>>>>> theirs static bool apply_typmod(NumericVar *var, int32 typmod, Node *escontext); static bool apply_typmod_special(Numeric num, int32 typmod, Node *escontext); @@@ -775,7 -653,12 +646,16 @@@ numeric_in(PG_FUNCTION_ARGS if (!apply_typmod(&value, typmod, escontext)) PG_RETURN_NULL(); ++<<<<<<< ours + res = make_result_safe(&value, escontext); ++======= + res = numeric_make_result_opt_error(&value, &have_error); + + if (have_error) + ereturn(escontext, (Datum) 0, + (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), + errmsg("value overflows numeric format"))); ++>>>>>>> theirs free_var(&value); } @@@ -2923,7 -2892,7 +2803,11 @@@ numeric_add_safe(Numeric num1, Numeric init_var(&result); add_var(&arg1, &arg2, &result); ++<<<<<<< ours + res = make_result_safe(&result, escontext); ++======= + res = numeric_make_result_opt_error(&result, have_error); ++>>>>>>> theirs free_var(&result); @@@ -2999,7 -2970,7 +2883,11 @@@ numeric_sub_safe(Numeric num1, Numeric init_var(&result); sub_var(&arg1, &arg2, &result); ++<<<<<<< ours + res = make_result_safe(&result, escontext); ++======= + res = numeric_make_result_opt_error(&result, have_error); ++>>>>>>> theirs free_var(&result); @@@ -3118,7 -3091,7 +3006,11 @@@ numeric_mul_safe(Numeric num1, Numeric if (result.dscale > NUMERIC_DSCALE_MAX) round_var(&result, NUMERIC_DSCALE_MAX); ++<<<<<<< ours + res = make_result_safe(&result, escontext); ++======= + res = numeric_make_result_opt_error(&result, have_error); ++>>>>>>> theirs free_var(&result); @@@ -3172,11 -3150,19 +3064,11 @@@ numeric_div_safe(Numeric num1, Numeric switch (numeric_sign_internal(num2)) { case 0: - if (have_error) - { - *have_error = true; - return NULL; - } - ereport(ERROR, - (errcode(ERRCODE_DIVISION_BY_ZERO), - errmsg("division by zero"))); - break; + goto division_by_zero; case 1: - return make_result(&const_pinf); + return numeric_make_result(&const_pinf); case -1: - return make_result(&const_ninf); + return numeric_make_result(&const_ninf); } Assert(false); } @@@ -3187,11 -3173,19 +3079,11 @@@ switch (numeric_sign_internal(num2)) { case 0: - if (have_error) - { - *have_error = true; - return NULL; - } - ereport(ERROR, - (errcode(ERRCODE_DIVISION_BY_ZERO), - errmsg("division by zero"))); - break; + goto division_by_zero; case 1: - return make_result(&const_ninf); + return numeric_make_result(&const_ninf); case -1: - return make_result(&const_pinf); + return numeric_make_result(&const_pinf); } Assert(false); } @@@ -3227,7 -3226,7 +3119,11 @@@ */ div_var(&arg1, &arg2, &result, rscale, true, true); ++<<<<<<< ours + res = make_result_safe(&result, escontext); ++======= + res = numeric_make_result_opt_error(&result, have_error); ++>>>>>>> theirs free_var(&result); @@@ -3372,10 -3371,18 +3268,10 @@@ numeric_mod_safe(Numeric num1, Numeric if (NUMERIC_IS_INF(num1)) { if (numeric_sign_internal(num2) == 0) - { - if (have_error) - { - *have_error = true; - return NULL; - } - ereport(ERROR, - (errcode(ERRCODE_DIVISION_BY_ZERO), - errmsg("division by zero"))); - } + goto division_by_zero; + /* Inf % any nonzero = NaN */ - return make_result(&const_nan); + return numeric_make_result(&const_nan); } /* num2 must be [-]Inf; result is num1 regardless of sign of num2 */ return duplicate_numeric(num1); @@@ -3392,7 -3404,7 +3288,11 @@@ mod_var(&arg1, &arg2, &result); ++<<<<<<< ours + res = make_result_safe(&result, escontext); ++======= + res = numeric_make_result_opt_error(&result, NULL); ++>>>>>>> theirs free_var(&result); @@@ -7501,13 -7754,16 +7401,22 @@@ duplicate_numeric(Numeric num } /* ++<<<<<<< ours + * make_result_safe() - ++======= + * numeric_make_result_opt_error() - ++>>>>>>> theirs * * Create the packed db numeric format in palloc()'d memory from * a variable. This will handle NaN and Infinity cases. - * - * If "have_error" isn't NULL, on overflow *have_error is set to true and - * NULL is returned. This is helpful when caller needs to handle errors. */ ++<<<<<<< ours +static Numeric +make_result_safe(const NumericVar *var, Node *escontext) ++======= + Numeric + numeric_make_result_opt_error(const NumericVar *var, bool *have_error) ++>>>>>>> theirs { Numeric result; NumericDigit *digits = var->digits; @@@ -7588,24 -7847,34 +7497,32 @@@ /* Check for overflow of int16 fields */ if (NUMERIC_WEIGHT(result) != weight || NUMERIC_DSCALE(result) != var->dscale) - { - if (have_error) - { - *have_error = true; - return NULL; - } - else - { - ereport(ERROR, - (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), - errmsg("value overflows numeric format"))); - } - } + ereturn(escontext, NULL, + (errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE), + errmsg("value overflows numeric format"))); - dump_numeric("make_result()", result); + dump_numeric("numeric_make_result()", result); return result; } /* - * make_result() - + * numeric_make_result() - * ++<<<<<<< ours + * An interface to make_result_safe() without "escontext" argument. ++======= + * An interface to numeric_make_result_opt_error() without "have_error" argument. ++>>>>>>> theirs */ - static Numeric - make_result(const NumericVar *var) + Numeric + numeric_make_result(const NumericVar *var) { ++<<<<<<< ours + return make_result_safe(var, NULL); ++======= + return numeric_make_result_opt_error(var, NULL); ++>>>>>>> theirs }