8000 Split handling of reloptions for partitioned tables · postgres/postgres@1bbd608 · GitHub
[go: up one dir, main page]

Skip to content
< 10000 script type="application/json" data-target="react-app.embeddedData">{"payload":{"commit":{"oid":"1bbd608fdae7af314d8e2229e369a45a3da83cd8","url":"/postgres/postgres/commit/1bbd608fdae7af314d8e2229e369a45a3da83cd8","authoredDate":"2019-11-14T12:34:28.000+09:00","committedDate":"2019-11-14T12:34:28.000+09:00","shortMessage":null,"shortMessageMarkdown":"\u003cdiv\u003eSplit handling of reloptions for partitioned tables\u003c/div\u003e","shortMessageMarkdownLink":null,"bodyMessageHtml":"Partitioned tables do not have relation options yet, but, similarly to\nwhat's done for views which have their own parsing table, it could make\nsense to introduce new parameters for some of the existing default ones\nlike fillfactor, autovacuum, etc. Splitting things has the advantage to\nmake the information stored in rd_options include only the necessary\ninformation, reducing the amount of memory used for a relcache entry\nwith partitioned tables if new reloptions are introduced at this level.\n\nAuthor: Nikolay Shaplov\nReviewed-by: Amit Langote, Michael Paquier\nDiscussion: \u003ca href=\"https://postgr.es/m/1627387.Qykg9O6zpu@x200m\" rel=\"nofollow\"\u003ehttps://postgr.es/m/1627387.Qykg9O6zpu@x200m\u003c/a\u003e","authors":[{"login":"michaelpq","displayName":"Michael Paquier","avatarUrl":"https://avatars.githubusercontent.com/u/985332?v=4","path":"/michaelpq","isGitHub":false}],"committerAttribution":false,"committer":{"login":"michaelpq","displayName":"Michael Paquier","avatarUrl":"https://avatars.githubusercontent.com/u/985332?v=4","path":"/michaelpq","isGitHub":false},"parents":["80ef34fc7075b37fc23f4ab714a5ce60f82400de"],"globalRelayId":"MDY6Q29tbWl0OTI3NDQyOjFiYmQ2MDhmZGFlN2FmMzE0ZDhlMjIyOWUzNjlhNDVhM2RhODNjZDg=","sha1":"80ef34fc7075b37fc23f4ab714a5ce60f82400de","sha2":"1bbd608fdae7af314d8e2229e369a45a3da83cd8"},"currentUser":null,"repo":{"id":927442,"defaultBranch":"master","name":"postgres","ownerLogin":"postgres","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2010-09-21T11:35:45.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/177543?v=4","public":true,"private":false,"isOrgOwned":true},"diffEntryData":[{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":1098,"text":"@@ -1099,9 +1099,11 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc,","html":"@@ -1099,9 +1099,11 @@ extractRelOptions(HeapTuple tuple, TupleDesc tupdesc,","displayNoNewLineWarning":false,"position":0,"left":1098,"right":1098},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1099,"text":" \t\tcase RELKIND_RELATION:","html":" \t\t\u003cspan class=pl-k\u003ecase\u003c/span\u003e \u003cspan class=pl-c1\u003eRELKIND_RELATION\u003c/span\u003e:","displayNoNewLineWarning":false,"position":1,"left":1099,"right":1099},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1100,"text":" \t\tcase RELKIND_TOASTVALUE:","html":" \t\t\u003cspan class=pl-k\u003ecase\u003c/span\u003e \u003cspan class=pl-c1\u003eRELKIND_TOASTVALUE\u003c/span\u003e:","displayNoNewLineWarning":false,"position":2,"left":1100,"right":1100},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1101,"text":" \t\tcase RELKIND_MATVIEW:","html":" \t\t\u003cspan class=pl-k\u003ecase\u003c/span\u003e \u003cspan class=pl-c1\u003eRELKIND_MATVIEW\u003c/span\u003e:","displayNoNewLineWarning":false,"position":3,"left":1101,"right":1101},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1102,"text":"-\t\tcase RELKIND_PARTITIONED_TABLE:","html":"-\t\t\u003cspan class=pl-k\u003ecase\u003c/span\u003e \u003cspan class=pl-c1\u003eRELKIND_PARTITIONED_TABLE\u003c/span\u003e:","displayNoNewLineWarning":false,"position":4,"left":1102,"right":1101},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1102,"text":" \t\t\toptions = heap_reloptions(classForm-\u003erelkind, datum, false);","html":" \t\t\t\u003cspan class=pl-s1\u003eoptions\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003eheap_reloptions\u003c/span\u003e(\u003cspan class=pl-s1\u003eclassForm\u003c/span\u003e\u003cspan class=pl-c1\u003e-\u0026gt;\u003c/span\u003e\u003cspan class=pl-c1\u003erelkind\u003c/span\u003e, \u003cspan class=pl-s1\u003edatum\u003c/span\u003e, false);","displayNoNewLineWarning":false,"position":5,"left":1103,"right":1102},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1103,"text":" \t\t\tbreak;","html":" \t\t\t\u003cspan class=pl-k\u003ebreak\u003c/span\u003e;","displayNoNewLineWarning":false,"position":6,"left":1104,"right":1103},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1104,"text":"+\t\tcase RELKIND_PARTITIONED_TABLE:","html":"+\t\t\u003cspan class=pl-k\u003ecase\u003c/span\u003e \u003cspan class=pl-c1\u003eRELKIND_PARTITIONED_TABLE\u003c/span\u003e:","displayNoNewLineWarning":false,"position":7,"left":1104,"right":1104},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1105,"text":"+\t\t\toptions = partitioned_table_reloptions(datum, false);","html":"+\t\t\t\u003cspan class=pl-s1\u003eoptions\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003epartitioned_table_reloptions\u003c/span\u003e(\u003cspan class=pl-s1\u003edatum\u003c/span\u003e, false);","displayNoNewLineWarning":false,"position":8,"left":1104,"right":1105},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1106,"text":"+\t\t\tbreak;","html":"+\t\t\t\u003cspan class=pl-k\u003ebreak\u003c/span\u003e;","displayNoNewLineWarning":false,"position":9,"left":1104,"right":1106},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1107,"text":" \t\tcase RELKIND_VIEW:","html":" \t\t\u003cspan class=pl-k\u003ecase\u003c/span\u003e \u003cspan class=pl-c1\u003eRELKIND_VIEW\u003c/span\u003e:","displayNoNewLineWarning":false,"position":10,"left":1105,"right":1107},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1108,"text":" \t\t\toptions = view_reloptions(datum, false);","html":" \t\t\t\u003cspan class=pl-s1\u003eoptions\u003c/span\u003e \u003cspan class=pl-c1\u003e=\u003c/span\u003e \u003cspan class=pl-en\u003eview_reloptions\u003c/span\u003e(\u003cspan class=pl-s1\u003edatum\u003c/span\u003e, false);","displayNoNewLineWarning":false,"position":11,"left":1106,"right":1108},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1109,"text":" \t\t\tbreak;","html":" \t\t\t\u003cspan class=pl-k\u003ebreak\u003c/span\u003e;","displayNoNewLineWarning":false,"position":12,"left":1107,"right":1109},{"stylingDirective":null,"type":"HUNK","blobLineNumber":1572,"text":"@@ -1571,6 +1573,21 @@ build_reloptions(Datum reloptions, bool validate,","html":"@@ -1571,6 +1573,21 @@ build_reloptions(Datum reloptions, bool validate,","displayNoNewLineWarning":false,"position":13,"left":1570,"right":1572},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1573,"text":" \treturn rdopts;","html":" \t\u003cspan class=pl-k\u003ereturn\u003c/span\u003e \u003cspan class=pl-s1\u003erdopts\u003c/span\u003e;","displayNoNewLineWarning":false,"position":14,"left":1571,"right":1573},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1574,"text":" }","html":" }","displayNoNewLineWarning":false,"position":15,"left":1572,"right":1574},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1575,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":16,"left":1573,"right":1575},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1576,"text":"+/*","html":"+\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":17,"left":1573,"right":1576},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1577,"text":"+ * Option parser for partitioned tables","html":"+\u003cspan class=pl-c\u003e * Option parser for partitioned tables\u003c/span\u003e","displayNoNewLineWarning":false,"position":18,"left":1573,"right":1577},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1578,"text":"+ */","html":"+\u003cspan class=pl-c\u003e */\u003c/span\u003e","displayNoNewLineWarning":false,"position":19,"left":1573,"right":1578},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1579,"text":"+bytea *","html":"+\u003cspan class=pl-smi\u003ebytea\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e","displayNoNewLineWarning":false,"position":20,"left":1573,"right":1579},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1580,"text":"+partitioned_table_reloptions(Datum reloptions, bool validate)","html":"+\u003cspan class=pl-en\u003epartitioned_table_reloptions\u003c/span\u003e(\u003cspan class=pl-smi\u003eDatum\u003c/span\u003e \u003cspan class=pl-s1\u003ereloptions\u003c/span\u003e, \u003cspan class=pl-smi\u003ebool\u003c/span\u003e \u003cspan class=pl-s1\u003evalidate\u003c/span\u003e)","displayNoNewLineWarning":false,"position":21,"left":1573,"right":1580},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1581,"text":"+{","html":"+{","displayNoNewLineWarning":false,"position":22,"left":1573,"right":1581},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1582,"text":"+\t/*","html":"+\t\u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":23,"left":1573,"right":1582},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1583,"text":"+\t * There are no options for partitioned tables yet, but this is able to do","html":"+\u003cspan class=pl-c\u003e\t * There are no options for partitioned tables yet, but this is able to do\u003c/span\u003e","displayNoNewLineWarning":false,"position":24,"left":1573,"right":1583},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1584,"text":"+\t * some validation.","html":"+\u003cspan class=pl-c\u003e\t * some validation.\u003c/span\u003e","displayNoNewLineWarning":false,"position":25,"left":1573,"right":1584},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1585,"text":"+\t */","html":"+\u003cspan class=pl-c\u003e\t */\u003c/span\u003e","displayNoNewLineWarning":false,"position":26,"left":1573,"right":1585},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1586,"text":"+\treturn (bytea *) build_reloptions(reloptions, validate,","html":"+\t\u003cspan class=pl-k\u003ereturn\u003c/span\u003e (\u003cspan class=pl-smi\u003ebytea\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e) \u003cspan class=pl-en\u003ebuild_reloptions\u003c/span\u003e(\u003cspan class=pl-s1\u003ereloptions\u003c/span\u003e, \u003cspan class=pl-s1\u003evalidate\u003c/span\u003e,","displayNoNewLineWarning":false,"position":27,"left":1573,"right":1586},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1587,"text":"+\t\t\t\t\t\t\t\t\t RELOPT_KIND_PARTITIONED,","html":"+\t\t\t\t\t\t\t\t\t \u003cspan class=pl-c1\u003eRELOPT_KIND_PARTITIONED\u003c/span\u003e,","displayNoNewLineWarning":false,"position":28,"left":1573,"right":1587},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1588,"text":"+\t\t\t\t\t\t\t\t\t 0, NULL, 0);","html":"+\t\t\t\t\t\t\t\t\t \u003cspan class=pl-c1\u003e0\u003c/span\u003e, \u003cspan class=pl-c1\u003eNULL\u003c/span\u003e, \u003cspan class=pl-c1\u003e0\u003c/span\u003e);","displayNoNewLineWarning":false,"position":29,"left":1573,"right":1588},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1589,"text":"+}","html":"+}","displayNoNewLineWarning":false,"position":30,"left":1573,"right":1589},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":1590,"text":"+","html":"+","displayNoNewLineWarning":false,"position":31,"left":1573,"right":1590},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1591,"text":" /*","html":" \u003cspan class=pl-c\u003e/*\u003c/span\u003e","displayNoNewLineWarning":false,"position":32,"left":1574,"right":1591},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1592,"text":" * Option parser for views","html":" \u003cspan class=pl-c\u003e * Option parser for views\u003c/span\u003e","displayNoNewLineWarning":false,"position":33,"left":1575,"right":1592},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1593,"text":" */","html":" \u003cspan class=pl-c\u003e */\u003c/span\u003e","displayNoNewLineWarning":false,"position":34,"left":1576,"right":1593},{"stylingDirective":null,"type":"HUNK","blobLineNumber":1630,"text":"@@ -1614,9 +1631,6 @@ heap_reloptions(char relkind, Datum reloptions, bool validate)","html":"@@ -1614,9 +1631,6 @@ heap_reloptions(char relkind, Datum reloptions, bool validate)","displayNoNewLineWarning":false,"position":35,"left":1613,"right":1630},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1631,"text":" \t\tcase RELKIND_RELATION:","html":" \t\t\u003cspan class=pl-k\u003ecase\u003c/span\u003e \u003cspan class=pl-c1\u003eRELKIND_RELATION\u003c/span\u003e:","displayNoNewLineWarning":false,"position":36,"left":1614,"right":1631},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1632,"text":" \t\tcase RELKIND_MATVIEW:","html":" \t\t\u003cspan class=pl-k\u003ecase\u003c/span\u003e \u003cspan class=pl-c1\u003eRELKIND_MATVIEW\u003c/span\u003e:","displayNoNewLineWarning":false,"position":37,"left":1615,"right":1632},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1633,"text":" \t\t\treturn default_reloptions(reloptions, validate, RELOPT_KIND_HEAP);","html":" \t\t\t\u003cspan class=pl-k\u003ereturn\u003c/span\u003e \u003cspan class=pl-en\u003edefault_reloptions\u003c/span\u003e(\u003cspan class=pl-s1\u003ereloptions\u003c/span\u003e, \u003cspan class=pl-s1\u003evalidate\u003c/span\u003e, \u003cspan class=pl-c1\u003eRELOPT_KIND_HEAP\u003c/span\u003e);","displayNoNewLineWarning":false,"position":38,"left":1616,"right":1633},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1617,"text":"-\t\tcase RELKIND_PARTITIONED_TABLE:","html":"-\t\t\u003cspan class=pl-k\u003ecase\u003c/span\u003e \u003cspan class=pl-c1\u003eRELKIND_PARTITIONED_TABLE\u003c/span\u003e:","displayNoNewLineWarning":false,"position":39,"left":1617,"right":1633},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1618,"text":"-\t\t\treturn default_reloptions(reloptions, validate,","html":"-\t\t\t\u003cspan class=pl-k\u003ereturn\u003c/span\u003e \u003cspan class=pl-en\u003edefault_reloptions\u003c/span\u003e(\u003cspan class=pl-s1\u003ereloptions\u003c/span\u003e, \u003cspan class=pl-s1\u003evalidate\u003c/span\u003e,","displayNoNewLineWarning":false,"position":40,"left":1618,"right":1633},{"stylingDirective":null,"type":"DELETION","blobLineNumber":1619,"text":"-\t\t\t\t\t\t\t\t\t RELOPT_KIND_PARTITIONED);","html":"-\t\t\t\t\t\t\t\t\t \u003cspan class=pl-c1\u003eRELOPT_KIND_PARTITIONED\u003c/span\u003e);","displayNoNewLineWarning":false,"position":41,"left":1619,"right":1633},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1634,"text":" \t\tdefault:","html":" \t\t\u003cspan class=pl-k\u003edefault\u003c/span\u003e:","displayNoNewLineWarning":false,"position":42,"left":1620,"right":1634},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1635,"text":" \t\t\t/* other relkinds are not supported */","html":" \t\t\t\u003cspan class=pl-c\u003e/* other relkinds are not supported */\u003c/span\u003e","displayNoNewLineWarning":false,"position":43,"left":1621,"right":1635},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":1636,"text":" \t\t\treturn NULL;","html":" \t\t\t\u003cspan class=pl-k\u003ereturn\u003c/span\u003e \u003cspan class=pl-c1\u003eNULL\u003c/span\u003e;","displayNoNewLineWarning":false,"position":44,"left":1622,"right":1636}],"diffNumber":0,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":1731,"linesChanged":22,"newTreeEntry":{"lineCount":1731,"path":"src/backend/access/common/reloptions.c","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"src/backend/access/common/reloptions.c","mode":100644},"linesAdded":18,"linesDeleted":4,"path":"src/backend/access/common/reloptions.c","pathDigest":"ba65e57ed6af886d159f82e6b0a1bdba7ae08bffbda331964670ba91e0dcae61","status":"MODIFIED","truncatedReason":null,"oldOid":"80ef34fc7075b37fc23f4ab714a5ce60f82400de","newOid":"1bbd608fdae7af314d8e2229e369a45a3da83cd8","copilotChatReference":null,"deletedSha":"80ef34fc7075b37fc23f4ab714a5ce60f82400de","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null},{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":718,"text":"@@ -719,10 +719,17 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,","html":"@@ -719,10 +719,17 @@ DefineRelation(CreateStmt *stmt, char relkind, Oid ownerId,","displayNoNewLineWarning":false,"position":0,"left":718,"right":718},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":719,"text":" \treloptions = transformRelOptions((Datum) 0, stmt-\u003eoptions, NULL, validnsps,","html":" \treloptions = transformRelOptions((Datum) 0, stmt-\u0026gt;options, NULL, validnsps,","displayNoNewLineWarning":false,"position":1,"left":719,"right":719},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":720,"text":" \t\t\t\t\t\t\t\t\t true, false);","html":" \t\t\t\t\t\t\t\t\t true, false);","displayNoNewLineWarning":false,"position":2,"left":720,"right":720},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":721,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":3,"left":721,"right":721},{"stylingDirective":null,"type":"DELETION","blobLineNumber":722,"text":"-\tif (relkind == RELKIND_VIEW)","html":"-\tif (relkind == RELKIND_VIEW)","displayNoNewLineWarning":false,"position":4,"left":722,"right":721},{"stylingDirective":null,"type":"DELETION","blobLineNumber":723,"text":"-\t\t(void) view_reloptions(reloptions, true);","html":"-\t\t(void) view_reloptions(reloptions, true);","displayNoNewLineWarning":false,"position":5,"left":723,"right":721},{"stylingDirective":null,"type":"DELETION","blobLineNumber":724,"text":"-\telse","html":"-\telse","displayNoNewLineWarning":false,"position":6,"left":724,"right":721},{"stylingDirective":null,"type":"DELETION","blobLineNumber":725,"text":"-\t\t(void) heap_reloptions(relkind, reloptions, true);","html":"-\t\t(void) heap_reloptions(relkind, reloptions, true);","displayNoNewLineWarning":false,"position":7,"left":725,"right":721},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":722,"text":"+\tswitch (relkind)","html":"+\tswitch (relkind)","displayNoNewLineWarning":false,"position":8,"left":725,"right":722},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":723,"text":"+\t{","html":"+\t{","displayNoNewLineWarning":false,"position":9,"left":725,"right":723},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":724,"text":"+\t\tcase RELKIND_VIEW:","html":"+\t\tcase RELKIND_VIEW:","displayNoNewLineWarning":false,"position":10,"left":725,"right":724},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":725,"text":"+\t\t\t(void) view_reloptions(reloptions, true);","html":"+\t\t\t(void) view_reloptions(reloptions, true);","displayNoNewLineWarning":false,"position":11,"left":725,"right":725},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":726,"text":"+\t\t\tbreak;","html":"+\t\t\tbreak;","displayNoNewLineWarning":false,"position":12,"left":725,"right":726},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":727,"text":"+\t\tcase RELKIND_PARTITIONED_TABLE:","html":"+\t\tcase RELKIND_PARTITIONED_TABLE:","displayNoNewLineWarning":false,"position":13,"left":725,"right":727},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":728,"text":"+\t\t\t(void) partitioned_table_reloptions(reloptions, true);","html":"+\t\t\t(void) partitioned_table_reloptions(reloptions, true);","displayNoNewLineWarning":false,"position":14,"left":725,"right":728},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":729,"text":"+\t\t\tbreak;","html":"+\t\t\tbreak;","displayNoNewLineWarning":false,"position":15,"left":725,"right":729},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":730,"text":"+\t\tdefault:","html":"+\t\tdefault:","displayNoNewLineWarning":false,"position":16,"left":725,"right":730},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":731,"text":"+\t\t\t(void) heap_reloptions(relkind, reloptions, true);","html":"+\t\t\t(void) heap_reloptions(relkind, reloptions, true);","displayNoNewLineWarning":false,"position":17,"left":725,"right":731},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":732,"text":"+\t}","html":"+\t}","displayNoNewLineWarning":false,"position":18,"left":725,"right":732},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":733,"text":" ","html":"\u003cbr\u003e","displayNoNewLineWarning":false,"position":19,"left":726,"right":733},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":734,"text":" \tif (stmt-\u003eofTypename)","html":" \tif (stmt-\u0026gt;ofTypename)","displayNoNewLineWarning":false,"position":20,"left":727,"right":734},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":735,"text":" \t{","html":" \t{","displayNoNewLineWarning":false,"position":21,"left":728,"right":735},{"stylingDirective":null,"type":"HUNK","blobLineNumber":12193,"text":"@@ -12187,9 +12194,11 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,","html":"@@ -12187,9 +12194,11 @@ ATExecSetRelOptions(Relation rel, List *defList, AlterTableType operation,","displayNoNewLineWarning":false,"position":22,"left":12186,"right":12193},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":12194,"text":" \t\tcase RELKIND_RELATION:","html":" \t\tcase RELKIND_RELATION:","displayNoNewLineWarning":false,"position":23,"left":12187,"right":12194},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":12195,"text":" \t\tcase RELKIND_TOASTVALUE:","html":" \t\tcase RELKIND_TOASTVALUE:","displayNoNewLineWarning":false,"position":24,"left":12188,"right":12195},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":12196,"text":" \t\tcase RELKIND_MATVIEW:","html":" \t\tcase RELKIND_MATVIEW:","displayNoNewLineWarning":false,"position":25,"left":12189,"right":12196},{"stylingDirective":null,"type":"DELETION","blobLineNumber":12190,"text":"-\t\tcase RELKIND_PARTITIONED_TABLE:","html":"-\t\tcase RELKIND_PARTITIONED_TABLE:","displayNoNewLineWarning":false,"position":26,"left":12190,"right":12196},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":12197,"text":" \t\t\t(void) heap_reloptions(rel-\u003erd_rel-\u003erelkind, newOptions, true);","html":" \t\t\t(void) heap_reloptions(rel-\u0026gt;rd_rel-\u0026gt;relkind, newOptions, true);","displayNoNewLineWarning":false,"position":27,"left":12191,"right":12197},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":12198,"text":" \t\t\tbreak;","html":" \t\t\tbreak;","displayNoNewLineWarning":false,"position":28,"left":12192,"right":12198},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":12199,"text":"+\t\tcase RELKIND_PARTITIONED_TABLE:","html":"+\t\tcase RELKIND_PARTITIONED_TABLE:","displayNoNewLineWarning":false,"position":29,"left":12192,"right":12199},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":12200,"text":"+\t\t\t(void) partitioned_table_reloptions(newOptions, true);","html":"+\t\t\t(void) partitioned_table_reloptions(newOptions, true);","displayNoNewLineWarning":false,"position":30,"left":12192,"right":12200},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":12201,"text":"+\t\t\tbreak;","html":"+\t\t\tbreak;","displayNoNewLineWarning":false,"position":31,"left":12192,"right":12201},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":12202,"text":" \t\tcase RELKIND_VIEW:","html":" \t\tcase RELKIND_VIEW:","displayNoNewLineWarning":false,"position":32,"left":12193,"right":12202},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":12203,"text":" \t\t\t(void) view_reloptions(newOptions, true);","html":" \t\t\t(void) view_reloptions(newOptions, true);","displayNoNewLineWarning":false,"position":33,"left":12194,"right":12203},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":12204,"text":" \t\t\tbreak;","html":" \t\t\tbreak;","displayNoNewLineWarning":false,"position":34,"left":12195,"right":12204}],"diffNumber":1,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":16732,"linesChanged":19,"newTreeEntry":{"lineCount":16732,"path":"src/backend/commands/tablecmds.c","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"src/backend/commands/tablecmds.c","mode":100644},"linesAdded":14,"linesDeleted":5,"path":"src/backend/commands/tablecmds.c","pathDigest":"d373fb790605aded212c2e3a0fbe8c015d110077ff46c07d0a6d6647a2d7e928","status":"MODIFIED","truncatedReason":null,"oldOid":"80ef34fc7075b37fc23f4ab714a5ce60f82400de","newOid":"1bbd608fdae7af314d8e2229e369a45a3da83cd8","copilotChatReference":null,"deletedSha":"80ef34fc7075b37fc23f4ab714a5ce60f82400de","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null},{"diffLines":[{"stylingDirective":null,"type":"HUNK","blobLineNumber":305,"text":"@@ -306,6 +306,7 @@ extern bytea *default_reloptions(Datum reloptions, bool validate,","html":"@@ -306,6 +306,7 @@ extern bytea *default_reloptions(Datum reloptions, bool validate,","displayNoNewLineWarning":false,"position":0,"left":305,"right":305},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":306,"text":" \t\t\t\t\t\t\t\t relopt_kind kind);","html":" \t\t\t\t\t\t\t\t \u003cspan class=pl-smi\u003erelopt_kind\u003c/span\u003e \u003cspan class=pl-s1\u003ekind\u003c/span\u003e);","displayNoNewLineWarning":false,"position":1,"left":306,"right":306},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":307,"text":" extern bytea *heap_reloptions(char relkind, Datum reloptions, bool validate);","html":" \u003cspan class=pl-k\u003eextern\u003c/span\u003e \u003cspan class=pl-smi\u003ebytea\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-en\u003eheap_reloptions\u003c/span\u003e(\u003cspan class=pl-smi\u003echar\u003c/span\u003e \u003cspan class=pl-s1\u003erelkind\u003c/span\u003e, \u003cspan class=pl-smi\u003eDatum\u003c/span\u003e \u003cspan class=pl-s1\u003ereloptions\u003c/span\u003e, \u003cspan class=pl-smi\u003ebool\u003c/span\u003e \u003cspan class=pl-s1\u003evalidate\u003c/span\u003e);","displayNoNewLineWarning":false,"position":2,"left":307,"right":307},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":308,"text":" extern bytea *view_reloptions(Datum reloptions, bool validate);","html":" \u003cspan class=pl-k\u003eextern\u003c/span\u003e \u003cspan class=pl-smi\u003ebytea\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-en\u003eview_reloptions\u003c/span\u003e(\u003cspan class=pl-smi\u003eDatum\u003c/span\u003e \u003cspan class=pl-s1\u003ereloptions\u003c/span\u003e, \u003cspan class=pl-smi\u003ebool\u003c/span\u003e \u003cspan class=pl-s1\u003evalidate\u003c/span\u003e);","displayNoNewLineWarning":false,"position":3,"left":308,"right":308},{"stylingDirective":null,"type":"ADDITION","blobLineNumber":309,"text":"+extern bytea *partitioned_table_reloptions(Datum reloptions, bool validate);","html":"+\u003cspan class=pl-k\u003eextern\u003c/span\u003e \u003cspan class=pl-smi\u003ebytea\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-en\u003epartitioned_table_reloptions\u003c/span\u003e(\u003cspan class=pl-smi\u003eDatum\u003c/span\u003e \u003cspan class=pl-s1\u003ereloptions\u003c/span\u003e, \u003cspan class=pl-smi\u003ebool\u003c/span\u003e \u003cspan class=pl-s1\u003evalidate\u003c/span\u003e);","displayNoNewLineWarning":false,"position":4,"left":308,"right":309},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":310,"text":" extern bytea *index_reloptions(amoptions_function amoptions, Datum reloptions,","html":" \u003cspan class=pl-k\u003eextern\u003c/span\u003e \u003cspan class=pl-smi\u003ebytea\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-en\u003eindex_reloptions\u003c/span\u003e(\u003cspan class=pl-smi\u003eamoptions_function\u003c/span\u003e \u003cspan class=pl-s1\u003eamoptions\u003c/span\u003e, \u003cspan class=pl-smi\u003eDatum\u003c/span\u003e \u003cspan class=pl-s1\u003ereloptions\u003c/span\u003e,","displayNoNewLineWarning":false,"position":5,"left":309,"right":310},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":311,"text":" \t\t\t\t\t\t\t bool validate);","html":" \t\t\t\t\t\t\t \u003cspan class=pl-smi\u003ebool\u003c/span\u003e \u003cspan class=pl-s1\u003evalidate\u003c/span\u003e);","displayNoNewLineWarning":false,"position":6,"left":310,"right":311},{"stylingDirective":null,"type":"CONTEXT","blobLineNumber":312,"text":" extern bytea *attribute_reloptions(Datum reloptions, bool validate);","html":" \u003cspan class=pl-k\u003eextern\u003c/span\u003e \u003cspan class=pl-smi\u003ebytea\u003c/span\u003e \u003cspan class=pl-c1\u003e*\u003c/span\u003e\u003cspan class=pl-en\u003eattribute_reloptions\u003c/span\u003e(\u003cspan class=pl-smi\u003eDatum\u003c/span\u003e \u003cspan class=pl-s1\u003ereloptions\u003c/span\u003e, \u003cspan class=pl-smi\u003ebool\u003c/span\u003e \u003cspan class=pl-s1\u003evalidate\u003c/span\u003e);","displayNoNewLineWarning":false,"position":7,"left":311,"right":312}],"diffNumber":2,"diffSize":"0 Bytes","isBinary":false,"isTooBig":false,"collapsed":false,"isSubmodule":false,"lineCount":316,"linesChanged":1,"newTreeEntry":{"lineCount":316,"path":"src/include/access/reloptions.h","mode":100644,"isGenerated":false},"oldTreeEntry":{"lineCount":0,"path":"src/include/access/reloptions.h","mode":100644},"linesAdded":1,"linesDeleted":0,"path":"src/include/access/reloptions.h","pathDigest":"c125141a0290343a3878702b4ddab96eb565d08e24f278d2d115e0284dc53f91","status":"MODIFIED","truncatedReason":null,"oldOid":"80ef34fc7075b37fc23f4ab714a5ce60f82400de","newOid":"1bbd608fdae7af314d8e2229e369a45a3da83cd8","copilotChatReference":null,"deletedSha":"80ef34fc7075b37fc23f4ab714a5ce60f82400de","canToggleRichDiff":false,"defaultToRichDiff":false,"proseDifffHtml":null,"renderInfo":null,"dependencyDiffPath":null,"submodule":null}],"splitViewPreference":"unified","ignoreWhitespace":false,"repoOwnerGlobalRelayId":"MDEyOk9yZ2FuaXphdGlvbjE3NzU0Mw==","commentsPreference":"visible","diffLineSpacingPreference":"relaxed","useMonospaceFont":false,"pasteUrlLinkAsPlainText":false,"userNotices":[],"path":"/postgres/postgres/commit/1bbd608fdae7af314d8e2229e369a45a3da83cd8","fileTreeExpanded":true,"headerInfo":{"additions":33,"deletions":9,"filesChanged":3,"filesChangedString":"3"},"moreDiffsToLoad":false,"asyncDiffLoadInfo":{"startIndex":3,"truncated":false,"byteCount":2965,"lineShownCount":88},"commentInfo":{"canComment":false,"locked":false,"canLock":false,"repoArchived":false},"csrf_tokens":{"/users/diffview?diff=split":{"post":"XxtKaOeo3yWQqcjEPvk1kuXH8GbMmEM5MYoY33xp8AJTL-sWwLhhQ432gR9hqlQtJcDHmDYK6DKC0NOQMzqbaQ"},"/users/diffview?diff=unified":{"post":"pvmTg_dgR82N04xehVJQg0E9Qs6BIJaofza_eJUjb8WqzTL90HD5q5CMxYXaATE8gTp1MHuyPaPMbHQ32nAErg"},"/notifications/thread":{"post":"5Rm4COV62tsZPg1EButnPGia8bNjWzPO2-LT70yUC1SwpNmGkBfQDCkkaHgOi05VhaqrLzU-VYBGNA2Zmtxasw"}}},"title":"Split handling of reloptions for partitioned tables · postgres/postgres@1bbd608","appPayload":{"helpUrl":"https://docs.github.com","findInDiffWorkerPath":"/assets-cdn/worker/find-in-diff-worker-2bfe39677d14.js","enabled_features":{"diff_ux_refresh_beta":false,"diff_inline_comments":true,"diff_ux_refresh_ssr_five":false,"diff_ux_refresh_ssr_ten":false,"react_diff_line_type_character_correction":true}}}

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

Lines changed: 18 additions & 4 deletions
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,
158 10000 8+
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

Lines changed: 14 additions & 5 deletions
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

Lines changed: 1 addition & 0 deletions
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)
0