36 Star 101 Fork 107

openGauss / openGauss-connector-jdbc

 / 详情

【测试类型:工具功能】jdbc调用自定义函数,out参数和return值对numeric类型的0,返回结果不一致

已完成
缺陷
创建于  
2023-07-07 12:06

【标题描述】:
【测试类型:SQL功能/存储功能/接口功能/工具功能/性能/并发/压力长稳/故障注入/安全/资料/编码规范】【测试版本:2.0.0】 jdbc调用自定义函数,out参数和return值对numeric类型的0,返回结果不一致

【操作系统和硬件信息】(查询命令: cat /etc/system-release, uname -a):

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

【被测功能】:

【测试类型】:

【数据库版本】(查询命令: gaussdb -V):

【预置条件】:数据库正常运行
alter database postgres set behavior_compat_options ='proc_outparam_override';

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

import java.sql.*;

public class callSP_type3 {

  static final String driverName = "org.opengauss.Driver";
  static final String urlString = "jdbc:opengauss://192.168.163.185:20000/postgres?batchMode=off";
  static final String userName = "xxxx";
  static final String password = "xxxx@123";

  /**
 * @param args
 * @throws Exception
 */

public static void main(String[] args) throws SQLException
	{    
		Connection conn = null;
		CallableStatement pstmt_callSP = null;  
		
	 	String strCallSP = "{? = call fn_ty_in_ty_out3(?)}";    
		try {
			Class.forName(driverName);
			conn = DriverManager.getConnection(urlString, userName, password);
			//conn.setAutoCommit(false); 
			Statement stmt = null; 
			stmt = conn.createStatement();
      		stmt.execute("create or replace FUNCTION fn_ty_in_ty_out3(o_code out numeric) return numeric is begin o_code := 0; return o_code; end;");
			
			pstmt_callSP = conn.prepareCall(strCallSP); 
			{ 
				pstmt_callSP.registerOutParameter(1, Types.NUMERIC); 
				pstmt_callSP.registerOutParameter(2, Types.NUMERIC); 
			}			 
			pstmt_callSP.execute(); 
			
			System.out.println(pstmt_callSP.getObject(1));
   			System.out.println(pstmt_callSP.getObject(2));

        	pstmt_callSP.close();
	        conn.close(); 

		} catch (Exception e) {
			e.printStackTrace();
			
			if(null != conn)
			{
				try
				{
					conn.rollback();
					conn.close(); 	
					conn=null;
					
				}catch (Exception e_close) {
					e_close.printStackTrace();
				}
			}
		} 
}
}

【预期输出】:
0
0
【实际输出】:
0
0E-107
【原因分析】:

【日志信息】(请附上日志文件、截图、coredump信息):
输入图片说明
输入图片说明
【测试代码】:

评论 (2)

DarkAthena 创建了缺陷

Hey @DarkAthena, 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 @DarkAthena,
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: @aaronwell , @Loong , @Kamus , @vimiix , @汪伟 , @travelliu
if you have any question, please contact the SIG: Connectors.

DarkAthena 修改了描述
DarkAthena 修改了描述
travelliu 任务状态待办的 修改为已确认
travelliu 任务状态已确认 修改为修复中
travelliu 任务状态修复中 修改为已完成

登录 后才可以发表评论

状态
负责人
项目
里程碑
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
分支
开始日期   -   截止日期
-
置顶选项
优先级
预计工期 (小时)
参与者(2)
13084139 opengauss bot 1686829535 2304844 darkathena 1632669471
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

搜索帮助