]> granicus.if.org Git - postgresql/blobdiff - src/backend/access/nbtree/nbtutils.c
Report progress of CREATE INDEX operations
[postgresql] / src / backend / access / nbtree / nbtutils.c
index 140ac9202659398924239308082ba771f60afde9..7e409d616fe401fa3843d2931b6e4eca9ab97099 100644 (file)
@@ -20,6 +20,7 @@
 #include "access/nbtree.h"
 #include "access/reloptions.h"
 #include "access/relscan.h"
+#include "commands/progress.h"
 #include "miscadmin.h"
 #include "utils/array.h"
 #include "utils/datum.h"
@@ -2051,6 +2052,29 @@ btproperty(Oid index_oid, int attno,
        }
 }
 
+/*
+ *     btbuildphasename() -- Return name of index build phase.
+ */
+char *
+btbuildphasename(int64 phasenum)
+{
+       switch (phasenum)
+       {
+               case PROGRESS_CREATEIDX_SUBPHASE_INITIALIZE:
+                       return "initializing";
+               case PROGRESS_BTREE_PHASE_INDEXBUILD_TABLESCAN:
+                       return "scanning table";
+               case PROGRESS_BTREE_PHASE_PERFORMSORT_1:
+                       return "sorting live tuples";
+               case PROGRESS_BTREE_PHASE_PERFORMSORT_2:
+                       return "sorting dead tuples";
+               case PROGRESS_BTREE_PHASE_LEAF_LOAD:
+                       return "loading tuples in tree";
+               default:
+                       return NULL;
+       }
+}
+
 /*
  *     _bt_truncate() -- create tuple without unneeded suffix attributes.
  *