Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite4d9b69

Browse files
author
Neil Conway
committed
Rename pg_complete_relation_size() to pg_total_relation_size(), for the
sake of brevity and clarity.Make pg_reload_conf(), pg_rotate_logfile(), and pg_cancel_backend()return a boolean rather than an integer to indicate success or failure.Along the way, make some minor cleanups to dbsize.c -- in particular,use elog() rather than ereport() for "shouldn't happen" errorconditions, and remove some of the more flagrant violations of thePostgres indentation conventions.Catalog version bumped.
1 parent148c00a commite4d9b69

File tree

7 files changed

+90
-85
lines changed

7 files changed

+90
-85
lines changed

‎doc/src/sgml/func.sgml

Lines changed: 32 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.285 2005/09/14 21:14:26 neilc Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/func.sgml,v 1.286 2005/09/16 05:35:39 neilc Exp $
33
PostgreSQL documentation
44
-->
55

@@ -9368,29 +9368,30 @@ SELECT set_config('log_statement_stats', 'off', false);
93689368
<entry>
93699369
<literal><function>pg_cancel_backend</function>(<parameter>pid</parameter> <type>int</>)</literal>
93709370
</entry>
9371-
<entry><type>int</type></entry>
9371+
<entry><type>boolean</type></entry>
93729372
<entry>Cancel a backend's current query</entry>
93739373
</row>
93749374
<row>
93759375
<entry>
93769376
<literal><function>pg_reload_conf</function>()</literal>
93779377
</entry>
9378-
<entry><type>int</type></entry>
9378+
<entry><type>boolean</type></entry>
93799379
<entry>Cause server processes to reload their configuration files</entry>
93809380
</row>
93819381
<row>
93829382
<entry>
93839383
<literal><function>pg_rotate_logfile</function>()</literal>
93849384
</entry>
9385-
<entry><type>int</type></entry>
9385+
<entry><type>boolean</type></entry>
93869386
<entry>Rotate server's logfile</entry>
93879387
</row>
93889388
</tbody>
93899389
</tgroup>
93909390
</table>
93919391

93929392
<para>
9393-
Each of these functions returns 1 if successful, 0 if not successful.
9393+
Each of these functions returns <literal>true</literal> if
9394+
successful and <literal>false</literal> otherwise.
93949395
</para>
93959396

93969397
<para>
@@ -9502,7 +9503,7 @@ SELECT set_config('log_statement_stats', 'off', false);
95029503
<primary>pg_relation_size</primary>
95039504
</indexterm>
95049505
<indexterm zone="functions-admin">
9505-
<primary>pg_complete_relation_size</primary>
9506+
<primary>pg_total_relation_size</primary>
95069507
</indexterm>
95079508
<indexterm zone="functions-admin">
95089509
<primary>pg_size_pretty</primary>
@@ -9527,28 +9528,28 @@ SELECT set_config('log_statement_stats', 'off', false);
95279528
<literal><function>pg_tablespace_size</function>(<type>oid</type>)</literal>
95289529
</entry>
95299530
<entry><type>bigint</type></entry>
9530-
<entry>Total disk space used by the tablespace with the specified OID</entry>
9531+
<entry>Disk space used by the tablespace with the specified OID</entry>
95319532
</row>
95329533
<row>
95339534
<entry>
95349535
<literal><function>pg_tablespace_size</function>(<type>name</type>)</literal>
95359536
</entry>
95369537
<entry><type>bigint</type></entry>
9537-
<entry>Total disk space used by the tablespace with the specified name</entry>
9538+
<entry>Disk space used by the tablespace with the specified name</entry>
95389539
</row>
95399540
<row>
95409541
<entry>
95419542
<literal><function>pg_database_size</function>(<type>oid</type>)</literal>
95429543
</entry>
95439544
<entry><type>bigint</type></entry>
9544-
<entry>Total disk space used by the database with the specified OID</entry>
9545+
<entry>Disk space used by the database with the specified OID</entry>
95459546
</row>
95469547
<row>
95479548
<entry>
95489549
<literal><function>pg_database_size</function>(<type>name</type>)</literal>
95499550
</entry>
95509551
<entry><type>bigint</type></entry>
9551-
<entry>Total disk space used by the database with the specified name</entry>
9552+
<entry>Disk space used by the database with the specified name</entry>
95529553
</row>
95539554
<row>
95549555
<entry>
@@ -9562,25 +9563,31 @@ SELECT set_config('log_statement_stats', 'off', false);
95629563
<literal><function>pg_relation_size</function>(<type>text</type>)</literal>
95639564
</entry>
95649565
<entry><type>bigint</type></entry>
9565-
<entry>Disk space used by the table or index with the specified name.
9566-
The name may be qualified with a schema name</entry>
9566+
<entry>
9567+
Disk space used by the table or index with the specified name.
9568+
The table name may be qualified with a schema name
9569+
</entry>
95679570
</row>
95689571
<row>
95699572
<entry>
9570-
<literal><function>pg_complete_relation_size</function>(<type>oid</type>)</literal>
9573+
<literal><function>pg_total_relation_size</function>(<type>oid</type>)</literal>
95719574
</entry>
95729575
<entry><type>bigint</type></entry>
9573-
<entry>Total disk space used by the table with the specified OID,
9574-
including indexes and toasted data</entry>
9576+
<entry>
9577+
Total disk space used by the table with the specified OID,
9578+
including indexes and toasted data
9579+
</entry>
95759580
</row>
95769581
<row>
95779582
<entry>
9578-
<literal><function>pg_complete_relation_size</function>(<type>text</type>)</literal>
9583+
<literal><function>pg_total_relation_size</function>(<type>text</type>)</literal>
95799584
</entry>
95809585
<entry><type>bigint</type></entry>
9581-
<entry>Total disk space used by the table with the specified name,
9582-
including indexes and toasted data.
9583-
The table name may be qualified with a schema name</entry>
9586+
<entry>
9587+
Total disk space used by the table with the specified name,
9588+
including indexes and toasted data. The table name may be
9589+
qualified with a schema name
9590+
</entry>
95849591
</row>
95859592
<row>
95869593
<entry>
@@ -9610,9 +9617,9 @@ SELECT set_config('log_statement_stats', 'off', false);
96109617
</para>
96119618

96129619
<para>
9613-
<function>pg_complete_relation_size</> accepts the OID or name of a table
9614-
or toast table, and returns the size in bytes of the data and all
9615-
associated indexes and toast tables.
9620+
<function>pg_total_relation_size</> accepts the OID or name of a
9621+
tableor toast table, and returns the size in bytes of the data
9622+
and allassociated indexes and toast tables.
96169623
</para>
96179624

96189625
<para>
@@ -9669,7 +9676,7 @@ SELECT set_config('log_statement_stats', 'off', false);
96699676
<primary>pg_ls_dir</primary>
96709677
</indexterm>
96719678
<para>
9672-
<function>pg_ls_dir()</> returns all the names in the specified
9679+
<function>pg_ls_dir</> returns all the names in the specified
96739680
directory, except the special entries <quote><literal>.</></> and
96749681
<quote><literal>..</></>.
96759682
</para>
@@ -9678,7 +9685,7 @@ SELECT set_config('log_statement_stats', 'off', false);
96789685
<primary>pg_read_file</primary>
96799686
</indexterm>
96809687
<para>
9681-
<function>pg_read_file()</> returns part of a text file, starting
9688+
<function>pg_read_file</> returns part of a text file, starting
96829689
at the given <parameter>offset</>, returning at most <parameter>length</>
96839690
bytes (less if the end of file is reached first). If <parameter>offset</>
96849691
is negative, it is relative to the end of the file.
@@ -9688,7 +9695,7 @@ SELECT set_config('log_statement_stats', 'off', false);
96889695
<primary>pg_stat_file</primary>
96899696
</indexterm>
96909697
<para>
9691-
<function>pg_stat_file()</> returns a record containing the file
9698+
<function>pg_stat_file</> returns a record containing the file
96929699
size, last accessed timestamp, last modified timestamp,
96939700
last file status change timestamp (Unix platforms only),
96949701
file creation timestamp (Win32 only), and a boolean indicating

‎doc/src/sgml/release.sgml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!--
2-
$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.368 2005/09/1603:37:35 tgl Exp $
2+
$PostgreSQL: pgsql/doc/src/sgml/release.sgml,v 1.369 2005/09/1605:35:39 neilc Exp $
33

44
Typical markup:
55

@@ -408,6 +408,12 @@ pg_[A-Za-z0-9_] <application>
408408
</para>
409409
</listitem>
410410

411+
<listitem>
412+
<para>
413+
Make <function>pg_cancel_backend(int)</function> return a
414+
<type>boolean</type> rather than an <type>integer</type> (Neil)
415+
</para>
416+
</listitem>
411417
</itemizedlist>
412418
</sect2>
413419

@@ -1167,7 +1173,7 @@ pg_[A-Za-z0-9_] <application>
11671173

11681174
<listitem>
11691175
<para>
1170-
<function>pg_complete_relation_size()</>
1176+
<function>pg_total_relation_size()</>
11711177
</para>
11721178
</listitem>
11731179

@@ -1180,7 +1186,7 @@ pg_[A-Za-z0-9_] <application>
11801186
</itemizedlist>
11811187
</para>
11821188
<para>
1183-
<function>pg_complete_relation_size()</> includes indexes and TOAST
1189+
<function>pg_total_relation_size()</> includes indexes and TOAST
11841190
tables.
11851191
</para>
11861192
</listitem>

‎src/backend/utils/adt/dbsize.c

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
* Copyright (c) 2002-2005, PostgreSQL Global Development Group
66
*
77
* IDENTIFICATION
8-
* $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.3 2005/08/02 15:17:24 tgl Exp $
8+
* $PostgreSQL: pgsql/src/backend/utils/adt/dbsize.c,v 1.4 2005/09/16 05:35:40 neilc Exp $
99
*
1010
*/
1111

@@ -68,7 +68,7 @@ db_dir_size(const char *path)
6868
staticint64
6969
calculate_database_size(OiddbOid)
7070
{
71-
int64totalsize=0;
71+
int64totalsize;
7272
DIR*dirdesc;
7373
structdirent*direntry;
7474
chardirpath[MAXPGPATH];
@@ -78,7 +78,7 @@ calculate_database_size(Oid dbOid)
7878

7979
/* Include pg_default storage */
8080
snprintf(pathname,MAXPGPATH,"%s/base/%u",DataDir,dbOid);
81-
totalsize+=db_dir_size(pathname);
81+
totalsize=db_dir_size(pathname);
8282

8383
/* Scan the non-default tablespaces */
8484
snprintf(dirpath,MAXPGPATH,"%s/pg_tblspc",DataDir);
@@ -273,9 +273,7 @@ pg_relation_size_oid(PG_FUNCTION_ARGS)
273273
ObjectIdGetDatum(relOid),
274274
0,0,0);
275275
if (!HeapTupleIsValid(tuple))
276-
ereport(ERROR,
277-
(ERRCODE_UNDEFINED_TABLE,
278-
errmsg("relation with OID %u does not exist",relOid)));
276+
elog(ERROR,"cache lookup failed for relation %u",relOid);
279277

280278
pg_class= (Form_pg_class)GETSTRUCT(tuple);
281279
relnodeOid=pg_class->relfilenode;
@@ -308,11 +306,12 @@ pg_relation_size_name(PG_FUNCTION_ARGS)
308306

309307

310308
/*
311-
* Compute on-disk size of files for 'relation' according to the stat function,
312-
* optionally including heap data, index data, and/or toast data.
309+
* Compute the on-disk size of files for 'relation' according to the
310+
* stat function, optionally including heap data, index data, and/or
311+
* toast data.
313312
*/
314313
staticint64
315-
calculate_complete_relation_size(OidtblspcOid,OidrelnodeOid)
314+
calculate_total_relation_size(OidtblspcOid,OidrelnodeOid)
316315
{
317316
RelationheapRelation;
318317
RelationidxRelation;
@@ -322,7 +321,7 @@ calculate_complete_relation_size(Oid tblspcOid, Oid relnodeOid)
322321
OidtoastOid;
323322
OidtoastTblspcOid;
324323
boolhasIndices;
325-
int64size=0;
324+
int64size;
326325
List*indexoidlist;
327326
ListCell*idx;
328327

@@ -331,14 +330,16 @@ calculate_complete_relation_size(Oid tblspcOid, Oid relnodeOid)
331330
hasIndices=heapRelation->rd_rel->relhasindex;
332331

333332
/* Get the heap size */
334-
size+=calculate_relation_size(tblspcOid,relnodeOid);
333+
size=calculate_relation_size(tblspcOid,relnodeOid);
335334

336-
/* Get Index size */
337-
if (hasIndices ) {
338-
/* recursively include any dependent indexes ... */
335+
/* Get index size */
336+
if (hasIndices)
337+
{
338+
/* recursively include any dependent indexes */
339339
indexoidlist=RelationGetIndexList(heapRelation);
340-
341-
foreach(idx,indexoidlist) {
340+
341+
foreach(idx,indexoidlist)
342+
{
342343
idxOid=lfirst_oid(idx);
343344
idxRelation=relation_open(idxOid,AccessShareLock);
344345
idxTblspcOid=idxRelation->rd_rel->reltablespace;
@@ -347,14 +348,13 @@ calculate_complete_relation_size(Oid tblspcOid, Oid relnodeOid)
347348
}
348349
list_free(indexoidlist);
349350
}
350-
351-
/* Close heapReleation now we no longer need it */
351+
352352
relation_close(heapRelation,AccessShareLock);
353353

354354
/* Get toast table size */
355-
if (toastOid!=0 ) {
356-
357-
/* recursively include any toast relations...*/
355+
if (toastOid!=0)
356+
{
357+
/* recursively include any toast relations */
358358
toastRelation=relation_open(toastOid,AccessShareLock);
359359
toastTblspcOid=toastRelation->rd_rel->reltablespace;
360360
size+=calculate_relation_size(toastTblspcOid,toastOid);
@@ -369,7 +369,7 @@ calculate_complete_relation_size(Oid tblspcOid, Oid relnodeOid)
369369
* heap data, index data, and toasted data.
370370
*/
371371
Datum
372-
pg_complete_relation_size_oid(PG_FUNCTION_ARGS)
372+
pg_total_relation_size_oid(PG_FUNCTION_ARGS)
373373
{
374374
OidrelOid=PG_GETARG_OID(0);
375375
HeapTupletuple;
@@ -378,24 +378,22 @@ pg_complete_relation_size_oid(PG_FUNCTION_ARGS)
378378
OidtblspcOid;
379379

380380
tuple=SearchSysCache(RELOID,
381-
ObjectIdGetDatum(relOid),
382-
0,0,0);
381+
ObjectIdGetDatum(relOid),
382+
0,0,0);
383383
if (!HeapTupleIsValid(tuple))
384-
ereport(ERROR,
385-
(ERRCODE_UNDEFINED_TABLE,
386-
errmsg("relation with OID %u does not exist",relOid)));
384+
elog(ERROR,"cache lookup failed for relation %u",relOid);
387385

388386
pg_class= (Form_pg_class)GETSTRUCT(tuple);
389387
relnodeOid=pg_class->relfilenode;
390388
tblspcOid=pg_class->reltablespace;
391389

392390
ReleaseSysCache(tuple);
393391

394-
PG_RETURN_INT64(calculate_complete_relation_size(tblspcOid,relnodeOid));
392+
PG_RETURN_INT64(calculate_total_relation_size(tblspcOid,relnodeOid));
395393
}
396394

397395
Datum
398-
pg_complete_relation_size_name(PG_FUNCTION_ARGS)
396+
pg_total_relation_size_name(PG_FUNCTION_ARGS)
399397
{
400398
text*relname=PG_GETARG_TEXT_P(0);
401399
RangeVar*relrv;
@@ -411,7 +409,7 @@ pg_complete_relation_size_name(PG_FUNCTION_ARGS)
411409

412410
relation_close(relation,AccessShareLock);
413411

414-
PG_RETURN_INT64(calculate_complete_relation_size(tblspcOid,relnodeOid));
412+
PG_RETURN_INT64(calculate_total_relation_size(tblspcOid,relnodeOid));
415413
}
416414

417415
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp