From: | Justin Pryzby <pryzby(at)telsasoft(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-hackers(at)lists(dot)postgresql(dot)org |
Subject: | [PATCH] check_random_seed: use a boolean not an int.. |
Date: | 2021-06-12 16:13:15 |
Message-ID: | 20210612161315.GX16435@telsasoft.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
This confused me for a minute so took the opportunity to clean it up.
Since: 2594cf0e8c04406ffff19b1651c5a406d376657c
---
src/backend/commands/variable.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c
index 0c85679420..56f15d2e37 100644
--- a/src/backend/commands/variable.c
+++ b/src/backend/commands/variable.c
@@ -589,11 +589,12 @@ check_transaction_deferrable(bool *newval, void **extra, GucSource source)
bool
check_random_seed(double *newval, void **extra, GucSource source)
{
- *extra = malloc(sizeof(int));
- if (!*extra)
+ bool *doit = *extra = malloc(sizeof(bool));
+ if (doit == NULL)
return false;
+
/* Arm the assign only if source of value is an interactive SET */
- *((int *) *extra) = (source >= PGC_S_INTERACTIVE);
+ *doit = (source >= PGC_S_INTERACTIVE);
return true;
}
@@ -601,10 +602,11 @@ check_random_seed(double *newval, void **extra, GucSource source)
void
assign_random_seed(double newval, void *extra)
{
+ bool *doit = (bool *)extra;
/* We'll do this at most once for any setting of the GUC variable */
- if (*((int *) extra))
+ if (*doit)
DirectFunctionCall1(setseed, Float8GetDatum(newval));
- *((int *) extra) = 0;
+ *doit = false;
}
const char *
--
2.17.0
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2021-06-12 17:01:02 | Re: logical replication of truncate command with trigger causes Assert |
Previous Message | Andrew Dunstan | 2021-06-12 15:47:34 | Re: Race condition in recovery? |