PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <sys/stat.h>
#include "access/htup_details.h"
#include "access/relation.h"
#include "catalog/namespace.h"
#include "catalog/pg_authid.h"
#include "catalog/pg_database.h"
#include "catalog/pg_tablespace.h"
#include "commands/dbcommands.h"
#include "commands/tablespace.h"
#include "miscadmin.h"
#include "storage/fd.h"
#include "utils/acl.h"
#include "utils/builtins.h"
#include "utils/numeric.h"
#include "utils/rel.h"
#include "utils/relfilenumbermap.h"
#include "utils/relmapper.h"
#include "utils/syscache.h"
Go to the source code of this file.
Data Structures | |
struct | size_pretty_unit |
struct | size_bytes_unit_alias |
Macros | |
#define | half_rounded(x) (((x) + ((x) < 0 ? -1 : 1)) / 2) |
Variables | |
static const struct size_pretty_unit | size_pretty_units [] |
static const struct size_bytes_unit_alias | size_bytes_aliases [] |
|
static |
Definition at line 118 of file dbsize.c.
References ACL_CONNECT, aclcheck_error(), ACLCHECK_OK, AllocateDir(), CHECK_FOR_INTERRUPTS, dirent::d_name, db_dir_size(), FreeDir(), get_database_name(), GetUserId(), has_privs_of_role(), MAXPGPATH, object_aclcheck(), OBJECT_DATABASE, PG_TBLSPC_DIR, ReadDir(), snprintf, and TABLESPACE_VERSION_DIRECTORY.
Referenced by pg_database_size_name(), and pg_database_size_oid().
|
static |
Definition at line 451 of file dbsize.c.
References AccessShareLock, calculate_relation_size(), lfirst_oid, list_free(), MAX_FORKNUM, RelationData::rd_backend, RelationData::rd_locator, RelationData::rd_rel, relation_close(), relation_open(), RelationGetIndexList(), and size.
Referenced by calculate_total_relation_size(), and pg_indexes_size().
|
static |
Definition at line 308 of file dbsize.c.
References CHECK_FOR_INTERRUPTS, ereport, errcode_for_file_access(), errmsg(), ERROR, MAXPGPATH, relpathbackend, snprintf, stat::st_size, and stat.
Referenced by calculate_indexes_size(), calculate_table_size(), calculate_toast_table_size(), and pg_relation_size().
|
static |
Definition at line 424 of file dbsize.c.
References calculate_relation_size(), calculate_toast_table_size(), MAX_FORKNUM, OidIsValid, RelationData::rd_backend, RelationData::rd_locator, RelationData::rd_rel, and size.
Referenced by calculate_total_relation_size(), and pg_table_size().
|
static |
Definition at line 202 of file dbsize.c.
References ACL_CREATE, aclcheck_error(), ACLCHECK_OK, AllocateDir(), CHECK_FOR_INTERRUPTS, dirent::d_name, db_dir_size(), ereport, errcode_for_file_access(), errmsg(), ERROR, FreeDir(), get_tablespace_name(), GetUserId(), has_privs_of_role(), MAXPGPATH, MyDatabaseTableSpace, object_aclcheck(), OBJECT_TABLESPACE, PG_TBLSPC_DIR, ReadDir(), S_ISDIR, snprintf, stat::st_mode, stat::st_size, stat, and TABLESPACE_VERSION_DIRECTORY.
Referenced by pg_tablespace_size_name(), and pg_tablespace_size_oid().
|
static |
Definition at line 378 of file dbsize.c.
References AccessShareLock, calculate_relation_size(), lfirst_oid, list_free(), MAX_FORKNUM, RelationData::rd_backend, RelationData::rd_locator, relation_close(), relation_open(), RelationGetIndexList(), and size.
Referenced by calculate_table_size().
|
static |
Definition at line 528 of file dbsize.c.
References calculate_indexes_size(), calculate_table_size(), and size.
Referenced by pg_total_relation_size().
|
static |
Definition at line 74 of file dbsize.c.
References AllocateDir(), CHECK_FOR_INTERRUPTS, dirent::d_name, ereport, errcode_for_file_access(), errmsg(), ERROR, filename, FreeDir(), MAXPGPATH, ReadDir(), snprintf, stat::st_size, and stat.
Referenced by calculate_database_size(), and calculate_tablespace_size().
Definition at line 628 of file dbsize.c.
References DatumGetNumeric(), DirectFunctionCall1, numeric_abs(), and NumericGetDatum().
Referenced by pg_size_pretty_numeric().
Definition at line 638 of file dbsize.c.
References DatumGetBool(), DatumGetNumeric(), DirectFunctionCall2, int64_to_numeric(), numeric_add(), numeric_div_trunc(), numeric_ge(), numeric_sub(), and NumericGetDatum().
Referenced by pg_size_pretty_numeric().
Definition at line 619 of file dbsize.c.
References a, b, DatumGetBool(), DirectFunctionCall2, numeric_lt(), and NumericGetDatum().
Referenced by pg_size_pretty_numeric().
|
static |
Definition at line 611 of file dbsize.c.
References DatumGetCString(), DirectFunctionCall1, numeric_out(), and NumericGetDatum().
Referenced by pg_size_pretty_numeric().
Definition at line 660 of file dbsize.c.
References DatumGetNumeric(), DirectFunctionCall2, int64_to_numeric(), numeric_div_trunc(), and NumericGetDatum().
Referenced by pg_size_pretty_numeric().
Datum pg_database_size_name | ( | PG_FUNCTION_ARGS | ) |
Definition at line 182 of file dbsize.c.
References calculate_database_size(), dbName, get_database_oid(), NameStr, PG_GETARG_NAME, PG_RETURN_INT64, PG_RETURN_NULL, and size.
Datum pg_database_size_oid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 168 of file dbsize.c.
References calculate_database_size(), PG_GETARG_OID, PG_RETURN_INT64, PG_RETURN_NULL, and size.
Datum pg_filenode_relation | ( | PG_FUNCTION_ARGS | ) |
Definition at line 927 of file dbsize.c.
References OidIsValid, PG_GETARG_OID, PG_RETURN_NULL, PG_RETURN_OID, RelFileNumberIsValid, and RelidByRelfilenumber().
Datum pg_indexes_size | ( | PG_FUNCTION_ARGS | ) |
Definition at line 505 of file dbsize.c.
References AccessShareLock, calculate_indexes_size(), PG_GETARG_OID, PG_RETURN_INT64, PG_RETURN_NULL, relation_close(), size, and try_relation_open().
Datum pg_relation_filenode | ( | PG_FUNCTION_ARGS | ) |
Definition at line 879 of file dbsize.c.
References GETSTRUCT, HeapTupleIsValid, InvalidRelFileNumber, ObjectIdGetDatum(), PG_GETARG_OID, PG_RETURN_NULL, PG_RETURN_OID, RelationMapOidToFilenumber(), ReleaseSysCache(), RelFileNumberIsValid, and SearchSysCache1().
Datum pg_relation_filepath | ( | PG_FUNCTION_ARGS | ) |
Definition at line 951 of file dbsize.c.
References Assert, cstring_to_text(), RelFileLocator::dbOid, elog, ERROR, GETSTRUCT, GetTempNamespaceProcNumber(), HeapTupleIsValid, INVALID_PROC_NUMBER, InvalidOid, InvalidRelFileNumber, isTempOrTempToastNamespace(), MAIN_FORKNUM, MyDatabaseId, MyDatabaseTableSpace, ObjectIdGetDatum(), PG_GETARG_OID, PG_RETURN_NULL, PG_RETURN_TEXT_P, ProcNumberForTempRelations, RelationMapOidToFilenumber(), ReleaseSysCache(), RelFileNumberIsValid, RelFileLocator::relNumber, relpathbackend, SearchSysCache1(), and RelFileLocator::spcOid.
Datum pg_relation_size | ( | PG_FUNCTION_ARGS | ) |
Definition at line 346 of file dbsize.c.
References AccessShareLock, calculate_relation_size(), forkname_to_number(), PG_GETARG_OID, PG_GETARG_TEXT_PP, PG_RETURN_INT64, PG_RETURN_NULL, RelationData::rd_backend, RelationData::rd_locator, relation_close(), size, text_to_cstring(), and try_relation_open().
Datum pg_size_bytes | ( | PG_FUNCTION_ARGS | ) |
Definition at line 713 of file dbsize.c.
References a, arg, CStringGetDatum(), DatumGetInt64(), DatumGetNumeric(), DirectFunctionCall1, DirectFunctionCall2, DirectFunctionCall3, ereport, errcode(), errdetail(), errhint(), errmsg(), ERROR, Int32GetDatum(), int64_to_numeric(), InvalidOid, size_pretty_unit::name, numeric_in(), numeric_int8(), numeric_mul(), NumericGetDatum(), ObjectIdGetDatum(), PG_GETARG_TEXT_PP, PG_RETURN_INT64, pg_strcasecmp(), size_bytes_aliases, size_pretty_units, str, text_to_cstring(), size_pretty_unit::unitbits, and VARSIZE_ANY_EXHDR.
Datum pg_size_pretty | ( | PG_FUNCTION_ARGS | ) |
Definition at line 569 of file dbsize.c.
References buf, cstring_to_text(), half_rounded, INT64_FORMAT, size_pretty_unit::limit, name, size_pretty_unit::name, PG_GETARG_INT64, PG_RETURN_TEXT_P, size_pretty_unit::round, size, size_pretty_units, snprintf, and size_pretty_unit::unitbits.
Datum pg_size_pretty_numeric | ( | PG_FUNCTION_ARGS | ) |
Definition at line 672 of file dbsize.c.
References cstring_to_text(), int64_to_numeric(), size_pretty_unit::limit, name, size_pretty_unit::name, numeric_absolute(), numeric_half_rounded(), numeric_is_less(), numeric_to_cstring(), numeric_truncated_divide(), PG_GETARG_NUMERIC, PG_RETURN_TEXT_P, psprintf(), size_pretty_unit::round, size, size_pretty_units, and size_pretty_unit::unitbits.
Datum pg_table_size | ( | PG_FUNCTION_ARGS | ) |
Definition at line 486 of file dbsize.c.
References AccessShareLock, calculate_table_size(), PG_GETARG_OID, PG_RETURN_INT64, PG_RETURN_NULL, relation_close(), size, and try_relation_open().
Datum pg_tablespace_size_name | ( | PG_FUNCTION_ARGS | ) |
Definition at line 286 of file dbsize.c.
References calculate_tablespace_size(), get_tablespace_oid(), NameStr, PG_GETARG_NAME, PG_RETURN_INT64, PG_RETURN_NULL, and size.
Datum pg_tablespace_size_oid | ( | PG_FUNCTION_ARGS | ) |
Definition at line 272 of file dbsize.c.
References calculate_tablespace_size(), PG_GETARG_OID, PG_RETURN_INT64, PG_RETURN_NULL, and size.
Datum pg_total_relation_size | ( | PG_FUNCTION_ARGS | ) |
Definition at line 547 of file dbsize.c.
References AccessShareLock, calculate_total_relation_size(), PG_GETARG_OID, PG_RETURN_INT64, PG_RETURN_NULL, relation_close(), size, and try_relation_open().
|
static |
Definition at line 1 of file dbsize.c.
Referenced by pg_size_bytes().
|
static |
Definition at line 1 of file dbsize.c.
Referenced by pg_size_bytes(), pg_size_pretty(), and pg_size_pretty_numeric().