*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.118 2001/06/09 18:16:55 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.119 2001/06/22 19:16:20 wieck Exp $
*
*
* INTERFACE ROUTINES
#include "miscadmin.h"
#include "utils/inval.h"
#include "utils/relcache.h"
+#include "pgstat.h"
XLogRecPtr log_heap_move(Relation reln, Buffer oldbuf, ItemPointerData from,
if (lockmode != NoLock)
LockRelation(r, lockmode);
+ pgstat_initstats(&r->pgstat_info, r);
+
+ pgstat_initstats(&r->pgstat_info, r);
+
return r;
}
if (RelationIsValid(r) && r->rd_rel->relkind == RELKIND_INDEX)
elog(ERROR, "%s is an index relation", RelationGetRelationName(r));
+ if (RelationIsValid(r))
+ pgstat_initstats(&r->pgstat_info, r);
+
+ if (RelationIsValid(r))
+ pgstat_initstats(&r->pgstat_info, r);
+
return r;
}
scan->rs_snapshot = snapshot;
scan->rs_nkeys = (short) nkeys;
+ pgstat_initstats(&scan->rs_pgstat_info, relation);
+
/*
* we do this here instead of in initscan() because heap_rescan also
* calls initscan() and we don't want to allocate memory again
* reinitialize scan descriptor
*/
initscan(scan, scan->rs_rd, scanFromEnd, scan->rs_nkeys, key);
+
+ pgstat_reset_heap_scan(&scan->rs_pgstat_info);
}
/* ----------------
}
}
+ pgstat_count_heap_scan(&scan->rs_pgstat_info);
+
/*
* if we get here it means we have a new current scan tuple, so point
* to the proper return buffer and return the tuple.
HEAPDEBUG_3; /* heap_getnext returning tuple */
+ if (scan->rs_ctup.t_data != NULL)
+ pgstat_count_heap_getnext(&scan->rs_pgstat_info);
+
return ((scan->rs_ctup.t_data == NULL) ? NULL : &(scan->rs_ctup));
}
heap_fetch(Relation relation,
Snapshot snapshot,
HeapTuple tuple,
- Buffer *userbuf)
+ Buffer *userbuf,
+ IndexScanDesc iscan)
{
ItemId lp;
Buffer buffer;
* responsible for releasing the buffer.
*/
*userbuf = buffer;
+
+ if (iscan != NULL)
+ pgstat_count_heap_fetch(&iscan->xs_pgstat_info);
+ else
+ pgstat_count_heap_fetch(&relation->pgstat_info);
}
}
START_CRIT_SECTION();
RelationPutHeapTuple(relation, buffer, tup);
+ pgstat_count_heap_insert(&relation->pgstat_info);
+
/* XLOG stuff */
{
xl_heap_insert xlrec;
heap_tuple_toast_attrs(relation, NULL, &(tp));
#endif
+ pgstat_count_heap_delete(&relation->pgstat_info);
+
/*
* Mark tuple for invalidation from system caches at next command
* boundary. We have to do this before WriteBuffer because we need to
newbuf = buffer;
}
+ pgstat_count_heap_update(&relation->pgstat_info);
+
/*
* At this point newbuf and buffer are both pinned and locked,
* and newbuf has enough space for the new tuple.
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.22 2001/05/07 00:43:15 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.23 2001/06/22 19:16:20 wieck Exp $
*
*
* INTERFACE ROUTINES
while ((indexRes = index_getnext(toastscan, ForwardScanDirection)) != NULL)
{
toasttup.t_self = indexRes->heap_iptr;
- heap_fetch(toastrel, SnapshotAny, &toasttup, &buffer);
+ heap_fetch(toastrel, SnapshotAny, &toasttup, &buffer, toastscan);
pfree(indexRes);
if (!toasttup.t_data)
while ((indexRes = index_getnext(toastscan, ForwardScanDirection)) != NULL)
{
toasttup.t_self = indexRes->heap_iptr;
- heap_fetch(toastrel, SnapshotAny, &toasttup, &buffer);
+ heap_fetch(toastrel, SnapshotAny, &toasttup, &buffer, toastscan);
pfree(indexRes);
if (toasttup.t_data == NULL)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.27 2001/06/09 18:16:56 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.28 2001/06/22 19:16:21 wieck Exp $
*
* NOTES
* many of the old access method routines have been turned into
#include "postgres.h"
#include "access/genam.h"
+#include "pgstat.h"
/* ----------------------------------------------------------------
* general access method routines
ItemPointerSetInvalid(&scan->currentItemData);
ItemPointerSetInvalid(&scan->currentMarkData);
+ pgstat_initstats(&scan->xs_pgstat_info, relation);
+
/*
* mark cached function lookup data invalid; it will be set on first
* use
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.50 2001/06/01 02:41:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.51 2001/06/22 19:16:21 wieck Exp $
*
* INTERFACE ROUTINES
* index_open - open an index relation by relationId
#include "access/heapam.h"
#include "utils/relcache.h"
+#include "pgstat.h"
/* ----------------------------------------------------------------
* macros used in index_ routines
if (r->rd_rel->relkind != RELKIND_INDEX)
elog(ERROR, "%s is not an index relation", RelationGetRelationName(r));
+ pgstat_initstats(&r->pgstat_info, r);
+
return r;
}
if (r->rd_rel->relkind != RELKIND_INDEX)
elog(ERROR, "%s is not an index relation", RelationGetRelationName(r));
+ pgstat_initstats(&r->pgstat_info, r);
+
return r;
}
UInt16GetDatum(numberOfKeys),
PointerGetDatum(key)));
+ pgstat_initstats(&scan->xs_pgstat_info, relation);
+
/*
* We want to look up the amgettuple procedure just once per scan,
* not once per index_getnext call. So do it here and save
PointerGetDatum(scan),
BoolGetDatum(scanFromEnd),
PointerGetDatum(key));
+
+ pgstat_reset_index_scan(&scan->xs_pgstat_info);
}
/* ----------------
SCAN_CHECKS;
+ pgstat_count_index_scan(&scan->xs_pgstat_info);
+
/*
* have the am's gettuple proc do all the work.
* index_beginscan already set up fn_getnext.
PointerGetDatum(scan),
Int32GetDatum(direction)));
+ if (result != NULL)
+ pgstat_count_index_getnext(&scan->xs_pgstat_info);
return result;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.82 2001/03/22 03:59:14 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.83 2001/06/22 19:16:21 wieck Exp $
*
*-------------------------------------------------------------------------
*/
if (chtup)
{
htup.t_self = btitem->bti_itup.t_tid;
- heap_fetch(heapRel, SnapshotDirty, &htup, &buffer);
+ heap_fetch(heapRel, SnapshotDirty, &htup, &buffer, NULL);
if (htup.t_data == NULL) /* YES! */
break;
/* Live tuple is being inserted, so continue checking */
cbti = (BTItem) PageGetItem(page, PageGetItemId(page, offset));
htup.t_self = cbti->bti_itup.t_tid;
- heap_fetch(heapRel, SnapshotDirty, &htup, &buffer);
+ heap_fetch(heapRel, SnapshotDirty, &htup, &buffer, NULL);
if (htup.t_data != NULL) /* it is a duplicate */
{
TransactionId xwait =
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.103 2001/06/19 19:42:15 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.104 2001/06/22 19:16:21 wieck Exp $
*
* NOTES
* Transaction aborts can now occur two ways:
#include "utils/relcache.h"
#include "utils/temprel.h"
+#include "pgstat.h"
+
extern bool SharedBufferChanged;
static void AbortTransaction(void);
SharedBufferChanged = false;/* safest place to do it */
+ /* Count transaction commit in statistics collector */
+ pgstat_count_xact_commit();
+
/*
* done with commit processing, set current transaction state back to
* default
AtEOXact_portals();
RecordTransactionAbort();
+ /* Count transaction abort in statistics collector */
+ pgstat_count_xact_rollback();
+
RelationPurgeLocalRelation(false);
AtEOXact_temp_relations(false);
smgrDoPendingDeletes(false);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.79 2001/06/16 18:59:31 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.80 2001/06/22 19:16:21 wieck Exp $
*
*-------------------------------------------------------------------------
*/
while ((indexRes = index_getnext(sd, ForwardScanDirection)))
{
tuple.t_self = indexRes->heap_iptr;
- heap_fetch(heapRelation, SnapshotNow, &tuple, &buffer);
+ heap_fetch(heapRelation, SnapshotNow, &tuple, &buffer, sd);
pfree(indexRes);
if (tuple.t_data != NULL)
break;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.8 2001/03/22 03:59:20 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/catalog/pg_largeobject.c,v 1.9 2001/06/22 19:16:21 wieck Exp $
*
*-------------------------------------------------------------------------
*/
while ((indexRes = index_getnext(sd, ForwardScanDirection)))
{
tuple.t_self = indexRes->heap_iptr;
- heap_fetch(pg_largeobject, SnapshotNow, &tuple, &buffer);
+ heap_fetch(pg_largeobject, SnapshotNow, &tuple, &buffer, sd);
pfree(indexRes);
if (tuple.t_data != NULL)
{
while ((indexRes = index_getnext(sd, ForwardScanDirection)))
{
tuple.t_self = indexRes->heap_iptr;
- heap_fetch(pg_largeobject, SnapshotNow, &tuple, &buffer);
+ heap_fetch(pg_largeobject, SnapshotNow, &tuple, &buffer, sd);
pfree(indexRes);
if (tuple.t_data != NULL)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.20 2001/06/13 21:44:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.21 2001/06/22 19:16:21 wieck Exp $
*
*-------------------------------------------------------------------------
*/
goto pageloop;
}
ItemPointerSet(&targtuple.t_self, targblock, targoffset);
- heap_fetch(onerel, SnapshotNow, &targtuple, &targbuffer);
+ heap_fetch(onerel, SnapshotNow, &targtuple, &targbuffer, NULL);
if (targtuple.t_data != NULL)
{
/*
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.65 2001/03/22 03:59:21 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.66 2001/06/22 19:16:21 wieck Exp $
*
*-------------------------------------------------------------------------
*/
LocalHeapTuple.t_self = ScanResult->heap_iptr;
LocalHeapTuple.t_datamcxt = NULL;
LocalHeapTuple.t_data = NULL;
- heap_fetch(LocalOldHeap, SnapshotNow, &LocalHeapTuple, &LocalBuffer);
+ heap_fetch(LocalOldHeap, SnapshotNow, &LocalHeapTuple, &LocalBuffer,
+ ScanDesc);
if (LocalHeapTuple.t_data != NULL)
{
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.92 2001/06/01 02:41:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.93 2001/06/22 19:16:21 wieck Exp $
*
*-------------------------------------------------------------------------
*/
break;
tuple.t_self = indexRes->heap_iptr;
- heap_fetch(tgrel, SnapshotNow, &tuple, &buffer);
+ heap_fetch(tgrel, SnapshotNow, &tuple, &buffer, sd);
pfree(indexRes);
if (!tuple.t_data)
continue;
if (ItemPointerIsValid(&(event->dte_oldctid)))
{
ItemPointerCopy(&(event->dte_oldctid), &(oldtuple.t_self));
- heap_fetch(rel, SnapshotAny, &oldtuple, &oldbuffer);
+ heap_fetch(rel, SnapshotAny, &oldtuple, &oldbuffer, NULL);
if (!oldtuple.t_data)
elog(ERROR, "DeferredTriggerExecute: failed to fetch old tuple");
}
if (ItemPointerIsValid(&(event->dte_newctid)))
{
ItemPointerCopy(&(event->dte_newctid), &(newtuple.t_self));
- heap_fetch(rel, SnapshotAny, &newtuple, &newbuffer);
+ heap_fetch(rel, SnapshotAny, &newtuple, &newbuffer, NULL);
if (!newtuple.t_data)
elog(ERROR, "DeferredTriggerExecute: failed to fetch new tuple");
}
break;
tuple.t_self = indexRes->heap_iptr;
- heap_fetch(tgrel, SnapshotNow, &tuple, &buffer);
+ heap_fetch(tgrel, SnapshotNow, &tuple, &buffer, sd);
pfree(indexRes);
if (!tuple.t_data)
continue;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.196 2001/06/13 21:44:40 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.197 2001/06/22 19:16:21 wieck Exp $
*
*-------------------------------------------------------------------------
*/
#include "utils/syscache.h"
#include "utils/temprel.h"
+#include "pgstat.h"
+
extern XLogRecPtr log_heap_clean(Relation reln, Buffer buffer,
char *unused, int unlen);
extern XLogRecPtr log_heap_move(Relation reln,
if (IsTransactionBlock())
elog(ERROR, "%s cannot run inside a BEGIN/END block", stmttype);
+ /*
+ * Send info about dead objects to the statistics collector
+ */
+ pgstat_vacuum_tabstat();
+
if (vacstmt->verbose)
MESSAGE_LEVEL = NOTICE;
else
/* get the buffer cache tuple */
rtup.t_self = ctup->t_self;
ReleaseSysCache(ctup);
- heap_fetch(rd, SnapshotNow, &rtup, &buffer);
+ heap_fetch(rd, SnapshotNow, &rtup, &buffer, NULL);
/* overwrite the existing statistics in the tuple */
pgcform = (Form_pg_class) GETSTRUCT(&rtup);
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.143 2001/06/01 02:41:35 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.144 2001/06/22 19:16:22 wieck Exp $
*
*-------------------------------------------------------------------------
*/
{
Buffer buffer;
- heap_fetch(relation, SnapshotDirty, &tuple, &buffer);
+ heap_fetch(relation, SnapshotDirty, &tuple, &buffer, NULL);
if (tuple.t_data != NULL)
{
TransactionId xwait = SnapshotDirty->xmax;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.60 2001/05/27 20:42:18 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.61 2001/06/22 19:16:22 wieck Exp $
*
*-------------------------------------------------------------------------
*/
while ((result = index_getnext(scandesc, direction)) != NULL)
{
tuple->t_self = result->heap_iptr;
- heap_fetch(heapRelation, snapshot, tuple, &buffer);
+ heap_fetch(heapRelation, snapshot, tuple, &buffer, scandesc);
pfree(result);
if (tuple->t_data != NULL)
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.17 2001/05/27 20:42:20 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.18 2001/06/22 19:16:22 wieck Exp $
*
*-------------------------------------------------------------------------
*/
if (itemptr)
{
tuple->t_self = *(itemptr);
- heap_fetch(heapRelation, snapshot, tuple, &buffer);
+ heap_fetch(heapRelation, snapshot, tuple, &buffer, NULL);
}
if (tuple->t_data != NULL)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.108 2001/05/19 01:57:11 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.109 2001/06/22 19:16:22 wieck Exp $
*
*-------------------------------------------------------------------------
*/
tuple.t_datamcxt = NULL;
tuple.t_data = NULL;
tuple.t_self = indexRes->heap_iptr;
- heap_fetch(heapRelation, SnapshotNow, &tuple, &buffer);
+ heap_fetch(heapRelation, SnapshotNow, &tuple, &buffer, sd);
pfree(indexRes);
if (tuple.t_data != NULL)
{
# Makefile for postmaster
#
# IDENTIFICATION
-# $Header: /cvsroot/pgsql/src/backend/postmaster/Makefile,v 1.12 2000/08/31 16:10:23 petere Exp $
+# $Header: /cvsroot/pgsql/src/backend/postmaster/Makefile,v 1.13 2001/06/22 19:16:22 wieck Exp $
#
#-------------------------------------------------------------------------
top_builddir = ../../..
include $(top_builddir)/src/Makefile.global
-OBJS = postmaster.o
+OBJS = postmaster.o pgstat.o
all: SUBSYS.o
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.225 2001/06/21 16:43:24 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.226 2001/06/22 19:16:22 wieck Exp $
*
* NOTES
*
#include "utils/memutils.h"
#include "bootstrap/bootstrap.h"
+#include "pgstat.h"
+
#define INVALID_SOCK (-1)
#define ARGV_SIZE 64
ExitPostmaster(1);
}
+ /*
+ * Initialize and startup the statistics collector process
+ */
+ if (pgstat_init() < 0)
+ ExitPostmaster(1);
+ if (pgstat_start() < 0)
+ ExitPostmaster(1);
+
if (DebugLvl > 2)
{
extern char **environ;
{
exitstatus = status.w_status;
#endif
+ /*
+ * Check if this child was the statistics collector. If
+ * so, start a new one.
+ */
+ if (pgstat_ispgstat(pid))
+ {
+ fprintf(stderr, "%s: Performance collector exited with status %d\n",
+ progname, exitstatus);
+ pgstat_start();
+ continue;
+ }
+
if (ShutdownPID > 0)
{
if (pid != ShutdownPID)
errno = save_errno;
return;
}
+
CleanupProc(pid, exitstatus);
}
GetRedoRecPtr();
}
}
+ else
+ pgstat_beterm(pid);
return;
}
CheckPointPID = 0;
checkpointed = 0;
}
+ else
+ {
+ /*
+ * Tell the collector about backend termination
+ */
+ pgstat_beterm(pid);
+ }
FatalError = true;
}
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.112 2001/06/09 18:16:57 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.113 2001/06/22 19:16:22 wieck Exp $
*
*-------------------------------------------------------------------------
*/
#include "utils/relcache.h"
#include "catalog/pg_database.h"
+#include "pgstat.h"
+
#define BufferGetLSN(bufHdr) \
(*((XLogRecPtr*)MAKE_PTR((bufHdr)->data)))
if (isLocalBuf)
{
ReadLocalBufferCount++;
+ pgstat_count_buffer_read(&reln->pgstat_info, reln);
/* Substitute proper block number if caller asked for P_NEW */
if (blockNum == P_NEW)
{
}
bufHdr = LocalBufferAlloc(reln, blockNum, &found);
if (found)
+ {
LocalBufferHitCount++;
+ pgstat_count_buffer_hit(&reln->pgstat_info, reln);
+ }
}
else
{
ReadBufferCount++;
+ pgstat_count_buffer_read(&reln->pgstat_info, reln);
/* Substitute proper block number if caller asked for P_NEW */
if (blockNum == P_NEW)
{
SpinAcquire(BufMgrLock);
bufHdr = BufferAlloc(reln, blockNum, &found);
if (found)
+ {
BufferHitCount++;
+ pgstat_count_buffer_hit(&reln->pgstat_info, reln);
+ }
}
/* At this point we do NOT hold the bufmgr spinlock. */
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.87 2001/03/25 23:23:59 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.88 2001/06/22 19:16:23 wieck Exp $
*
*-------------------------------------------------------------------------
*/
while ((indexRes = index_getnext(sd, BackwardScanDirection)))
{
tuple.t_self = indexRes->heap_iptr;
- heap_fetch(obj_desc->heap_r, SnapshotNow, &tuple, &buffer);
+ heap_fetch(obj_desc->heap_r, SnapshotNow, &tuple, &buffer, sd);
pfree(indexRes);
if (tuple.t_data == NULL)
continue;
while ((indexRes = index_getnext(sd, ForwardScanDirection)))
{
tuple.t_self = indexRes->heap_iptr;
- heap_fetch(obj_desc->heap_r, SnapshotNow, &tuple, &buffer);
+ heap_fetch(obj_desc->heap_r, SnapshotNow, &tuple, &buffer, sd);
pfree(indexRes);
if (tuple.t_data == NULL)
while ((indexRes = index_getnext(sd, ForwardScanDirection)))
{
oldtuple.t_self = indexRes->heap_iptr;
- heap_fetch(obj_desc->heap_r, SnapshotNow, &oldtuple, &buffer);
+ heap_fetch(obj_desc->heap_r, SnapshotNow, &oldtuple, &buffer, sd);
pfree(indexRes);
if (oldtuple.t_data != NULL)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.223 2001/06/20 18:07:55 petere Exp $
+ * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.224 2001/06/22 19:16:23 wieck Exp $
*
* NOTES
* this is the "main" module of the postgres backend and
#include "mb/pg_wchar.h"
#endif
+#include "pgstat.h"
/* ----------------
* global variables
if (!IsUnderPostmaster)
{
puts("\nPOSTGRES backend interactive interface ");
- puts("$Revision: 1.223 $ $Date: 2001/06/20 18:07:55 $\n");
+ puts("$Revision: 1.224 $ $Date: 2001/06/22 19:16:23 $\n");
}
/*
ALLOCSET_DEFAULT_INITSIZE,
ALLOCSET_DEFAULT_MAXSIZE);
+ /* ----------
+ * Tell the statistics collector that we're alive and
+ * to which database we belong.
+ * ----------
+ */
+ pgstat_bestart();
+
/*
* POSTGRES main processing loop begins here
*
*/
ReadyForQuery(whereToSendOutput);
+ /* ----------
+ * Tell the statistics collector what we've collected
+ * so far.
+ * ----------
+ */
+ pgstat_report_tabstat();
+
if (IsTransactionBlock())
+ {
set_ps_display("idle in transaction");
+ pgstat_report_activity(" in transaction");
+ }
else
+ {
set_ps_display("idle");
+ pgstat_report_activity("");
+ }
/*
* (2) deal with pending asynchronous NOTIFY from other backends,
* 'F' indicates a fastpath call.
*/
case 'F':
+ /* ----------
+ * Tell the collector what we're doing
+ * ----------
+ */
+ pgstat_report_activity(" function call");
+
/* start an xact for this function invocation */
start_xact_command();
if (Show_query_stats)
ResetUsage();
+ pgstat_report_activity(parser_input->data);
+
pg_exec_query_string(parser_input->data,
whereToSendOutput,
QueryContext);
#
# Makefile for utils/adt
#
-# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.48 2000/10/20 21:03:52 petere Exp $
+# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.49 2001/06/22 19:16:23 wieck Exp $
#
subdir = src/backend/utils/adt
tid.o timestamp.o varbit.o varchar.o varlena.o version.o \
network.o mac.o inet_net_ntop.o inet_net_pton.o \
ri_triggers.o pg_lzcompress.o pg_locale.o formatting.o \
- ascii.o quote.o
+ ascii.o quote.o pgstatfuncs.o
all: SUBSYS.o
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.61 2001/03/22 03:59:53 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.62 2001/06/22 19:16:23 wieck Exp $
*
*-------------------------------------------------------------------------
*/
tuple.t_self = indexRes->heap_iptr;
heap_fetch(hdesc, SnapshotNow,
&tuple,
- &buffer);
+ &buffer,
+ sd);
pfree(indexRes);
if (tuple.t_data != NULL)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.80 2001/06/19 19:42:16 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.81 2001/06/22 19:16:23 wieck Exp $
*
*-------------------------------------------------------------------------
*/
while ((indexRes = index_getnext(isd, ForwardScanDirection)))
{
tuple.t_self = indexRes->heap_iptr;
- heap_fetch(relation, SnapshotNow, &tuple, &buffer);
+ heap_fetch(relation, SnapshotNow, &tuple, &buffer, isd);
pfree(indexRes);
if (tuple.t_data != NULL)
{
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.138 2001/06/18 03:35:07 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.139 2001/06/22 19:16:23 wieck Exp $
*
*-------------------------------------------------------------------------
*/
break;
tuple.t_self = indexRes->heap_iptr;
- heap_fetch(adrel, SnapshotNow, &tuple, &buffer);
+ heap_fetch(adrel, SnapshotNow, &tuple, &buffer, sd);
pfree(indexRes);
if (tuple.t_data == NULL)
continue;
break;
tuple.t_self = indexRes->heap_iptr;
- heap_fetch(rcrel, SnapshotNow, &tuple, &buffer);
+ heap_fetch(rcrel, SnapshotNow, &tuple, &buffer, sd);
pfree(indexRes);
if (tuple.t_data == NULL)
continue;
tuple.t_self = indexRes->heap_iptr;
tuple.t_datamcxt = NULL;
tuple.t_data = NULL;
- heap_fetch(indrel, SnapshotNow, &tuple, &buffer);
+ heap_fetch(indrel, SnapshotNow, &tuple, &buffer, sd);
pfree(indexRes);
if (tuple.t_data == NULL)
continue;
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.35 2001/03/22 03:59:59 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.36 2001/06/22 19:16:23 wieck Exp $
*
*-------------------------------------------------------------------------
*/
* ----------------
*/
static MemoryContext DynaHashCxt = NULL;
+static MemoryContext CurrentDynaHashCxt = NULL;
static void *
DynaHashAlloc(Size size)
{
- if (!DynaHashCxt)
- DynaHashCxt = AllocSetContextCreate(TopMemoryContext,
- "DynaHash",
- ALLOCSET_DEFAULT_MINSIZE,
- ALLOCSET_DEFAULT_INITSIZE,
- ALLOCSET_DEFAULT_MAXSIZE);
-
- return MemoryContextAlloc(DynaHashCxt, size);
+ Assert(MemoryContextIsValid(CurrentDynaHashCxt));
+ return MemoryContextAlloc(CurrentDynaHashCxt, size);
}
#define MEM_ALLOC DynaHashAlloc
HHDR *hctl;
HTAB *hashp;
+ if (!DynaHashCxt)
+ DynaHashCxt = AllocSetContextCreate(TopMemoryContext,
+ "DynaHash",
+ ALLOCSET_DEFAULT_MINSIZE,
+ ALLOCSET_DEFAULT_INITSIZE,
+ ALLOCSET_DEFAULT_MAXSIZE);
+
+ if (flags & HASH_CONTEXT)
+ CurrentDynaHashCxt = info->hcxt;
+ else
+ CurrentDynaHashCxt = DynaHashCxt;
hashp = (HTAB *) MEM_ALLOC(sizeof(HTAB));
MemSet(hashp, 0, sizeof(HTAB));
hashp->segbase = (char *) info->segbase;
hashp->alloc = info->alloc;
hashp->dir = (SEG_OFFSET *) info->dir;
+ hashp->hcxt = NULL;
/* hash table already exists, we're just attaching to it */
if (flags & HASH_ATTACH)
hashp->alloc = MEM_ALLOC;
hashp->dir = NULL;
hashp->segbase = NULL;
+ hashp->hcxt = DynaHashCxt;
}
if (!hashp->hctl)
{
- hashp->hctl = (HHDR *) hashp->alloc(sizeof(HHDR));
+ hashp->hctl = (HHDR *) hashp->alloc(sizeof(HHDR));
if (!hashp->hctl)
return 0;
}
}
if (flags & HASH_ALLOC)
hashp->alloc = info->alloc;
+ else
+ {
+ if (flags & HASH_CONTEXT)
+ {
+ CurrentDynaHashCxt = AllocSetContextCreate(info->hcxt,
+ "DynaHashTable",
+ ALLOCSET_DEFAULT_MINSIZE,
+ ALLOCSET_DEFAULT_INITSIZE,
+ ALLOCSET_DEFAULT_MAXSIZE);
+
+ hashp->hcxt = CurrentDynaHashCxt;
+ }
+ else
+ {
+ CurrentDynaHashCxt = AllocSetContextCreate(DynaHashCxt,
+ "DynaHashTable",
+ ALLOCSET_DEFAULT_MINSIZE,
+ ALLOCSET_DEFAULT_INITSIZE,
+ ALLOCSET_DEFAULT_MAXSIZE);
+ hashp->hcxt = CurrentDynaHashCxt;
+ }
+ }
if (init_htab(hashp, nelem))
{
/* Allocate a directory */
if (!(hashp->dir))
{
+ CurrentDynaHashCxt = hashp->hcxt;
hashp->dir = (SEG_OFFSET *)
hashp->alloc(hctl->dsize * sizeof(SEG_OFFSET));
if (!hashp->dir)
* allocated individually, see bucket_alloc!! Why doesn't it crash?
* ANSWER: it probably does crash, but is never invoked in normal
* operations...
+ *
+ * Thomas is right, it does crash. Therefore I changed the code
+ * to use a separate memory context which is a child of the DynaHashCxt
+ * by default. And the HASHCTL structure got extended with a hcxt
+ * field, where someone can specify an explicit context (giving new
+ * flag HASH_CONTEXT) and forget about hash_destroy() completely.
+ * The shmem operations aren't changed, but in shmem mode a destroy
+ * doesn't work anyway. Jan Wieck 03/2001.
*/
void
{
if (hashp != NULL)
{
+#if 0
SEG_OFFSET segNum;
SEGMENT segp;
int nsegs = hashp->hctl->nsegs;
p,
q;
ELEMENT *curr;
+#endif
/* cannot destroy a shared memory hash table */
Assert(!hashp->segbase);
/* allocation method must be one we know how to free, too */
Assert(hashp->alloc == MEM_ALLOC);
+ /* so this hashtable must have it's own context */
+ Assert(hashp->hcxt != NULL);
hash_stats("destroy", hashp);
+ /*
+ * Free buckets, dir etc. by destroying the hash tables
+ * memory context.
+ */
+ MemoryContextDelete(hashp->hcxt);
+
+#if 0
+ /*
+ * Dead code - replaced by MemoryContextDelete() above
+ */
for (segNum = 0; nsegs > 0; nsegs--, segNum++)
{
MEM_FREE((char *) segp);
}
MEM_FREE((char *) hashp->dir);
+#endif
+
+ /*
+ * Free the HTAB and control structure, which are allocated
+ * in the parent context (DynaHashCxt or the context given
+ * by the caller of hash_create().
+ */
MEM_FREE((char *) hashp->hctl);
MEM_FREE((char *) hashp);
}
old_dirsize = hashp->hctl->dsize * sizeof(SEG_OFFSET);
new_dirsize = new_dsize * sizeof(SEG_OFFSET);
+ CurrentDynaHashCxt = hashp->hcxt;
old_p = (char *) hashp->dir;
p = (char *) hashp->alloc((Size) new_dirsize);
SEGMENT segp;
SEG_OFFSET segOffset;
+ CurrentDynaHashCxt = hashp->hcxt;
segp = (SEGMENT) hashp->alloc(sizeof(BUCKET_INDEX) * hashp->hctl->ssize);
if (!segp)
/* make sure its aligned correctly */
bucketSize = MAXALIGN(bucketSize);
+ CurrentDynaHashCxt = hashp->hcxt;
tmpBucket = (ELEMENT *) hashp->alloc(BUCKET_ALLOC_INCR * bucketSize);
if (!tmpBucket)
# Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
# Portions Copyright (c) 1994, Regents of the University of California
#
-# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.127 2001/06/14 19:47:25 tgl Exp $
+# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.128 2001/06/22 19:16:23 wieck Exp $
#
#-------------------------------------------------------------------------
echo "REVOKE ALL on pg_statistic FROM public" \
| "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+echo "CREATE VIEW pg_stat_all_tables AS \
+ SELECT \
+ C.oid AS relid, \
+ C.relname AS relname, \
+ pg_stat_get_numscans(C.oid) AS seq_scan, \
+ pg_stat_get_tuples_returned(C.oid) AS seq_tup_read, \
+ sum(pg_stat_get_numscans(I.indexrelid)) AS idx_scan, \
+ sum(pg_stat_get_tuples_fetched(I.indexrelid)) AS idx_tup_fetch, \
+ pg_stat_get_tuples_inserted(C.oid) AS n_tup_ins, \
+ pg_stat_get_tuples_updated(C.oid) AS n_tup_upd, \
+ pg_stat_get_tuples_deleted(C.oid) AS n_tup_del \
+ FROM pg_class C FULL OUTER JOIN \
+ pg_index I ON C.oid = I.indrelid \
+ WHERE C.relkind = 'r' \
+ GROUP BY C.oid, C.relname;" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_stat_sys_tables AS \
+ SELECT * FROM pg_stat_all_tables \
+ WHERE relname ~ '^pg_';" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_stat_user_tables AS \
+ SELECT * FROM pg_stat_all_tables \
+ WHERE relname !~ '^pg_';" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_statio_all_tables AS \
+ SELECT \
+ C.oid AS relid, \
+ C.relname AS relname, \
+ pg_stat_get_blocks_fetched(C.oid) - \
+ pg_stat_get_blocks_hit(C.oid) AS heap_blks_read, \
+ pg_stat_get_blocks_hit(C.oid) AS heap_blks_hit, \
+ sum(pg_stat_get_blocks_fetched(I.indexrelid) - \
+ pg_stat_get_blocks_hit(I.indexrelid)) AS idx_blks_read, \
+ sum(pg_stat_get_blocks_hit(I.indexrelid)) AS idx_blks_hit, \
+ pg_stat_get_blocks_fetched(T.oid) - \
+ pg_stat_get_blocks_hit(T.oid) AS toast_blks_read, \
+ pg_stat_get_blocks_hit(T.oid) AS toast_blks_hit, \
+ pg_stat_get_blocks_fetched(X.oid) - \
+ pg_stat_get_blocks_hit(X.oid) AS tidx_blks_read, \
+ pg_stat_get_blocks_hit(X.oid) AS tidx_blks_hit \
+ FROM pg_class C FULL OUTER JOIN \
+ pg_index I ON C.oid = I.indrelid FULL OUTER JOIN \
+ pg_class T ON C.reltoastrelid = T.oid FULL OUTER JOIN \
+ pg_class X ON C.reltoastidxid = X.oid \
+ WHERE C.relkind = 'r' \
+ GROUP BY C.oid, C.relname, T.oid, X.oid;" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_statio_sys_tables AS \
+ SELECT * FROM pg_statio_all_tables \
+ WHERE relname ~ '^pg_';" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_statio_user_tables AS \
+ SELECT * FROM pg_statio_all_tables \
+ WHERE relname !~ '^pg_';" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_stat_all_indexes AS \
+ SELECT \
+ C.oid AS relid, \
+ I.oid AS indexrelid, \
+ C.relname AS relname, \
+ I.relname AS indexrelname, \
+ pg_stat_get_numscans(I.oid) AS idx_scan, \
+ pg_stat_get_tuples_returned(I.oid) AS idx_tup_read, \
+ pg_stat_get_tuples_fetched(I.oid) AS idx_tup_fetch \
+ FROM pg_class C, \
+ pg_class I, \
+ pg_index X \
+ WHERE C.relkind = 'r' AND \
+ X.indrelid = C.oid AND \
+ X.indexrelid = I.oid;" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_stat_sys_indexes AS \
+ SELECT * FROM pg_stat_all_indexes \
+ WHERE relname ~ '^pg_';" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_stat_user_indexes AS \
+ SELECT * FROM pg_stat_all_indexes \
+ WHERE relname !~ '^pg_';" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_statio_all_indexes AS \
+ SELECT \
+ C.oid AS relid, \
+ I.oid AS indexrelid, \
+ C.relname AS relname, \
+ I.relname AS indexrelname, \
+ pg_stat_get_blocks_fetched(I.oid) - \
+ pg_stat_get_blocks_hit(I.oid) AS idx_blks_read, \
+ pg_stat_get_blocks_hit(I.oid) AS idx_blks_hit \
+ FROM pg_class C, \
+ pg_class I, \
+ pg_index X \
+ WHERE C.relkind = 'r' AND \
+ X.indrelid = C.oid AND \
+ X.indexrelid = I.oid;" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_statio_sys_indexes AS \
+ SELECT * FROM pg_statio_all_indexes \
+ WHERE relname ~ '^pg_';" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_statio_user_indexes AS \
+ SELECT * FROM pg_statio_all_indexes \
+ WHERE relname !~ '^pg_';" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_statio_all_sequences AS \
+ SELECT \
+ C.oid AS relid, \
+ C.relname AS relname, \
+ pg_stat_get_blocks_fetched(C.oid) - \
+ pg_stat_get_blocks_hit(C.oid) AS blks_read, \
+ pg_stat_get_blocks_hit(C.oid) AS blks_hit \
+ FROM pg_class C \
+ WHERE C.relkind = 'S';" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_statio_sys_sequences AS \
+ SELECT * FROM pg_statio_all_sequences \
+ WHERE relname ~ '^pg_';" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_statio_user_sequences AS \
+ SELECT * FROM pg_statio_all_sequences \
+ WHERE relname !~ '^pg_';" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_stat_activity AS \
+ SELECT \
+ D.oid AS datid, \
+ D.datname AS datname, \
+ pg_stat_get_backend_pid(S.backendid) AS procpid, \
+ pg_stat_get_backend_userid(S.backendid) AS usesysid, \
+ U.usename AS usename, \
+ pg_stat_get_backend_activity(S.backendid) AS current_query \
+ FROM pg_database D, \
+ (SELECT pg_stat_get_backend_idset() AS backendid) AS S, \
+ pg_shadow U \
+ WHERE pg_stat_get_backend_dbid(S.backendid) = D.oid AND \
+ pg_stat_get_backend_userid(S.backendid) = U.usesysid;" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
+echo "CREATE VIEW pg_stat_database AS \
+ SELECT \
+ D.oid AS datid, \
+ D.datname AS datname, \
+ pg_stat_get_db_numbackends(D.oid) AS numbackends, \
+ pg_stat_get_db_xact_commit(D.oid) AS xact_commit, \
+ pg_stat_get_db_xact_rollback(D.oid) AS xact_rollback, \
+ pg_stat_get_db_blocks_fetched(D.oid) - \
+ 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;" \
+ | "$PGPATH"/postgres $PGSQL_OPT template1 > /dev/null || exit_nicely
+
echo "Loading pg_description."
echo "COPY pg_description FROM STDIN" > $TEMPFILE
cat "$POSTGRES_DESCR" >> $TEMPFILE
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: heapam.h,v 1.64 2001/06/12 05:55:50 tgl Exp $
+ * $Id: heapam.h,v 1.65 2001/06/22 19:16:23 wieck Exp $
*
*-------------------------------------------------------------------------
*/
extern void heap_rescan(HeapScanDesc scan, bool scanFromEnd, ScanKey key);
extern void heap_endscan(HeapScanDesc scan);
extern HeapTuple heap_getnext(HeapScanDesc scandesc, int backw);
-extern void heap_fetch(Relation relation, Snapshot snapshot, HeapTuple tup, Buffer *userbuf);
+extern void heap_fetch(Relation relation, Snapshot snapshot, HeapTuple tup, Buffer *userbuf, IndexScanDesc iscan);
extern ItemPointer heap_get_latest_tid(Relation relation, Snapshot snapshot, ItemPointer tid);
extern Oid heap_insert(Relation relation, HeapTuple tup);
extern int heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid);
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: relscan.h,v 1.21 2001/06/09 18:16:59 tgl Exp $
+ * $Id: relscan.h,v 1.22 2001/06/22 19:16:23 wieck Exp $
*
*-------------------------------------------------------------------------
*/
Snapshot rs_snapshot; /* snapshot to see */
uint16 rs_nkeys; /* number of scan keys to select tuples */
ScanKey rs_key; /* key descriptors */
+
+ PgStat_Info rs_pgstat_info; /* statistics collector hook */
} HeapScanDescData;
typedef HeapScanDescData *HeapScanDesc;
uint16 numberOfKeys; /* number of scan keys to select tuples */
ScanKey keyData; /* key descriptors */
FmgrInfo fn_getnext; /* cached lookup info for am's getnext fn */
+
+ PgStat_Info xs_pgstat_info; /* statistics collector hook */
} IndexScanDescData;
typedef IndexScanDescData *IndexScanDesc;
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: catversion.h,v 1.84 2001/06/19 22:39:12 tgl Exp $
+ * $Id: catversion.h,v 1.85 2001/06/22 19:16:24 wieck Exp $
*
*-------------------------------------------------------------------------
*/
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 200106191
+#define CATALOG_VERSION_NO 200106221
#endif
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: pg_proc.h,v 1.194 2001/06/14 01:09:22 tgl Exp $
+ * $Id: pg_proc.h,v 1.195 2001/06/22 19:16:24 wieck Exp $
*
* NOTES
* The script catalog/genbki.sh reads this file and generates .bki
DESCR("current user privilege on relation by rel oid");
+DATA(insert OID = 1928 ( pg_stat_get_numscans PGUID 12 f t t t 1 f 20 "26" 100 0 0 100 pg_stat_get_numscans - ));
+DESCR("Statistics: Number of scans done for table/index");
+DATA(insert OID = 1929 ( pg_stat_get_tuples_returned PGUID 12 f t t t 1 f 20 "26" 100 0 0 100 pg_stat_get_tuples_returned - ));
+DESCR("Statistics: Number of tuples read by seqscan");
+DATA(insert OID = 1930 ( pg_stat_get_tuples_fetched PGUID 12 f t t t 1 f 20 "26" 100 0 0 100 pg_stat_get_tuples_fetched - ));
+DESCR("Statistics: Number of tuples fetched by idxscan");
+DATA(insert OID = 1931 ( pg_stat_get_tuples_inserted PGUID 12 f t t t 1 f 20 "26" 100 0 0 100 pg_stat_get_tuples_inserted - ));
+DESCR("Statistics: Number of tuples inserted");
+DATA(insert OID = 1932 ( pg_stat_get_tuples_updated PGUID 12 f t t t 1 f 20 "26" 100 0 0 100 pg_stat_get_tuples_updated - ));
+DESCR("Statistics: Number of tuples updated");
+DATA(insert OID = 1933 ( pg_stat_get_tuples_deleted PGUID 12 f t t t 1 f 20 "26" 100 0 0 100 pg_stat_get_tuples_deleted - ));
+DESCR("Statistics: Number of tuples deleted");
+DATA(insert OID = 1934 ( pg_stat_get_blocks_fetched PGUID 12 f t t t 1 f 20 "26" 100 0 0 100 pg_stat_get_blocks_fetched - ));
+DESCR("Statistics: Number of blocks fetched");
+DATA(insert OID = 1935 ( pg_stat_get_blocks_hit PGUID 12 f t t t 1 f 20 "26" 100 0 0 100 pg_stat_get_blocks_hit - ));
+DESCR("Statistics: Number of blocks found in cache");
+DATA(insert OID = 1936 ( pg_stat_get_backend_idset PGUID 12 f t t t 0 t 23 "" 100 0 0 100 pg_stat_get_backend_idset - ));
+DESCR("Statistics: Currently active backend IDs");
+DATA(insert OID = 1937 ( pg_stat_get_backend_pid PGUID 12 f t t t 1 f 23 "23" 100 0 0 100 pg_stat_get_backend_pid - ));
+DESCR("Statistics: PID of backend");
+DATA(insert OID = 1938 ( pg_stat_get_backend_dbid PGUID 12 f t t t 1 f 26 "23" 100 0 0 100 pg_stat_get_backend_dbid - ));
+DESCR("Statistics: Database ID of backend");
+DATA(insert OID = 1939 ( pg_stat_get_backend_userid PGUID 12 f t t t 1 f 26 "23" 100 0 0 100 pg_stat_get_backend_userid - ));
+DESCR("Statistics: User ID of backend");
+DATA(insert OID = 1940 ( pg_stat_get_backend_activity PGUID 12 f t t t 1 f 25 "23" 100 0 0 100 pg_stat_get_backend_activity - ));
+DESCR("Statistics: Current query of backend");
+DATA(insert OID = 1941 ( pg_stat_get_db_numbackends PGUID 12 f t t t 1 f 23 "26" 100 0 0 100 pg_stat_get_db_numbackends - ));
+DESCR("Statistics: Number of backends in database");
+DATA(insert OID = 1942 ( pg_stat_get_db_xact_commit PGUID 12 f t t t 1 f 20 "26" 100 0 0 100 pg_stat_get_db_xact_commit - ));
+DESCR("Statistics: Transactions committed");
+DATA(insert OID = 1943 ( pg_stat_get_db_xact_rollback PGUID 12 f t t t 1 f 20 "26" 100 0 0 100 pg_stat_get_db_xact_rollback - ));
+DESCR("Statistics: Transactions rolled back");
+DATA(insert OID = 1944 ( pg_stat_get_db_blocks_fetched PGUID 12 f t t t 1 f 20 "26" 100 0 0 100 pg_stat_get_db_blocks_fetched - ));
+DESCR("Statistics: Blocks fetched for database");
+DATA(insert OID = 1945 ( pg_stat_get_db_blocks_hit PGUID 12 f t t t 1 f 20 "26" 100 0 0 100 pg_stat_get_db_blocks_hit - ));
+DESCR("Statistics: Block found in cache for database");
+
/*
* prototypes for functions pg_proc.c
*/
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: hsearch.h,v 1.19 2001/03/22 04:01:12 momjian Exp $
+ * $Id: hsearch.h,v 1.20 2001/06/22 19:16:24 wieck Exp $
*
*-------------------------------------------------------------------------
*/
* pointer values */
SEG_OFFSET *dir; /* 'directory' of segm starts */
void *(*alloc) (Size);/* memory allocator */
+ MemoryContext hcxt; /* memory context if default allocator used */
} HTAB;
typedef struct hashctl
long *dir; /* directory if allocated already */
long *hctl; /* location of header information in shd
* mem */
+ MemoryContext hcxt; /* memory context to use for all allocations */
} HASHCTL;
/* Flags to indicate action for hctl */
#define HASH_SHARED_MEM 0x040 /* Setting shared mem const */
#define HASH_ATTACH 0x080 /* Do not initialize hctl */
#define HASH_ALLOC 0x100 /* Setting memory allocator */
+#define HASH_CONTEXT 0x200 /* Setting explicit memory context */
/* seg_alloc assumes that INVALID_INDEX is 0 */
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Id: rel.h,v 1.49 2001/06/19 21:28:41 tgl Exp $
+ * $Id: rel.h,v 1.50 2001/06/22 19:16:24 wieck Exp $
*
*-------------------------------------------------------------------------
*/
int numtriggers;
} TriggerDesc;
+
+/* ----------
+ * Same for the statistics collector data in Relation and scan data.
+ * ----------
+ */
+typedef struct PgStat_Info
+{
+ void *tabentry;
+ bool no_stats;
+ bool heap_scan_counted;
+ bool index_scan_counted;
+} PgStat_Info;
+
/*
* Here are the contents of a relation cache entry.
*/
IndexStrategy rd_istrat; /* info needed if rel is an index */
RegProcedure *rd_support;
TriggerDesc *trigdesc; /* Trigger info, or NULL if rel has none */
+
+ PgStat_Info pgstat_info;
} RelationData;
typedef RelationData *Relation;
-- Check that ruleutils are working
--
SELECT viewname, definition FROM pg_views ORDER BY viewname;
- viewname | definition
---------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- iexit | SELECT ih.name, ih.thepath, interpt_pp(ih.thepath, r.thepath) AS exit FROM ihighway ih, ramp r WHERE (ih.thepath ## r.thepath);
- pg_indexes | SELECT c.relname AS tablename, i.relname AS indexname, pg_get_indexdef(x.indexrelid) AS indexdef FROM pg_index x, pg_class c, pg_class i WHERE ((((c.relkind = 'r'::"char") AND (i.relkind = 'i'::"char")) AND (c.oid = x.indrelid)) AND (i.oid = x.indexrelid));
- pg_rules | SELECT c.relname AS tablename, r.rulename, pg_get_ruledef(r.rulename) AS definition FROM pg_rewrite r, pg_class c WHERE ((r.rulename !~ '^_RET'::text) AND (c.oid = r.ev_class));
- pg_stats | SELECT c.relname AS tablename, a.attname, s.stanullfrac AS null_frac, s.stawidth AS avg_width, s.stadistinct AS n_distinct, CASE WHEN (1 = s.stakind1) THEN s.stavalues1 WHEN (1 = s.stakind2) THEN s.stavalues2 WHEN (1 = s.stakind3) THEN s.stavalues3 WHEN (1 = s.stakind4) THEN s.stavalues4 ELSE NULL::"_text" END AS most_common_vals, CASE WHEN (1 = s.stakind1) THEN s.stanumbers1 WHEN (1 = s.stakind2) THEN s.stanumbers2 WHEN (1 = s.stakind3) THEN s.stanumbers3 WHEN (1 = s.stakind4) THEN s.stanumbers4 ELSE NULL::"_float4" END AS most_common_freqs, CASE WHEN (2 = s.stakind1) THEN s.stavalues1 WHEN (2 = s.stakind2) THEN s.stavalues2 WHEN (2 = s.stakind3) THEN s.stavalues3 WHEN (2 = s.stakind4) THEN s.stavalues4 ELSE NULL::"_text" END AS histogram_bounds, CASE WHEN (3 = s.stakind1) THEN s.stanumbers1[1] WHEN (3 = s.stakind2) THEN s.stanumbers2[1] WHEN (3 = s.stakind3) THEN s.stanumbers3[1] WHEN (3 = s.stakind4) THEN s.stanumbers4[1] ELSE NULL::float4 END AS correlation FROM pg_class c, pg_attribute a, pg_statistic s WHERE ((((c.oid = s.starelid) AND (c.oid = a.attrelid)) AND (a.attnum = s.staattnum)) AND has_table_privilege(c.oid, 'select'::text));
- pg_tables | SELECT c.relname AS tablename, pg_get_userbyid(c.relowner) AS tableowner, c.relhasindex AS hasindexes, c.relhasrules AS hasrules, (c.reltriggers > 0) AS hastriggers FROM pg_class c WHERE ((c.relkind = 'r'::"char") OR (c.relkind = 's'::"char"));
- pg_user | SELECT pg_shadow.usename, pg_shadow.usesysid, pg_shadow.usecreatedb, pg_shadow.usetrace, pg_shadow.usesuper, pg_shadow.usecatupd, '********'::text AS passwd, pg_shadow.valuntil FROM pg_shadow;
- pg_views | SELECT c.relname AS viewname, pg_get_userbyid(c.relowner) AS viewowner, pg_get_viewdef(c.relname) AS definition FROM pg_class c WHERE (c.relkind = 'v'::"char");
- rtest_v1 | SELECT rtest_t1.a, rtest_t1.b FROM rtest_t1;
- rtest_vcomp | SELECT x.part, (x.size * y.factor) AS size_in_cm FROM rtest_comp x, rtest_unitfact y WHERE (x.unit = y.unit);
- rtest_vview1 | SELECT x.a, x.b FROM rtest_view1 x WHERE (0 < (SELECT count(*) AS count FROM rtest_view2 y WHERE (y.a = x.a)));
- rtest_vview2 | SELECT rtest_view1.a, rtest_view1.b FROM rtest_view1 WHERE rtest_view1.v;
- rtest_vview3 | SELECT x.a, x.b FROM rtest_vview2 x WHERE (0 < (SELECT count(*) AS count FROM rtest_view2 y WHERE (y.a = x.a)));
- rtest_vview4 | SELECT x.a, x.b, count(y.a) AS refcount FROM rtest_view1 x, rtest_view2 y WHERE (x.a = y.a) GROUP BY x.a, x.b;
- rtest_vview5 | SELECT rtest_view1.a, rtest_view1.b, rtest_viewfunc1(rtest_view1.a) AS refcount FROM rtest_view1;
- shoe | SELECT sh.shoename, sh.sh_avail, sh.slcolor, sh.slminlen, (sh.slminlen * un.un_fact) AS slminlen_cm, sh.slmaxlen, (sh.slmaxlen * un.un_fact) AS slmaxlen_cm, sh.slunit FROM shoe_data sh, unit un WHERE (sh.slunit = un.un_name);
- shoe_ready | SELECT rsh.shoename, rsh.sh_avail, rsl.sl_name, rsl.sl_avail, int4smaller(rsh.sh_avail, rsl.sl_avail) AS total_avail FROM shoe rsh, shoelace rsl WHERE (((rsl.sl_color = rsh.slcolor) AND (rsl.sl_len_cm >= rsh.slminlen_cm)) AND (rsl.sl_len_cm <= rsh.slmaxlen_cm));
- shoelace | SELECT s.sl_name, s.sl_avail, s.sl_color, s.sl_len, s.sl_unit, (s.sl_len * u.un_fact) AS sl_len_cm FROM shoelace_data s, unit u WHERE (s.sl_unit = u.un_name);
- shoelace_candelete | SELECT shoelace_obsolete.sl_name, shoelace_obsolete.sl_avail, shoelace_obsolete.sl_color, shoelace_obsolete.sl_len, shoelace_obsolete.sl_unit, shoelace_obsolete.sl_len_cm FROM shoelace_obsolete WHERE (shoelace_obsolete.sl_avail = 0);
- shoelace_obsolete | SELECT shoelace.sl_name, shoelace.sl_avail, shoelace.sl_color, shoelace.sl_len, shoelace.sl_unit, shoelace.sl_len_cm FROM shoelace WHERE (NOT (EXISTS (SELECT shoe.shoename FROM shoe WHERE (shoe.slcolor = shoelace.sl_color))));
- street | SELECT r.name, r.thepath, c.cname FROM ONLY road r, real_city c WHERE (c.outline ## r.thepath);
- toyemp | SELECT emp.name, emp.age, emp."location", (12 * emp.salary) AS annualsal FROM emp;
-(21 rows)
+ viewname | definition
+--------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ iexit | SELECT ih.name, ih.thepath, interpt_pp(ih.thepath, r.thepath) AS exit FROM ihighway ih, ramp r WHERE (ih.thepath ## r.thepath);
+ pg_indexes | SELECT c.relname AS tablename, i.relname AS indexname, pg_get_indexdef(x.indexrelid) AS indexdef FROM pg_index x, pg_class c, pg_class i WHERE ((((c.relkind = 'r'::"char") AND (i.relkind = 'i'::"char")) AND (c.oid = x.indrelid)) AND (i.oid = x.indexrelid));
+ pg_rules | SELECT c.relname AS tablename, r.rulename, pg_get_ruledef(r.rulename) AS definition FROM pg_rewrite r, pg_class c WHERE ((r.rulename !~ '^_RET'::text) AND (c.oid = r.ev_class));
+ pg_stat_activity | SELECT d.oid AS datid, d.datname, pg_stat_get_backend_pid(s.backendid) AS procpid, pg_stat_get_backend_userid(s.backendid) AS usesysid, u.usename, pg_stat_get_backend_activity(s.backendid) AS current_query FROM pg_database d, (SELECT pg_stat_get_backend_idset() AS backendid) s, pg_shadow u WHERE ((pg_stat_get_backend_dbid(s.backendid) = d.oid) AND (pg_stat_get_backend_userid(s.backendid) = u.usesysid));
+ pg_stat_all_indexes | SELECT c.oid AS relid, i.oid AS indexrelid, c.relname, i.relname AS indexrelname, pg_stat_get_numscans(i.oid) AS idx_scan, pg_stat_get_tuples_returned(i.oid) AS idx_tup_read, pg_stat_get_tuples_fetched(i.oid) AS idx_tup_fetch FROM pg_class c, pg_class i, pg_index x WHERE (((c.relkind = 'r'::"char") AND (x.indrelid = c.oid)) AND (x.indexrelid = i.oid));
+ pg_stat_all_tables | SELECT c.oid AS relid, c.relname, pg_stat_get_numscans(c.oid) AS seq_scan, pg_stat_get_tuples_returned(c.oid) AS seq_tup_read, sum(pg_stat_get_numscans(i.indexrelid)) AS idx_scan, sum(pg_stat_get_tuples_fetched(i.indexrelid)) AS idx_tup_fetch, pg_stat_get_tuples_inserted(c.oid) AS n_tup_ins, pg_stat_get_tuples_updated(c.oid) AS n_tup_upd, pg_stat_get_tuples_deleted(c.oid) AS n_tup_del FROM (pg_class c FULL JOIN pg_index i ON ((c.oid = i.indrelid))) WHERE (c.relkind = 'r'::"char") GROUP BY c.oid, c.relname;
+ pg_stat_database | SELECT d.oid AS datid, d.datname, pg_stat_get_db_numbackends(d.oid) AS numbackends, pg_stat_get_db_xact_commit(d.oid) AS xact_commit, pg_stat_get_db_xact_rollback(d.oid) AS xact_rollback, (pg_stat_get_db_blocks_fetched(d.oid) - 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;
+ pg_stat_sys_indexes | SELECT pg_stat_all_indexes.relid, pg_stat_all_indexes.indexrelid, pg_stat_all_indexes.relname, pg_stat_all_indexes.indexrelname, pg_stat_all_indexes.idx_scan, pg_stat_all_indexes.idx_tup_read, pg_stat_all_indexes.idx_tup_fetch FROM pg_stat_all_indexes WHERE (pg_stat_all_indexes.relname ~ '^pg_'::text);
+ pg_stat_sys_tables | SELECT pg_stat_all_tables.relid, pg_stat_all_tables.relname, pg_stat_all_tables.seq_scan, pg_stat_all_tables.seq_tup_read, pg_stat_all_tables.idx_scan, pg_stat_all_tables.idx_tup_fetch, pg_stat_all_tables.n_tup_ins, pg_stat_all_tables.n_tup_upd, pg_stat_all_tables.n_tup_del FROM pg_stat_all_tables WHERE (pg_stat_all_tables.relname ~ '^pg_'::text);
+ pg_stat_user_indexes | SELECT pg_stat_all_indexes.relid, pg_stat_all_indexes.indexrelid, pg_stat_all_indexes.relname, pg_stat_all_indexes.indexrelname, pg_stat_all_indexes.idx_scan, pg_stat_all_indexes.idx_tup_read, pg_stat_all_indexes.idx_tup_fetch FROM pg_stat_all_indexes WHERE (pg_stat_all_indexes.relname !~ '^pg_'::text);
+ pg_stat_user_tables | SELECT pg_stat_all_tables.relid, pg_stat_all_tables.relname, pg_stat_all_tables.seq_scan, pg_stat_all_tables.seq_tup_read, pg_stat_all_tables.idx_scan, pg_stat_all_tables.idx_tup_fetch, pg_stat_all_tables.n_tup_ins, pg_stat_all_tables.n_tup_upd, pg_stat_all_tables.n_tup_del FROM pg_stat_all_tables WHERE (pg_stat_all_tables.relname !~ '^pg_'::text);
+ pg_statio_all_indexes | SELECT c.oid AS relid, i.oid AS indexrelid, c.relname, i.relname AS indexrelname, (pg_stat_get_blocks_fetched(i.oid) - pg_stat_get_blocks_hit(i.oid)) AS idx_blks_read, pg_stat_get_blocks_hit(i.oid) AS idx_blks_hit FROM pg_class c, pg_class i, pg_index x WHERE (((c.relkind = 'r'::"char") AND (x.indrelid = c.oid)) AND (x.indexrelid = i.oid));
+ pg_statio_all_sequences | SELECT c.oid AS relid, c.relname, (pg_stat_get_blocks_fetched(c.oid) - pg_stat_get_blocks_hit(c.oid)) AS blks_read, pg_stat_get_blocks_hit(c.oid) AS blks_hit FROM pg_class c WHERE (c.relkind = 'S'::"char");
+ pg_statio_all_tables | SELECT c.oid AS relid, c.relname, (pg_stat_get_blocks_fetched(c.oid) - pg_stat_get_blocks_hit(c.oid)) AS heap_blks_read, pg_stat_get_blocks_hit(c.oid) AS heap_blks_hit, sum((pg_stat_get_blocks_fetched(i.indexrelid) - pg_stat_get_blocks_hit(i.indexrelid))) AS idx_blks_read, sum(pg_stat_get_blocks_hit(i.indexrelid)) AS idx_blks_hit, (pg_stat_get_blocks_fetched(t.oid) - pg_stat_get_blocks_hit(t.oid)) AS toast_blks_read, pg_stat_get_blocks_hit(t.oid) AS toast_blks_hit, (pg_stat_get_blocks_fetched(x.oid) - pg_stat_get_blocks_hit(x.oid)) AS tidx_blks_read, pg_stat_get_blocks_hit(x.oid) AS tidx_blks_hit FROM (((pg_class c FULL JOIN pg_index i ON ((c.oid = i.indrelid))) FULL JOIN pg_class t ON ((c.reltoastrelid = t.oid))) FULL JOIN pg_class x ON ((c.reltoastidxid = x.oid))) WHERE (c.relkind = 'r'::"char") GROUP BY c.oid, c.relname, t.oid, x.oid;
+ pg_statio_sys_indexes | SELECT pg_statio_all_indexes.relid, pg_statio_all_indexes.indexrelid, pg_statio_all_indexes.relname, pg_statio_all_indexes.indexrelname, pg_statio_all_indexes.idx_blks_read, pg_statio_all_indexes.idx_blks_hit FROM pg_statio_all_indexes WHERE (pg_statio_all_indexes.relname ~ '^pg_'::text);
+ pg_statio_sys_sequences | SELECT pg_statio_all_sequences.relid, pg_statio_all_sequences.relname, pg_statio_all_sequences.blks_read, pg_statio_all_sequences.blks_hit FROM pg_statio_all_sequences WHERE (pg_statio_all_sequences.relname ~ '^pg_'::text);
+ pg_statio_sys_tables | SELECT pg_statio_all_tables.relid, pg_statio_all_tables.relname, pg_statio_all_tables.heap_blks_read, pg_statio_all_tables.heap_blks_hit, pg_statio_all_tables.idx_blks_read, pg_statio_all_tables.idx_blks_hit, pg_statio_all_tables.toast_blks_read, pg_statio_all_tables.toast_blks_hit, pg_statio_all_tables.tidx_blks_read, pg_statio_all_tables.tidx_blks_hit FROM pg_statio_all_tables WHERE (pg_statio_all_tables.relname ~ '^pg_'::text);
+ pg_statio_user_indexes | SELECT pg_statio_all_indexes.relid, pg_statio_all_indexes.indexrelid, pg_statio_all_indexes.relname, pg_statio_all_indexes.indexrelname, pg_statio_all_indexes.idx_blks_read, pg_statio_all_indexes.idx_blks_hit FROM pg_statio_all_indexes WHERE (pg_statio_all_indexes.relname !~ '^pg_'::text);
+ pg_statio_user_sequences | SELECT pg_statio_all_sequences.relid, pg_statio_all_sequences.relname, pg_statio_all_sequences.blks_read, pg_statio_all_sequences.blks_hit FROM pg_statio_all_sequences WHERE (pg_statio_all_sequences.relname !~ '^pg_'::text);
+ pg_statio_user_tables | SELECT pg_statio_all_tables.relid, pg_statio_all_tables.relname, pg_statio_all_tables.heap_blks_read, pg_statio_all_tables.heap_blks_hit, pg_statio_all_tables.idx_blks_read, pg_statio_all_tables.idx_blks_hit, pg_statio_all_tables.toast_blks_read, pg_statio_all_tables.toast_blks_hit, pg_statio_all_tables.tidx_blks_read, pg_statio_all_tables.tidx_blks_hit FROM pg_statio_all_tables WHERE (pg_statio_all_tables.relname !~ '^pg_'::text);
+ pg_stats | SELECT c.relname AS tablename, a.attname, s.stanullfrac AS null_frac, s.stawidth AS avg_width, s.stadistinct AS n_distinct, CASE WHEN (1 = s.stakind1) THEN s.stavalues1 WHEN (1 = s.stakind2) THEN s.stavalues2 WHEN (1 = s.stakind3) THEN s.stavalues3 WHEN (1 = s.stakind4) THEN s.stavalues4 ELSE NULL::"_text" END AS most_common_vals, CASE WHEN (1 = s.stakind1) THEN s.stanumbers1 WHEN (1 = s.stakind2) THEN s.stanumbers2 WHEN (1 = s.stakind3) THEN s.stanumbers3 WHEN (1 = s.stakind4) THEN s.stanumbers4 ELSE NULL::"_float4" END AS most_common_freqs, CASE WHEN (2 = s.stakind1) THEN s.stavalues1 WHEN (2 = s.stakind2) THEN s.stavalues2 WHEN (2 = s.stakind3) THEN s.stavalues3 WHEN (2 = s.stakind4) THEN s.stavalues4 ELSE NULL::"_text" END AS histogram_bounds, CASE WHEN (3 = s.stakind1) THEN s.stanumbers1[1] WHEN (3 = s.stakind2) THEN s.stanumbers2[1] WHEN (3 = s.stakind3) THEN s.stanumbers3[1] WHEN (3 = s.stakind4) THEN s.stanumbers4[1] ELSE NULL::float4 END AS correlation FROM pg_class c, pg_attribute a, pg_statistic s WHERE ((((c.oid = s.starelid) AND (c.oid = a.attrelid)) AND (a.attnum = s.staattnum)) AND has_table_privilege(c.oid, 'select'::text));
+ pg_tables | SELECT c.relname AS tablename, pg_get_userbyid(c.relowner) AS tableowner, c.relhasindex AS hasindexes, c.relhasrules AS hasrules, (c.reltriggers > 0) AS hastriggers FROM pg_class c WHERE ((c.relkind = 'r'::"char") OR (c.relkind = 's'::"char"));
+ pg_user | SELECT pg_shadow.usename, pg_shadow.usesysid, pg_shadow.usecreatedb, pg_shadow.usetrace, pg_shadow.usesuper, pg_shadow.usecatupd, '********'::text AS passwd, pg_shadow.valuntil FROM pg_shadow;
+ pg_views | SELECT c.relname AS viewname, pg_get_userbyid(c.relowner) AS viewowner, pg_get_viewdef(c.relname) AS definition FROM pg_class c WHERE (c.relkind = 'v'::"char");
+ rtest_v1 | SELECT rtest_t1.a, rtest_t1.b FROM rtest_t1;
+ rtest_vcomp | SELECT x.part, (x.size * y.factor) AS size_in_cm FROM rtest_comp x, rtest_unitfact y WHERE (x.unit = y.unit);
+ rtest_vview1 | SELECT x.a, x.b FROM rtest_view1 x WHERE (0 < (SELECT count(*) AS count FROM rtest_view2 y WHERE (y.a = x.a)));
+ rtest_vview2 | SELECT rtest_view1.a, rtest_view1.b FROM rtest_view1 WHERE rtest_view1.v;
+ rtest_vview3 | SELECT x.a, x.b FROM rtest_vview2 x WHERE (0 < (SELECT count(*) AS count FROM rtest_view2 y WHERE (y.a = x.a)));
+ rtest_vview4 | SELECT x.a, x.b, count(y.a) AS refcount FROM rtest_view1 x, rtest_view2 y WHERE (x.a = y.a) GROUP BY x.a, x.b;
+ rtest_vview5 | SELECT rtest_view1.a, rtest_view1.b, rtest_viewfunc1(rtest_view1.a) AS refcount FROM rtest_view1;
+ shoe | SELECT sh.shoename, sh.sh_avail, sh.slcolor, sh.slminlen, (sh.slminlen * un.un_fact) AS slminlen_cm, sh.slmaxlen, (sh.slmaxlen * un.un_fact) AS slmaxlen_cm, sh.slunit FROM shoe_data sh, unit un WHERE (sh.slunit = un.un_name);
+ shoe_ready | SELECT rsh.shoename, rsh.sh_avail, rsl.sl_name, rsl.sl_avail, int4smaller(rsh.sh_avail, rsl.sl_avail) AS total_avail FROM shoe rsh, shoelace rsl WHERE (((rsl.sl_color = rsh.slcolor) AND (rsl.sl_len_cm >= rsh.slminlen_cm)) AND (rsl.sl_len_cm <= rsh.slmaxlen_cm));
+ shoelace | SELECT s.sl_name, s.sl_avail, s.sl_color, s.sl_len, s.sl_unit, (s.sl_len * u.un_fact) AS sl_len_cm FROM shoelace_data s, unit u WHERE (s.sl_unit = u.un_name);
+ shoelace_candelete | SELECT shoelace_obsolete.sl_name, shoelace_obsolete.sl_avail, shoelace_obsolete.sl_color, shoelace_obsolete.sl_len, shoelace_obsolete.sl_unit, shoelace_obsolete.sl_len_cm FROM shoelace_obsolete WHERE (shoelace_obsolete.sl_avail = 0);
+ shoelace_obsolete | SELECT shoelace.sl_name, shoelace.sl_avail, shoelace.sl_color, shoelace.sl_len, shoelace.sl_unit, shoelace.sl_len_cm FROM shoelace WHERE (NOT (EXISTS (SELECT shoe.shoename FROM shoe WHERE (shoe.slcolor = shoelace.sl_color))));
+ street | SELECT r.name, r.thepath, c.cname FROM ONLY road r, real_city c WHERE (c.outline ## r.thepath);
+ toyemp | SELECT emp.name, emp.age, emp."location", (12 * emp.salary) AS annualsal FROM emp;
+(38 rows)
SELECT tablename, rulename, definition FROM pg_rules
ORDER BY tablename, rulename;