這個標題似乎很繞口。我的意思是如果是如果安裝Postgres時,如果是自己下載源碼編譯安裝,而make時又沒有make world,就會導致的pg最終沒有類似pg_stat_statements的擴展功能。那么,這篇文章將會講述如何在編譯安裝后,為pg安裝擴展。
讓我們以 pg_stat_statements 為例,前提是我們希望人們沒有刪除當初用于編譯pg的目錄。
首先,看一下pg的源碼目錄,可以看到有一個名為 contrib的目錄。
$ ls
aclocal.m4 config config.log config.status configure configure.in contrib COPYRIGHT doc GNUmakefile GNUmakefile.in HISTORY INSTALL Makefile README src
在這個目錄中,我們可以看到擴展包:
$ cd contrib
$ ls
都在這里:
adminpack btree_gist dblink fuzzystrmatch intarray Makefile pgcrypto pg_stat_statements README start-scripts tsm_system_rows xml2
auth_delay chkpass dict_int hstore isn oid2name pg_freespacemap pgstattuple seg tablefunc tsm_system_time
auto_explain citext dict_xsyn hstore_plperl lo pageinspect pg_prewarm pg_trgm sepgsql tcn unaccent
bloom contrib-global.mk earthdistance hstore_plpython ltree passwordcheck pgrowlocks pg_visibility spi test_decoding uuid-ossp
btree_gin cube file_fdw intagg ltree_plpython pg_buffercache pg_standby postgres_fdw sslinfo tsearch2 vacuumlo
假設我們要安裝pg_stat_statements,步驟相當簡單,其他的擴展包也是類似的安裝方式:
$ cd pg_stat_statements
$ make
$ sudo make install
官方文檔在這里,一開始沒有寫明在哪里執(zhí)行make && make install 所以比較confusing。