/ home / computer / postgresql / .
Zu den MariaDB/MySQL Befehlen:
SQL> SELECT @@hostname;
SQL> SHOW GLOBAL VARIABLES LIKE 'hostname';
habe ich in PostgreSQL kein einfaches Äquivalent gefunden. Folgende Workarounds funktionieren aber:
postgresql# CREATE TEMP TABLE host_info (name text);
postgresql# COPY host_info FROM PROGRAM '/usr/bin/hostname';
postgresql# SELECT * FROM host_info;
postgresql# DROP TABLE host_info; -- optional
postgresql# SELECT pg_read_file('/etc/hostname');
Wobei noch zu prüfen ist, welche minimalen Privilegien man für diese Befehl braucht, da diese aus Sicht der Sicherheit wohl nicht ganz unproblematisch sind:
postgres=# SELECT pg_read_file('/etc/passwd');
pg_read_file
---------------------------------------------------------------------------------------------------------
root:x:0:0:root:/root:/bin/bash +
...
postgres=# SELECT pg_read_file('/etc/shadow');
ERROR: could not open file "/etc/shadow" for reading: Permission denied