0

我在 pipelinedb(基于 postgresql 9.5.3)中创建了一个 continunue Trasformer,以捕获设备状态代码更改的数据。然后这个CONTINUOUS TRANSFORM会调用一个函数(触发器),在函数中,代码根据设备状态码的变化计算出设备状态变化的时间范围,并写入一个表格。函数中的操作包含选择/更新/插入。在运行过程中,发现数据库日志中有很多错误信息,但是这些错误似乎并没有影响代码的正常执行。但是,当我继续在数据库中收到此错误时,我仍然担心会发生的坏事。

8 月 12 日 03:38:44 tst-gp5-srv3 管道[19296]:[141958-1]错误:relcache 引用 ct_rtd_his_narrow_func_fs 不属于资源所有者 TopTransaction 8 月 12 日 03:38:44 tst-gp5-srv3 管道[19296] :[141958-2] 声明:ct_rtd_his_narrow_func_fs

创建或替换函数 chr.f_modify_mn_ver_fs()
  RETURNS 触发 AS
  $$
  宣布
      v_rowcount 整数;
  开始
     如果 COALESCE(NEW.new_dev,'') <> COALESCE(NEW.old_dev,'') THEN
        SELECT count(1) INTO v_rowcount FROM chr.t_mn_ver_fs WHERE mn_code=NEW.mn_code AND ver_type='dev' AND is_current='Y';
        如果 v_rowcount > 0 那么
            更新 chr.t_mn_ver
                  SET end_time = NEW.arvl_time,
                      is_current = 'N',
                      更新时间 = 时钟时间戳()
                  WHERE mn_code = NEW.mn_code
                  和 ver_type='dev'
                  AND is_current = 'Y';
        万一;

INSERT INTO chr.t_mn_ver_fs (mn_code, ver_type, ver, begin_time, end_time, is_current, insert_time) VALUES (NEW.mn_code, 'dev', NEW.new_sver, NEW.arvl_time, NULL, 'Y', clock_timestamp()); END IF; IF COALESCE(NEW.new_usg,'') <> COALESCE(NEW.old_usg,'') THEN SELECT count(1) INTO v_rowcount FROM chr.t_mn_ver_fs WHERE mn_code=NEW.mn_code AND ver_type='usg' AND is_current='Y'; IF v_rowcount > 0 THEN UPDATE chr.t_mn_ver_fs SET end_time = NEW.arvl_time, is_current = 'N', update_time = clock_timestamp() WHERE mn_code = NEW.mn_code AND ver_type='usg' AND is_current = 'Y'; END IF; INSERT INTO chr.t_mn_ver_fs (mn_code, ver_type, ver, begin_time, end_time, is_current, insert_time) VALUES (NEW.mn_code, 'usg', NEW.new_usg, NEW.arvl_time, NULL, 'Y', clock_timestamp()); END IF; IF COALESCE(NEW.new_sver,'') <> COALESCE(NEW.old_sver,'') THEN SELECT count(1) INTO v_rowcount FROM chr.t_mn_ver_fs WHERE mn_code=NEW.mn_code AND ver_type='sver' AND is_current='Y'; IF v_rowcount > 0 THEN UPDATE chr.t_mn_ver_fs SET end_time = NEW.arvl_time, is_current = 'N', update_time = clock_timestamp() WHERE mn_code = NEW.mn_code AND ver_type='sver' AND is_current = 'Y'; END IF; INSERT INTO chr.t_mn_ver_fs (mn_code, ver_type, ver, begin_time, end_time, is_current, insert_time) VALUES (NEW.mn_code, 'sver', NEW.new_sver, NEW.arvl_time, NULL, 'Y', clock_timestamp()); END IF; IF COALESCE(NEW.new_hver,'') <> COALESCE(NEW.old_hver,'') THEN SELECT count(1) INTO v_rowcount FROM chr.t_mn_ver_fs WHERE mn_code=NEW.mn_code AND ver_type='hver' AND is_current='Y'; IF v_rowcount > 0 THEN UPDATE chr.t_mn_ver SET end_time = NEW.arvl_time, is_current = 'N', update_time = clock_timestamp() WHERE mn_code = NEW.mn_code AND ver_type='hver' AND is_current = 'Y'; END IF; INSERT INTO chr.t_mn_ver_fs (mn_code, ver_type, ver, begin_time, end_time, is_current, insert_time) VALUES (NEW.mn_code, 'hver', NEW.new_hver, NEW.arvl_time, NULL, 'Y', clock_timestamp()); END IF; RETURN NEW; END; $$ LANGUAGE plpgsql;

4

1 回答 1

0

请参阅 GitHub 问题以对此作出回应:

https://github.com/pipelinedb/pipelinedb/issues/1947

于 2018-08-22T00:26:13.250 回答