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

Commit44c5288

Browse files
committed
Change the way pg_dump retrieves partitioning info
This gets rid of the code that issued separate queries to retrieve thepartitioning parent-child relationship, parent partition key, and childpartition bound information. With this patch, the information isretrieved instead using the queries issued from getTables() andgetInherits(), which is both more efficient than the previous approachand doesn't require any new code.Since the partitioning parent-child relationship is now retrieved withthe same old code that handles inheritance, partition attributes receivea proper flagInhAttrs() treatment (that it didn't receive before), whichis needed so that the inherited NOT NULL constraints are not emitted ifwe already emitted it for the parent.Also, fix a bug in pg_dump's --binary-upgrade code, which caused pg_dumpto emit invalid command to attach a partition to its parent.Author: Amit Langote, with some additional changes by me.
1 parent5469e44 commit44c5288

File tree

4 files changed

+153
-252
lines changed

4 files changed

+153
-252
lines changed

‎src/bin/pg_dump/common.c

Lines changed: 0 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,13 @@ static intnumextmembers;
6868

6969
staticvoidflagInhTables(TableInfo*tbinfo,intnumTables,
7070
InhInfo*inhinfo,intnumInherits);
71-
staticvoidflagPartitions(TableInfo*tblinfo,intnumTables,
72-
PartInfo*partinfo,intnumPartitions);
7371
staticvoidflagInhAttrs(DumpOptions*dopt,TableInfo*tblinfo,intnumTables);
7472
staticDumpableObject**buildIndexArray(void*objArray,intnumObjs,
7573
SizeobjSize);
7674
staticintDOCatalogIdCompare(constvoid*p1,constvoid*p2);
7775
staticintExtensionMemberIdCompare(constvoid*p1,constvoid*p2);
7876
staticvoidfindParentsByOid(TableInfo*self,
7977
InhInfo*inhinfo,intnumInherits);
80-
staticvoidfindPartitionParentByOid(TableInfo*self,PartInfo*partinfo,
81-
intnumPartitions);
8278
staticintstrInArray(constchar*pattern,char**arr,intarr_size);
8379

8480

@@ -97,10 +93,8 @@ getSchemaData(Archive *fout, int *numTablesPtr)
9793
NamespaceInfo*nspinfo;
9894
ExtensionInfo*extinfo;
9995
InhInfo*inhinfo;
100-
PartInfo*partinfo;
10196
intnumAggregates;
10297
intnumInherits;
103-
intnumPartitions;
10498
intnumRules;
10599
intnumProcLangs;
106100
intnumCasts;
@@ -237,10 +231,6 @@ getSchemaData(Archive *fout, int *numTablesPtr)
237231
write_msg(NULL,"reading table inheritance information\n");
238232
inhinfo=getInherits(fout,&numInherits);
239233

240-
if (g_verbose)
241-
write_msg(NULL,"reading partition information\n");
242-
partinfo=getPartitions(fout,&numPartitions);
243-
244234
if (g_verbose)
245235
write_msg(NULL,"reading event triggers\n");
246236
getEventTriggers(fout,&numEventTriggers);
@@ -255,11 +245,6 @@ getSchemaData(Archive *fout, int *numTablesPtr)
255245
write_msg(NULL,"finding inheritance relationships\n");
256246
flagInhTables(tblinfo,numTables,inhinfo,numInherits);
257247

258-
/* Link tables to partition parents, mark parents as interesting */
259-
if (g_verbose)
260-
write_msg(NULL,"finding partition relationships\n");
261-
flagPartitions(tblinfo,numTables,partinfo,numPartitions);
262-
263248
if (g_verbose)
264249
write_msg(NULL,"reading column info for interesting tables\n");
265250
getTableAttrs(fout,tblinfo,numTables);
@@ -292,10 +277,6 @@ getSchemaData(Archive *fout, int *numTablesPtr)
292277
write_msg(NULL,"reading policies\n");
293278
getPolicies(fout,tblinfo,numTables);
294279

295-
if (g_verbose)
296-
write_msg(NULL,"reading partition key information for interesting tables\n");
297-
getTablePartitionKeyInfo(fout,tblinfo,numTables);
298-
299280
if (g_verbose)
300281
write_msg(NULL,"reading publications\n");
301282
getPublications(fout);
@@ -354,43 +335,6 @@ flagInhTables(TableInfo *tblinfo, int numTables,
354335
}
355336
}
356337

357-
/* flagPartitions -
358-
* Fill in parent link fields of every target table that is partition,
359-
* and mark parents of partitions as interesting
360-
*
361-
* modifies tblinfo
362-
*/
363-
staticvoid
364-
flagPartitions(TableInfo*tblinfo,intnumTables,
365-
PartInfo*partinfo,intnumPartitions)
366-
{
367-
inti;
368-
369-
for (i=0;i<numTables;i++)
370-
{
371-
/* Some kinds are never partitions */
372-
if (tblinfo[i].relkind==RELKIND_SEQUENCE||
373-
tblinfo[i].relkind==RELKIND_VIEW||
374-
tblinfo[i].relkind==RELKIND_MATVIEW)
375-
continue;
376-
377-
/* Don't bother computing anything for non-target tables, either */
378-
if (!tblinfo[i].dobj.dump)
379-
continue;
380-
381-
/* Find the parent TableInfo and save */
382-
findPartitionParentByOid(&tblinfo[i],partinfo,numPartitions);
383-
384-
/* Mark the parent as interesting for getTableAttrs */
385-
if (tblinfo[i].partitionOf)
386-
{
387-
tblinfo[i].partitionOf->interesting= true;
388-
addObjectDependency(&tblinfo[i].dobj,
389-
tblinfo[i].partitionOf->dobj.dumpId);
390-
}
391-
}
392-
}
393-
394338
/* flagInhAttrs -
395339
* for each dumpable table in tblinfo, flag its inherited attributes
396340
*
@@ -991,40 +935,6 @@ findParentsByOid(TableInfo *self,
991935
self->parents=NULL;
992936
}
993937

994-
/*
995-
* findPartitionParentByOid
996-
* find a partition's parent in tblinfo[]
997-
*/
998-
staticvoid
999-
findPartitionParentByOid(TableInfo*self,PartInfo*partinfo,
1000-
intnumPartitions)
1001-
{
1002-
Oidoid=self->dobj.catId.oid;
1003-
inti;
1004-
1005-
for (i=0;i<numPartitions;i++)
1006-
{
1007-
if (partinfo[i].partrelid==oid)
1008-
{
1009-
TableInfo*parent;
1010-
1011-
parent=findTableByOid(partinfo[i].partparent);
1012-
if (parent==NULL)
1013-
{
1014-
write_msg(NULL,"failed sanity check, parent OID %u of table \"%s\" (OID %u) not found\n",
1015-
partinfo[i].partparent,
1016-
self->dobj.name,
1017-
oid);
1018-
exit_nicely(1);
1019-
}
1020-
self->partitionOf=parent;
1021-
1022-
/* While we're at it, also save the partdef */
1023-
self->partitiondef=partinfo[i].partdef;
1024-
}
1025-
}
1026-
}
1027-
1028938
/*
1029939
* parseOidArray
1030940
* parse a string of numbers delimited by spaces into a character array

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp