Improve style of two code paths
authorMichael Paquier <[email protected]>
Tue, 8 Oct 2024 01:51:20 +0000 (10:51 +0900)
committerMichael Paquier <[email protected]>
Tue, 8 Oct 2024 01:51:20 +0000 (10:51 +0900)
In execGrouping.c, execTuplesMatchPrepare() was doing a memory
allocation that was not necessary when the number of columns was 0.
In foreign.c, pg_options_to_table() was assigning twice a variable to
the same value.

Author: Ranier Vilela
Discussion: https://postgr.es/m/CAEudQAqup0agbSzMjSLSTn=OANyCzxENF1+HrSYnr3WyZib7=Q@mail.gmail.com

src/backend/executor/execGrouping.c
src/backend/foreign/foreign.c

index 7233f1e3c039d567ec20b4a377881b722ea05921..774e4de882849062aba19ad8a3ab71ed2855058f 100644 (file)
@@ -62,13 +62,15 @@ execTuplesMatchPrepare(TupleDesc desc,
                       const Oid *collations,
                       PlanState *parent)
 {
-   Oid        *eqFunctions = (Oid *) palloc(numCols * sizeof(Oid));
+   Oid        *eqFunctions;
    int         i;
    ExprState  *expr;
 
    if (numCols == 0)
        return NULL;
 
+   eqFunctions = (Oid *) palloc(numCols * sizeof(Oid));
+
    /* lookup equality functions */
    for (i = 0; i < numCols; i++)
        eqFunctions[i] = get_opcode(eqOperators[i]);
index bb67d9f92b8a789f4a324c7d8f41fb5a92181a97..4c06e1ff1c43489811df48a7b0775513a0e9e731 100644 (file)
@@ -524,7 +524,7 @@ pg_options_to_table(PG_FUNCTION_ARGS)
    Datum       array = PG_GETARG_DATUM(0);
    ListCell   *cell;
    List       *options;
-   ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;
+   ReturnSetInfo *rsinfo;
 
    options = untransformRelOptions(array);
    rsinfo = (ReturnSetInfo *) fcinfo->resultinfo;