I was recently annoyed that I had to do
CREATE TABLESPACE x LOCATION y;
ALTER TABLESPACE x SET (random_page_cost = z);
The attached patch is a quick n' dirty extension to allow the SET
directly on the CREATE statement.
CREATE TABLESPACE x LOCATION y SET (random_page_cost = z);
If people think this is a good idea, I'll clean it up, add
documentation, and submit it to the next commitfest.
--
Vik
*** a/src/backend/commands/tablespace.c
--- b/src/backend/commands/tablespace.c
***************
*** 234,239 **** CreateTableSpace(CreateTableSpaceStmt *stmt)
--- 234,240 ----
Oid tablespaceoid;
char *location;
Oid ownerId;
+ Datum newOptions;
/* Must be super user */
if (!superuser())
***************
*** 317,323 **** CreateTableSpace(CreateTableSpaceStmt *stmt)
values[Anum_pg_tablespace_spcowner - 1] =
ObjectIdGetDatum(ownerId);
nulls[Anum_pg_tablespace_spcacl - 1] = true;
! nulls[Anum_pg_tablespace_spcoptions - 1] = true;
tuple = heap_form_tuple(rel->rd_att, values, nulls);
--- 318,333 ----
values[Anum_pg_tablespace_spcowner - 1] =
ObjectIdGetDatum(ownerId);
nulls[Anum_pg_tablespace_spcacl - 1] = true;
!
! /* Generate new proposed spcoptions (text array) */
! newOptions = transformRelOptions((Datum) 0,
! stmt->options,
! NULL, NULL, false, false);
! (void) tablespace_reloptions(newOptions, true);
! if (newOptions != (Datum) 0)
! values[Anum_pg_tablespace_spcoptions - 1] = newOptions;
! else
! nulls[Anum_pg_tablespace_spcoptions - 1] = true;
tuple = heap_form_tuple(rel->rd_att, values, nulls);
*** a/src/backend/nodes/copyfuncs.c
--- b/src/backend/nodes/copyfuncs.c
***************
*** 3370,3375 **** _copyCreateTableSpaceStmt(const CreateTableSpaceStmt *from)
--- 3370,3376 ----
COPY_STRING_FIELD(tablespacename);
COPY_STRING_FIELD(owner);
COPY_STRING_FIELD(location);
+ COPY_NODE_FIELD(options);
return newnode;
}
*** a/src/backend/nodes/equalfuncs.c
--- b/src/backend/nodes/equalfuncs.c
***************
*** 1610,1615 **** _equalCreateTableSpaceStmt(const CreateTableSpaceStmt *a, const CreateTableSpace
--- 1610,1616 ----
COMPARE_STRING_FIELD(tablespacename);
COMPARE_STRING_FIELD(owner);
COMPARE_STRING_FIELD(location);
+ COMPARE_NODE_FIELD(options);
return true;
}
*** a/src/backend/parser/gram.y
--- b/src/backend/parser/gram.y
***************
*** 325,331 **** static Node *makeRecursiveViewSelect(char *relname, List *aliases, Node *query);
%type <list> stmtblock stmtmulti
OptTableElementList TableElementList OptInherit definition
OptTypedTableElementList TypedTableElementList
! reloptions opt_reloptions
OptWith opt_distinct opt_definition func_args func_args_list
func_args_with_defaults func_args_with_defaults_list
aggr_args aggr_args_list
--- 325,331 ----
%type <list> stmtblock stmtmulti
OptTableElementList TableElementList OptInherit definition
OptTypedTableElementList TypedTableElementList
! reloptions opt_reloptions opt_setreloptions
OptWith opt_distinct opt_definition func_args func_args_list
func_args_with_defaults func_args_with_defaults_list
aggr_args aggr_args_list
***************
*** 2275,2280 **** opt_reloptions: WITH reloptions { $$ = $2; }
--- 2275,2284 ----
| /* EMPTY */ { $$ = NIL; }
;
+ opt_setreloptions: SET reloptions { $$ = $2; }
+ | /* EMPTY */ { $$ = NIL; }
+ ;
+
reloption_list:
reloption_elem { $$ = list_make1($1); }
| reloption_list ',' reloption_elem { $$ = lappend($1, $3); }
***************
*** 3588,3599 **** opt_procedural:
*
*****************************************************************************/
! CreateTableSpaceStmt: CREATE TABLESPACE name OptTableSpaceOwner LOCATION Sconst
{
CreateTableSpaceStmt *n = makeNode(CreateTableSpaceStmt);
n->tablespacename = $3;
n->owner = $4;
n->location = $6;
$$ = (Node *) n;
}
;
--- 3592,3604 ----
*
*****************************************************************************/
! CreateTableSpaceStmt: CREATE TABLESPACE name OptTableSpaceOwner LOCATION Sconst opt_setreloptions
{
CreateTableSpaceStmt *n = makeNode(CreateTableSpaceStmt);
n->tablespacename = $3;
n->owner = $4;
n->location = $6;
+ n->options = $7;
$$ = (Node *) n;
}
;
*** a/src/include/nodes/parsenodes.h
--- b/src/include/nodes/parsenodes.h
***************
*** 1669,1674 **** typedef struct CreateTableSpaceStmt
--- 1669,1675 ----
char *tablespacename;
char *owner;
char *location;
+ List *options;
} CreateTableSpaceStmt;
typedef struct DropTableSpaceStmt
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers