63 lines
2.3 KiB
Ruby
63 lines
2.3 KiB
Ruby
class CstoreFdw < Formula
|
|
desc "Columnar store for analytics with Postgres"
|
|
homepage "https://github.com/citusdata/cstore_fdw"
|
|
url "https://github.com/citusdata/cstore_fdw/archive/v1.7.0.tar.gz"
|
|
sha256 "bd8a06654b483d27b48d8196cf6baac0c7828b431b49ac097923ac0c54a1c38c"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "e5211784ea6d81722ca564dd8b66771a90b4a3f507ff4ccd951f842d9d57615e" => :catalina
|
|
sha256 "e6de592f4f6675ebe54cbab9f0c1c999dc478b8a06e1c9c6ac8fd40609aa4c69" => :mojave
|
|
sha256 "733229f90415188167c33fe9affaca694587a5a533221bef90626b10e4e48e89" => :high_sierra
|
|
end
|
|
|
|
depends_on "postgresql"
|
|
depends_on "protobuf-c"
|
|
|
|
def install
|
|
# workaround for https://github.com/Homebrew/homebrew/issues/49948
|
|
system "make", "libpq=-L#{Formula["postgresql"].opt_lib} -lpq"
|
|
|
|
# Use stage directory to prevent installing to pg_config-defined dirs,
|
|
# which would not be within this package's Cellar.
|
|
mkdir "stage"
|
|
system "make", "install", "DESTDIR=#{buildpath}/stage"
|
|
|
|
lib.install Dir["stage/**/lib/*"]
|
|
(share/"postgresql/extension").install Dir["stage/**/share/postgresql/extension/*"]
|
|
end
|
|
|
|
test do
|
|
pg_bin = Formula["postgresql"].opt_bin
|
|
pg_port = "55561"
|
|
system "#{pg_bin}/initdb", testpath/"test"
|
|
pid = fork do
|
|
exec("#{pg_bin}/postgres",
|
|
"-D", testpath/"test",
|
|
"-c", "shared_preload_libraries=cstore_fdw",
|
|
"-p", pg_port)
|
|
end
|
|
|
|
begin
|
|
sleep 2
|
|
|
|
cmds = ["CREATE EXTENSION cstore_fdw;",
|
|
"CREATE SERVER cstore_server FOREIGN data WRAPPER cstore_fdw;",
|
|
"CREATE FOREIGN TABLE T(x int) SERVER cstore_server OPTIONS(compression 'pglz');",
|
|
"INSERT INTO T(x) SELECT 42;"]
|
|
|
|
system "#{pg_bin}/createdb", "-p", pg_port, "test"
|
|
system "#{pg_bin}/psql", "-p", pg_port, "-d", "test", "--command", cmds[0]
|
|
system "#{pg_bin}/psql", "-p", pg_port, "-d", "test", "--command", cmds[1]
|
|
system "#{pg_bin}/psql", "-p", pg_port, "-d", "test", "--command", cmds[2]
|
|
system "#{pg_bin}/psql", "-p", pg_port, "-d", "test", "--command", cmds[3]
|
|
|
|
assert_equal "42", shell_output("#{pg_bin}/psql -p #{pg_port} -d test -AXtc" \
|
|
"'SELECT x from T;'").strip
|
|
ensure
|
|
Process.kill 9, pid
|
|
Process.wait pid
|
|
end
|
|
end
|
|
end
|