Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
01e62da1
Commit
01e62da1
authored
Nov 13, 2003
by
Tom Lane
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Dunno why this got committed with DOS newlines, but fix that, and
add a header comment/copyright notice.
parent
c7bfc7df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
273 additions
and
270 deletions
+273
-270
src/backend/catalog/system_views.sql
src/backend/catalog/system_views.sql
+273
-270
No files found.
src/backend/catalog/system_views.sql
View file @
01e62da1
/*
* PostgreSQL System Views
*
CREATE
VIEW
pg_user
AS
* Copyright 1996-2003, PostgreSQL Global Development Group
SELECT
*
usename
,
* $Id: system_views.sql,v 1.2 2003/11/13 22:13:39 tgl Exp $
usesysid
,
*/
usecreatedb
,
usesuper
,
CREATE
VIEW
pg_user
AS
usecatupd
,
SELECT
'********'
::
text
as
passwd
,
usename
,
valuntil
,
usesysid
,
useconfig
usecreatedb
,
FROM
pg_shadow
;
usesuper
,
usecatupd
,
CREATE
VIEW
pg_rules
AS
'********'
::
text
as
passwd
,
SELECT
valuntil
,
N
.
nspname
AS
schemaname
,
useconfig
C
.
relname
AS
tablename
,
FROM
pg_shadow
;
R
.
rulename
AS
rulename
,
pg_get_ruledef
(
R
.
oid
)
AS
definition
CREATE
VIEW
pg_rules
AS
FROM
(
pg_rewrite
R
JOIN
pg_class
C
ON
(
C
.
oid
=
R
.
ev_class
))
SELECT
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
N
.
nspname
AS
schemaname
,
WHERE
R
.
rulename
!=
'_RETURN'
;
C
.
relname
AS
tablename
,
R
.
rulename
AS
rulename
,
CREATE
VIEW
pg_views
AS
pg_get_ruledef
(
R
.
oid
)
AS
definition
SELECT
FROM
(
pg_rewrite
R
JOIN
pg_class
C
ON
(
C
.
oid
=
R
.
ev_class
))
N
.
nspname
AS
schemaname
,
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
C
.
relname
AS
viewname
,
WHERE
R
.
rulename
!=
'_RETURN'
;
pg_get_userbyid
(
C
.
relowner
)
AS
viewowner
,
pg_get_viewdef
(
C
.
oid
)
AS
definition
CREATE
VIEW
pg_views
AS
FROM
pg_class
C
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
SELECT
WHERE
C
.
relkind
=
'v'
;
N
.
nspname
AS
schemaname
,
C
.
relname
AS
viewname
,
CREATE
VIEW
pg_tables
AS
pg_get_userbyid
(
C
.
relowner
)
AS
viewowner
,
SELECT
pg_get_viewdef
(
C
.
oid
)
AS
definition
N
.
nspname
AS
schemaname
,
FROM
pg_class
C
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
C
.
relname
AS
tablename
,
WHERE
C
.
relkind
=
'v'
;
pg_get_userbyid
(
C
.
relowner
)
AS
tableowner
,
C
.
relhasindex
AS
hasindexes
,
CREATE
VIEW
pg_tables
AS
C
.
relhasrules
AS
hasrules
,
SELECT
(
C
.
reltriggers
>
0
)
AS
hastriggers
N
.
nspname
AS
schemaname
,
FROM
pg_class
C
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
C
.
relname
AS
tablename
,
WHERE
C
.
relkind
=
'r'
;
pg_get_userbyid
(
C
.
relowner
)
AS
tableowner
,
C
.
relhasindex
AS
hasindexes
,
CREATE
VIEW
pg_indexes
AS
C
.
relhasrules
AS
hasrules
,
SELECT
(
C
.
reltriggers
>
0
)
AS
hastriggers
N
.
nspname
AS
schemaname
,
FROM
pg_class
C
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
C
.
relname
AS
tablename
,
WHERE
C
.
relkind
=
'r'
;
I
.
relname
AS
indexname
,
pg_get_indexdef
(
I
.
oid
)
AS
indexdef
CREATE
VIEW
pg_indexes
AS
FROM
pg_index
X
JOIN
pg_class
C
ON
(
C
.
oid
=
X
.
indrelid
)
SELECT
JOIN
pg_class
I
ON
(
I
.
oid
=
X
.
indexrelid
)
N
.
nspname
AS
schemaname
,
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
C
.
relname
AS
tablename
,
WHERE
C
.
relkind
=
'r'
AND
I
.
relkind
=
'i'
;
I
.
relname
AS
indexname
,
pg_get_indexdef
(
I
.
oid
)
AS
indexdef
CREATE
VIEW
pg_stats
AS
FROM
pg_index
X
JOIN
pg_class
C
ON
(
C
.
oid
=
X
.
indrelid
)
SELECT
JOIN
pg_class
I
ON
(
I
.
oid
=
X
.
indexrelid
)
nspname
AS
schemaname
,
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
relname
AS
tablename
,
WHERE
C
.
relkind
=
'r'
AND
I
.
relkind
=
'i'
;
attname
AS
attname
,
stanullfrac
AS
null_frac
,
CREATE
VIEW
pg_stats
AS
stawidth
AS
avg_width
,
SELECT
stadistinct
AS
n_distinct
,
nspname
AS
schemaname
,
CASE
1
relname
AS
tablename
,
WHEN
stakind1
THEN
stavalues1
attname
AS
attname
,
WHEN
stakind2
THEN
stavalues2
stanullfrac
AS
null_frac
,
WHEN
stakind3
THEN
stavalues3
stawidth
AS
avg_width
,
WHEN
stakind4
THEN
stavalues4
stadistinct
AS
n_distinct
,
END
AS
most_common_vals
,
CASE
1
CASE
1
WHEN
stakind1
THEN
stavalues1
WHEN
stakind1
THEN
stanumbers1
WHEN
stakind2
THEN
stavalues2
WHEN
stakind2
THEN
stanumbers2
WHEN
stakind3
THEN
stavalues3
WHEN
stakind3
THEN
stanumbers3
WHEN
stakind4
THEN
stavalues4
WHEN
stakind4
THEN
stanumbers4
END
AS
most_common_vals
,
END
AS
most_common_freqs
,
CASE
1
CASE
2
WHEN
stakind1
THEN
stanumbers1
WHEN
stakind1
THEN
stavalues1
WHEN
stakind2
THEN
stanumbers2
WHEN
stakind2
THEN
stavalues2
WHEN
stakind3
THEN
stanumbers3
WHEN
stakind3
THEN
stavalues3
WHEN
stakind4
THEN
stanumbers4
WHEN
stakind4
THEN
stavalues4
END
AS
most_common_freqs
,
END
AS
histogram_bounds
,
CASE
2
CASE
3
WHEN
stakind1
THEN
stavalues1
WHEN
stakind1
THEN
stanumbers1
[
1
]
WHEN
stakind2
THEN
stavalues2
WHEN
stakind2
THEN
stanumbers2
[
1
]
WHEN
stakind3
THEN
stavalues3
WHEN
stakind3
THEN
stanumbers3
[
1
]
WHEN
stakind4
THEN
stavalues4
WHEN
stakind4
THEN
stanumbers4
[
1
]
END
AS
histogram_bounds
,
END
AS
correlation
CASE
3
FROM
pg_statistic
s
JOIN
pg_class
c
ON
(
c
.
oid
=
s
.
starelid
)
WHEN
stakind1
THEN
stanumbers1
[
1
]
JOIN
pg_attribute
a
ON
(
c
.
oid
=
attrelid
AND
attnum
=
s
.
staattnum
)
WHEN
stakind2
THEN
stanumbers2
[
1
]
LEFT
JOIN
pg_namespace
n
ON
(
n
.
oid
=
c
.
relnamespace
)
WHEN
stakind3
THEN
stanumbers3
[
1
]
WHERE
has_table_privilege
(
c
.
oid
,
'select'
);
WHEN
stakind4
THEN
stanumbers4
[
1
]
END
AS
correlation
REVOKE
ALL
on
pg_statistic
FROM
public
;
FROM
pg_statistic
s
JOIN
pg_class
c
ON
(
c
.
oid
=
s
.
starelid
)
JOIN
pg_attribute
a
ON
(
c
.
oid
=
attrelid
AND
attnum
=
s
.
staattnum
)
CREATE
VIEW
pg_stat_all_tables
AS
LEFT
JOIN
pg_namespace
n
ON
(
n
.
oid
=
c
.
relnamespace
)
SELECT
WHERE
has_table_privilege
(
c
.
oid
,
'select'
);
C
.
oid
AS
relid
,
N
.
nspname
AS
schemaname
,
REVOKE
ALL
on
pg_statistic
FROM
public
;
C
.
relname
AS
relname
,
pg_stat_get_numscans
(
C
.
oid
)
AS
seq_scan
,
CREATE
VIEW
pg_stat_all_tables
AS
pg_stat_get_tuples_returned
(
C
.
oid
)
AS
seq_tup_read
,
SELECT
sum
(
pg_stat_get_numscans
(
I
.
indexrelid
))
AS
idx_scan
,
C
.
oid
AS
relid
,
sum
(
pg_stat_get_tuples_fetched
(
I
.
indexrelid
))
AS
idx_tup_fetch
,
N
.
nspname
AS
schemaname
,
pg_stat_get_tuples_inserted
(
C
.
oid
)
AS
n_tup_ins
,
C
.
relname
AS
relname
,
pg_stat_get_tuples_updated
(
C
.
oid
)
AS
n_tup_upd
,
pg_stat_get_numscans
(
C
.
oid
)
AS
seq_scan
,
pg_stat_get_tuples_deleted
(
C
.
oid
)
AS
n_tup_del
pg_stat_get_tuples_returned
(
C
.
oid
)
AS
seq_tup_read
,
FROM
pg_class
C
LEFT
JOIN
sum
(
pg_stat_get_numscans
(
I
.
indexrelid
))
AS
idx_scan
,
pg_index
I
ON
C
.
oid
=
I
.
indrelid
sum
(
pg_stat_get_tuples_fetched
(
I
.
indexrelid
))
AS
idx_tup_fetch
,
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
pg_stat_get_tuples_inserted
(
C
.
oid
)
AS
n_tup_ins
,
WHERE
C
.
relkind
=
'r'
pg_stat_get_tuples_updated
(
C
.
oid
)
AS
n_tup_upd
,
GROUP
BY
C
.
oid
,
N
.
nspname
,
C
.
relname
;
pg_stat_get_tuples_deleted
(
C
.
oid
)
AS
n_tup_del
FROM
pg_class
C
LEFT
JOIN
CREATE
VIEW
pg_stat_sys_tables
AS
pg_index
I
ON
C
.
oid
=
I
.
indrelid
SELECT
*
FROM
pg_stat_all_tables
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
WHERE
schemaname
IN
(
'pg_catalog'
,
'pg_toast'
);
WHERE
C
.
relkind
=
'r'
GROUP
BY
C
.
oid
,
N
.
nspname
,
C
.
relname
;
CREATE
VIEW
pg_stat_user_tables
AS
SELECT
*
FROM
pg_stat_all_tables
CREATE
VIEW
pg_stat_sys_tables
AS
WHERE
schemaname
NOT
IN
(
'pg_catalog'
,
'pg_toast'
);
SELECT
*
FROM
pg_stat_all_tables
WHERE
schemaname
IN
(
'pg_catalog'
,
'pg_toast'
);
CREATE
VIEW
pg_statio_all_tables
AS
SELECT
CREATE
VIEW
pg_stat_user_tables
AS
C
.
oid
AS
relid
,
SELECT
*
FROM
pg_stat_all_tables
N
.
nspname
AS
schemaname
,
WHERE
schemaname
NOT
IN
(
'pg_catalog'
,
'pg_toast'
);
C
.
relname
AS
relname
,
pg_stat_get_blocks_fetched
(
C
.
oid
)
-
CREATE
VIEW
pg_statio_all_tables
AS
pg_stat_get_blocks_hit
(
C
.
oid
)
AS
heap_blks_read
,
SELECT
pg_stat_get_blocks_hit
(
C
.
oid
)
AS
heap_blks_hit
,
C
.
oid
AS
relid
,
sum
(
pg_stat_get_blocks_fetched
(
I
.
indexrelid
)
-
N
.
nspname
AS
schemaname
,
pg_stat_get_blocks_hit
(
I
.
indexrelid
))
AS
idx_blks_read
,
C
.
relname
AS
relname
,
sum
(
pg_stat_get_blocks_hit
(
I
.
indexrelid
))
AS
idx_blks_hit
,
pg_stat_get_blocks_fetched
(
C
.
oid
)
-
pg_stat_get_blocks_fetched
(
T
.
oid
)
-
pg_stat_get_blocks_hit
(
C
.
oid
)
AS
heap_blks_read
,
pg_stat_get_blocks_hit
(
T
.
oid
)
AS
toast_blks_read
,
pg_stat_get_blocks_hit
(
C
.
oid
)
AS
heap_blks_hit
,
pg_stat_get_blocks_hit
(
T
.
oid
)
AS
toast_blks_hit
,
sum
(
pg_stat_get_blocks_fetched
(
I
.
indexrelid
)
-
pg_stat_get_blocks_fetched
(
X
.
oid
)
-
pg_stat_get_blocks_hit
(
I
.
indexrelid
))
AS
idx_blks_read
,
pg_stat_get_blocks_hit
(
X
.
oid
)
AS
tidx_blks_read
,
sum
(
pg_stat_get_blocks_hit
(
I
.
indexrelid
))
AS
idx_blks_hit
,
pg_stat_get_blocks_hit
(
X
.
oid
)
AS
tidx_blks_hit
pg_stat_get_blocks_fetched
(
T
.
oid
)
-
FROM
pg_class
C
LEFT
JOIN
pg_stat_get_blocks_hit
(
T
.
oid
)
AS
toast_blks_read
,
pg_index
I
ON
C
.
oid
=
I
.
indrelid
LEFT
JOIN
pg_stat_get_blocks_hit
(
T
.
oid
)
AS
toast_blks_hit
,
pg_class
T
ON
C
.
reltoastrelid
=
T
.
oid
LEFT
JOIN
pg_stat_get_blocks_fetched
(
X
.
oid
)
-
pg_class
X
ON
T
.
reltoastidxid
=
X
.
oid
pg_stat_get_blocks_hit
(
X
.
oid
)
AS
tidx_blks_read
,
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
pg_stat_get_blocks_hit
(
X
.
oid
)
AS
tidx_blks_hit
WHERE
C
.
relkind
=
'r'
FROM
pg_class
C
LEFT
JOIN
GROUP
BY
C
.
oid
,
N
.
nspname
,
C
.
relname
,
T
.
oid
,
X
.
oid
;
pg_index
I
ON
C
.
oid
=
I
.
indrelid
LEFT
JOIN
pg_class
T
ON
C
.
reltoastrelid
=
T
.
oid
LEFT
JOIN
CREATE
VIEW
pg_statio_sys_tables
AS
pg_class
X
ON
T
.
reltoastidxid
=
X
.
oid
SELECT
*
FROM
pg_statio_all_tables
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
WHERE
schemaname
IN
(
'pg_catalog'
,
'pg_toast'
);
WHERE
C
.
relkind
=
'r'
GROUP
BY
C
.
oid
,
N
.
nspname
,
C
.
relname
,
T
.
oid
,
X
.
oid
;
CREATE
VIEW
pg_statio_user_tables
AS
SELECT
*
FROM
pg_statio_all_tables
CREATE
VIEW
pg_statio_sys_tables
AS
WHERE
schemaname
NOT
IN
(
'pg_catalog'
,
'pg_toast'
);
SELECT
*
FROM
pg_statio_all_tables
WHERE
schemaname
IN
(
'pg_catalog'
,
'pg_toast'
);
CREATE
VIEW
pg_stat_all_indexes
AS
SELECT
CREATE
VIEW
pg_statio_user_tables
AS
C
.
oid
AS
relid
,
SELECT
*
FROM
pg_statio_all_tables
I
.
oid
AS
indexrelid
,
WHERE
schemaname
NOT
IN
(
'pg_catalog'
,
'pg_toast'
);
N
.
nspname
AS
schemaname
,
C
.
relname
AS
relname
,
CREATE
VIEW
pg_stat_all_indexes
AS
I
.
relname
AS
indexrelname
,
SELECT
pg_stat_get_numscans
(
I
.
oid
)
AS
idx_scan
,
C
.
oid
AS
relid
,
pg_stat_get_tuples_returned
(
I
.
oid
)
AS
idx_tup_read
,
I
.
oid
AS
indexrelid
,
pg_stat_get_tuples_fetched
(
I
.
oid
)
AS
idx_tup_fetch
N
.
nspname
AS
schemaname
,
FROM
pg_class
C
JOIN
C
.
relname
AS
relname
,
pg_index
X
ON
C
.
oid
=
X
.
indrelid
JOIN
I
.
relname
AS
indexrelname
,
pg_class
I
ON
I
.
oid
=
X
.
indexrelid
pg_stat_get_numscans
(
I
.
oid
)
AS
idx_scan
,
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
pg_stat_get_tuples_returned
(
I
.
oid
)
AS
idx_tup_read
,
WHERE
C
.
relkind
=
'r'
;
pg_stat_get_tuples_fetched
(
I
.
oid
)
AS
idx_tup_fetch
FROM
pg_class
C
JOIN
CREATE
VIEW
pg_stat_sys_indexes
AS
pg_index
X
ON
C
.
oid
=
X
.
indrelid
JOIN
SELECT
*
FROM
pg_stat_all_indexes
pg_class
I
ON
I
.
oid
=
X
.
indexrelid
WHERE
schemaname
IN
(
'pg_catalog'
,
'pg_toast'
);
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
WHERE
C
.
relkind
=
'r'
;
CREATE
VIEW
pg_stat_user_indexes
AS
SELECT
*
FROM
pg_stat_all_indexes
CREATE
VIEW
pg_stat_sys_indexes
AS
WHERE
schemaname
NOT
IN
(
'pg_catalog'
,
'pg_toast'
);
SELECT
*
FROM
pg_stat_all_indexes
WHERE
schemaname
IN
(
'pg_catalog'
,
'pg_toast'
);
CREATE
VIEW
pg_statio_all_indexes
AS
SELECT
CREATE
VIEW
pg_stat_user_indexes
AS
C
.
oid
AS
relid
,
SELECT
*
FROM
pg_stat_all_indexes
I
.
oid
AS
indexrelid
,
WHERE
schemaname
NOT
IN
(
'pg_catalog'
,
'pg_toast'
);
N
.
nspname
AS
schemaname
,
C
.
relname
AS
relname
,
CREATE
VIEW
pg_statio_all_indexes
AS
I
.
relname
AS
indexrelname
,
SELECT
pg_stat_get_blocks_fetched
(
I
.
oid
)
-
C
.
oid
AS
relid
,
pg_stat_get_blocks_hit
(
I
.
oid
)
AS
idx_blks_read
,
I
.
oid
AS
indexrelid
,
pg_stat_get_blocks_hit
(
I
.
oid
)
AS
idx_blks_hit
N
.
nspname
AS
schemaname
,
FROM
pg_class
C
JOIN
C
.
relname
AS
relname
,
pg_index
X
ON
C
.
oid
=
X
.
indrelid
JOIN
I
.
relname
AS
indexrelname
,
pg_class
I
ON
I
.
oid
=
X
.
indexrelid
pg_stat_get_blocks_fetched
(
I
.
oid
)
-
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
pg_stat_get_blocks_hit
(
I
.
oid
)
AS
idx_blks_read
,
WHERE
C
.
relkind
=
'r'
;
pg_stat_get_blocks_hit
(
I
.
oid
)
AS
idx_blks_hit
FROM
pg_class
C
JOIN
CREATE
VIEW
pg_statio_sys_indexes
AS
pg_index
X
ON
C
.
oid
=
X
.
indrelid
JOIN
SELECT
*
FROM
pg_statio_all_indexes
pg_class
I
ON
I
.
oid
=
X
.
indexrelid
WHERE
schemaname
IN
(
'pg_catalog'
,
'pg_toast'
);
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
WHERE
C
.
relkind
=
'r'
;
CREATE
VIEW
pg_statio_user_indexes
AS
SELECT
*
FROM
pg_statio_all_indexes
CREATE
VIEW
pg_statio_sys_indexes
AS
WHERE
schemaname
NOT
IN
(
'pg_catalog'
,
'pg_toast'
);
SELECT
*
FROM
pg_statio_all_indexes
WHERE
schemaname
IN
(
'pg_catalog'
,
'pg_toast'
);
CREATE
VIEW
pg_statio_all_sequences
AS
SELECT
CREATE
VIEW
pg_statio_user_indexes
AS
C
.
oid
AS
relid
,
SELECT
*
FROM
pg_statio_all_indexes
N
.
nspname
AS
schemaname
,
WHERE
schemaname
NOT
IN
(
'pg_catalog'
,
'pg_toast'
);
C
.
relname
AS
relname
,
pg_stat_get_blocks_fetched
(
C
.
oid
)
-
CREATE
VIEW
pg_statio_all_sequences
AS
pg_stat_get_blocks_hit
(
C
.
oid
)
AS
blks_read
,
SELECT
pg_stat_get_blocks_hit
(
C
.
oid
)
AS
blks_hit
C
.
oid
AS
relid
,
FROM
pg_class
C
N
.
nspname
AS
schemaname
,
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
C
.
relname
AS
relname
,
WHERE
C
.
relkind
=
'S'
;
pg_stat_get_blocks_fetched
(
C
.
oid
)
-
pg_stat_get_blocks_hit
(
C
.
oid
)
AS
blks_read
,
CREATE
VIEW
pg_statio_sys_sequences
AS
pg_stat_get_blocks_hit
(
C
.
oid
)
AS
blks_hit
SELECT
*
FROM
pg_statio_all_sequences
FROM
pg_class
C
WHERE
schemaname
IN
(
'pg_catalog'
,
'pg_toast'
);
LEFT
JOIN
pg_namespace
N
ON
(
N
.
oid
=
C
.
relnamespace
)
WHERE
C
.
relkind
=
'S'
;
CREATE
VIEW
pg_statio_user_sequences
AS
SELECT
*
FROM
pg_statio_all_sequences
CREATE
VIEW
pg_statio_sys_sequences
AS
WHERE
schemaname
NOT
IN
(
'pg_catalog'
,
'pg_toast'
);
SELECT
*
FROM
pg_statio_all_sequences
WHERE
schemaname
IN
(
'pg_catalog'
,
'pg_toast'
);
CREATE
VIEW
pg_stat_activity
AS
SELECT
CREATE
VIEW
pg_statio_user_sequences
AS
D
.
oid
AS
datid
,
SELECT
*
FROM
pg_statio_all_sequences
D
.
datname
AS
datname
,
WHERE
schemaname
NOT
IN
(
'pg_catalog'
,
'pg_toast'
);
pg_stat_get_backend_pid
(
S
.
backendid
)
AS
procpid
,
pg_stat_get_backend_userid
(
S
.
backendid
)
AS
usesysid
,
CREATE
VIEW
pg_stat_activity
AS
U
.
usename
AS
usename
,
SELECT
pg_stat_get_backend_activity
(
S
.
backendid
)
AS
current_query
,
D
.
oid
AS
datid
,
pg_stat_get_backend_activity_start
(
S
.
backendid
)
AS
query_start
D
.
datname
AS
datname
,
FROM
pg_database
D
,
pg_stat_get_backend_pid
(
S
.
backendid
)
AS
procpid
,
(
SELECT
pg_stat_get_backend_idset
()
AS
backendid
)
AS
S
,
pg_stat_get_backend_userid
(
S
.
backendid
)
AS
usesysid
,
pg_shadow
U
U
.
usename
AS
usename
,
WHERE
pg_stat_get_backend_dbid
(
S
.
backendid
)
=
D
.
oid
AND
pg_stat_get_backend_activity
(
S
.
backendid
)
AS
current_query
,
pg_stat_get_backend_userid
(
S
.
backendid
)
=
U
.
usesysid
;
pg_stat_get_backend_activity_start
(
S
.
backendid
)
AS
query_start
FROM
pg_database
D
,
CREATE
VIEW
pg_stat_database
AS
(
SELECT
pg_stat_get_backend_idset
()
AS
backendid
)
AS
S
,
SELECT
pg_shadow
U
D
.
oid
AS
datid
,
WHERE
pg_stat_get_backend_dbid
(
S
.
backendid
)
=
D
.
oid
AND
D
.
datname
AS
datname
,
pg_stat_get_backend_userid
(
S
.
backendid
)
=
U
.
usesysid
;
pg_stat_get_db_numbackends
(
D
.
oid
)
AS
numbackends
,
pg_stat_get_db_xact_commit
(
D
.
oid
)
AS
xact_commit
,
CREATE
VIEW
pg_stat_database
AS
pg_stat_get_db_xact_rollback
(
D
.
oid
)
AS
xact_rollback
,
SELECT
pg_stat_get_db_blocks_fetched
(
D
.
oid
)
-
D
.
oid
AS
datid
,
pg_stat_get_db_blocks_hit
(
D
.
oid
)
AS
blks_read
,
D
.
datname
AS
datname
,
pg_stat_get_db_blocks_hit
(
D
.
oid
)
AS
blks_hit
pg_stat_get_db_numbackends
(
D
.
oid
)
AS
numbackends
,
FROM
pg_database
D
;
pg_stat_get_db_xact_commit
(
D
.
oid
)
AS
xact_commit
,
pg_stat_get_db_xact_rollback
(
D
.
oid
)
AS
xact_rollback
,
CREATE
VIEW
pg_locks
AS
pg_stat_get_db_blocks_fetched
(
D
.
oid
)
-
SELECT
*
pg_stat_get_db_blocks_hit
(
D
.
oid
)
AS
blks_read
,
FROM
pg_lock_status
()
AS
L
(
relation
oid
,
database
oid
,
pg_stat_get_db_blocks_hit
(
D
.
oid
)
AS
blks_hit
transaction
xid
,
pid
int4
,
mode
text
,
granted
boolean
);
FROM
pg_database
D
;
CREATE
VIEW
pg_settings
AS
CREATE
VIEW
pg_locks
AS
SELECT
*
SELECT
*
FROM
pg_show_all_settings
()
AS
A
FROM
pg_lock_status
()
AS
L
(
relation
oid
,
database
oid
,
(
name
text
,
setting
text
,
context
text
,
vartype
text
,
transaction
xid
,
pid
int4
,
mode
text
,
granted
boolean
);
source
text
,
min_val
text
,
max_val
text
);
CREATE
VIEW
pg_settings
AS
CREATE
RULE
pg_settings_u
AS
SELECT
*
ON
UPDATE
TO
pg_settings
FROM
pg_show_all_settings
()
AS
A
WHERE
new
.
name
=
old
.
name
DO
(
name
text
,
setting
text
,
context
text
,
vartype
text
,
SELECT
set_config
(
old
.
name
,
new
.
setting
,
'f'
);
source
text
,
min_val
text
,
max_val
text
);
CREATE
RULE
pg_settings_n
AS
CREATE
RULE
pg_settings_u
AS
ON
UPDATE
TO
pg_settings
ON
UPDATE
TO
pg_settings
DO
INSTEAD
NOTHING
;
WHERE
new
.
name
=
old
.
name
DO
SELECT
set_config
(
old
.
name
,
new
.
setting
,
'f'
);
CREATE
RULE
pg_settings_n
AS
ON
UPDATE
TO
pg_settings
DO
INSTEAD
NOTHING
;
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment