当前位置:Gxlcms > 数据库问题 > PostgreSQL-JDBC疑似bug:部分接口参数的表名、列名必须全部小写

PostgreSQL-JDBC疑似bug:部分接口参数的表名、列名必须全部小写

时间:2021-07-01 10:21:17 帮助过:25人阅读

pg_attribute.attname as colname,pg_type.typname as typename,pg_constraint.conname as pk_name from pg_constraint inner join pg_class on pg_constraint.conrelid = pg_class.oid inner join pg_attribute on pg_attribute.attrelid = pg_class.oid and pg_attribute.attnum = pg_constraint.conkey[1] inner join pg_type on pg_type.oid = pg_attribute.atttypid where pg_class.relname = table_name and pg_constraint.contype=p;

当table_name为全小写时,可以获得正确结果,其它情况结果均为空。

也许PostgreSQL方面因某种原因而刻意为之,但本人倾向于认为这是bug。毕竟,其它主流数据库的JDBC都能正确应对这种情况。

经简单测试,本项目涉及的接口包括:

//获取表主键
public ResultSet getPrimaryKeys(String catalog, String schema, String table)  throws SQLException;

//获取表外键
public ResultSet getImportedKeys(String catalog, String schema, String table)  throws SQLException;

//获取列名
public String getColumnName(int column);

受影响的接口应该还有不少,很可能也不止PgDatabaseMetaData一个类;另外猜测,模式名、用户名、数据库名等可能也在影响之列。

但因项目时间紧迫没有核实,大家在使用时留心这个问题,在应用程序中加入大小写转换的代码。

 

PostgreSQL-JDBC疑似bug:部分接口参数的表名、列名必须全部小写

标签:class   情况下   支持   pid   pen   经验   get   包括   sch   

人气教程排行