PgPedia 周报, 2023-08-27

提醒大家,即将发布的 PostgreSQL 16 的发布日期 已经公布

rc1 版本已通过提交 (commit d94dadcc) 但在撰写本文时尚未打上标签。

PostgreSQL 16 文章

PostgreSQL 17 的新特性

带名称的 NOT NULL 约束

提交列表中一个有趣的新增内容是 b0e96f31 " Catalog not-null constraints",经过漫长的开发过程和几次试错,现在增加了带名称的 NOT NULL 约束。实际上,这意味着在 PostgreSQL 16 及更早版本中,像这样定义的表

postgres=# CREATE TABLE foo (id INT NOT NULL);
CREATE TABLE

postgres=# \d+ foo
                                           Table "public.foo"
 Column |  Type   | Collation | Nullable | Default | Storage | Compression | Stats target | Description 
--------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
 id     | integer |           | not null |         | plain   |             |              | 
Access method: heap

PostgreSQL 17 中将变为

postgres=# CREATE TABLE foo (id INT NOT NULL);
CREATE TABLE

postgres=# \d+ foo
                                           Table "public.foo"
 Column |  Type   | Collation | Nullable | Default | Storage | Compression | Stats target | Description 
--------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
 id     | integer |           | not null |         | plain   |             |              | 
Not-null constraints:
    "foo_id_not_null" NOT NULL "id"
Access method: heap

NOT NULL 约束也可以显式定义

postgres=# CREATE TABLE foo (
             id INT,
             CONSTRAINT foo_id_is_not_null NOT NULL id
           );
CREATE TABLE

postgres=# \d+ foo
                                           Table "public.foo"
 Column |  Type   | Collation | Nullable | Default | Storage | Compression | Stats target | Description 
--------+---------+-----------+----------+---------+---------+-------------+--------------+-------------
 id     | integer |           | not null |         | plain   |             |              | 
Not-null constraints:
    "foo_id_is_not_null" NOT NULL "id"
Access method: heap

PostgreSQL 提交的值得关注的变更

请注意,提交按其在提交日志中的出现顺序显示,这可能不反映单个提交的创建日期。

请参阅 PostgreSQL GIT 提交日志 查看完整的提交列表。

新 PgPedia 条目

已添加以下新条目

更新

以下文章已更新,增加了额外信息或更正

已添加了指向外部文章的链接

最后...

如果有什么遗漏,或者您有什么(建设性的)想法,请留下一些 反馈 和/或 请我喝杯咖啡


发表评论
姓名
*
电子邮件
地址不会显示
主页
评论