aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2024-10-08 10:51:20 +0900
committerMichael Paquier <michael@paquier.xyz>2024-10-08 10:51:20 +0900
commit4572d59e3c9b0ef6c056544b6336561efd9bb5ec (patch)
treef29711312d0bfd8e1eced82822027ca787b6ece3
parenta9ed7d944965865e5c6b44e58602f621cd185856 (diff)
downloadpostgresql-4572d59e3c9b0ef6c056544b6336561efd9bb5ec.tar.gz
postgresql-4572d59e3c9b0ef6c056544b6336561efd9bb5ec.zip
Improve style of two code paths
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
-rw-r--r--src/backend/executor/execGrouping.c4
-rw-r--r--src/backend/foreign/foreign.c2
2 files changed, 4 insertions, 2 deletions
diff --git a/src/backend/executor/execGrouping.c b/src/backend/executor/execGrouping.c
index 7233f1e3c03..774e4de8828 100644
--- a/src/backend/executor/execGrouping.c
+++ b/src/backend/executor/execGrouping.c
@@ -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]);
diff --git a/src/backend/foreign/foreign.c b/src/backend/foreign/foreign.c
index bb67d9f92b8..4c06e1ff1c4 100644
--- a/src/backend/foreign/foreign.c
+++ b/src/backend/foreign/foreign.c
@@ -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;