Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1079564

Browse files
committed
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.
1 parent5c617f4 commit1079564

File tree

2 files changed

+25
-23
lines changed

2 files changed

+25
-23
lines changed

‎src/backend/access/common/reloptions.c

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.22 2009/02/28 00:10:51 tgl Exp $
11+
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.23 2009/03/23 16:36:27 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -175,7 +175,7 @@ static relopt_real realRelOpts[] =
175175
{ {NULL } }
176176
};
177177

178-
staticrelopt_stringstringRelOpts[]=
178+
staticrelopt_stringstringRelOpts[]=
179179
{
180180
/* list terminator */
181181
{ {NULL } }
@@ -739,7 +739,7 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc, Oid amoptions)
739739
options=NULL;/* keep compiler quiet */
740740
break;
741741
}
742-
742+
743743
returnoptions;
744744
}
745745

@@ -972,16 +972,17 @@ allocateReloptStruct(Size base, relopt_value *options, int numoptions)
972972
* struct (previously allocated with allocateReloptStruct) with the parsed
973973
* values.
974974
*
975-
* rdopts is the pointer to the allocated struct to be filled; basesize is
976-
* the sizeof(struct) that was passed to allocateReloptStruct. options and
977-
* numoptions are parseRelOptions' output. elems and numelems is the array
978-
* ofelements to be parsed. Note that when validate is true, it is expected
979-
* that all optionsare also in elems.
975+
* rdopts is the pointer to the allocated struct to be filled.
976+
*basesize isthe sizeof(struct) that was passed to allocateReloptStruct.
977+
*options, of lengthnumoptions, is parseRelOptions' output.
978+
*elems,oflength numelems, is the table describing the allowed options.
979+
*When validate is true, it is expectedthat all optionsappear in elems.
980980
*/
981981
void
982-
fillRelOptions(void*rdopts,Sizebasesize,relopt_value*options,
983-
intnumoptions,boolvalidate,relopt_parse_elt*elems,
984-
intnumelems)
982+
fillRelOptions(void*rdopts,Sizebasesize,
983+
relopt_value*options,intnumoptions,
984+
boolvalidate,
985+
constrelopt_parse_elt*elems,intnumelems)
985986
{
986987
inti;
987988
intoffset=basesize;
@@ -1044,7 +1045,7 @@ fillRelOptions(void *rdopts, Size basesize, relopt_value *options,
10441045
}
10451046
}
10461047
if (validate&& !found)
1047-
elog(ERROR,"storate parameter \"%s\" not found in parse table",
1048+
elog(ERROR,"reloption \"%s\" not found in parse table",
10481049
options[i].gen->name);
10491050
}
10501051
SET_VARSIZE(rdopts,offset);
@@ -1061,7 +1062,7 @@ default_reloptions(Datum reloptions, bool validate, relopt_kind kind)
10611062
relopt_value*options;
10621063
StdRdOptions*rdopts;
10631064
intnumoptions;
1064-
relopt_parse_elttab[]= {
1065+
staticconstrelopt_parse_elttab[]= {
10651066
{"fillfactor",RELOPT_TYPE_INT, offsetof(StdRdOptions,fillfactor)},
10661067
{"autovacuum_enabled",RELOPT_TYPE_BOOL,
10671068
offsetof(StdRdOptions,autovacuum)+ offsetof(AutoVacOpts,enabled)},

‎src/include/access/reloptions.h

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $PostgreSQL: pgsql/src/include/access/reloptions.h,v 1.12 2009/02/02 19:31:39 alvherre Exp $
14+
* $PostgreSQL: pgsql/src/include/access/reloptions.h,v 1.13 2009/03/23 16:36:27 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -106,12 +106,12 @@ typedef struct relopt_string
106106
chardefault_val[1];/* variable length, zero-terminated */
107107
}relopt_string;
108108

109-
/* This is theinput type for fillRelOptions */
109+
/* This is thetable datatype for fillRelOptions */
110110
typedefstruct
111111
{
112-
char*optname;
113-
relopt_typeopttype;
114-
intoffset;
112+
constchar*optname;/* option's name */
113+
relopt_typeopttype;/* option's datatype */
114+
intoffset;/* offset of field in result struct */
115115
}relopt_parse_elt;
116116

117117

@@ -149,8 +149,8 @@ typedef struct
149149
* }
150150
*
151151
* Note that this is more or less the same that fillRelOptions does, so only
152-
* use this if you need to do something non-standard within someoptions'
153-
* block.
152+
* use this if you need to do something non-standard within someoption's
153+
*codeblock.
154154
*/
155155
#defineHAVE_RELOPTION(optname,option) \
156156
(pg_strncasecmp(option.gen->name, optname, option.gen->namelen + 1) == 0)
@@ -252,9 +252,10 @@ extern relopt_value *parseRelOptions(Datum options, bool validate,
252252
relopt_kindkind,int*numrelopts);
253253
externvoid*allocateReloptStruct(Sizebase,relopt_value*options,
254254
intnumoptions);
255-
externvoidfillRelOptions(void*rdopts,Sizebasesize,relopt_value*options,
256-
intnumoptions,boolvalidate,relopt_parse_elt*elems,
257-
intnelems);
255+
externvoidfillRelOptions(void*rdopts,Sizebasesize,
256+
relopt_value*options,intnumoptions,
257+
boolvalidate,
258+
constrelopt_parse_elt*elems,intnelems);
258259

259260
externbytea*default_reloptions(Datumreloptions,boolvalidate,
260261
relopt_kindkind);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp