Add column 'segment' to pgficcore()
authorCédric Villemain <cedric@2ndquadrant.fr>
Wed, 27 Jul 2011 22:04:20 +0000 (00:04 +0200)
committerCédric Villemain <cedric@2ndquadrant.fr>
Wed, 27 Jul 2011 22:05:55 +0000 (00:05 +0200)
This is easier to manage the restore after.

pgfincore.c
sql/pgfincore.sql

index ed9f76874a4cfbd50e654d05c5d53da2e4bd104b..7164fc1f4c4eeed535144fb7d90334319fae591a 100644 (file)
@@ -45,7 +45,7 @@ PG_MODULE_MAGIC;
 #define PGSYSCONF_COLS                 3
 #define PGFADVISE_COLS                 4
 #define PGFADVISE_LOADER_COLS  5
-#define PGFINCORE_COLS                 7
+#define PGFINCORE_COLS                 8
 
 #define PGF_WILLNEED   10
 #define PGF_DONTNEED   20
@@ -929,34 +929,36 @@ pgfincore(PG_FUNCTION_ARGS)
                /* initialize nulls array to build the tuple */
                memset(nulls, 0, sizeof(nulls));
 
-               /* prepare the number of the next segment */
-               fctx->segcount++;
-
                /* Filename */
                values[0] = CStringGetTextDatum(filename);
+               /* Segment Number */
+               values[1] = Int32GetDatum(fctx->segcount);
                /* os page size */
-               values[1] = Int64GetDatum(pgfncr->pageSize);
+               values[2] = Int64GetDatum(pgfncr->pageSize);
                /* number of pages used by segment */
-               values[2] = Int64GetDatum(pgfncr->rel_os_pages);
+               values[3] = Int64GetDatum(pgfncr->rel_os_pages);
                /* number of pages in OS cache */
-               values[3] = Int64GetDatum(pgfncr->pages_mem);
+               values[4] = Int64GetDatum(pgfncr->pages_mem);
                /* number of group of contigous page in os cache */
-               values[4] = Int64GetDatum(pgfncr->group_mem);
+               values[5] = Int64GetDatum(pgfncr->group_mem);
                /* free page cache */
-               values[5] = Int64GetDatum(pgfncr->pagesFree);
+               values[6] = Int64GetDatum(pgfncr->pagesFree);
                /* the map of the file with bit set for in os cache page */
                if (fctx->getvector && pgfncr->rel_os_pages)
                {
-                       values[6] = VarBitPGetDatum(pgfncr->databit);
+                       values[7] = VarBitPGetDatum(pgfncr->databit);
                }
                else
                {
-                       nulls[6]  = true;
-                       values[6] = (Datum) NULL;
+                       nulls[7]  = true;
+                       values[7] = (Datum) NULL;
                }
                /* Build the result tuple. */
                tuple = heap_form_tuple(fctx->tupd, values, nulls);
 
+        /* prepare the number of the next segment */
+        fctx->segcount++;
+
                /* Ok, return results, and go for next call */
                SRF_RETURN_NEXT(funcctx, HeapTupleGetDatum(tuple));
        }
index 5d373ff35bf212b9d9ea54a0b0e67ce7a011372e..06116b38146c02664f48180a3f7833b1f917b18d 100644 (file)
@@ -116,6 +116,7 @@ LANGUAGE SQL;
 CREATE OR REPLACE FUNCTION
 pgfincore(IN regclass, IN text, IN bool,
                  OUT relpath text,
+                 OUT segment int,
                  OUT os_page_size bigint,
                  OUT rel_os_pages bigint,
                  OUT pages_mem bigint,
@@ -129,6 +130,7 @@ LANGUAGE C;
 CREATE OR REPLACE FUNCTION
 pgfincore(IN regclass, IN bool,
                  OUT relpath text,
+                 OUT segment int,
                  OUT os_page_size bigint,
                  OUT rel_os_pages bigint,
                  OUT pages_mem bigint,
@@ -142,6 +144,7 @@ LANGUAGE SQL;
 CREATE OR REPLACE FUNCTION
 pgfincore(IN regclass,
                  OUT relpath text,
+                 OUT segment int,
                  OUT os_page_size bigint,
                  OUT rel_os_pages bigint,
                  OUT pages_mem bigint,