@@ -140,132 +140,24 @@ typedef struct relopt_string
140
140
char * default_val ;
141
141
}relopt_string ;
142
142
143
- /* This is the table datatype forfillRelOptions */
143
+ /* This is the table datatype forbuild_reloptions() */
144
144
typedef struct
145
145
{
146
146
const char * optname ;/* option's name */
147
147
relopt_type opttype ;/* option's datatype */
148
148
int offset ;/* offset of field in result struct */
149
149
}relopt_parse_elt ;
150
150
151
-
152
151
/*
153
- * These macros exist for the convenience of amoptions writers (but consider
154
- * using fillRelOptions, which is a lot simpler). Beware of multiple
155
- * evaluation of arguments!
156
- *
157
- * The last argument in the HANDLE_*_RELOPTION macros allows the caller to
158
- * determine whether the option was set (true), or its value acquired from
159
- * defaults (false); it can be passed as (char *) NULL if the caller does not
160
- * need this information.
161
- *
162
- * optname is the option name (a string), var is the variable
163
- * on which the value should be stored (e.g. StdRdOptions->fillfactor), and
164
- * option is a relopt_value pointer.
165
- *
166
- * The normal way to use this is to loop on the relopt_value array returned by
167
- * parseRelOptions:
168
- * for (i = 0; options[i].gen->name; i++)
169
- * {
170
- *if (HAVE_RELOPTION("fillfactor", options[i])
171
- *{
172
- *HANDLE_INT_RELOPTION("fillfactor", rdopts->fillfactor, options[i], &isset);
173
- *continue;
174
- *}
175
- *if (HAVE_RELOPTION("default_row_acl", options[i])
176
- *{
177
- *...
178
- *}
179
- *...
180
- *if (validate)
181
- *ereport(ERROR,
182
- *(errmsg("unknown option")));
183
- *}
184
- *
185
- *Note that this is more or less the same that fillRelOptions does, so only
186
- *use this if you need to do something non-standard within some option's
187
- *code block.
188
- */
189
- #define HAVE_RELOPTION (optname ,option ) \
190
- (strncmp(option.gen->name, optname, option.gen->namelen + 1) == 0)
191
-
192
- #define HANDLE_INT_RELOPTION (optname ,var ,option ,wasset )\
193
- do {\
194
- if (option.isset)\
195
- var = option.values.int_val;\
196
- else\
197
- var = ((relopt_int *) option.gen)->default_val;\
198
- (wasset) != NULL ? *(wasset) = option.isset : (dummyret)NULL; \
199
- } while (0)
200
-
201
- #define HANDLE_BOOL_RELOPTION (optname ,var ,option ,wasset )\
202
- do {\
203
- if (option.isset)\
204
- var = option.values.bool_val;\
205
- else\
206
- var = ((relopt_bool *) option.gen)->default_val;\
207
- (wasset) != NULL ? *(wasset) = option.isset : (dummyret) NULL; \
208
- } while (0)
209
-
210
- #define HANDLE_REAL_RELOPTION (optname ,var ,option ,wasset )\
211
- do {\
212
- if (option.isset)\
213
- var = option.values.real_val;\
214
- else\
215
- var = ((relopt_real *) option.gen)->default_val;\
216
- (wasset) != NULL ? *(wasset) = option.isset : (dummyret) NULL; \
217
- } while (0)
218
-
219
- /*
220
- * Note that this assumes that the variable is already allocated at the tail of
221
- * reloptions structure (StdRdOptions or equivalent).
222
- *
223
- * "base" is a pointer to the reloptions structure, and "offset" is an integer
224
- * variable that must be initialized to sizeof(reloptions structure). This
225
- * struct must have been allocated with enough space to hold any string option
226
- * present, including terminating \0 for every option. SET_VARSIZE() must be
227
- * called on the struct with this offset as the second argument, after all the
228
- * string options have been processed.
229
- */
230
- #define HANDLE_STRING_RELOPTION (optname ,var ,option ,base ,offset ,wasset ) \
231
- do {\
232
- relopt_string *optstring = (relopt_string *) option.gen;\
233
- char *string_val;\
234
- if (option.isset)\
235
- string_val = option.values.string_val;\
236
- else if (!optstring->default_isnull)\
237
- string_val = optstring->default_val;\
238
- else\
239
- string_val = NULL;\
240
- (wasset) != NULL ? *(wasset) = option.isset : (dummyret) NULL; \
241
- if (string_val == NULL)\
242
- var = 0;\
243
- else\
244
- {\
245
- strcpy(((char *)(base)) + (offset), string_val);\
246
- var = (offset);\
247
- (offset) += strlen(string_val) + 1;\
248
- }\
249
- } while (0)
250
-
251
- /*
252
- * For use during amoptions: get the strlen of a string option
253
- * (either default or the user defined value)
254
- */
255
- #define GET_STRING_RELOPTION_LEN (option ) \
256
- ((option).isset ? strlen((option).values.string_val) : \
257
- ((relopt_string *) (option).gen)->default_len)
258
-
259
- /*
260
- * For use by code reading options already parsed: get a pointer to the string
261
- * value itself. "optstruct" is the StdRdOptions struct or equivalent, "member"
262
- * is the struct member corresponding to the string option
152
+ * Utility macro to get a value for a string reloption once the options
153
+ * are parsed. This gets a pointer to the string value itself. "optstruct"
154
+ * is the StdRdOptions struct or equivalent, "member" is the struct member
155
+ * corresponding to the string option.
263
156
*/
264
157
#define GET_STRING_RELOPTION (optstruct ,member ) \
265
158
((optstruct)->member == 0 ? NULL : \
266
159
(char *)(optstruct) + (optstruct)->member)
267
160
268
-
269
161
extern relopt_kind add_reloption_kind (void );
270
162
extern void add_bool_reloption (bits32 kinds ,const char * name ,const char * desc ,
271
163
bool default_val ,LOCKMODE lockmode );
@@ -288,14 +180,6 @@ extern Datum transformRelOptions(Datum oldOptions, List *defList,
288
180
extern List * untransformRelOptions (Datum options );
289
181
extern bytea * extractRelOptions (HeapTuple tuple ,TupleDesc tupdesc ,
290
182
amoptions_function amoptions );
291
- extern relopt_value * parseRelOptions (Datum options ,bool validate ,
292
- relopt_kind kind ,int * numrelopts );
293
- extern void * allocateReloptStruct (Size base ,relopt_value * options ,
294
- int numoptions );
295
- extern void fillRelOptions (void * rdopts ,Size basesize ,
296
- relopt_value * options ,int numoptions ,
297
- bool validate ,
298
- const relopt_parse_elt * elems ,int nelems );
299
183
extern void * build_reloptions (Datum reloptions ,bool validate ,
300
184
relopt_kind kind ,
301
185
Size relopt_struct_size ,