【问题标题】:Using pgLogical row filter for jsonB column type对 jsonB 列类型使用 pgLogical 行过滤器
【发布时间】:2021-10-19 01:42:25
【问题描述】:

我正在尝试复制包含 jsonB 列的表。我想使用行过滤来仅选择我需要的行。如何为 jsonB 定义行过滤器?

桌人:

        id                  serial,
        name                TEXT NOT NULL,
        details          JSONB NOT NULL,
        modified_at         TIMESTAMPTZ NOT NULL DEFAULT NOW(),
        PRIMARY KEY (name)); 

样本数据:

 id |  name   |     details     |          modified_at          
----+---------+-----------------+-------------------------------
  1 | person1 | {"city": "nyc"} | 2021-05-17 06:05:55.735086+00
  2 | person2 | {"city": "SF"}  | 2021-05-17 06:06:30.028065+00

我尝试了以下方法,但它们不起作用:

SELECT pglogical.replication_set_add_table(set_name:= 'replicate1', relation := 'person', row_filter:= details->>'city' = 'nyc');

我尝试的另一个选项:

SELECT pglogical.replication_set_add_table(set_name:= 'replicate1', relation := 'person', row_filter:= "details->>'city' = 'nyc'");

【问题讨论】:

  • 不相关,但是::= 用于为命名参数提供值已被弃用,取而代之的是符合标准的 => 运算符。
  • 我会假设 row_filter 是一个 varchar/text 参数,所以它应该是:row_filter => 'details->>''city'' = ''nyc'''
  • @a_horse_with_no_name 谢谢,没有意识到它已被弃用。

标签: postgresql replication pglogical


【解决方案1】:

可以在这里找到解决方案:https://github.com/2ndQuadrant/pglogical/issues/332

【讨论】:

    猜你喜欢
    • 2020-10-20
    • 1970-01-01
    • 1970-01-01
    • 2015-07-21
    • 2021-06-30
    • 1970-01-01
    • 2017-10-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多