Skip to content

Commit 1bbd608

Browse files
committed
Split handling of reloptions for partitioned tables
Partitioned tables do not have relation options yet, but, similarly to what's done for views which have their own parsing table, it could make sense to introduce new parameters for some of the existing default ones like fillfactor, autovacuum, etc. Splitting things has the advantage to make the information stored in rd_options include only the necessary information, reducing the amount of memory used for a relcache entry with partitioned tables if new reloptions are introduced at this level. Author: Nikolay Shaplov Reviewed-by: Amit Langote, Michael Paquier Discussion: https://postgr.es/m/1627387.Qykg9O6zpu@x200m
1 parent 80ef34f commit 1bbd608

File tree

3 files changed

+33
-9
lines changed

3 files changed

+33
-9
lines changed

src/backend/access/common/reloptions.c

+18-4
Original file line numberDiff line numberDiff line change
@@ -1099,9 +1099,11 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc,
10991099
case RELKIND_RELATION:
11001100
case RELKIND_TOASTVALUE:
11011101
case RELKIND_MATVIEW:
1102-
case RELKIND_PARTITIONED_TABLE:
11031102
options = heap_reloptions(classForm->relkind, datum, false);
11041103
break;
1104+
case RELKIND_PARTITIONED_TABLE:
1105+
options = partitioned_table_reloptions(datum, false);
1106+
break;
11051107
case RELKIND_VIEW:
11061108
options = view_reloptions(datum, false);
11071109
break;
@@ -1571,6 +1573,21 @@ build_reloptions(Datum reloptions, bool validate,
15711573
return rdopts;
15721574
}
15731575

1576+
/*
1577+
* Option parser for partitioned tables
1578+
*/
1579+
bytea *
1580+
partitioned_table_reloptions(Datum reloptions, bool validate)
1581+
{
1582+
/*
1583+
* There are no options for partitioned tables yet, but this is able to do
1584+
* some validation.
1585+
*/
1586+
return (bytea *) build_reloptions(reloptions, validate,
1587+
RELOPT_KIND_PARTITIONED,
1588+
0, NULL, 0);
1589+
}
1590+
15741591
/*
15751592
* Option parser for views
15761593
*/
@@ -1614,9 +1631,6 @@ heap_reloptions(char relkind, Datum reloptions, bool validate)
16141631
case RELKIND_RELATION:
16151632
case RELKIND_MATVIEW:
16161633
return default_reloptions(reloptions, validate, RELOPT_KIND_HEAP);
1617-
case RELKIND_PARTITIONED_TABLE:
1618-
return default_reloptions(reloptions, validate,
1619-
RELOPT_KIND_PARTITIONED);
16201634
default:
16211635
/* other relkinds are not supported */
16221636
return NULL;

src/backend/commands/tablecmds.c

+14-5
Original file line numberDiff line numberDiff line change
@@ -719,10 +719,17 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,
719719
reloptions = transformRelOptions((Datum) 0, stmt->options, NULL, validnsps,
720720
true, false);
721721

722-
if (relkind == RELKIND_VIEW)
723-
(void) view_reloptions(reloptions, true);
724-
else
725-
(void) heap_reloptions(relkind, reloptions, true);
722+
switch (relkind)
723+
{
724+
case RELKIND_VIEW:
725+
(void) view_reloptions(reloptions, true);
726+
break;
727+
case RELKIND_PARTITIONED_TABLE:
728+
(void) partitioned_table_reloptions(reloptions, true);
729+
break;
730+
default:
731+
(void) heap_reloptions(relkind, reloptions, true);
732+
}
726733

727734
if (stmt->ofTypename)
728735
{
@@ -12187,9 +12194,11 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,
1218712194
case RELKIND_RELATION:
1218812195
case RELKIND_TOASTVALUE:
1218912196
case RELKIND_MATVIEW:
12190-
case RELKIND_PARTITIONED_TABLE:
1219112197
(void) heap_reloptions(rel->rd_rel->relkind, newOptions, true);
1219212198
break;
12199+
case RELKIND_PARTITIONED_TABLE:
12200+
(void) partitioned_table_reloptions(newOptions, true);
12201+
break;
1219312202
case RELKIND_VIEW:
1219412203
(void) view_reloptions(newOptions, true);
1219512204
break;

src/include/access/reloptions.h

+1
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ extern bytea *default_reloptions(Datum reloptions, bool validate,
306306
relopt_kind kind);
307307
extern bytea *heap_reloptions(char relkind, Datum reloptions, bool validate);
308308
extern bytea *view_reloptions(Datum reloptions, bool validate);
309+
extern bytea *partitioned_table_reloptions(Datum reloptions, bool validate);
309310
extern bytea *index_reloptions(amoptions_function amoptions, Datum reloptions,
310311
bool validate);
311312
extern bytea *attribute_reloptions(Datum reloptions, bool validate);

0 commit comments

Comments
 (0)