小编dev*_*dev的帖子

使用Postgres中的rowversions实现增量客户端更新

我是Postgres的新手并且喜欢它.我已经给了这个问题很多想法,RTFM尽我所能,但是走到了尽头,所以我需要朝着正确的方向轻推.

我正在设计一个数据库,其中每个感兴趣的实体都有一个rowversion从全局序列中分配值的列.所以,在最简单的场景中,在一个emps包含两行的表中:emp1with rowversion@3emp2with rowversion@5,我知道之后emp2被修改emp1(即在稍后的事务中 - 不要介意同一事务中的行是否具有相同的行rowversion).

这是形成数据同步逻辑的基础,其中知道它们在@ 3之前具有所有内容的客户端可以使用诸如的查询来获取最新的更新SELECT * FROM emps WHERE rowversion>3 and rowversion<=new_anchor.

以下是已更新@ 3的客户端的示例方案 - 假设以下事务:

@3 - committed
@4 - committed
@5 - committed
@6 - in progress - not committed yet
@7 - committed
@8 - in progress - not committed yet
@9 - committed
Run Code Online (Sandbox Code Playgroud)

客户端更新分三个阶段执行:

  1. 询问数据库是否合适new_anchor.
  2. 执行SELECT * FROM emps WHERE …

sql database sql-server postgresql

6
推荐指数
1
解决办法
603
查看次数

为什么我不能从setopt中获取?

我偶然遇到了这个,因为它一直在唠叨我:

% setopt
alwaystoend
autocd
autonamedirs
...
sharehistory
shinstdin
zle
%
% setopt | grep zle
# nothing printed
%
% setopt | cat -vet
alwaystoend$
autocd$
autonamedirs$
...
sharehistory$
shinstdin$
# no zle here!
Run Code Online (Sandbox Code Playgroud)

正如你所看到的那样,grep未能检测到zle,并且为了检测任何不规则的字符(不是它会更有意义)setopt来管道输出cat,也没有zle显示!

unix linux shell zsh zsh-zle

0
推荐指数
1
解决办法
92
查看次数

标签 统计

database ×1

linux ×1

postgresql ×1

shell ×1

sql ×1

sql-server ×1

unix ×1

zsh ×1

zsh-zle ×1