*** src/backend/access/nbtree/nbtinsert.c	3 Nov 2008 20:47:48 -0000	1.168
--- src/backend/access/nbtree/nbtinsert.c	30 Dec 2008 14:29:21 -0000
***************
*** 565,570 ****
--- 565,581 ----
  	OffsetNumber firstright = InvalidOffsetNumber;
  	Size		itemsz;
  
+ 	{
+ 		BtOptions *options = (BtOptions *) rel->rd_options;
+ 
+ 		if (options)
+ 		{
+ 			elog(LOG, "the testbool option is %s", options->testbool ? "true" : "false");
+ 			elog(LOG, "the testint option is %d", options->testint);
+ 			elog(LOG, "the testreal option is %f", options->testreal);
+ 		}
+ 	}
+ 
  	page = BufferGetPage(buf);
  	lpageop = (BTPageOpaque) PageGetSpecialPointer(page);
  
*** src/backend/access/nbtree/nbtutils.c	19 Jun 2008 00:46:03 -0000	1.91
--- src/backend/access/nbtree/nbtutils.c	30 Dec 2008 14:26:17 -0000
***************
*** 1401,1409 ****
  	Datum		reloptions = PG_GETARG_DATUM(0);
  	bool		validate = PG_GETARG_BOOL(1);
  	bytea	   *result;
- 
- 	result = default_reloptions(reloptions, validate, RELOPT_KIND_BTREE);
  
  	if (result)
  		PG_RETURN_BYTEA_P(result);
  	PG_RETURN_NULL();
--- 1401,1481 ----
  	Datum		reloptions = PG_GETARG_DATUM(0);
  	bool		validate = PG_GETARG_BOOL(1);
  	bytea	   *result;
+ 	relopt_value *options;
+ 	BtOptions  *rdopts;
+ 	BtOptions	lopts;
+ 	int			numoptions;
+ 	int			len;
+ 	int			i;
+ 	static	bool initialized = false;
+ 
+ 	if (!initialized)
+ 	{
+ 		add_bool_reloption(RELOPT_KIND_BTREE, "testbool", NULL, false);
+ 		add_int_reloption(RELOPT_KIND_BTREE, "testint", NULL, 25, 10, 100);
+ 		add_real_reloption(RELOPT_KIND_BTREE, "testreal", NULL, 3.14, 2.78, 42.0);
+ 		initialized = true;
+ 	}
+ 
+ 	options = parseRelOptions(reloptions, validate, RELOPT_KIND_BTREE, &numoptions);
+ 
+ 	/* if none set, we're done */
+ 	if (numoptions == 0)
+ 		result = NULL;
+ 	else
+ 	{
+ 		MemSet(&lopts, 0, sizeof(BtOptions));
+ 
+ 		for (i = 0; i < numoptions; i++)
+ 		{
+ 			if (pg_strncasecmp(options[i].gen->name, "fillfactor",
+ 							   options[i].gen->namelen) == 0)
+ 			{
+ 				if (options[i].isset)
+ 					lopts.fillfactor = options[i].values.int_val;
+ 				else
+ 					lopts.fillfactor = ((relopt_int *) options[i].gen)->default_val;
+ 				continue;
+ 			}
+ 			if (pg_strncasecmp(options[i].gen->name, "testbool",
+ 							   options[i].gen->namelen) == 0)
+ 			{
+ 				if (options[i].isset)
+ 					lopts.testbool = options[i].values.bool_val;
+ 				else
+ 					lopts.testbool = ((relopt_bool *) options[i].gen)->default_val;
+ 				continue;
+ 			}
+ 			if (pg_strncasecmp(options[i].gen->name, "testint",
+ 							   options[i].gen->namelen) == 0)
+ 			{
+ 				if (options[i].isset)
+ 					lopts.testint = options[i].values.int_val;
+ 				else
+ 					lopts.testint = ((relopt_int *) options[i].gen)->default_val;
+ 				continue;
+ 			}
+ 			if (pg_strncasecmp(options[i].gen->name, "testreal",
+ 							   options[i].gen->namelen) == 0)
+ 			{
+ 				if (options[i].isset)
+ 					lopts.testreal = options[i].values.real_val;
+ 				else
+ 					lopts.testreal = ((relopt_real *) options[i].gen)->default_val;
+ 				continue;
+ 			}
+ 		}
+ 
+ 		pfree(options);
+ 
+ 		len = sizeof(BtOptions);
+ 		rdopts = palloc(len);
+ 		memcpy(rdopts, &lopts, len);
+ 		SET_VARSIZE(rdopts, len);
+ 
+ 		result = (bytea *) rdopts;
+ 	}
  
  	if (result)
  		PG_RETURN_BYTEA_P(result);
  	PG_RETURN_NULL();
*** src/include/access/nbtree.h	13 Jul 2008 20:45:47 -0000	1.121
--- src/include/access/nbtree.h	30 Dec 2008 14:26:28 -0000
***************
*** 595,598 ****
--- 595,608 ----
  extern void btree_xlog_cleanup(void);
  extern bool btree_safe_restartpoint(void);
  
+ /* must follow StdRdOptions conventions */
+ typedef struct BtOptions
+ {
+ 	int32	vl_len_;
+ 	int		fillfactor;
+ 	bool	testbool;
+ 	int		testint;
+ 	double	testreal;
+ } BtOptions;
+ 
  #endif   /* NBTREE_H */
