Skip to content

Commit 17f82fd

Browse files
committed
add first_last_agg extension
1 parent fd09e3f commit 17f82fd

4 files changed

Lines changed: 131 additions & 0 deletions

File tree

.github/workflows/bake.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
- postgis
1414
- pgaudit
1515
- pg-crash
16+
- first-last-agg
1617

1718
defaults:
1819
run:
@@ -55,6 +56,9 @@ jobs:
5556
pg-crash:
5657
- 'pg-crash/**'
5758
- *shared
59+
first-last-agg:
60+
- 'first-last-agg/**'
61+
- *shared
5862
5963
# Compute a matrix containing the list of all extensions that have been modified
6064
- name: Compute matrix

first-last-agg/Dockerfile

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
ARG BASE=ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
2+
FROM $BASE AS builder
3+
4+
ARG PG_MAJOR
5+
ARG EXT_VERSION
6+
7+
USER 0
8+
9+
RUN apt-get update && \
10+
apt-get install -y --no-install-recommends "postgresql-${PG_MAJOR}-first-last-agg=${EXT_VERSION}"
11+
12+
FROM scratch
13+
ARG PG_MAJOR
14+
15+
# Licenses
16+
COPY --from=builder /usr/share/doc/postgresql-${PG_MAJOR}-first-last-agg/copyright /licenses/postgresql-${PG_MAJOR}-first-last-agg/
17+
18+
# Libraries
19+
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/first_last_agg* /lib/
20+
COPY --from=builder /usr/lib/postgresql/${PG_MAJOR}/lib/bitcode/ /lib/bitcode/
21+
22+
# Share
23+
COPY --from=builder /usr/share/postgresql/${PG_MAJOR}/extension/first_last_agg* /share/extension/
24+
25+
USER 65532:65532

first-last-agg/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# First-Last-Agg
2+
3+
[First-Last-Agg](https://github.com/wulczer/first_last_agg) is a simple
4+
extension providing two aggregate functions, last and first aggregate
5+
functions, operating on any element type and returning the last or the first
6+
value of the group.
7+
8+
This image provides a convenient way to deploy and manage `first_last_agg` with
9+
[CloudNativePG](https://cloudnative-pg.io/).
10+
11+
## Usage
12+
13+
### 1. Add the first_last_agg extension image to your Cluster
14+
15+
Define the `first_last_agg` extension under the `postgresql.extensions` section of
16+
your `Cluster` resource. For example:
17+
18+
```yaml
19+
apiVersion: postgresql.cnpg.io/v1
20+
kind: Cluster
21+
metadata:
22+
name: cluster-first-last-agg
23+
spec:
24+
imageName: ghcr.io/cloudnative-pg/postgresql:18-minimal-trixie
25+
instances: 1
26+
27+
storage:
28+
size: 1Gi
29+
30+
postgresql:
31+
extensions:
32+
- name: first_last_agg
33+
image:
34+
# renovate: suite=trixie-pgdg depName=postgresql-18-first-last-agg
35+
reference: ghcr.io/cloudnative-pg/first-last-agg:0.8.2-18-trixie
36+
```
37+
38+
### 2. Enable the extension in a database
39+
40+
You can install `first_last_agg` in a specific database by creating or updating a
41+
`Database` resource. For example, to enable it in the `app` database:
42+
43+
```yaml
44+
apiVersion: postgresql.cnpg.io/v1
45+
kind: Database
46+
metadata:
47+
name: cluster-first-last-agg-app
48+
spec:
49+
name: app
50+
owner: app
51+
cluster:
52+
name: cluster-first-last-agg
53+
extensions:
54+
- name: first_last_agg
55+
# renovate: suite=trixie-pgdg depName=postgresql-18-first-last-agg extractVersion=^(?<version>\d+\.\d+\.\d+)
56+
version: '0.8.2'
57+
```
58+
59+
### 3. Verify installation
60+
61+
Once the database is ready, connect to it with `psql` and run:
62+
63+
```sql
64+
\dx
65+
```
66+
67+
You should see `first_last_agg` listed among the installed extensions.

first-last-agg/metadata.hcl

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
metadata = {
2+
name = "first-last-agg"
3+
sql_name = "first_last_agg"
4+
image_name = "first-last-agg"
5+
licenses = ["PostgreSQL"]
6+
shared_preload_libraries = []
7+
postgresql_parameters = {}
8+
extension_control_path = []
9+
dynamic_library_path = []
10+
ld_library_path = []
11+
bin_path = []
12+
env = {}
13+
auto_update_os_libs = false
14+
required_extensions = []
15+
create_extension = true
16+
17+
versions = {
18+
bookworm = {
19+
"18" = {
20+
// renovate: suite=bookworm-pgdg depName=postgresql-18-first-last-agg
21+
package = "0.1.4-4-gd63ea3b-9.pgdg12+1"
22+
// renovate: suite=bookworm-pgdg depName=postgresql-18-first-last-agg extractVersion=^(?<version>\d+\.\d+\.\d+)
23+
sql = "0.1.4"
24+
}
25+
}
26+
trixie = {
27+
"18" = {
28+
// renovate: suite=trixie-pgdg depName=postgresql-18-first-last-agg
29+
package = "0.1.4-4-gd63ea3b-9.pgdg13+1"
30+
// renovate: suite=trixie-pgdg depName=postgresql-18-first-last-agg extractVersion=^(?<version>\d+\.\d+\.\d+)
31+
sql = "0.1.4"
32+
}
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)