-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f6efc1c
Showing
11 changed files
with
178 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
|
||
[*.{c,h}] | ||
indent_style = tab | ||
indent_size = 4 | ||
|
||
[Makefile] | ||
indent_style = tab |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Build | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
defaults: | ||
run: | ||
shell: sh | ||
|
||
strategy: | ||
matrix: | ||
pgversion: | ||
- 16 | ||
- 15 | ||
- 14 | ||
- 13 | ||
- 12 | ||
|
||
env: | ||
PGVERSION: ${{ matrix.pgversion }} | ||
|
||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: install pg | ||
run: | | ||
sudo /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -v $PGVERSION -p -i | ||
sudo -u postgres createuser -s "$USER" | ||
- name: build | ||
run: | | ||
make PROFILE="-Werror" | ||
sudo -E make install | ||
- name: test | ||
run: | | ||
sudo pg_conftool set shared_preload_libraries postgresql_extension_template | ||
sudo pg_ctlcluster $PGVERSION main restart | ||
make installcheck | ||
- name: show regression diffs | ||
if: ${{ failure() }} | ||
run: | | ||
cat regression.diffs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Compilation artifacts | ||
.deps/ | ||
*.bc | ||
*.o | ||
*.so | ||
|
||
# Regression Tests Output | ||
results/ | ||
regression.* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
Copyright (c) 2023, CYBERTEC PostgreSQL International GmbH | ||
|
||
Permission to use, copy, modify, and distribute this software and its | ||
documentation for any purpose, without fee, and without a written agreement is | ||
hereby granted, provided that the above copyright notice and this paragraph and | ||
the following two paragraphs appear in all copies. | ||
|
||
IN NO EVENT SHALL CYBERTEC PostgreSQL International GmbH BE LIABLE TO ANY PARTY | ||
FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING | ||
LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, | ||
EVEN IF CYBERTEC PostgreSQL International GmbH HAS BEEN ADVISED OF THE | ||
POSSIBILITY OF SUCH DAMAGE. | ||
|
||
CYBERTEC PostgreSQL International GmbH SPECIFICALLY DISCLAIMS ANY WARRANTIES, | ||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | ||
FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS | ||
IS" BASIS, AND CYBERTEC PostgreSQL International GmbH HAS NO OBLIGATIONS TO | ||
PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
PG_CONFIG ?= pg_config | ||
|
||
EXTENSION = postgresql_extension_template | ||
MODULE_big = postgresql_extension_template | ||
OBJS = postgresql_extension_template.o | ||
DATA = postgresql_extension_template--1.0.sql | ||
REGRESS = postgresql_extension_template | ||
# To provide your README.md as docs, create a symlink like that: | ||
# | ||
# `ln -s README.md extension_name.md` | ||
# | ||
# And uncomment the following line: | ||
#DOCS = extension_name.md | ||
|
||
USE_PGXS = 1 | ||
ifdef USE_PGXS | ||
PGXS := $(shell $(PG_CONFIG) --pgxs) | ||
include $(PGXS) | ||
else | ||
subdir = contrib/pg_show_plans | ||
top_builddir = ../.. | ||
include $(top_builddir)/src/Makefile.global | ||
include $(top_srcdir)/contrib/contrib-global.mk | ||
endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# PostgreSQL Extension Template | ||
|
||
This is a template repository for a PostgreSQL C extension. This repository | ||
includes: | ||
|
||
* [EditorConfig](https://editorconfig.org/) to set C indentation to 4 space | ||
tabs, works with all text editors and GitHub. | ||
* GitHub Action to run `make installcheck` against all supported PostgreSQL | ||
server major versions. | ||
* Proper license file that you do not have to worry about. | ||
* ~10 lines boilerplate C code. | ||
* Regression tests. | ||
* `Makefile` for `PGXS`. | ||
|
||
# USAGE | ||
|
||
This is the simplest possible working extension, you can install it and run | ||
regression tests: | ||
|
||
```bash | ||
git clone [email protected]:cybertec-postgresql/postgresql_extension_template.git your-extension-name | ||
cd your-extension-name | ||
make | ||
make install | ||
make installcheck | ||
``` | ||
|
||
At this point everything is pre-configured, just make your edits. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE EXTENSION postgresql_extension_template; | ||
SELECT my_function(); | ||
my_function | ||
--------------------------- | ||
Hello from my_function()! | ||
(1 row) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* postgresql_extension_template--1.0.sql */ | ||
|
||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION | ||
\echo Use "CREATE EXTENSION pg_show_plans" to load this file. \quit | ||
|
||
CREATE FUNCTION my_function() | ||
RETURNS cstring | ||
AS 'MODULE_PATHNAME' | ||
LANGUAGE C; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "postgres.h" | ||
#include "fmgr.h" | ||
|
||
PG_MODULE_MAGIC; | ||
|
||
Datum my_function(PG_FUNCTION_ARGS); | ||
PG_FUNCTION_INFO_V1(my_function); | ||
|
||
Datum | ||
my_function(PG_FUNCTION_ARGS) | ||
{ | ||
PG_RETURN_CSTRING("Hello from my_function()!"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
# postgresql_extension_template extension | ||
comment = 'Briefly describe your extension here' | ||
default_version = '1.0' | ||
module_pathname = '$libdir/postgresql_extension_template' | ||
relocatable = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
CREATE EXTENSION postgresql_extension_template; | ||
|
||
SELECT my_function(); |