remove var irable WriteStat to action, and do the PG_GETARG for action early
authorCédric Villemain <cedric.villemain.debian@gmail.com>
Fri, 29 Jan 2010 23:30:11 +0000 (00:30 +0100)
committerCédric Villemain <cedric.villemain.debian@gmail.com>
Fri, 29 Jan 2010 23:30:11 +0000 (00:30 +0100)
pgfincore.c

index bf4e7398468a8dc789564787f31f2500307fc60a..4a0a480ed1349622e0a5718164e6d00f3da69631 100644 (file)
@@ -48,7 +48,7 @@ typedef struct
 
 Datum pgsysconf(PG_FUNCTION_ARGS);
 Datum pgfincore(PG_FUNCTION_ARGS);
-static Datum pgmincore_file(char *filename, int writeStat, FunctionCallInfo fcinfo);
+static Datum pgmincore_file(char *filename, int action, FunctionCallInfo fcinfo);
 static Datum pgfadvise_file(char *filename, int action, FunctionCallInfo fcinfo);
 static int pgfadv_snapshot(char *filename, int fd, int action);
 
@@ -104,6 +104,7 @@ pgfincore(PG_FUNCTION_ARGS)
        MemoryContext oldcontext;
        Oid                       relOid    = PG_GETARG_OID(0);
        text              *forkName = PG_GETARG_TEXT_P(1);
+       int                       action        = PG_GETARG_INT32(2);
 
        /* create a function context for cross-call persistence */
        funcctx = SRF_FIRSTCALL_INIT();
@@ -135,7 +136,7 @@ pgfincore(PG_FUNCTION_ARGS)
                                                                 forkname_to_number( text_to_cstring(forkName) ));
 
        /* Here we keep track of current action in all calls */
-       fctx->action = PG_GETARG_INT32(2);
+       fctx->action = action;
 
        /* segcount is used to get the next segment of the current relation */
        fctx->segcount = 0;
@@ -209,7 +210,7 @@ pgfincore(PG_FUNCTION_ARGS)
  * pgmincore_file handle the mmaping, mincore process (and access file, etc.)
  */
 static Datum
-pgmincore_file(char *filename, int writeStat, FunctionCallInfo fcinfo)
+pgmincore_file(char *filename, int action, FunctionCallInfo fcinfo)
 {
   HeapTuple    tuple;
   TupleDesc tupdesc;
@@ -324,7 +325,7 @@ pgmincore_file(char *filename, int writeStat, FunctionCallInfo fcinfo)
        * in the PGDATA, suffix : _mincore
        * FIXME use some postgres internal for that ?
        */
-       if (writeStat == 11)
+       if (action == 11)
        {
                char        path[MAXPGPATH];
            FILE       *file;