Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions docs/generated/sql/functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -3789,13 +3789,15 @@ may increase either contention or retry errors, or both.</p>
</span></td><td>Stable</td></tr>
<tr><td><a name="pg_has_role"></a><code>pg_has_role(user: oid, role: oid, privilege: <a href="string.html">string</a>) &rarr; <a href="bool.html">bool</a></code></td><td><span class="funcdesc"><p>Returns whether or not the user has privileges for role.</p>
</span></td><td>Stable</td></tr>
<tr><td><a name="pg_indexes_size"></a><code>pg_indexes_size(relation_oid: oid) &rarr; <a href="int.html">int</a></code></td><td><span class="funcdesc"><p>Returns the total on-disk size, in bytes, of the secondary indexes attached to the relation with the given OID. The primary index is excluded (it is reported by pg_relation_size and pg_table_size, since CockroachDB stores row data in the primary index). The size is read from a periodically-refreshed cache and may lag behind the true value by minutes.</p>
</span></td><td>Volatile</td></tr>
<tr><td><a name="pg_is_other_temp_schema"></a><code>pg_is_other_temp_schema(oid: oid) &rarr; <a href="bool.html">bool</a></code></td><td><span class="funcdesc"><p>Returns true if the given OID is the OID of another session’s temporary schema. (This can be useful, for example, to exclude other sessions’ temporary tables from a catalog display.)</p>
</span></td><td>Stable</td></tr>
<tr><td><a name="pg_my_temp_schema"></a><code>pg_my_temp_schema() &rarr; oid</code></td><td><span class="funcdesc"><p>Returns the OID of the current session’s temporary schema, or zero if it has none (because it has not created any temporary tables).</p>
</span></td><td>Stable</td></tr>
<tr><td><a name="pg_relation_is_updatable"></a><code>pg_relation_is_updatable(reloid: oid, include_triggers: <a href="bool.html">bool</a>) &rarr; int4</code></td><td><span class="funcdesc"><p>Returns the update events the relation supports.</p>
</span></td><td>Stable</td></tr>
<tr><td><a name="pg_relation_size"></a><code>pg_relation_size(relation_oid: oid) &rarr; <a href="int.html">int</a></code></td><td><span class="funcdesc"><p>Returns the on-disk size, in bytes, of the relation with the given OID. The size is read from a periodically-refreshed cache and may lag behind the true value by minutes. Returns NULL if no such relation exists.</p>
<tr><td><a name="pg_relation_size"></a><code>pg_relation_size(relation_oid: oid) &rarr; <a href="int.html">int</a></code></td><td><span class="funcdesc"><p>Returns the on-disk size, in bytes, of the relation with the given OID. For a table-class relation this is the primary index size (matching PG’s “heap only” semantics, since CockroachDB’s primary index is the row data). For an index this is the size of just that index. The size is read from a periodically-refreshed cache and may lag behind the true value by minutes. Returns NULL if no such relation is visible to the caller.</p>
</span></td><td>Volatile</td></tr>
<tr><td><a name="pg_sequence_last_value"></a><code>pg_sequence_last_value(sequence_oid: oid) &rarr; <a href="int.html">int</a></code></td><td><span class="funcdesc"><p>Returns the last value generated by a sequence, or NULL if the sequence has not been used yet.</p>
</span></td><td>Volatile</td></tr>
Expand All @@ -3809,9 +3811,9 @@ may increase either contention or retry errors, or both.</p>
</span></td><td>Volatile</td></tr>
<tr><td><a name="pg_table_is_visible"></a><code>pg_table_is_visible(oid: oid) &rarr; <a href="bool.html">bool</a></code></td><td><span class="funcdesc"><p>Returns whether the table with the given OID belongs to one of the schemas on the search path.</p>
</span></td><td>Stable</td></tr>
<tr><td><a name="pg_table_size"></a><code>pg_table_size(relation_oid: oid) &rarr; <a href="int.html">int</a></code></td><td><span class="funcdesc"><p>Returns the on-disk size, in bytes, of the table, including TOAST and visibility map (where applicable) with the given OID. The size is read from a periodically-refreshed cache and may lag behind the true value by minutes. Returns NULL if no such relation exists.</p>
<tr><td><a name="pg_table_size"></a><code>pg_table_size(relation_oid: oid) &rarr; <a href="int.html">int</a></code></td><td><span class="funcdesc"><p>Returns the on-disk size, in bytes, of the table with the given OID, excluding indexes. In CockroachDB this is the primary index size, since the primary index is the row data. The size is read from a periodically-refreshed cache and may lag behind the true value by minutes.</p>
</span></td><td>Volatile</td></tr>
<tr><td><a name="pg_total_relation_size"></a><code>pg_total_relation_size(relation_oid: oid) &rarr; <a href="int.html">int</a></code></td><td><span class="funcdesc"><p>Returns the on-disk size, in bytes, of the relation, including all indexes with the given OID. The size is read from a periodically-refreshed cache and may lag behind the true value by minutes. Returns NULL if no such relation exists.</p>
<tr><td><a name="pg_total_relation_size"></a><code>pg_total_relation_size(relation_oid: oid) &rarr; <a href="int.html">int</a></code></td><td><span class="funcdesc"><p>Returns the on-disk size, in bytes, of the relation with the given OID, including all indexes and any data still occupying the table’s keyspace (such as dropped-index data awaiting garbage collection). The size is read from a periodically-refreshed cache and may lag behind the true value by minutes.</p>
</span></td><td>Volatile</td></tr>
<tr><td><a name="pg_trigger_depth"></a><code>pg_trigger_depth() &rarr; <a href="int.html">int</a></code></td><td><span class="funcdesc"><p>Returns the current nesting level of PostgreSQL triggers (0 if not called, directly or indirectly, from inside a trigger).</p>
</span></td><td>Volatile</td></tr>
Expand Down
16 changes: 12 additions & 4 deletions pkg/cli/clisqlshell/describe.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,21 @@ func listAllDbs(hasPattern bool, verbose bool) (string, string) {
printACLColumn(&buf, "d.datacl")
if verbose {
// TODO(sql-sessions): "Tablespace" is omitted.
// TODO(sql-sessions): "Size" is omited.
// (pg_database_size is not yet supported.)
// "Size" is read from the periodically-refreshed system.table_metadata
// cache and may lag the truth by minutes; the column is omitted entirely
// (rather than reported as zero) for databases the caller cannot CONNECT
// to, matching the upstream psql behavior.
buf.WriteString(`,
CASE
WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT')
THEN IF(d.datconnlimit < 0, 'Unlimited', d.datconnlimit::STRING)
ELSE 'No Access'
END AS "Connections",
CASE
WHEN pg_catalog.has_database_privilege(d.datname, 'CONNECT')
THEN pg_catalog.pg_size_pretty(pg_catalog.pg_database_size(d.datname))
ELSE 'No Access'
END AS "Size",
COALESCE(pg_catalog.shobj_description(d.oid, 'pg_database'), '') AS "Description"`)
}
buf.WriteString(`
Expand Down Expand Up @@ -403,9 +410,10 @@ func listTables(tabTypes string, hasPattern bool, verbose, showSystem bool) (str
am.amname AS "Access Method"`)
}

// TODO(sql-sessions): Column "Size" omitted here.
// This is because pg_table_size() is not supported yet.
// "Size" is read from the periodically-refreshed
// system.table_metadata cache and may lag the truth by minutes.
buf.WriteString(`,
pg_catalog.pg_size_pretty(pg_catalog.pg_table_size(c.oid)) AS "Size",
COALESCE(pg_catalog.obj_description(c.oid, 'pg_class'),'') as "Description"`)
}

Expand Down
Loading
Loading