]> granicus.if.org Git - postgresql/commitdiff
Avoid theoretical infinite loop loading relcache partition key.
authorRobert Haas <rhaas@postgresql.org>
Wed, 10 May 2017 03:51:54 +0000 (23:51 -0400)
committerRobert Haas <rhaas@postgresql.org>
Wed, 10 May 2017 03:53:35 +0000 (23:53 -0400)
Amit Langote, per report from 甄明洋

Discussion: http://postgr.es/m/57bd1e1.1886.15bd7b79cee.Coremail.18612389267@yeah.net

src/backend/utils/cache/relcache.c

index 30789c1edc5ed936d37251591a5f6b56f0bec893..c3721d9e4310f9f871062ab74cafd0e9ef1264f9 100644 (file)
@@ -3858,13 +3858,20 @@ RelationCacheInitializePhase3(void)
                }
 
                /*
-                * Reload partition key and descriptor for a partitioned table.
+                * Reload the partition key and descriptor for a partitioned table.
                 */
-               if (relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
+               if (relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE &&
+                       relation->rd_partkey == NULL)
                {
                        RelationBuildPartitionKey(relation);
                        Assert(relation->rd_partkey != NULL);
 
+                       restart = true;
+               }
+
+               if (relation->rd_rel->relkind == RELKIND_PARTITIONED_TABLE &&
+                       relation->rd_partdesc == NULL)
+               {
                        RelationBuildPartitionDesc(relation);
                        Assert(relation->rd_partdesc != NULL);