Postgres: why do some function calls require () and others not?

JPM

My question is this: Why do some postgresql functions require an empty bracket and others don't and how can I tell the correct syntax?

Examples: This does not work

select pg_postmaster_start_time;

results in

ERROR:  column "pg_postmaster_start_time" does not exist
LINE 1: select pg_postmaster_start_time;
           ^

However this works:

select pg_postmaster_start_time();

resulting in

   pg_postmaster_start_time
-------------------------------
 2016-08-01 16:07:12.728306+01
(1 row)

Now for the converse case: This works

select current_user;

and it results in

 current_user
--------------
 edbstore
(1 row)

But this does not work

select current_user();

Resulting in

ERROR:  syntax error at or near "("
LINE 1: select current_user();
                       ^

I did find this has been asked here, but there didn't seem to be an answer

Vao Tsun

Read docs - it says

Note: current_catalog, current_schema, current_user, session_user, and user have special syntactic status in SQL: they must be called without trailing parentheses. (In PostgreSQL, parentheses can optionally be used with current_schema, but not with the others.)

I know it sounds like "because it says so", so does not actually answer your question. But this is how docs explain it.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why do some classes require main methods and others do not?

From Dev

Why do some classes require main methods and others do not?

From Dev

Why do some programs require installing but others don't?

From Dev

Why do some JavaScript functions require a new variable to be created, but others do not?

From Dev

Is this a thread safe vector, and if so why do some methods of std::vector require locking for thread safety while others do not?

From Dev

Why do some lists of tuples are sorted and not others?

From Dev

Why do some network connections dominate others?

From Dev

Why do some drivers still require firmware?

From Java

Why do some variables declared using let inside a function become available in another function, while others result in a reference error?

From Dev

Return keyword: why do some languages have it while others do not?

From Dev

Why do some linux commands work with a "*" in a list of files but others do not?

From Dev

Why do some processes use swap and others don't?

From Dev

Why do some includes in Django need strings, and others variable names?

From Dev

Why do some methods have .prototype and others don't?

From Dev

Why do some DataMember attributes have brackets while others have not?

From Dev

Why do some methods use dot notation and others don't?

From Dev

Why do some excel documents have to be open for a Vlookup, and not others?

From Dev

Why do some processes use swap and others don't?

From Dev

Why do some angular directives need double curlies and others not?

From Dev

Why do some aliases work in xterm while others don't?

From Dev

Why do I get a FileNotFoundError for some Windows filepaths but not others?

From Dev

Why do some methods in Java do not require creating an instance to use?

From Dev

Why do some Linux system calls not have a wrapper, but are documented as if they do?

From Dev

Why do some docker images require a command when run?

From Dev

Why some devices does not require usb driver on Linux, but do on Windows?

From Dev

Why do some Linux system calls have two man pages?

From Dev

For a django unit test, why do some test runners take into account the production database, and others do not?

From Dev

Why do some programs running from Terminal using '&' close when Terminal does and others do not?

From Dev

For a django unit test, why do some test runners take into account the production database, and others do not?

Related Related

  1. 1

    Why do some classes require main methods and others do not?

  2. 2

    Why do some classes require main methods and others do not?

  3. 3

    Why do some programs require installing but others don't?

  4. 4

    Why do some JavaScript functions require a new variable to be created, but others do not?

  5. 5

    Is this a thread safe vector, and if so why do some methods of std::vector require locking for thread safety while others do not?

  6. 6

    Why do some lists of tuples are sorted and not others?

  7. 7

    Why do some network connections dominate others?

  8. 8

    Why do some drivers still require firmware?

  9. 9

    Why do some variables declared using let inside a function become available in another function, while others result in a reference error?

  10. 10

    Return keyword: why do some languages have it while others do not?

  11. 11

    Why do some linux commands work with a "*" in a list of files but others do not?

  12. 12

    Why do some processes use swap and others don't?

  13. 13

    Why do some includes in Django need strings, and others variable names?

  14. 14

    Why do some methods have .prototype and others don't?

  15. 15

    Why do some DataMember attributes have brackets while others have not?

  16. 16

    Why do some methods use dot notation and others don't?

  17. 17

    Why do some excel documents have to be open for a Vlookup, and not others?

  18. 18

    Why do some processes use swap and others don't?

  19. 19

    Why do some angular directives need double curlies and others not?

  20. 20

    Why do some aliases work in xterm while others don't?

  21. 21

    Why do I get a FileNotFoundError for some Windows filepaths but not others?

  22. 22

    Why do some methods in Java do not require creating an instance to use?

  23. 23

    Why do some Linux system calls not have a wrapper, but are documented as if they do?

  24. 24

    Why do some docker images require a command when run?

  25. 25

    Why some devices does not require usb driver on Linux, but do on Windows?

  26. 26

    Why do some Linux system calls have two man pages?

  27. 27

    For a django unit test, why do some test runners take into account the production database, and others do not?

  28. 28

    Why do some programs running from Terminal using '&' close when Terminal does and others do not?

  29. 29

    For a django unit test, why do some test runners take into account the production database, and others do not?

HotTag

Archive