Peter Eisentraut wrote:
> On Sunday 21 December 2008 01:48:42 Alvaro Herrera wrote:
> > ALTER TABLE foo SET (TOAST autovacuum_enabled = false);
> > ALTER TABLE foo SET (toast.autovacuum_enabled = false);
> > ALTER TABLE foo TOAST SET (autovacuum_enabled = false);
> > ALTER TABLE foo SET TOAST (autovacuum_enabled = false);
>
> The last two don't appear to allow setting TOAST and non-TOAST options in one
> go. I think it would be handy to allow that, though.
Agreed -- so I'm now playing with this version:
> > ALTER TABLE foo SET (TOAST autovacuum_enabled = false);
So the grammar modifications needed to accept that are attached. The
support code is a lot messier than I'd like :-(
--
Alvaro Herrera http://www.CommandPrompt.com/
PostgreSQL Replication, Consulting, Custom Development, 24x7 support
Index: src/backend/commands/define.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/commands/define.c,v
retrieving revision 1.101
diff -c -p -r1.101 define.c
*** src/backend/commands/define.c 1 Jan 2008 19:45:48 -0000 1.101
--- src/backend/commands/define.c 31 Dec 2008 17:53:38 -0000
*************** defGetTypeLength(DefElem *def)
*** 306,319 ****
}
/*
! * Create a DefElem setting "oids" to the specified value.
*/
! DefElem *
defWithOids(bool value)
{
! DefElem *f = makeNode(DefElem);
f->defname = "oids";
f->arg = (Node *) makeInteger(value);
return f;
}
--- 306,320 ----
}
/*
! * Create a TDefElem setting "oids" to the specified value.
*/
! TDefElem *
defWithOids(bool value)
{
! TDefElem *f = makeNode(TDefElem);
f->defname = "oids";
f->arg = (Node *) makeInteger(value);
+ f->toast = false;
return f;
}
Index: src/backend/nodes/copyfuncs.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/nodes/copyfuncs.c,v
retrieving revision 1.418
diff -c -p -r1.418 copyfuncs.c
*** src/backend/nodes/copyfuncs.c 31 Dec 2008 00:08:35 -0000 1.418
--- src/backend/nodes/copyfuncs.c 31 Dec 2008 17:16:59 -0000
*************** _copyDefElem(DefElem *from)
*** 2112,2117 ****
--- 2112,2130 ----
return newnode;
}
+ static TDefElem *
+ _copyTDefElem(TDefElem *from)
+ {
+ TDefElem *newnode = makeNode(TDefElem);
+
+ COPY_STRING_FIELD(defname);
+ COPY_NODE_FIELD(arg);
+ COPY_SCALAR_FIELD(toast);
+
+ return newnode;
+ }
+
+
static OptionDefElem *
_copyOptionDefElem(OptionDefElem *from)
{
*************** copyObject(void *from)
*** 4063,4068 ****
--- 4076,4084 ----
case T_DefElem:
retval = _copyDefElem(from);
break;
+ case T_TDefElem:
+ retval = _copyTDefElem(from);
+ break;
case T_OptionDefElem:
retval = _copyOptionDefElem(from);
break;
Index: src/backend/nodes/makefuncs.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/nodes/makefuncs.c,v
retrieving revision 1.61
diff -c -p -r1.61 makefuncs.c
*** src/backend/nodes/makefuncs.c 19 Dec 2008 16:25:17 -0000 1.61
--- src/backend/nodes/makefuncs.c 31 Dec 2008 16:51:09 -0000
*************** makeDefElem(char *name, Node *arg)
*** 363,368 ****
--- 363,383 ----
}
/*
+ * makeTDefElem -
+ * build a TDefElem node
+ */
+ TDefElem *
+ makeTDefElem(char *name, Node *arg, bool toast)
+ {
+ TDefElem *res = makeNode(TDefElem);
+
+ res->defname = name;
+ res->arg = arg;
+ res->toast = toast;
+ return res;
+ }
+
+ /*
* makeOptionDefElem -
* build an OptionDefElem node
*/
Index: src/backend/nodes/outfuncs.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/nodes/outfuncs.c,v
retrieving revision 1.348
diff -c -p -r1.348 outfuncs.c
*** src/backend/nodes/outfuncs.c 31 Dec 2008 00:08:36 -0000 1.348
--- src/backend/nodes/outfuncs.c 31 Dec 2008 17:17:19 -0000
*************** _outDefElem(StringInfo str, DefElem *nod
*** 1807,1812 ****
--- 1807,1822 ----
}
static void
+ _outTDefElem(StringInfo str, TDefElem *node)
+ {
+ WRITE_NODE_TYPE("TDEFELEM");
+
+ WRITE_STRING_FIELD(defname);
+ WRITE_NODE_FIELD(arg);
+ WRITE_BOOL_FIELD(toast);
+ }
+
+ static void
_outLockingClause(StringInfo str, LockingClause *node)
{
WRITE_NODE_TYPE("LOCKINGCLAUSE");
*************** _outNode(StringInfo str, void *obj)
*** 2770,2775 ****
--- 2780,2788 ----
case T_DefElem:
_outDefElem(str, obj);
break;
+ case T_TDefElem:
+ _outTDefElem(str, obj);
+ break;
case T_LockingClause:
_outLockingClause(str, obj);
break;
Index: src/backend/parser/gram.y
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/parser/gram.y,v
retrieving revision 2.650
diff -c -p -r2.650 gram.y
*** src/backend/parser/gram.y 31 Dec 2008 02:25:04 -0000 2.650
--- src/backend/parser/gram.y 31 Dec 2008 19:38:02 -0000
*************** static TypeName *TableFuncTypeName(List
*** 156,161 ****
--- 156,162 ----
FunctionParameterMode fun_param_mode;
FuncWithArgs *funwithargs;
DefElem *defelt;
+ TDefElem *tdefelt;
OptionDefElem *optdef;
SortBy *sortby;
WindowDef *windef;
*************** static TypeName *TableFuncTypeName(List
*** 263,268 ****
--- 264,270 ----
%type <list> stmtblock stmtmulti
OptTableElementList TableElementList OptInherit definition
+ t_definition
OptWith opt_distinct opt_definition func_args func_args_list
func_args_with_defaults func_args_with_defaults_list
func_as createfunc_opt_list alterfunc_opt_list
*************** static TypeName *TableFuncTypeName(List
*** 275,281 ****
any_operator expr_list attrs
target_list insert_column_list set_target_list
set_clause_list set_clause multiple_set_clause
! ctext_expr_list ctext_row def_list indirection opt_indirection
group_clause TriggerFuncArgs select_limit
opt_select_limit opclass_item_list opclass_drop_list
opt_opfamily transaction_mode_list_or_empty
--- 277,283 ----
any_operator expr_list attrs
target_list insert_column_list set_target_list
set_clause_list set_clause multiple_set_clause
! ctext_expr_list ctext_row def_list t_def_list indirection opt_indirection
group_clause TriggerFuncArgs select_limit
opt_select_limit opclass_item_list opclass_drop_list
opt_opfamily transaction_mode_list_or_empty
*************** static TypeName *TableFuncTypeName(List
*** 333,338 ****
--- 335,341 ----
%type <node> TableElement ConstraintElem TableFuncElement
%type <node> columnDef
%type <defelt> def_elem old_aggr_elem
+ %type <tdefelt> t_def_elem
%type <node> def_arg columnElem where_clause where_or_current_clause
a_expr b_expr c_expr func_expr AexprConst indirection_el
columnref in_expr having_clause func_table array_expr
*************** static TypeName *TableFuncTypeName(List
*** 486,492 ****
SYMMETRIC SYSID SYSTEM_P
TABLE TABLESPACE TEMP TEMPLATE TEMPORARY TEXT_P THEN TIME TIMESTAMP
! TO TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P
TRUNCATE TRUSTED TYPE_P
UNBOUNDED UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN UNLISTEN UNTIL
--- 489,495 ----
SYMMETRIC SYSID SYSTEM_P
TABLE TABLESPACE TEMP TEMPLATE TEMPORARY TEXT_P THEN TIME TIMESTAMP
! TO TOAST TRAILING TRANSACTION TREAT TRIGGER TRIM TRUE_P
TRUNCATE TRUSTED TYPE_P
UNBOUNDED UNCOMMITTED UNENCRYPTED UNION UNIQUE UNKNOWN UNLISTEN UNTIL
*************** alter_table_cmd:
*** 1772,1778 ****
$$ = (Node *)n;
}
/* ALTER TABLE <name> SET (...) */
! | SET definition
{
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_SetRelOptions;
--- 1775,1781 ----
$$ = (Node *)n;
}
/* ALTER TABLE <name> SET (...) */
! | SET t_definition
{
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_SetRelOptions;
*************** alter_table_cmd:
*** 1780,1786 ****
$$ = (Node *)n;
}
/* ALTER TABLE <name> RESET (...) */
! | RESET definition
{
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_ResetRelOptions;
--- 1783,1789 ----
$$ = (Node *)n;
}
/* ALTER TABLE <name> RESET (...) */
! | RESET t_definition
{
AlterTableCmd *n = makeNode(AlterTableCmd);
n->subtype = AT_ResetRelOptions;
*************** alter_using:
*** 1805,1811 ****
--- 1808,1837 ----
| /* EMPTY */ { $$ = NULL; }
;
+ t_definition: '(' t_def_list ')' { $$ = $2; }
+ ;
+
+ t_def_list: t_def_elem { $$ = list_make1($1); }
+ | t_def_list ',' t_def_elem { $$ = lappend($1, $3); }
+ ;
+ t_def_elem: TOAST ColLabel '=' def_arg
+ {
+ $$ = makeTDefElem($2, (Node *) $4, true);
+ }
+ | TOAST ColLabel
+ {
+ $$ = makeTDefElem($2, NULL, true);
+ }
+ | ColLabel '=' def_arg
+ {
+ $$ = makeTDefElem($1, (Node *) $3, false);
+ }
+ | ColLabel
+ {
+ $$ = makeTDefElem($1, NULL, false);
+ }
+ ;
/*****************************************************************************
*
*************** OptInherit: INHERITS '(' qualified_name_
*** 2431,2437 ****
/* WITH (options) is preferred, WITH OIDS and WITHOUT OIDS are legacy forms */
OptWith:
! WITH definition { $$ = $2; }
| WITH OIDS { $$ = list_make1(defWithOids(true)); }
| WITHOUT OIDS { $$ = list_make1(defWithOids(false)); }
| /*EMPTY*/ { $$ = NIL; }
--- 2457,2463 ----
/* WITH (options) is preferred, WITH OIDS and WITHOUT OIDS are legacy forms */
OptWith:
! WITH t_definition { $$ = $2; }
| WITH OIDS { $$ = list_make1(defWithOids(true)); }
| WITHOUT OIDS { $$ = list_make1(defWithOids(false)); }
| /*EMPTY*/ { $$ = NIL; }
*************** unreserved_keyword:
*** 10234,10239 ****
--- 10260,10266 ----
| TEMPLATE
| TEMPORARY
| TEXT_P
+ | TOAST
| TRANSACTION
| TRIGGER
| TRUNCATE
Index: src/backend/parser/keywords.c
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/backend/parser/keywords.c,v
retrieving revision 1.208
diff -c -p -r1.208 keywords.c
*** src/backend/parser/keywords.c 31 Dec 2008 00:08:37 -0000 1.208
--- src/backend/parser/keywords.c 31 Dec 2008 17:00:37 -0000
*************** const ScanKeyword ScanKeywords[] = {
*** 382,387 ****
--- 382,388 ----
{"time", TIME, COL_NAME_KEYWORD},
{"timestamp", TIMESTAMP, COL_NAME_KEYWORD},
{"to", TO, RESERVED_KEYWORD},
+ {"toast", TOAST, UNRESERVED_KEYWORD},
{"trailing", TRAILING, RESERVED_KEYWORD},
{"transaction", TRANSACTION, UNRESERVED_KEYWORD},
{"treat", TREAT, COL_NAME_KEYWORD},
Index: src/include/commands/defrem.h
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/include/commands/defrem.h,v
retrieving revision 1.91
diff -c -p -r1.91 defrem.h
*** src/include/commands/defrem.h 19 Dec 2008 16:25:19 -0000 1.91
--- src/include/commands/defrem.h 31 Dec 2008 17:53:50 -0000
*************** extern int64 defGetInt64(DefElem *def);
*** 145,150 ****
extern List *defGetQualifiedName(DefElem *def);
extern TypeName *defGetTypeName(DefElem *def);
extern int defGetTypeLength(DefElem *def);
! extern DefElem *defWithOids(bool value);
#endif /* DEFREM_H */
--- 145,150 ----
extern List *defGetQualifiedName(DefElem *def);
extern TypeName *defGetTypeName(DefElem *def);
extern int defGetTypeLength(DefElem *def);
! extern TDefElem *defWithOids(bool value);
#endif /* DEFREM_H */
Index: src/include/nodes/makefuncs.h
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/include/nodes/makefuncs.h,v
retrieving revision 1.64
diff -c -p -r1.64 makefuncs.h
*** src/include/nodes/makefuncs.h 19 Dec 2008 16:25:19 -0000 1.64
--- src/include/nodes/makefuncs.h 31 Dec 2008 17:13:59 -0000
*************** extern FuncExpr *makeFuncExpr(Oid funcid
*** 67,72 ****
--- 67,74 ----
extern DefElem *makeDefElem(char *name, Node *arg);
+ extern TDefElem *makeTDefElem(char *name, Node *arg, bool toast);
+
extern OptionDefElem *makeOptionDefElem(int op, DefElem *def);
#endif /* MAKEFUNC_H */
Index: src/include/nodes/nodes.h
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/include/nodes/nodes.h,v
retrieving revision 1.217
diff -c -p -r1.217 nodes.h
*** src/include/nodes/nodes.h 28 Dec 2008 18:54:00 -0000 1.217
--- src/include/nodes/nodes.h 31 Dec 2008 16:51:31 -0000
*************** typedef enum NodeTag
*** 362,367 ****
--- 362,368 ----
T_IndexElem,
T_Constraint,
T_DefElem,
+ T_TDefElem,
T_OptionDefElem,
T_RangeTblEntry,
T_SortGroupClause,
Index: src/include/nodes/parsenodes.h
===================================================================
RCS file: /home/alvherre/Code/cvs/pgsql/src/include/nodes/parsenodes.h,v
retrieving revision 1.386
diff -c -p -r1.386 parsenodes.h
*** src/include/nodes/parsenodes.h 31 Dec 2008 00:08:38 -0000 1.386
--- src/include/nodes/parsenodes.h 31 Dec 2008 16:58:07 -0000
*************** typedef struct DefElem
*** 521,526 ****
--- 521,538 ----
} DefElem;
/*
+ * TDefElem -
+ * As DefElem, with a flag to distinguish whether it applies to TOAST
+ */
+ typedef struct TDefElem
+ {
+ NodeTag type;
+ char *defname;
+ Node *arg;
+ bool toast;
+ } TDefElem;
+
+ /*
* Option definition. Used in options definition lists, with optional alter
* operation.
*/
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers