postgresql.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:parsec-cloud 作者: Scille 项目源码 文件源码
def _perform_vlob_update(self, intent):
        async with self.connection.acquire() as conn:
            async with conn.cursor() as cur:
                await cur.execute("SELECT version, read_trust_seed, write_trust_seed FROM "
                                  "vlobs WHERE id=%s ORDER BY version DESC;", (intent.id, ))
                ret = await cur.fetchone()
                if ret is None:
                    raise VlobNotFound('Vlob not found.')
                last_version, rts, wts = ret
                if wts != intent.trust_seed:
                    raise TrustSeedError('Invalid write trust seed.')
                if intent.version != last_version + 1:
                    raise VlobNotFound('Wrong blob version.')
                # TODO: insertion doesn't do atomic check of version
                await cur.execute("INSERT INTO vlobs VALUES (%s, %s, %s, %s, %s);",
                    (intent.id, intent.version, rts, wts, intent.blob))
                await cur.execute("NOTIFY vlob_updated, %s", (intent.id, ))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号