Index: genfile.c =================================================================== RCS file: /projects/pgadmin-tools/support/genfile.c,v retrieving revision 1.2 retrieving revision 1.3 diff -Lsupport/genfile.c -Lsupport/genfile.c -u -w -r1.2 -r1.3 --- support/genfile.c +++ support/genfile.c @@ -193,7 +193,7 @@ pos = PG_GETARG_INT64(1); size = PG_GETARG_INT64(2); - f = fopen(filename, "r"); + f = fopen(filename, "rb"); if (!f) { ereport(ERROR, @@ -245,10 +245,10 @@ (ERRCODE_DUPLICATE_FILE, errmsg("file %s exists", filename))); - f = fopen(filename, "w"); + f = fopen(filename, "wb"); } else - f = fopen(filename, "a"); + f = fopen(filename, "ab"); if (!f) { Index: misc.c =================================================================== RCS file: /projects/pgadmin-tools/support/misc.c,v retrieving revision 1.2 retrieving revision 1.3 diff -Lsupport/misc.c -Lsupport/misc.c -u -w -r1.2 -r1.3 --- support/misc.c +++ support/misc.c @@ -153,25 +153,24 @@ /* * format as created in logfile_getname(): - * prefix_YYYY-MM-DD_HHMMSS_PPPPP.log + * prefix_PPPPP_YYYY-MM-DD_HHMMSS.log * prefixLen ^ - * prefixLen+17 ^ + * prefixLen+5 ^ * prefixLen+23 ^ */ - if (strlen(de->d_name) != prefixLen + 27 || memcmp(de->d_name, Log_filename_prefix, prefixLen) - || de->d_name[prefixLen + 17] != '_' + || de->d_name[prefixLen + 5] != '_' || strcmp(de->d_name + prefixLen + 23, ".log")) continue; values[2] = palloc(strlen(fctx->location) + strlen(de->d_name) + 2); sprintf(values[2], "%s/%s", fctx->location, de->d_name); - values[0] = de->d_name + prefixLen; /* timestamp */ + values[0] = de->d_name + prefixLen+6; /* timestamp */ values[0][17] = 0; - values[1] = de->d_name + prefixLen + 18; /* pid */ + values[1] = de->d_name + prefixLen; /* pid */ values[1][5] = 0; /* check if pid is purely numeric as expected */ @@ -188,7 +187,6 @@ /* Seems the format fits the expected format; feed it into the tuple */ - tuple = BuildTupleFromCStrings(funcctx->attinmeta, values); SRF_RETURN_NEXT(funcctx, HeapTupleGetDatum(tuple));