mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Const-ify the parse table passed to fillRelOptions. The previous coding
meant it had to be built on-the-fly at each entry to default_reloptions.
This commit is contained in:
@ -8,7 +8,7 @@
|
|||||||
*
|
*
|
||||||
*
|
*
|
||||||
* IDENTIFICATION
|
* IDENTIFICATION
|
||||||
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.22 2009/02/28 00:10:51 tgl Exp $
|
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.23 2009/03/23 16:36:27 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -175,7 +175,7 @@ static relopt_real realRelOpts[] =
|
|||||||
{ { NULL } }
|
{ { NULL } }
|
||||||
};
|
};
|
||||||
|
|
||||||
static relopt_string stringRelOpts[] =
|
static relopt_string stringRelOpts[] =
|
||||||
{
|
{
|
||||||
/* list terminator */
|
/* list terminator */
|
||||||
{ { NULL } }
|
{ { NULL } }
|
||||||
@ -739,7 +739,7 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc, Oid amoptions)
|
|||||||
options = NULL; /* keep compiler quiet */
|
options = NULL; /* keep compiler quiet */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return options;
|
return options;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -972,16 +972,17 @@ allocateReloptStruct(Size base, relopt_value *options, int numoptions)
|
|||||||
* struct (previously allocated with allocateReloptStruct) with the parsed
|
* struct (previously allocated with allocateReloptStruct) with the parsed
|
||||||
* values.
|
* values.
|
||||||
*
|
*
|
||||||
* rdopts is the pointer to the allocated struct to be filled; basesize is
|
* rdopts is the pointer to the allocated struct to be filled.
|
||||||
* the sizeof(struct) that was passed to allocateReloptStruct. options and
|
* basesize is the sizeof(struct) that was passed to allocateReloptStruct.
|
||||||
* numoptions are parseRelOptions' output. elems and numelems is the array
|
* options, of length numoptions, is parseRelOptions' output.
|
||||||
* of elements to be parsed. Note that when validate is true, it is expected
|
* elems, of length numelems, is the table describing the allowed options.
|
||||||
* that all options are also in elems.
|
* When validate is true, it is expected that all options appear in elems.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
fillRelOptions(void *rdopts, Size basesize, relopt_value *options,
|
fillRelOptions(void *rdopts, Size basesize,
|
||||||
int numoptions, bool validate, relopt_parse_elt *elems,
|
relopt_value *options, int numoptions,
|
||||||
int numelems)
|
bool validate,
|
||||||
|
const relopt_parse_elt *elems, int numelems)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int offset = basesize;
|
int offset = basesize;
|
||||||
@ -1044,7 +1045,7 @@ fillRelOptions(void *rdopts, Size basesize, relopt_value *options,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (validate && !found)
|
if (validate && !found)
|
||||||
elog(ERROR, "storate parameter \"%s\" not found in parse table",
|
elog(ERROR, "reloption \"%s\" not found in parse table",
|
||||||
options[i].gen->name);
|
options[i].gen->name);
|
||||||
}
|
}
|
||||||
SET_VARSIZE(rdopts, offset);
|
SET_VARSIZE(rdopts, offset);
|
||||||
@ -1061,7 +1062,7 @@ default_reloptions(Datum reloptions, bool validate, relopt_kind kind)
|
|||||||
relopt_value *options;
|
relopt_value *options;
|
||||||
StdRdOptions *rdopts;
|
StdRdOptions *rdopts;
|
||||||
int numoptions;
|
int numoptions;
|
||||||
relopt_parse_elt tab[] = {
|
static const relopt_parse_elt tab[] = {
|
||||||
{"fillfactor", RELOPT_TYPE_INT, offsetof(StdRdOptions, fillfactor)},
|
{"fillfactor", RELOPT_TYPE_INT, offsetof(StdRdOptions, fillfactor)},
|
||||||
{"autovacuum_enabled", RELOPT_TYPE_BOOL,
|
{"autovacuum_enabled", RELOPT_TYPE_BOOL,
|
||||||
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, enabled)},
|
offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, enabled)},
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
|
||||||
* Portions Copyright (c) 1994, Regents of the University of California
|
* Portions Copyright (c) 1994, Regents of the University of California
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/include/access/reloptions.h,v 1.12 2009/02/02 19:31:39 alvherre Exp $
|
* $PostgreSQL: pgsql/src/include/access/reloptions.h,v 1.13 2009/03/23 16:36:27 tgl Exp $
|
||||||
*
|
*
|
||||||
*-------------------------------------------------------------------------
|
*-------------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
@ -106,12 +106,12 @@ typedef struct relopt_string
|
|||||||
char default_val[1]; /* variable length, zero-terminated */
|
char default_val[1]; /* variable length, zero-terminated */
|
||||||
} relopt_string;
|
} relopt_string;
|
||||||
|
|
||||||
/* This is the input type for fillRelOptions */
|
/* This is the table datatype for fillRelOptions */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
char *optname;
|
const char *optname; /* option's name */
|
||||||
relopt_type opttype;
|
relopt_type opttype; /* option's datatype */
|
||||||
int offset;
|
int offset; /* offset of field in result struct */
|
||||||
} relopt_parse_elt;
|
} relopt_parse_elt;
|
||||||
|
|
||||||
|
|
||||||
@ -149,8 +149,8 @@ typedef struct
|
|||||||
* }
|
* }
|
||||||
*
|
*
|
||||||
* Note that this is more or less the same that fillRelOptions does, so only
|
* Note that this is more or less the same that fillRelOptions does, so only
|
||||||
* use this if you need to do something non-standard within some options'
|
* use this if you need to do something non-standard within some option's
|
||||||
* block.
|
* code block.
|
||||||
*/
|
*/
|
||||||
#define HAVE_RELOPTION(optname, option) \
|
#define HAVE_RELOPTION(optname, option) \
|
||||||
(pg_strncasecmp(option.gen->name, optname, option.gen->namelen + 1) == 0)
|
(pg_strncasecmp(option.gen->name, optname, option.gen->namelen + 1) == 0)
|
||||||
@ -252,9 +252,10 @@ extern relopt_value *parseRelOptions(Datum options, bool validate,
|
|||||||
relopt_kind kind, int *numrelopts);
|
relopt_kind kind, int *numrelopts);
|
||||||
extern void *allocateReloptStruct(Size base, relopt_value *options,
|
extern void *allocateReloptStruct(Size base, relopt_value *options,
|
||||||
int numoptions);
|
int numoptions);
|
||||||
extern void fillRelOptions(void *rdopts, Size basesize, relopt_value *options,
|
extern void fillRelOptions(void *rdopts, Size basesize,
|
||||||
int numoptions, bool validate, relopt_parse_elt *elems,
|
relopt_value *options, int numoptions,
|
||||||
int nelems);
|
bool validate,
|
||||||
|
const relopt_parse_elt *elems, int nelems);
|
||||||
|
|
||||||
extern bytea *default_reloptions(Datum reloptions, bool validate,
|
extern bytea *default_reloptions(Datum reloptions, bool validate,
|
||||||
relopt_kind kind);
|
relopt_kind kind);
|
||||||
|
Reference in New Issue
Block a user