mirror of
https://github.com/postgres/postgres.git
synced 2025-04-22 23:02:54 +03:00
Rename pg_stat_file columns to be more consistent. Split apart change
and creation columns to behave for Unix or Win32.
This commit is contained in:
parent
24bd9447ac
commit
070a3ad76b
@ -1,5 +1,5 @@
|
||||
<!--
|
||||
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.280 2005/08/13 19:02:32 tgl Exp $
|
||||
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.281 2005/08/15 23:00:13 momjian Exp $
|
||||
PostgreSQL documentation
|
||||
-->
|
||||
|
||||
@ -9414,12 +9414,13 @@ SELECT set_config('log_statement_stats', 'off', false);
|
||||
</indexterm>
|
||||
<para>
|
||||
<function>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:
|
||||
<programlisting>
|
||||
SELECT * FROM pg_stat_file('filename');
|
||||
SELECT (pg_stat_file('filename')).mtime;
|
||||
SELECT (pg_stat_file('filename')).modification;
|
||||
</programlisting>
|
||||
</para>
|
||||
|
||||
|
@ -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;
|
||||
|
@ -9,7 +9,7 @@
|
||||
* Author: Andreas Pflug <pgadmin@pse-consulting.de>
|
||||
*
|
||||
* 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);
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user