summaryrefslogtreecommitdiff
path: root/src/backend/access/gist/gistutil.c
diff options
context:
space:
mode:
authorMichael Paquier <michael@paquier.xyz>2019-11-05 09:17:05 +0900
committerMichael Paquier <michael@paquier.xyz>2019-11-05 09:17:05 +0900
commit3534fa2233285c1fab1e668871aabf05e5541213 (patch)
tree4b6b708590540bee0b2d66b7a485f35df8680809 /src/backend/access/gist/gistutil.c
parent5102f39440f758ea53c2e1cdea7d8411df1805d2 (diff)
downloadpostgresql-3534fa2233285c1fab1e668871aabf05e5541213.tar.gz
Refactor code building relation options
Historically, the code to build relation options has been shaped the same way in multiple code paths by using a set of datums in input with the options parsed with a static table which is then filled with the option values. This introduces a new common routine in reloptions.c to do most of the legwork for the in-core code paths. Author: Amit Langote Reviewed-by: Michael Paquier Discussion: https://postgr.es/m/CA+HiwqGsoSn_uTPPYT19WrtR7oYpYtv4CdS0xuedTKiHHWuk_g@mail.gmail.com
Diffstat (limited to 'src/backend/access/gist/gistutil.c')
-rw-r--r--src/backend/access/gist/gistutil.c22
1 files changed, 4 insertions, 18 deletions
diff --git a/src/backend/access/gist/gistutil.c b/src/backend/access/gist/gistutil.c
index 45804d7a91..a23dec76a2 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -908,29 +908,15 @@ gistPageRecyclable(Page page)
bytea *
gistoptions(Datum reloptions, bool validate)
{
- relopt_value *options;
- GiSTOptions *rdopts;
- int numoptions;
static const relopt_parse_elt tab[] = {
{"fillfactor", RELOPT_TYPE_INT, offsetof(GiSTOptions, fillfactor)},
{"buffering", RELOPT_TYPE_ENUM, offsetof(GiSTOptions, buffering_mode)}
};
- options = parseRelOptions(reloptions, validate, RELOPT_KIND_GIST,
- &numoptions);
-
- /* if none set, we're done */
- if (numoptions == 0)
- return NULL;
-
- rdopts = allocateReloptStruct(sizeof(GiSTOptions), options, numoptions);
-
- fillRelOptions((void *) rdopts, sizeof(GiSTOptions), options, numoptions,
- validate, tab, lengthof(tab));
-
- pfree(options);
-
- return (bytea *) rdopts;
+ return (bytea *) build_reloptions(reloptions, validate,
+ RELOPT_KIND_GIST,
+ sizeof(GiSTOptions),
+ tab, lengthof(tab));
}
/*