38 Star 102 Fork 108

openGauss / openGauss-connector-jdbc

 / 详情

【测试类型:接口功能】【测试版本:6.0.0】 JDBC的getBlob()和getString()获取blob类型值与gsql查询值不一致

待办的
缺陷
创建于  
2024-04-03 10:42

【测试类型:接口功能】【测试版本:6.0.0】 JDBC的getBlob()和getString()获取blob类型值与gsql查询值不一致

【操作系统和硬件信息】(查询命令: cat /etc/system-release, uname -a):
CentOS Linux release 7.6.1908 (Core)
Linux kwemhisprc01300 3.10.0-1062.el7.x86_64 #1 SMP Wed Aug 7 18:08:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

【测试环境】(单机/1主x备x级联备):单机

【被测功能】:blob类型

【测试类型】:功能测试

【数据库版本】(查询命令: gaussdb -V):
gaussdb (openGauss 6.0.0-RC1 build e4282ae9) compiled at 2024-03-29 11:00:19 commit 0 last mr

【预置条件】:数据库正常运行

【操作步骤】(请填写详细的操作步骤):

  1. 建表插入数据
    drop table if exists t_blob_0034;
    create table t_blob_0034(c_id int,b_blob blob) with (storage_type=ustore);
    insert into t_blob_0034 values(1,'1234'::blob);
  2. 查询
    select * from t_blob_0034 where c_id=1;
  3. 环境清理
    drop table t_blob_0034;

【预期输出】:

  1. 执行成功
  2. 查询成功,结果与gsql查询结果一致
  3. 执行成功

【实际输出】:

  1. 执行成功
  2. 查询成功,结果与gsql查询结果不一致
    输入图片说明
    输入图片说明
  3. 执行成功

【原因分析】:

  1. 这个问题的根因
  2. 问题推断过程
  3. 还有哪些原因可能造成类似现象
  4. 该问题是否有临时规避措施
  5. 问题解决方案
  6. 预计修复问题时间

【日志信息】(请附上日志文件、截图、coredump信息):

【测试代码】:

附件
ningyali 2024-04-03 10:46

评论 (5)

ningyali 创建了缺陷

Hey @ningyali, Welcome to openGauss Community.
All of the projects in openGauss Community are maintained by @opengauss_bot.
That means the developers can comment below every pull request or issue to trigger Bot Commands.
Please follow instructions at Here to find the details.

opengauss_bot 添加了
 
sig/connectors
标签

Hi @ningyali,
if you want to get quick review about your issue, please contact the owner in first: @周斌 ,
and then any of the maintainers: @Pike
and then any of the committers: @travelliu , @aaronwell , @Loong , @Kamus , @vimiix , @汪伟
if you have any question, please contact the SIG: Connectors.

ningyali 负责人设置为zhangtingtingting
ningyali 关联项目设置为openGauss 6.0.0 community
ningyali 添加协作者申正
ningyali 优先级设置为次要
ningyali 关联分支设置为master

数据库内核对b库返回的blob类型数据为十六进制的ASCII码,对a库返回的为原始数据的ASCII码,当前jdbc针对blob类型的处理是兼容的b库,所以a库查询值不正确。

申正 负责人zhangtingtingting 修改为未设置
申正 取消协作者申正
王恬静 添加协作者pengjiong
pengjiong 负责人设置为wangfeihuo
pengjiong 取消协作者wangfeihuo

对于blob类型,A库和B库的处理流程确实不一样:
A 库的blob类型是按照text进行存储的:
输入图片说明
读取的时候也是按照text处理的:
输入图片说明
因此返回给JDBC的就是字符串"1234"了:
输入图片说明

对于B库:
blob是按照binary进行处理的:
输入图片说明

返回给JDBC的也是按照binary的形式31323334返回的:
输入图片说明

这个应该是为了解决一些特殊字符字使用符串存储不了等问题做的,因此A库和B库返回给JDBC的数据不一样应该是符合预期的,应该要在JDBC侧去适配处理一下。

与JDBC对齐,在JDBC侧修改,方案是只有B库,且dolphin.b_compatibility_mode = on的时候,blob的数据才按照16进制处理,其他的情形均按照文本处理。

wangfeihuo 添加协作者wangfeihuo
wangfeihuo 负责人wangfeihuo 修改为zhangtingtingting
pengjiong 取消协作者pengjiong
pengjiong 添加协作者申正
zhangtingtingting 计划截止日期设置为2024-05-31

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(5)
13084139 opengauss bot 1686829535 8772917 ningyali 1691032793
Java
1
https://gitee.com/opengauss/openGauss-connector-jdbc.git
git@gitee.com:opengauss/openGauss-connector-jdbc.git
opengauss
openGauss-connector-jdbc
openGauss-connector-jdbc

搜索帮助