Index: admin.sql.in =================================================================== RCS file: /projects/pgadmin-tools/support/admin.sql.in,v retrieving revision 1.3 retrieving revision 1.4 diff -Lsupport/admin.sql.in -Lsupport/admin.sql.in -u -w -r1.3 -r1.4 --- support/admin.sql.in +++ support/admin.sql.in @@ -79,4 +79,4 @@ CREATE VIEW pg_logdir_ls AS SELECT * FROM pg_logdir_ls() AS A - (filetime timestamp, pid int4, filename text); + (filetime timestamp, filename text); Index: misc.c =================================================================== RCS file: /projects/pgadmin-tools/support/misc.c,v retrieving revision 1.6 retrieving revision 1.7 diff -Lsupport/misc.c -Lsupport/misc.c -u -w -r1.6 -r1.7 --- support/misc.c +++ support/misc.c @@ -30,7 +30,7 @@ extern DLLIMPORT char *DataDir; extern DLLIMPORT char *Log_directory; -extern DLLIMPORT char *Log_filename_prefix; +extern DLLIMPORT char *Log_filename; extern DLLIMPORT pid_t PostmasterPid; Datum pg_reload_conf(PG_FUNCTION_ARGS); @@ -98,6 +98,11 @@ (errcode(ERRCODE_INSUFFICIENT_PRIVILEGE), (errmsg("only superuser can list the log directory")))); + if (memcmp(Log_filename, "postgresql-%Y-%m-%d_%H%M%S.log", 30) != 0) + ereport(ERROR, + (errcode(ERRCODE_INVALID_PARAMETER_VALUE), + (errmsg("the log_filename parameter must equal 'postgresql-%%Y-%%m-%%d_%%H%%M%%S.log'")))); + if (SRF_IS_FIRSTCALL()) { MemoryContext oldcontext; @@ -114,12 +119,10 @@ fctx->location = palloc(strlen(DataDir) + strlen(Log_directory) +2); sprintf(fctx->location, "%s/%s", DataDir, Log_directory); } - tupdesc = CreateTemplateTupleDesc(3, false); + tupdesc = CreateTemplateTupleDesc(2, false); TupleDescInitEntry(tupdesc, (AttrNumber) 1, "starttime", TIMESTAMPOID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 2, "pid", - INT4OID, -1, 0); - TupleDescInitEntry(tupdesc, (AttrNumber) 3, "filename", + TupleDescInitEntry(tupdesc, (AttrNumber) 2, "filename", TEXTOID, -1, 0); funcctx->attinmeta = TupleDescGetAttInMetadata(tupdesc); @@ -143,9 +146,8 @@ while ((de = readdir(fctx->dirdesc)) != NULL) { - char *values[3]; + char *values[2]; HeapTuple tuple; - int prefixLen=strlen(Log_filename_prefix); char *field[MAXDATEFIELDS]; char lowstr[MAXDATELEN + 1]; @@ -154,35 +156,23 @@ fsec_t fsec; int tz = 0; struct pg_tm date; - int i; /* - * format as created in logfile_getname(): - * prefix_PPPPP_YYYY-MM-DD_HHMMSS.log - * prefixLen ^ - * prefixLen+5 ^ - * prefixLen+23 ^ + * Default format: + * postgresql-YYYY-MM-DD_HHMMSS.log */ - if (strlen(de->d_name) != prefixLen + 27 - || memcmp(de->d_name, Log_filename_prefix, prefixLen) - || de->d_name[prefixLen + 5] != '_' - || strcmp(de->d_name + prefixLen + 23, ".log")) + if (strlen(de->d_name) != 32 + || memcmp(de->d_name, "postgresql-", 11) + || de->d_name[21] != '_' + || strcmp(de->d_name + 28, ".log")) continue; - values[2] = palloc(strlen(fctx->location) + strlen(de->d_name) + 2); - sprintf(values[2], "%s/%s", fctx->location, de->d_name); + values[1] = palloc(strlen(fctx->location) + strlen(de->d_name) + 2); + sprintf(values[1], "%s/%s", fctx->location, de->d_name); - values[0] = de->d_name + prefixLen+6; /* timestamp */ + values[0] = de->d_name + 11; /* timestamp */ values[0][17] = 0; - values[1] = de->d_name + prefixLen; /* pid */ - values[1][5] = 0; - - /* check if pid is purely numeric as expected */ - for (i = 0 ; i < 5 ; i++) - if (!isdigit(values[0][i])) - continue; - /* parse and decode expected timestamp */ if (ParseDateTime(values[0], lowstr, field, ftype, MAXDATEFIELDS, &nf)) continue;