Skip to content

Commit 070a3ad

Browse files
committed
Rename pg_stat_file columns to be more consistent. Split apart change
and creation columns to behave for Unix or Win32.
1 parent 24bd944 commit 070a3ad

File tree

4 files changed

+33
-22
lines changed

4 files changed

+33
-22
lines changed

doc/src/sgml/func.sgml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.280 2005/08/13 19:02:32 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.281 2005/08/15 23:00:13 momjian Exp $
33
PostgreSQL documentation
44
-->
55

@@ -9414,12 +9414,13 @@ SELECT set_config('log_statement_stats', 'off', false);
94149414
</indexterm>
94159415
<para>
94169416
<function>pg_stat_file()</> returns a record containing the file
9417-
length, last accessed timestamp, last modified timestamp,
9418-
creation timestamp, and a boolean indicating if it is a directory.
9419-
Typical usages include:
9417+
size, last accessed timestamp, last modified timestamp,
9418+
last file status change timestamp (Unix platforms only),
9419+
file creation timestamp (Win32 only), and a boolean indicating
9420+
if it is a directory. Typical usages include:
94209421
<programlisting>
94219422
SELECT * FROM pg_stat_file('filename');
9422-
SELECT (pg_stat_file('filename')).mtime;
9423+
SELECT (pg_stat_file('filename')).modification;
94239424
</programlisting>
94249425
</para>
94259426

src/backend/catalog/system_views.sql

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 1996-2005, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.20 2005/08/15 16:25:17 tgl Exp $
6+
* $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.21 2005/08/15 23:00:13 momjian Exp $
77
*/
88

99
CREATE VIEW pg_roles AS
@@ -346,8 +346,9 @@ UPDATE pg_proc SET
346346
'timestamptz',
347347
'timestamptz',
348348
'timestamptz',
349+
'timestamptz',
349350
'bool'],
350-
proargmodes = ARRAY['i'::"char", 'o', 'o', 'o', 'o', 'o'],
351-
proargnames = ARRAY['filename'::text,
352-
'length', 'atime', 'mtime', 'ctime','isdir']
351+
proargmodes = ARRAY['i'::"char", 'o', 'o', 'o', 'o', 'o', 'o'],
352+
proargnames = ARRAY['filename'::text, 'size', 'access', 'modification',
353+
'change', 'creation', 'isdir']
353354
WHERE oid = 'pg_stat_file(text)'::regprocedure;

src/backend/utils/adt/genfile.c

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* Author: Andreas Pflug <pgadmin@pse-consulting.de>
1010
*
1111
* IDENTIFICATION
12-
* $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.4 2005/08/13 19:02:34 tgl Exp $
12+
* $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.5 2005/08/15 23:00:14 momjian Exp $
1313
*
1414
*-------------------------------------------------------------------------
1515
*/
@@ -154,8 +154,8 @@ pg_stat_file(PG_FUNCTION_ARGS)
154154
text *filename_t = PG_GETARG_TEXT_P(0);
155155
char *filename;
156156
struct stat fst;
157-
Datum values[5];
158-
bool isnull[5];
157+
Datum values[6];
158+
bool isnull[6];
159159
HeapTuple tuple;
160160
TupleDesc tupdesc;
161161

@@ -175,26 +175,35 @@ pg_stat_file(PG_FUNCTION_ARGS)
175175
* This record type had better match the output parameters declared
176176
* for me in pg_proc.h (actually, in system_views.sql at the moment).
177177
*/
178-
tupdesc = CreateTemplateTupleDesc(5, false);
178+
tupdesc = CreateTemplateTupleDesc(6, false);
179179
TupleDescInitEntry(tupdesc, (AttrNumber) 1,
180-
"length", INT8OID, -1, 0);
180+
"size", INT8OID, -1, 0);
181181
TupleDescInitEntry(tupdesc, (AttrNumber) 2,
182-
"atime", TIMESTAMPTZOID, -1, 0);
182+
"access", TIMESTAMPTZOID, -1, 0);
183183
TupleDescInitEntry(tupdesc, (AttrNumber) 3,
184-
"mtime", TIMESTAMPTZOID, -1, 0);
184+
"modification", TIMESTAMPTZOID, -1, 0);
185185
TupleDescInitEntry(tupdesc, (AttrNumber) 4,
186-
"ctime", TIMESTAMPTZOID, -1, 0);
186+
"change", TIMESTAMPTZOID, -1, 0);
187187
TupleDescInitEntry(tupdesc, (AttrNumber) 5,
188+
"creation", TIMESTAMPTZOID, -1, 0);
189+
TupleDescInitEntry(tupdesc, (AttrNumber) 6,
188190
"isdir", BOOLOID, -1, 0);
189191
BlessTupleDesc(tupdesc);
190192

193+
memset(isnull, false, sizeof(isnull));
194+
191195
values[0] = Int64GetDatum((int64) fst.st_size);
192196
values[1] = TimestampTzGetDatum(time_t_to_timestamptz(fst.st_atime));
193197
values[2] = TimestampTzGetDatum(time_t_to_timestamptz(fst.st_mtime));
198+
/* Unix has file status change time, while Win32 has creation time */
199+
#if !defined(WIN32) && !defined(__CYGWIN__)
194200
values[3] = TimestampTzGetDatum(time_t_to_timestamptz(fst.st_ctime));
195-
values[4] = BoolGetDatum(fst.st_mode & S_IFDIR);
196-
197-
memset(isnull, false, sizeof(isnull));
201+
isnull[4] = true;
202+
#else
203+
isnull[3] = true;
204+
values[4] = TimestampTzGetDatum(time_t_to_timestamptz(fst.st_ctime));
205+
#endif
206+
values[5] = BoolGetDatum(fst.st_mode & S_IFDIR);
198207

199208
tuple = heap_form_tuple(tupdesc, values, isnull);
200209

src/include/catalog/catversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
* Portions Copyright (c) 1996-2005, PostgreSQL Global Development Group
3838
* Portions Copyright (c) 1994, Regents of the University of California
3939
*
40-
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.299 2005/08/15 16:25:18 tgl Exp $
40+
* $PostgreSQL: pgsql/src/include/catalog/catversion.h,v 1.300 2005/08/15 23:00:14 momjian Exp $
4141
*
4242
*-------------------------------------------------------------------------
4343
*/
@@ -53,6 +53,6 @@
5353
*/
5454

5555
/* yyyymmddN */
56-
#define CATALOG_VERSION_NO 200508151
56+
#define CATALOG_VERSION_NO 200508152
5757

5858
#endif

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy