Rename pg_stat_file columns to be more consistent. Split apart change
authorBruce Momjian
Mon, 15 Aug 2005 23:00:14 +0000 (23:00 +0000)
committerBruce Momjian
Mon, 15 Aug 2005 23:00:14 +0000 (23:00 +0000)
and creation columns to behave for Unix or Win32.

doc/src/sgml/func.sgml
src/backend/catalog/system_views.sql
src/backend/utils/adt/genfile.c
src/include/catalog/catversion.h

index d9495e8ee48c76c6198aa92de450b8a433ddf85b..c5c81a028ff67a7ebceb332f818c87683a534bc0 100644 (file)
@@ -1,5 +1,5 @@
 
 
@@ -9414,12 +9414,13 @@ SELECT set_config('log_statement_stats', 'off', false);
    
    
     pg_stat_file() returns a record containing the file
-    length, last accessed timestamp, last modified timestamp, 
-    creation timestamp, and a boolean indicating if it is a directory.
-    Typical usages include:
+    size, last accessed timestamp, last modified timestamp, 
+    last file status change timestamp (Unix platforms only), 
+    file creation timestamp (Win32 only), and a boolean indicating 
+    if it is a directory.  Typical usages include:
 
 SELECT * FROM pg_stat_file('filename');
-SELECT (pg_stat_file('filename')).mtime;
+SELECT (pg_stat_file('filename')).modification;
 
    
 
index 1f091d55d35207171881fb5a8b58fd3e20245de5..10826e21f7befd853fab22669889ddf10a56b44b 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Copyright (c) 1996-2005, PostgreSQL Global Development Group
  *
- * $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.20 2005/08/15 16:25:17 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.21 2005/08/15 23:00:13 momjian Exp $
  */
 
 CREATE VIEW pg_roles AS 
@@ -346,8 +346,9 @@ UPDATE pg_proc SET
                          'timestamptz',
                          'timestamptz',
                          'timestamptz',
+                         'timestamptz',
                          'bool'],
-  proargmodes = ARRAY['i'::"char", 'o', 'o', 'o', 'o', 'o'],
-  proargnames = ARRAY['filename'::text,
-                      'length', 'atime', 'mtime', 'ctime','isdir']
+  proargmodes = ARRAY['i'::"char", 'o', 'o', 'o', 'o', 'o', 'o'],
+  proargnames = ARRAY['filename'::text, 'size', 'access', 'modification',
+             'change', 'creation', 'isdir']
 WHERE oid = 'pg_stat_file(text)'::regprocedure;
index d67ed4c791f90e110df38a1dc884112af18d9340..43a05659a26e9646d1f2f79a888c9e7df626300d 100644 (file)
@@ -9,7 +9,7 @@
  * Author: Andreas Pflug 
  *
  * IDENTIFICATION
- *   $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.4 2005/08/13 19:02:34 tgl Exp $
+ *   $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.5 2005/08/15 23:00:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -154,8 +154,8 @@ pg_stat_file(PG_FUNCTION_ARGS)
    text       *filename_t = PG_GETARG_TEXT_P(0);
    char        *filename;
    struct stat fst;
-   Datum       values[5];
-   bool        isnull[5];
+   Datum       values[6];
+   bool        isnull[6];
    HeapTuple   tuple;
    TupleDesc   tupdesc;
 
@@ -175,26 +175,35 @@ pg_stat_file(PG_FUNCTION_ARGS)
     * This record type had better match the output parameters declared
     * for me in pg_proc.h (actually, in system_views.sql at the moment).
     */
-   tupdesc = CreateTemplateTupleDesc(5, false);
+   tupdesc = CreateTemplateTupleDesc(6, false);
    TupleDescInitEntry(tupdesc, (AttrNumber) 1,
-                      "length", INT8OID, -1, 0);
+                      "size", INT8OID, -1, 0);
    TupleDescInitEntry(tupdesc, (AttrNumber) 2,
-                      "atime", TIMESTAMPTZOID, -1, 0);
+                      "access", TIMESTAMPTZOID, -1, 0);
    TupleDescInitEntry(tupdesc, (AttrNumber) 3,
-                      "mtime", TIMESTAMPTZOID, -1, 0);
+                      "modification", TIMESTAMPTZOID, -1, 0);
    TupleDescInitEntry(tupdesc, (AttrNumber) 4,
-                      "ctime", TIMESTAMPTZOID, -1, 0);
+                      "change", TIMESTAMPTZOID, -1, 0);
    TupleDescInitEntry(tupdesc, (AttrNumber) 5,
+                      "creation", TIMESTAMPTZOID, -1, 0);
+   TupleDescInitEntry(tupdesc, (AttrNumber) 6,
                       "isdir", BOOLOID, -1, 0);
    BlessTupleDesc(tupdesc);
 
+   memset(isnull, false, sizeof(isnull));
+
    values[0] = Int64GetDatum((int64) fst.st_size);
    values[1] = TimestampTzGetDatum(time_t_to_timestamptz(fst.st_atime));
    values[2] = TimestampTzGetDatum(time_t_to_timestamptz(fst.st_mtime));
+   /* Unix has file status change time, while Win32 has creation time */
+#if !defined(WIN32) && !defined(__CYGWIN__)
    values[3] = TimestampTzGetDatum(time_t_to_timestamptz(fst.st_ctime));
-   values[4] = BoolGetDatum(fst.st_mode & S_IFDIR);
-
-   memset(isnull, false, sizeof(isnull));
+   isnull[4] = true;
+#else
+   isnull[3] = true;
+   values[4] = TimestampTzGetDatum(time_t_to_timestamptz(fst.st_ctime));
+#endif
+   values[5] = BoolGetDatum(fst.st_mode & S_IFDIR);
 
    tuple = heap_form_tuple(tupdesc, values, isnull);
 
index abbcc2522c7159deca78347054ea19142142709c..3b3b792847d1b05fde27010b0efba33c981748fa 100644 (file)
@@ -37,7 +37,7 @@
  * Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
  * Portions Copyright (c) 1994, Regents of the University of California
  *
- * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.299 2005/08/15 16:25:18 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.300 2005/08/15 23:00:14 momjian Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -53,6 +53,6 @@
  */
 
 /*                         yyyymmddN */
-#define CATALOG_VERSION_NO 200508151
+#define CATALOG_VERSION_NO 200508152
 
 #endif