Skip to content

Commit

Permalink
PG Contribs: added support for btree_gist and btree_gin indexes in Po…
Browse files Browse the repository at this point in the history
…stgres 9.0 and 9.1
  • Loading branch information
Ines Sombra committed Feb 2, 2012
1 parent 7571c4b commit 89aecd9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 11 deletions.
10 changes: 6 additions & 4 deletions cookbooks/main/recipes/default.rb
Expand Up @@ -80,10 +80,12 @@
#require_recipe "newrelic_server_monitoring"

#enable contrib modules for a given Postgresql database
if ['solo','db_master', 'db_slave'].include?(node[:instance_role])
# if ['solo','db_master', 'db_slave'].include?(node[:instance_role])
# postgresql9_autoexplain "dbname"
# postgresql9_btree_gin "todosinatra"
postgresql9_chkpass "todosinatra"
# postgresql9_btree_gin "dbname"
# postgresql9_btree_gist "dbname"
# postgresql9_chkpass "dbname"

# postgresql9_citext "dbname"
# postgresql9_cube "dbname"
# postgresql9_dblink "dbname"
Expand All @@ -108,4 +110,4 @@
# postgresql9_pg_buffercache "postgres"
# postgresql9_pg_freespacemap "postgres"

end
# end
9 changes: 4 additions & 5 deletions cookbooks/postgresql9_extensions/README.md
Expand Up @@ -40,20 +40,19 @@ extension applied to.


##btree_gist
###supported versions: 9.1
support for indexing common datatypes in GiST

###supported versions: 9.0, 9.1
This extension provides support for indexing common datatypes in GiST

Enabling this extension:

* Edit main/recipes/default.rb and comment out the line shown below. Replace dbname with the name of the database you want this
extension applied to.

``postgresql9_chkpass "dbname""``
``postgresql9_btree_gist "dbname""``


##chkpass
###supported versions: 9.0
###supported versions: 9.0, 9.1
This extension implements a data type chkpass that is designed for storing encrypted passwords. Each password is automatically converted
to encrypted form upon entry, and is always stored encrypted.

Expand Down
11 changes: 11 additions & 0 deletions cookbooks/postgresql9_extensions/definitions/btree_gist.rb
@@ -0,0 +1,11 @@
define :postgresql9_btree_gist do
dbname_to_use = params[:name]

load_sql_file do
db_name dbname_to_use
username "postgres"
extname "btree_gist"
supported_versions %w[9.0 9.1]
end

end
6 changes: 4 additions & 2 deletions cookbooks/postgresql9_extensions/definitions/load_sql_file.rb
Expand Up @@ -3,15 +3,17 @@
extname = params[:extname]
supported_versions = params[:supported_versions]

Chef::Log.info "Loading to database #{db_name} extension #{extname} supported on versions: (#{supported_versions}). PG version installed is #{@node[:postgres_version]}"

if @node[:postgres_version] == "9.0" && supported_versions.include?("9.0")
execute "Postgresql loading contrib #{extname} on database #{db_name}" do
command "psql -U postgres -d #{db_name} -f /usr/share/postgresql-9.0/contrib/#{extname}.sql"
end
elsif @node[:postgres_version] == "9.1" && supported_versions.include?("9.1")
execute "Postgresql loading extension #{extname}" do
command "psql -U postgres -d #{db_name} -c \"CREATE EXTENSION #{extname}\";"
not_if {"psql -U postgres -d #{db_name} -t -c \"select name from pg_available_extensions where installed_version is not null and name like '#{extname}';\" | grep -q #{extname}"}
not_if "psql -U postgres -d #{db_name} -t -c \"select name from pg_available_extensions where installed_version is not null;\" | grep #{extname}"
end
end

end
end

0 comments on commit 89aecd9

Please sign in to comment.