Description
The installer is pghist_init.sql file that creates the pghist schema.
The installation consists in executing it in the psql terminal client or SQL manager, for example:
psql -d -mydb -f pghist_init.sql
If the developers are not superusers, need to grant them privileges on the pghist schema and its procedures.
To do this, use the SQL script pghist_grants.sql with the roles variable. For example:
psql -d -mydb -f pghist_grants.sql -v roles=developers
Also possible download zip archive with documentation, examples, extension, install and uninstall scripts.
For batch use, installation is carried out in command line using psql:
1. Download and execute pghist_init.sql file
wget -O - https://pghist.org/files/download/pghist_init.sql | psql -d [database]
2. Grant privileges to developers (optional)
wget -O - https://pghist.org/files/download/pghist_grants.sql | psql -d [database] -v roles=[developers]
Installation example in test database
$ wget -O - https://pghist.org/files/download/pghist_init.sql | psql -d test --2024-04-02 19:39:28-- https://pghist.org/files/download/pghist_init.sql Resolving pghist.org (pghist.org)... 194.67.205.60 Connecting to pghist.org (pghist.org)|194.67.205.60|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 45527 (44K) [application/octet-stream] Saving to: ‘STDOUT’ 100%[=================================================>] 45,527 --.-K/s in 0s 2024-04-02 19:39:28 (97.7 MB/s) - written to stdout [45527/45527] CREATE SCHEMA CREATE FUNCTION CREATE TABLE CREATE TABLE CREATE TABLE CREATE TABLE DO CREATE FUNCTION CREATE FUNCTION CREATE PROCEDURE CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE FUNCTION CREATE PROCEDURE CREATE PROCEDURE CREATE PROCEDURE CREATE PROCEDURE CREATE PROCEDURE CREATE FUNCTION CREATE FUNCTION DO CREATE PROCEDURE CREATE PROCEDURE CREATE FUNCTION CREATE FUNCTION CREATE PROCEDURE CREATE FUNCTION CREATE FUNCTION DO $ wget -O - https://pghist.org/files/download/pghist_grants.sql | psql -d test -v roles=developer_1 --2024-04-02 19:40:46-- https://pghist.org/files/download/pghist_grants.sql Resolving pghist.org (pghist.org)... 194.67.205.60 Connecting to pghist.org (pghist.org)|194.67.205.60|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 1174 (1.1K) [application/octet-stream] Saving to: ‘STDOUT’ 100%[==============================================================>] 1,174 --.-K/s in 0s 2024-04-02 19:40:46 (111 MB/s) - written to stdout [1174/1174] GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT GRANT
To install tool as an extension, unpack pghist_extension.tar archive into the [sharedir]/extension directory of the postgres installation and create extension, for example (run as root):
su - postgres -c "pg_config --sharedir"
tar xf pghist_extension.tar -C /usr/pgsql-14/share/extension
psql -U postgres -d mydb -c "create extension pghist"
Installation example in test database
[root@pgsuite ~]# wget -O - https://pghist.org/files/download/pghist_extension.tar | tar x -C `su - postgres -c "pg_config --sharedir"`/extension --2024-08-22 15:37:49-- https://pghist.org/files/download/pghist_extension.tar Resolving pghist.org (pghist.org)... 194.67.205.60 Connecting to pghist.org (pghist.org)|194.67.205.60|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 51200 (50K) [application/octet-stream] Saving to: ‘STDOUT’ 100%[=====================================================================================================>] 51,200 --.-K/s in 0.001s 2024-08-22 15:37:49 (71.0 MB/s) - written to stdout [51200/51200] [root@pgsuite ~]# psql -U postgres -d test -c "create extension pghist" CREATE EXTENSION
The source code is upload in GitHub repository
PGHist is released under the MIT License (open and free software license).
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.