{"id":15295170,"url":"https://github.com/bluejekyll/pg-extend-rs","last_synced_at":"2025-04-04T12:09:20.403Z","repository":{"id":33884675,"uuid":"162778118","full_name":"bluejekyll/pg-extend-rs","owner":"bluejekyll","description":"Postgres extension library for Rust","archived":false,"fork":false,"pushed_at":"2022-08-22T13:14:10.000Z","size":4231,"stargazers_count":278,"open_issues_count":29,"forks_count":30,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-03-28T11:11:15.067Z","etag":null,"topics":["postgres","postgres-extension","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bluejekyll.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-22T03:22:23.000Z","updated_at":"2025-01-20T11:16:24.000Z","dependencies_parsed_at":"2022-08-08T18:00:07.481Z","dependency_job_id":null,"html_url":"https://github.com/bluejekyll/pg-extend-rs","commit_stats":null,"previous_names":["bluejekyll/pg-extend"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluejekyll%2Fpg-extend-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluejekyll%2Fpg-extend-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluejekyll%2Fpg-extend-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bluejekyll%2Fpg-extend-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bluejekyll","download_url":"https://codeload.github.com/bluejekyll/pg-extend-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247174454,"owners_count":20896078,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["postgres","postgres-extension","rust"],"created_at":"2024-09-30T17:08:56.053Z","updated_at":"2025-04-04T12:09:20.383Z","avatar_url":"https://github.com/bluejekyll.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"\n[![Build Status](https://github.com/bluejekyll/pg-extend-rs/workflows/test/badge.svg?branch=master)](https://github.com/bluejekyll/pg-extend-rs/actions?query=workflow%3Atest)\n[![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE-MIT)\n[![License: Apache 2.0](https://img.shields.io/badge/license-Apache_2.0-blue.svg)](LICENSE-APACHE)\n[![Dependabot Status](https://api.dependabot.com/badges/status?host=github\u0026repo=bluejekyll/pg-extend-rs)](https://dependabot.com)\n[![](http://meritbadge.herokuapp.com/pg-extend)](https://crates.io/crates/pg-extend)\n[![Discord](https://img.shields.io/discord/589988605322199149.svg)](https://discord.gg/y7ZvY5p)\n\n# Rust based Postgres extension\n\nThe main things provided by this crate are some macros that help with writing Postgres extensions in Rust.\n\nThe objective (not all these are yet implemented):\n\n- Automatic type conversions, see `PgDatum` and `TryFromPgDatum` to `Into\u003cPgDatum\u003e`\n- `pg_magic` macro for declaring libraries as Postgres extensions\n- `pg_extern` attribute for wrapping Rust functions in Postgres C style definitions\n- panic handlers for conversion into Postgres errors\n- allocator that uses Postgres `palloc` allocator and `pfree`\n- *tbd* integrate postgres error logs with `log`\n- *tbd* support all Datum types\n- *tbd* support table like returns and manipulation\n- *tbd* generators for the psql scripts to load functions\n\n## Getting started\n\nThis project uses `cargo-make` for automation. While not necessary, it does help with a lot of the build tasks, so is recommended. This can be installed with `cargo install cargo-make`.\n\nOnce installed, it will install Postgres into the `target` directory for testing. There are profiles for each supported Postgres version, `v10`, `v11`, and `v12`. The specific minor version used is in \n\nTo run all tests with all features, for example, run:\n\n```shell\n\u003e cargo make all-features -p v12 # if -p is left off, then the default is v12\n```\n\n## Building\n\nIf using `cargo-make` then the environment variable `PG_DIR` can be used to specify the location of the Postgres install.\n\nFirst install Postgres. The build should be able to find the directory for the Postgres server headers, it uses the `pg_config --includedir-server` to attempt to find the directory. If it is unsuccessful then this environment variable is required:\n\n`PG_INCLUDE_PATH=[/path/to/postgres]/include/server # e.g. /usr/local/pgsql/include/server`\n\nFor the dynamic library to compile, your project should also have `.cargo/config` file with content:\n\n```toml\n[target.'cfg(unix)']\nrustflags = \"-C link-arg=-undefineddynamic_lookup\"\n\n[target.'cfg(windows)']\nrustflags = \"-C link-arg=/FORCE\"\n```\n\nThis informs the linker that some of the symbols for Postgres won't be available until runtime on the dynamic library load.\n\n## Running the integration tests\n\nStandard tests can be run with the normal `cargo test`, but the integration tests are a little more involved. They require a connection to an actual Postgres DB. These instructions were performed on macOS. Create a DB in Postgres to be use. In this example a DB was created in the `/usr/local/var/posgres` path, with the name `postgres`. When using `cargo-make` all the automation of starting, installing and setting up the DB is handled for you:\n\nTest all features:\n\n```shell\n\u003e cargo make all-features\n```\n\nTest default features:\n\n```shell\n\u003e cargo make default-features\n```\n\nTest no-default-features:\n\n```shell\n\u003e cargo make no-default-features\n```\n\nTesting against different versions; `v10`, `v11`, `v12` are valid:\n\n```shell\n\u003e cargo make all-features -p v10\n```\n\n### Without cargo-make\n\nTo run the test must know the DB name to use, the DB must be running, and then the tests can be run:\n\n```shell\nexport POSTGRES_TEST_DB=postgres\n\npg_ctl -D /usr/local/var/postgres start\ncargo test\n```\n\n## Examples\n\n- [adding](https://github.com/bluejekyll/pg-extend-rs/tree/master/examples/adding)\n- [panicking](https://github.com/bluejekyll/pg-extend-rs/tree/master/examples/panicking)\n\n## Features\n\nTBD\n\n## Community\n\nFor live discussions beyond this repository, please see this [Discord](https://discord.gg/y7ZvY5p).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluejekyll%2Fpg-extend-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbluejekyll%2Fpg-extend-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbluejekyll%2Fpg-extend-rs/lists"}