1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-12 15:23:02 +03:00

Make pg_stat_file() use OUT parameters so that the user doesn't have to

remember the output parameter set for himself.  It's a bit of a kluge
but fixing array_in to work in bootstrap mode looks worse.
I removed the separate pg_file_length() function, as it no longer has any
real notational advantage --- you can write (pg_stat_file(...)).length.
This commit is contained in:
Tom Lane
2005-08-13 19:02:34 +00:00
parent f547909db7
commit 2af9a44fa9
5 changed files with 80 additions and 73 deletions

View File

@@ -3,7 +3,7 @@
*
* Copyright (c) 1996-2005, PostgreSQL Global Development Group
*
* $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.18 2005/07/31 17:19:17 tgl Exp $
* $PostgreSQL: pgsql/src/backend/catalog/system_views.sql,v 1.19 2005/08/13 19:02:33 tgl Exp $
*/
CREATE VIEW pg_roles AS
@@ -331,3 +331,23 @@ CREATE VIEW pg_stat_database AS
pg_stat_get_db_blocks_hit(D.oid) AS blks_read,
pg_stat_get_db_blocks_hit(D.oid) AS blks_hit
FROM pg_database D;
--
-- Fix up built-in functions that make use of OUT parameters.
-- We can't currently fill these values in during bootstrap, because
-- array_in doesn't work in bootstrap mode. Eventually that should be
-- fixed, but for now the path of least resistance is to patch their
-- pg_proc entries later during initdb.
--
UPDATE pg_proc SET
proallargtypes = ARRAY['text'::regtype,
'int8',
'timestamptz',
'timestamptz',
'timestamptz',
'bool'],
proargmodes = ARRAY['i'::"char", 'o', 'o', 'o', 'o', 'o'],
proargnames = ARRAY['filename'::text,
'length', 'atime', 'mtime', 'ctime','isdir']
WHERE oid = 'pg_stat_file(text)'::regprocedure;

View File

@@ -9,7 +9,7 @@
* Author: Andreas Pflug <pgadmin@pse-consulting.de>
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.3 2005/08/12 21:07:52 tgl Exp $
* $PostgreSQL: pgsql/src/backend/utils/adt/genfile.c,v 1.4 2005/08/13 19:02:34 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -171,6 +171,10 @@ pg_stat_file(PG_FUNCTION_ARGS)
(errcode_for_file_access(),
errmsg("could not stat file \"%s\": %m", filename)));
/*
* 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);
TupleDescInitEntry(tupdesc, (AttrNumber) 1,
"length", INT8OID, -1, 0);