Is this a BUG REPORT or FEATURE REQUEST?:
Uncomment only one, leave it on its own line:
- bug
What happened:
opengauss
postgres=# select quote_literal('');
quote_literal
---------------
(1 row)
What you expected to happen:
pg11, pg9.2
postgres=# select quote_literal('');
quote_literal
---------------
''
(1 row)
How to reproduce it (as minimally and precisely as possible):
Anything else we need to know?:
Environment:
uname -a
):Hey @nwen, 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 https://gitee.com/opengauss/community/blob/master/contributors/command.en.md to find the details.
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。
/kind bug
opengauss中默认认为空和NULL一样,自动将‘’转化为NULL处理,该功能由参数sql_compatibility控制,但是pg默认认为是不相等的,在语法解析的时候不一样,因此显示不一样,语法解析如下
static Node *
makeStringConst(char *str, int location)
{
A_Const *n = makeNode(A_Const);
if (u_sess->attr.attr_sql.sql_compatibility == A_FORMAT)
{
if (NULL == str || 0 == strlen(str))
{
n->val.type = T_Null;
n->val.val.str = str;
n->location = location;
}
else
{
n->val.type = T_String;
n->val.val.str = str;
n->location = location;
}
}
else
{
n->val.type = T_String;
n->val.val.str = str;
n->location = location;
}
return (Node *)n;
A
(1 row)
(1 row)
(0 rows)
postgres=# create database pg_type_databse dbcompatibility 'PG';
CREATE DATABASE
postgres=#
postgres=# \c pg_type_databse
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "pg_type_databse" as user "omm".
pg_type_databse=# show sql_compatibility;
sql_compatibility
-------------------
PG
(1 row)
pg_type_databse=# select quote_literal('');
quote_literal
---------------
''
(1 row)
pg_type_databse=#
社区在最新版本代码中可以创建PG数据库兼容, 这样结果就跟PostgreSql的一样了
相应pr为: !91:pgdb compatibility support
登录 后才可以发表评论