mirror of
https://github.com/postgres/postgres.git
synced 2025-07-12 21:01:52 +03:00
Support ALTER TABLESPACE name SET/RESET ( tablespace_options ).
This patch only supports seq_page_cost and random_page_cost as parameters, but it provides the infrastructure to scalably support many more. In particular, we may want to add support for effective_io_concurrency, but I'm leaving that as future work for now. Thanks to Tom Lane for design help and Alvaro Herrera for the review.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.30 2010/01/02 16:57:33 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/access/common/reloptions.c,v 1.31 2010/01/05 21:53:58 rhaas Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -21,6 +21,7 @@
|
||||
#include "access/reloptions.h"
|
||||
#include "catalog/pg_type.h"
|
||||
#include "commands/defrem.h"
|
||||
#include "commands/tablespace.h"
|
||||
#include "nodes/makefuncs.h"
|
||||
#include "utils/array.h"
|
||||
#include "utils/builtins.h"
|
||||
@ -179,6 +180,22 @@ static relopt_real realRelOpts[] =
|
||||
},
|
||||
-1, 0.0, 100.0
|
||||
},
|
||||
{
|
||||
{
|
||||
"seq_page_cost",
|
||||
"Sets the planner's estimate of the cost of a sequentially fetched disk page.",
|
||||
RELOPT_KIND_TABLESPACE
|
||||
},
|
||||
-1, 0.0, DBL_MAX
|
||||
},
|
||||
{
|
||||
{
|
||||
"random_page_cost",
|
||||
"Sets the planner's estimate of the cost of a nonsequentially fetched disk page.",
|
||||
RELOPT_KIND_TABLESPACE
|
||||
},
|
||||
-1, 0.0, DBL_MAX
|
||||
},
|
||||
/* list terminator */
|
||||
{{NULL}}
|
||||
};
|
||||
@ -1168,3 +1185,34 @@ index_reloptions(RegProcedure amoptions, Datum reloptions, bool validate)
|
||||
|
||||
return DatumGetByteaP(result);
|
||||
}
|
||||
|
||||
/*
|
||||
* Option parser for tablespace reloptions
|
||||
*/
|
||||
bytea *
|
||||
tablespace_reloptions(Datum reloptions, bool validate)
|
||||
{
|
||||
relopt_value *options;
|
||||
TableSpaceOpts *tsopts;
|
||||
int numoptions;
|
||||
static const relopt_parse_elt tab[] = {
|
||||
{"random_page_cost", RELOPT_TYPE_REAL, offsetof(TableSpaceOpts, random_page_cost)},
|
||||
{"seq_page_cost", RELOPT_TYPE_REAL, offsetof(TableSpaceOpts, seq_page_cost)}
|
||||
};
|
||||
|
||||
options = parseRelOptions(reloptions, validate, RELOPT_KIND_TABLESPACE,
|
||||
&numoptions);
|
||||
|
||||
/* if none set, we're done */
|
||||
if (numoptions == 0)
|
||||
return NULL;
|
||||
|
||||
tsopts = allocateReloptStruct(sizeof(TableSpaceOpts), options, numoptions);
|
||||
|
||||
fillRelOptions((void *) tsopts, sizeof(TableSpaceOpts), options, numoptions,
|
||||
validate, tab, lengthof(tab));
|
||||
|
||||
pfree(options);
|
||||
|
||||
return (bytea *) tsopts;
|
||||
}
|
||||
|
Reference in New Issue
Block a user