diff --git a/README.md b/README.md index 3ff5757..3c1242e 100644 --- a/README.md +++ b/README.md @@ -103,11 +103,34 @@ a variable-length type. ## Installation -To install the extension, run `make install` in the project root. Then, in your -PostgreSQL connection, execute `CREATE EXTENSION hashset;`. +To install the extension on any platform, follow these general steps: + +1. Ensure you have PostgreSQL installed on your system, including the development files. +2. Clone the repository. +3. Navigate to the cloned repository directory. +4. Compile the extension using `make`. +5. Install the extension using `sudo make install`. +6. Run the tests using `make installcheck` (optional). + +In your PostgreSQL connection, enable the hashset extension using the following SQL command: +```sql +CREATE EXTENSION hashset; +``` This extension requires PostgreSQL version ?.? or later. +For Ubuntu 22.04.1 LTS, you would run the following commands: + +```sh +sudo apt install postgresql-15 postgresql-server-dev-15 postgresql-client-15 +git clone https://github.com/tvondra/hashset.git +cd hashset +make +sudo make install +make installcheck +``` + +Please note that this project is currently under active development and is not yet considered production-ready. ## License diff --git a/test/c_tests/test_send_recv.c b/test/c_tests/test_send_recv.c index 5655b8b..cc7c48a 100644 --- a/test/c_tests/test_send_recv.c +++ b/test/c_tests/test_send_recv.c @@ -9,8 +9,16 @@ void exit_nicely(PGconn *conn) { int main() { /* Connect to database specified by the PGDATABASE environment variable */ - const char *conninfo = "host=localhost port=5432"; - PGconn *conn = PQconnectdb(conninfo); + const char *hostname = getenv("PGHOST"); + char conninfo[1024]; + PGconn *conn; + + if (hostname == NULL) + hostname = "localhost"; + + /* Connect to database specified by the PGDATABASE environment variable */ + snprintf(conninfo, sizeof(conninfo), "host=%s port=5432", hostname); + conn = PQconnectdb(conninfo); if (PQstatus(conn) != CONNECTION_OK) { fprintf(stderr, "Connection to database failed: %s", PQerrorMessage(conn)); exit_nicely(conn); @@ -20,13 +28,13 @@ int main() { PQexec(conn, "CREATE EXTENSION IF NOT EXISTS hashset"); /* Create temporary table */ - PQexec(conn, "CREATE TABLE IF NOT EXISTS test_hashset_send_recv (hashset_col hashset)"); + PQexec(conn, "CREATE TABLE IF NOT EXISTS test_hashset_send_recv (hashset_col int4hashset)"); /* Enable binary output */ PQexec(conn, "SET bytea_output = 'escape'"); /* Insert dummy data */ - const char *insert_command = "INSERT INTO test_hashset_send_recv (hashset_col) VALUES ('{1,2,3}'::hashset)"; + const char *insert_command = "INSERT INTO test_hashset_send_recv (hashset_col) VALUES ('{1,2,3}'::int4hashset)"; PGresult *res = PQexec(conn, insert_command); if (PQresultStatus(res) != PGRES_COMMAND_OK) { fprintf(stderr, "INSERT failed: %s", PQerrorMessage(conn)); @@ -64,7 +72,7 @@ int main() { PQclear(res); /* Check the data */ - const char *check_command = "SELECT COUNT(DISTINCT hashset_col::text) AS unique_count, COUNT(*) FROM test_hashset_send_recv"; + const char *check_command = "SELECT COUNT(DISTINCT hashset_col) AS unique_count, COUNT(*) FROM test_hashset_send_recv"; res = PQexec(conn, check_command); if (PQresultStatus(res) != PGRES_TUPLES_OK) { fprintf(stderr, "SELECT failed: %s", PQerrorMessage(conn));