Accessing system information functions

Started by Johnson, Bruce E - (bjohnson)over 2 years ago6 messagesgeneral
Jump to latest
#1Johnson, Bruce E - (bjohnson)
Johnson@pharmacy.arizona.edu

Environment: Ubuntu 22.04 lts, postgres 15 installed via postgres.org<http://postgres.org&gt; repository

I am attempting to use the system information functions here: https://www.postgresql.org/docs/15/functions-info.html

I’m logged on as the postgres superuser on the host

Trying any of the functions gives me a syntax error

postgres=# pg_database_size(avi);

ERROR: syntax error at or near "pg_database_size"

LINE 1: pg_database_size(avi);

Do I have to add anything to the search_path?

postgres=# show search_path;

search_path

-----------------

"$user", public

(1 row)

--
Bruce Johnson
University of Arizona
College of Pharmacy
Information Technology Group

Institutions do not have opinions, merely customs

#2Erik Wienhold
ewie@ewie.name
In reply to: Johnson, Bruce E - (bjohnson) (#1)
Re: Accessing system information functions

On 2023-09-22 17:37 +0000, Johnson, Bruce E - (bjohnson) wrote:

postgres=# pg_database_size(avi);
ERROR: syntax error at or near "pg_database_size"
LINE 1: pg_database_size(avi);

Call functions with SELECT, e.g.:

SELECT pg_database_size('avi');

Also, the database name must be a string.

Do I have to add anything to the search_path?

Not for objects in schema pg_catalog which is always searched whether
it's listed in the search path or not.

--
Erik

#3Rob Sargent
robjsargent@gmail.com
In reply to: Johnson, Bruce E - (bjohnson) (#1)
Re: Accessing system information functions
#4Rob Sargent
robjsargent@gmail.com
In reply to: Johnson, Bruce E - (bjohnson) (#1)
Re: Accessing system information functions
#5Johnson, Bruce E - (bjohnson)
Johnson@pharmacy.arizona.edu
In reply to: Erik Wienhold (#2)
Re: [EXT]Re: Accessing system information functions

Thank you.

On Sep 25, 2023, at 4:18 AM, Erik Wienhold <ewie@ewie.name> wrote:

External Email

On 2023-09-22 17:37 +0000, Johnson, Bruce E - (bjohnson) wrote:
postgres=# pg_database_size(avi);
ERROR: syntax error at or near "pg_database_size"
LINE 1: pg_database_size(avi);

Call functions with SELECT, e.g.:

SELECT pg_database_size('avi');

Also, the database name must be a string.

Do I have to add anything to the search_path?

Not for objects in schema pg_catalog which is always searched whether
it's listed in the search path or not.

--
Erik

--
Bruce Johnson
University of Arizona
College of Pharmacy
Information Technology Group

Institutions do not have opinions, merely customs

#6Pavel Stehule
pavel.stehule@gmail.com
In reply to: Rob Sargent (#4)
Re: Accessing system information functions

Hi

po 25. 9. 2023 v 19:51 odesílatel Rob Sargent <robjsargent@gmail.com>
napsal:

On Sep 25, 2023, at 5:05 AM, Johnson, Bruce E - (bjohnson) <
Johnson@pharmacy.arizona.edu> wrote:

 Environment: Ubuntu 22.04 lts, postgres 15 installed via postgres.org repository

I am attempting to use the system information functions here:
https://www.postgresql.org/docs/15/functions-info.html

I’m logged on as the postgres superuser on the host

Trying any of the functions gives me a syntax error

postgres=# pg_database_size(avi);

ERROR: syntax error at or near "pg_database_size"

LINE 1: pg_database_size(avi);

Do I have to add anything to the search_path?

postgres=# show search_path;

search_path

-----------------

"$user", public

(1 row)

you are missing SELECT keyword

(2023-09-25 20:05:08) postgres=# select pg_database_size('postgres');
┌──────────────────┐
│ pg_database_size │
╞══════════════════╡
│ 7901667 │
└──────────────────┘
(1 row)

Regards

Pavel

Show quoted text

And single quote name. 'avi'

--
Bruce Johnson
University of Arizona
College of Pharmacy
Information Technology Group

Institutions do not have opinions, merely customs