gpt4 book ai didi

postgresql - 比较 bytea 和 plpgsql 中的 bytea

转载 作者:行者123 更新时间:2023-11-29 12:07:38 25 4
gpt4 key购买 nike

我正在编写一个函数,它将从大对象中读取数据并将其与作为 arg 提供的数据进行比较。 (我想确保我写的是正确的,这是写后完整性检查)

我已经想出了如何分块读取大对象

   fd := lo_open(looid,x'40000'::int);
loop
buff := loread(fd, 1000);
len := octet_length(buff);
raise NOTICE 'buff %', len;
if len = 0 then
exit;
end if;
end loop;
return 0;

但我坚持将每个 block 与我的输入 bytea(比如 indata)的等效切片进行比较的看似简单的操作。我什至不知道从哪里开始,广泛的 ggoling 没有任何线索

最佳答案

使用substring(string [from int] [for int]) .

循环可能是这样的:

offst := 1;
loop
buff := loread(fd, 1000);
len := octet_length(buff);
raise NOTICE 'buff %', len;
if buff <> substring(indata from offst for 1000) then
return false;
end if;
if len = 0 then
return true;
end if;
offst := offst + len;
end loop;

关于postgresql - 比较 bytea 和 plpgsql 中的 bytea,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53754062/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com