跳转到主要内容

pgcalendar

为 PostgreSQL 提供循环日程、投影与例外处理的日历扩展

pgcalendar · 为 PostgreSQL 提供循环日程、投影与例外处理的日历扩展

概览

ID扩展软件包版本类别许可证编程语言
3890pgcalendarpgcalendar1.1.0TYPEMITSQL
属性可执行文件动态库需要预加载需要建扩展可迁移可信
----d--否否否是否否
Deb/RPM recipes patch the stale upstream 1.1.0 control metadata (default_version/module_pathname).

软件包

类型仓库版本兼容的 PostgreSQL 大版本包名模式依赖
EXTPIGSTY1.1.019 18 17 16 15pgcalendar-
RPMPIGSTY1.1.019 18 17 16 15pgcalendar_$v-
DEBPIGSTY1.1.019 18 17 16 15postgresql-$v-pgcalendar-
Linux / PGPG19PG18PG17PG16PG15
el8.x86_64N/APIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
el8.aarch64N/APIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
el9.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
el9.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
el10.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
el10.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
d12.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
d12.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
d13.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
d13.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u22.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u22.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u24.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u24.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u26.x86_64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
u26.aarch64PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0PIGSTY 1.1.0
软件包版本平台仓库大小下载
pgcalendar_191.1.0el9.x86_64pigsty13.4 KiBpgcalendar_19-1.1.0-1PGSTY.el9.noarch.rpm
pgcalendar_191.1.0el9.aarch64pigsty13.4 KiBpgcalendar_19-1.1.0-1PGSTY.el9.noarch.rpm
pgcalendar_191.1.0el10.x86_64pigsty13.5 KiBpgcalendar_19-1.1.0-1PGSTY.el10.noarch.rpm
pgcalendar_191.1.0el10.aarch64pigsty13.5 KiBpgcalendar_19-1.1.0-1PGSTY.el10.noarch.rpm
postgresql-19-pgcalendar1.1.0d12.x86_64pigsty7.3 KiBpostgresql-19-pgcalendar_1.1.0-1PGSTY~bookworm_all.deb
postgresql-19-pgcalendar1.1.0d12.aarch64pigsty7.3 KiBpostgresql-19-pgcalendar_1.1.0-1PGSTY~bookworm_all.deb
postgresql-19-pgcalendar1.1.0d13.x86_64pigsty7.3 KiBpostgresql-19-pgcalendar_1.1.0-1PGSTY~trixie_all.deb
postgresql-19-pgcalendar1.1.0d13.aarch64pigsty7.3 KiBpostgresql-19-pgcalendar_1.1.0-1PGSTY~trixie_all.deb
postgresql-19-pgcalendar1.1.0u22.x86_64pigsty7.4 KiBpostgresql-19-pgcalendar_1.1.0-1PGSTY~jammy_all.deb
postgresql-19-pgcalendar1.1.0u22.aarch64pigsty7.4 KiBpostgresql-19-pgcalendar_1.1.0-1PGSTY~jammy_all.deb
postgresql-19-pgcalendar1.1.0u24.x86_64pigsty7.4 KiBpostgresql-19-pgcalendar_1.1.0-1PGSTY~noble_all.deb
postgresql-19-pgcalendar1.1.0u24.aarch64pigsty7.4 KiBpostgresql-19-pgcalendar_1.1.0-1PGSTY~noble_all.deb
postgresql-19-pgcalendar1.1.0u26.x86_64pigsty7.4 KiBpostgresql-19-pgcalendar_1.1.0-1PGSTY~resolute_all.deb
postgresql-19-pgcalendar1.1.0u26.aarch64pigsty7.4 KiBpostgresql-19-pgcalendar_1.1.0-1PGSTY~resolute_all.deb
软件包版本平台仓库大小下载
pgcalendar_181.1.0el8.x86_64pigsty13.5 KiBpgcalendar_18-1.1.0-1PGSTY.el8.noarch.rpm
pgcalendar_181.1.0el8.aarch64pigsty13.5 KiBpgcalendar_18-1.1.0-1PGSTY.el8.noarch.rpm
pgcalendar_181.1.0el9.x86_64pigsty13.4 KiBpgcalendar_18-1.1.0-1PGSTY.el9.noarch.rpm
pgcalendar_181.1.0el9.aarch64pigsty13.4 KiBpgcalendar_18-1.1.0-1PGSTY.el9.noarch.rpm
pgcalendar_181.1.0el10.x86_64pigsty13.5 KiBpgcalendar_18-1.1.0-1PGSTY.el10.noarch.rpm
pgcalendar_181.1.0el10.aarch64pigsty13.5 KiBpgcalendar_18-1.1.0-1PGSTY.el10.noarch.rpm
postgresql-18-pgcalendar1.1.0d12.x86_64pigsty7.3 KiBpostgresql-18-pgcalendar_1.1.0-1PGSTY~bookworm_all.deb
postgresql-18-pgcalendar1.1.0d12.aarch64pigsty7.3 KiBpostgresql-18-pgcalendar_1.1.0-1PGSTY~bookworm_all.deb
postgresql-18-pgcalendar1.1.0d13.x86_64pigsty7.3 KiBpostgresql-18-pgcalendar_1.1.0-1PGSTY~trixie_all.deb
postgresql-18-pgcalendar1.1.0d13.aarch64pigsty7.3 KiBpostgresql-18-pgcalendar_1.1.0-1PGSTY~trixie_all.deb
postgresql-18-pgcalendar1.1.0u22.x86_64pigsty7.4 KiBpostgresql-18-pgcalendar_1.1.0-1PGSTY~jammy_all.deb
postgresql-18-pgcalendar1.1.0u22.aarch64pigsty7.4 KiBpostgresql-18-pgcalendar_1.1.0-1PGSTY~jammy_all.deb
postgresql-18-pgcalendar1.1.0u24.x86_64pigsty7.4 KiBpostgresql-18-pgcalendar_1.1.0-1PGSTY~noble_all.deb
postgresql-18-pgcalendar1.1.0u24.aarch64pigsty7.4 KiBpostgresql-18-pgcalendar_1.1.0-1PGSTY~noble_all.deb
postgresql-18-pgcalendar1.1.0u26.x86_64pigsty7.4 KiBpostgresql-18-pgcalendar_1.1.0-1PGSTY~resolute_all.deb
postgresql-18-pgcalendar1.1.0u26.aarch64pigsty7.4 KiBpostgresql-18-pgcalendar_1.1.0-1PGSTY~resolute_all.deb
软件包版本平台仓库大小下载
pgcalendar_171.1.0el8.x86_64pigsty13.5 KiBpgcalendar_17-1.1.0-1PGSTY.el8.noarch.rpm
pgcalendar_171.1.0el8.aarch64pigsty13.5 KiBpgcalendar_17-1.1.0-1PGSTY.el8.noarch.rpm
pgcalendar_171.1.0el9.x86_64pigsty13.4 KiBpgcalendar_17-1.1.0-1PGSTY.el9.noarch.rpm
pgcalendar_171.1.0el9.aarch64pigsty13.4 KiBpgcalendar_17-1.1.0-1PGSTY.el9.noarch.rpm
pgcalendar_171.1.0el10.x86_64pigsty13.5 KiBpgcalendar_17-1.1.0-1PGSTY.el10.noarch.rpm
pgcalendar_171.1.0el10.aarch64pigsty13.5 KiBpgcalendar_17-1.1.0-1PGSTY.el10.noarch.rpm
postgresql-17-pgcalendar1.1.0d12.x86_64pigsty7.3 KiBpostgresql-17-pgcalendar_1.1.0-1PGSTY~bookworm_all.deb
postgresql-17-pgcalendar1.1.0d12.aarch64pigsty7.3 KiBpostgresql-17-pgcalendar_1.1.0-1PGSTY~bookworm_all.deb
postgresql-17-pgcalendar1.1.0d13.x86_64pigsty7.3 KiBpostgresql-17-pgcalendar_1.1.0-1PGSTY~trixie_all.deb
postgresql-17-pgcalendar1.1.0d13.aarch64pigsty7.3 KiBpostgresql-17-pgcalendar_1.1.0-1PGSTY~trixie_all.deb
postgresql-17-pgcalendar1.1.0u22.x86_64pigsty7.4 KiBpostgresql-17-pgcalendar_1.1.0-1PGSTY~jammy_all.deb
postgresql-17-pgcalendar1.1.0u22.aarch64pigsty7.4 KiBpostgresql-17-pgcalendar_1.1.0-1PGSTY~jammy_all.deb
postgresql-17-pgcalendar1.1.0u24.x86_64pigsty7.4 KiBpostgresql-17-pgcalendar_1.1.0-1PGSTY~noble_all.deb
postgresql-17-pgcalendar1.1.0u24.aarch64pigsty7.4 KiBpostgresql-17-pgcalendar_1.1.0-1PGSTY~noble_all.deb
postgresql-17-pgcalendar1.1.0u26.x86_64pigsty7.4 KiBpostgresql-17-pgcalendar_1.1.0-1PGSTY~resolute_all.deb
postgresql-17-pgcalendar1.1.0u26.aarch64pigsty7.4 KiBpostgresql-17-pgcalendar_1.1.0-1PGSTY~resolute_all.deb
软件包版本平台仓库大小下载
pgcalendar_161.1.0el8.x86_64pigsty13.5 KiBpgcalendar_16-1.1.0-1PGSTY.el8.noarch.rpm
pgcalendar_161.1.0el8.aarch64pigsty13.5 KiBpgcalendar_16-1.1.0-1PGSTY.el8.noarch.rpm
pgcalendar_161.1.0el9.x86_64pigsty13.4 KiBpgcalendar_16-1.1.0-1PGSTY.el9.noarch.rpm
pgcalendar_161.1.0el9.aarch64pigsty13.4 KiBpgcalendar_16-1.1.0-1PGSTY.el9.noarch.rpm
pgcalendar_161.1.0el10.x86_64pigsty13.5 KiBpgcalendar_16-1.1.0-1PGSTY.el10.noarch.rpm
pgcalendar_161.1.0el10.aarch64pigsty13.5 KiBpgcalendar_16-1.1.0-1PGSTY.el10.noarch.rpm
postgresql-16-pgcalendar1.1.0d12.x86_64pigsty7.3 KiBpostgresql-16-pgcalendar_1.1.0-1PGSTY~bookworm_all.deb
postgresql-16-pgcalendar1.1.0d12.aarch64pigsty7.3 KiBpostgresql-16-pgcalendar_1.1.0-1PGSTY~bookworm_all.deb
postgresql-16-pgcalendar1.1.0d13.x86_64pigsty7.3 KiBpostgresql-16-pgcalendar_1.1.0-1PGSTY~trixie_all.deb
postgresql-16-pgcalendar1.1.0d13.aarch64pigsty7.3 KiBpostgresql-16-pgcalendar_1.1.0-1PGSTY~trixie_all.deb
postgresql-16-pgcalendar1.1.0u22.x86_64pigsty7.4 KiBpostgresql-16-pgcalendar_1.1.0-1PGSTY~jammy_all.deb
postgresql-16-pgcalendar1.1.0u22.aarch64pigsty7.4 KiBpostgresql-16-pgcalendar_1.1.0-1PGSTY~jammy_all.deb
postgresql-16-pgcalendar1.1.0u24.x86_64pigsty7.4 KiBpostgresql-16-pgcalendar_1.1.0-1PGSTY~noble_all.deb
postgresql-16-pgcalendar1.1.0u24.aarch64pigsty7.4 KiBpostgresql-16-pgcalendar_1.1.0-1PGSTY~noble_all.deb
postgresql-16-pgcalendar1.1.0u26.x86_64pigsty7.4 KiBpostgresql-16-pgcalendar_1.1.0-1PGSTY~resolute_all.deb
postgresql-16-pgcalendar1.1.0u26.aarch64pigsty7.4 KiBpostgresql-16-pgcalendar_1.1.0-1PGSTY~resolute_all.deb
软件包版本平台仓库大小下载
pgcalendar_151.1.0el8.x86_64pigsty13.5 KiBpgcalendar_15-1.1.0-1PGSTY.el8.noarch.rpm
pgcalendar_151.1.0el8.aarch64pigsty13.5 KiBpgcalendar_15-1.1.0-1PGSTY.el8.noarch.rpm
pgcalendar_151.1.0el9.x86_64pigsty13.4 KiBpgcalendar_15-1.1.0-1PGSTY.el9.noarch.rpm
pgcalendar_151.1.0el9.aarch64pigsty13.4 KiBpgcalendar_15-1.1.0-1PGSTY.el9.noarch.rpm
pgcalendar_151.1.0el10.x86_64pigsty13.5 KiBpgcalendar_15-1.1.0-1PGSTY.el10.noarch.rpm
pgcalendar_151.1.0el10.aarch64pigsty13.5 KiBpgcalendar_15-1.1.0-1PGSTY.el10.noarch.rpm
postgresql-15-pgcalendar1.1.0d12.x86_64pigsty7.3 KiBpostgresql-15-pgcalendar_1.1.0-1PGSTY~bookworm_all.deb
postgresql-15-pgcalendar1.1.0d12.aarch64pigsty7.3 KiBpostgresql-15-pgcalendar_1.1.0-1PGSTY~bookworm_all.deb
postgresql-15-pgcalendar1.1.0d13.x86_64pigsty7.3 KiBpostgresql-15-pgcalendar_1.1.0-1PGSTY~trixie_all.deb
postgresql-15-pgcalendar1.1.0d13.aarch64pigsty7.3 KiBpostgresql-15-pgcalendar_1.1.0-1PGSTY~trixie_all.deb
postgresql-15-pgcalendar1.1.0u22.x86_64pigsty7.4 KiBpostgresql-15-pgcalendar_1.1.0-1PGSTY~jammy_all.deb
postgresql-15-pgcalendar1.1.0u22.aarch64pigsty7.4 KiBpostgresql-15-pgcalendar_1.1.0-1PGSTY~jammy_all.deb
postgresql-15-pgcalendar1.1.0u24.x86_64pigsty7.4 KiBpostgresql-15-pgcalendar_1.1.0-1PGSTY~noble_all.deb
postgresql-15-pgcalendar1.1.0u24.aarch64pigsty7.4 KiBpostgresql-15-pgcalendar_1.1.0-1PGSTY~noble_all.deb
postgresql-15-pgcalendar1.1.0u26.x86_64pigsty7.4 KiBpostgresql-15-pgcalendar_1.1.0-1PGSTY~resolute_all.deb
postgresql-15-pgcalendar1.1.0u26.aarch64pigsty7.4 KiBpostgresql-15-pgcalendar_1.1.0-1PGSTY~resolute_all.deb

源码

pig build pkg pgcalendar;		# build rpm/deb

安装

启用 PGDG 和 PIGSTY 仓库并更新缓存。

pig repo add pgsql -u   # add both repo and update cache

使用 pig 安装扩展。

pig install pgcalendar;		# install by package name

pig install pgcalendar -v 19;   # install for PG 19
pig install pgcalendar -v 18;   # install for PG 18
pig install pgcalendar -v 17;   # install for PG 17
pig install pgcalendar -v 16;   # install for PG 16
pig install pgcalendar -v 15;   # install for PG 15

在数据库中创建扩展。

CREATE EXTENSION pgcalendar;

用法

来源:README,repo

pgcalendar 是一个 PostgreSQL 循环日历扩展。上游 README 用四个核心对象来建模循环日程:events、schedules、exceptions 和生成出来的 projections。

创建事件和日程

CREATE EXTENSION pgcalendar;

INSERT INTO pgcalendar.events (name, description, category)
VALUES ('Daily Standup', 'Team daily standup meeting', 'meeting');

INSERT INTO pgcalendar.schedules (
    event_id, start_date, end_date, recurrence_type, recurrence_interval
) VALUES (
    1, '2024-01-01 09:00:00', '2024-01-07 23:59:59', 'daily', 1
);

README 展示了 daily、weekly、monthly 和 yearly 四类循环,并会根据类型使用 recurrence_day_of_week、recurrence_day_of_month、recurrence_month 等额外列。

查询投影

SELECT * FROM pgcalendar.get_event_projections(
    1, '2024-01-01'::date, '2024-01-07'::date
);

SELECT * FROM pgcalendar.get_events_detailed(
    '2024-01-01'::date, '2024-01-31'::date
);

README 还把 pgcalendar.event_calendar 视图作为快速核验结果的入口。

例外与日程切换

INSERT INTO pgcalendar.exceptions (
    schedule_id, exception_date, exception_type, notes
) VALUES (
    1, '2024-01-15', 'cancelled', 'Holiday - meeting cancelled'
);

SELECT pgcalendar.transition_event_schedule(
    p_event_id := 1,
    p_new_start_date := '2024-01-15 09:00:00',
    p_new_end_date := '2024-01-31 23:59:59',
    p_recurrence_type := 'weekly',
    p_recurrence_interval := 2,
    p_recurrence_day_of_week := 1,
    p_description := 'Changed to bi-weekly schedule'
);

如果需要在新增日程前确认日期范围不重叠,可以先调用 pgcalendar.check_schedule_overlap(...)。

注意事项

目前上游唯一公开的用户文档就是 README。它已经给出了较完整的表结构和函数示例,但没有另外维护按版本划分的用户可见 SQL 变更说明。

表格阅读器