Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitc94e694

Browse files
committed
Don't allocate storage for partitioned tables.
Also, don't allow setting reloptions on them, since that would have noeffect given the lack of storage. The patch does this by introducinga new reloption kind for which there are currently no reloptions -- wemight have some in the future -- so it adjusts parseRelOptions tohandle that case correctly.Bumped catversion. System catalogs that contained reloptions forpartitioned tables are no longer valid; plus, there are now fewerphysical files on disk, which is not technically a catalog change butstill a good reason to re-initdb.Amit Langote, reviewed by Maksim Milyutin and Kyotaro Horiguchi andrevised a bit by me.Discussion:http://postgr.es/m/20170331.173326.212311140.horiguchi.kyotaro@lab.ntt.co.jp
1 parentf49bcd4 commitc94e694

File tree

5 files changed

+32
-25
lines changed

5 files changed

+32
-25
lines changed

‎doc/src/sgml/ref/create_table.sgml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,6 +1038,8 @@ CREATE [ [ GLOBAL | LOCAL ] { TEMPORARY | TEMP } | UNLOGGED ] TABLE [ IF NOT EXI
10381038
If a table parameter value is set and the
10391039
equivalent <literal>toast.</literal> parameter is not, the TOAST table
10401040
will use the table's parameter value.
1041+
Specifying these parameters for partitioned tables is not supported,
1042+
but you may specify them for individual leaf partitions.
10411043
</para>
10421044

10431045
<variablelist>

‎src/backend/access/common/reloptions.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1000,7 +1000,8 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc,
10001000
* array; this is so that the caller can easily locate the default values.
10011001
*
10021002
* If there are no options of the given kind, numrelopts is set to 0 and NULL
1003-
* is returned.
1003+
* is returned (unless options are illegally supplied despite none being
1004+
* defined, in which case an error occurs).
10041005
*
10051006
* Note: values of type int, bool and real are allocated as part of the
10061007
* returned array. Values of type string are allocated separately and must
@@ -1010,7 +1011,7 @@ relopt_value *
10101011
parseRelOptions(Datumoptions,boolvalidate,relopt_kindkind,
10111012
int*numrelopts)
10121013
{
1013-
relopt_value*reloptions;
1014+
relopt_value*reloptions=NULL;
10141015
intnumoptions=0;
10151016
inti;
10161017
intj;
@@ -1024,21 +1025,18 @@ parseRelOptions(Datum options, bool validate, relopt_kind kind,
10241025
if (relOpts[i]->kinds&kind)
10251026
numoptions++;
10261027

1027-
if (numoptions==0)
1028+
if (numoptions>0)
10281029
{
1029-
*numrelopts=0;
1030-
returnNULL;
1031-
}
1030+
reloptions=palloc(numoptions*sizeof(relopt_value));
10321031

1033-
reloptions=palloc(numoptions*sizeof(relopt_value));
1034-
1035-
for (i=0,j=0;relOpts[i];i++)
1036-
{
1037-
if (relOpts[i]->kinds&kind)
1032+
for (i=0,j=0;relOpts[i];i++)
10381033
{
1039-
reloptions[j].gen=relOpts[i];
1040-
reloptions[j].isset= false;
1041-
j++;
1034+
if (relOpts[i]->kinds&kind)
1035+
{
1036+
reloptions[j].gen=relOpts[i];
1037+
reloptions[j].isset= false;
1038+
j++;
1039+
}
10421040
}
10431041
}
10441042

@@ -1418,8 +1416,10 @@ heap_reloptions(char relkind, Datum reloptions, bool validate)
14181416
return (bytea*)rdopts;
14191417
caseRELKIND_RELATION:
14201418
caseRELKIND_MATVIEW:
1421-
caseRELKIND_PARTITIONED_TABLE:
14221419
returndefault_reloptions(reloptions,validate,RELOPT_KIND_HEAP);
1420+
caseRELKIND_PARTITIONED_TABLE:
1421+
returndefault_reloptions(reloptions,validate,
1422+
RELOPT_KIND_PARTITIONED);
14231423
default:
14241424
/* other relkinds are not supported */
14251425
returnNULL;

‎src/backend/catalog/heap.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,7 @@ heap_create(const char *relname,
293293
caseRELKIND_VIEW:
294294
caseRELKIND_COMPOSITE_TYPE:
295295
caseRELKIND_FOREIGN_TABLE:
296+
caseRELKIND_PARTITIONED_TABLE:
296297
create_storage= false;
297298

298299
/*
@@ -1347,14 +1348,13 @@ heap_create_with_catalog(const char *relname,
13471348
if (oncommit!=ONCOMMIT_NOOP)
13481349
register_on_commit_action(relid,oncommit);
13491350

1350-
if (relpersistence==RELPERSISTENCE_UNLOGGED)
1351-
{
1352-
Assert(relkind==RELKIND_RELATION||relkind==RELKIND_MATVIEW||
1353-
relkind==RELKIND_TOASTVALUE||
1354-
relkind==RELKIND_PARTITIONED_TABLE);
1355-
1351+
/*
1352+
* Unlogged objects need an init fork, except for partitioned tables which
1353+
* have no storage at all.
1354+
*/
1355+
if (relpersistence==RELPERSISTENCE_UNLOGGED&&
1356+
relkind!=RELKIND_PARTITIONED_TABLE)
13561357
heap_create_init_fork(new_rel_desc);
1357-
}
13581358

13591359
/*
13601360
* ok, the relation has been cataloged, so close our relations and return
@@ -1378,6 +1378,9 @@ heap_create_with_catalog(const char *relname,
13781378
void
13791379
heap_create_init_fork(Relationrel)
13801380
{
1381+
Assert(rel->rd_rel->relkind==RELKIND_RELATION||
1382+
rel->rd_rel->relkind==RELKIND_MATVIEW||
1383+
rel->rd_rel->relkind==RELKIND_TOASTVALUE);
13811384
RelationOpenSmgr(rel);
13821385
smgrcreate(rel->rd_smgr,INIT_FORKNUM, false);
13831386
log_smgrcreate(&rel->rd_smgr->smgr_rnode.node,INIT_FORKNUM);
@@ -1824,7 +1827,8 @@ heap_drop_with_catalog(Oid relid)
18241827
*/
18251828
if (rel->rd_rel->relkind!=RELKIND_VIEW&&
18261829
rel->rd_rel->relkind!=RELKIND_COMPOSITE_TYPE&&
1827-
rel->rd_rel->relkind!=RELKIND_FOREIGN_TABLE)
1830+
rel->rd_rel->relkind!=RELKIND_FOREIGN_TABLE&&
1831+
rel->rd_rel->relkind!=RELKIND_PARTITIONED_TABLE)
18281832
{
18291833
RelationDropStorage(rel);
18301834
}

‎src/include/access/reloptions.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,9 @@ typedef enum relopt_kind
4848
RELOPT_KIND_SPGIST= (1 <<8),
4949
RELOPT_KIND_VIEW= (1 <<9),
5050
RELOPT_KIND_BRIN= (1 <<10),
51+
RELOPT_KIND_PARTITIONED= (1 <<11),
5152
/* if you add a new kind, make sure you update "last_default" too */
52-
RELOPT_KIND_LAST_DEFAULT=RELOPT_KIND_BRIN,
53+
RELOPT_KIND_LAST_DEFAULT=RELOPT_KIND_PARTITIONED,
5354
/* some compilers treat enums as signed ints, so we can't use 1 << 31 */
5455
RELOPT_KIND_MAX= (1 <<30)
5556
}relopt_kind;

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/*yyyymmddN */
56-
#defineCATALOG_VERSION_NO201703292
56+
#defineCATALOG_VERSION_NO201703311
5757

5858
#endif

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp