
# 平台和客户端兼容性
很多平台都使用数据库系统，数据库系统的对外兼容性给平台提供了很大的方便。
#### convert_string_to_digit
**参数说明**：设置隐式转换优先级，是否优先将字符串转为数字。
该参数属于USERSET类型参数，请参考[表1](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_1169.html#ZH-CN_TOPIC_0000002222152125__zh-cn_topic_0000002063779510_zh-cn_topic_0289899927_zh-cn_topic_0283137176_zh-cn_topic_0237121562_zh-cn_topic_0059777490_t91a6f212010f4503b24d7943aed6d846)中对应设置方法进行设置。
**取值范围：**布尔型
- on表示优先将字符串转为数字。
- off表示不优先将字符串转为数字。
**默认值**：on
![](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/public_sys-resources/notice_3.0-zh-cn.png)
该参数调整会修改内部数据类型转换规则，导致不可预期的行为，请谨慎操作。
#### nls_timestamp_format
**参数说明**：设置时间戳默认格式。
该参数属于USERSET类型参数，请参考[表1](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_1169.html#ZH-CN_TOPIC_0000002222152125__zh-cn_topic_0000002063779510_zh-cn_topic_0289899927_zh-cn_topic_0283137176_zh-cn_topic_0237121562_zh-cn_topic_0059777490_t91a6f212010f4503b24d7943aed6d846)中对应设置方法进行设置。
**取值范围**：字符串
**默认值**：DD-Mon-YYYY HH:MI:SS.FF AM
#### max_function_args
**参数说明**：函数参数最大个数。
该参数属于INTERNAL类型参数，为固定参数，用户无法修改此参数，只能查看。
**取值范围**：整型
**默认值**：8192
#### transform_null_equals
**参数说明：**控制表达式expr = NULL（或NULL = expr）当做expr IS NULL处理。如果expr得出NULL值则返回真，否则返回假。
- 正确的SQL标准兼容的expr = NULL总是返回NULL（未知）。
- Microsoft Access里的过滤表单生成的查询使用expr = NULL来测试空值。打开这个选项，可以使用该接口来访问数据库。
该参数属于USERSET类型参数，请参考[表2](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_1169.html#ZH-CN_TOPIC_0000002222152125__zh-cn_topic_0000002063779510_zh-cn_topic_0289899927_zh-cn_topic_0283137176_zh-cn_topic_0237121562_zh-cn_topic_0059777490_t290c8f15953843db8d8e53d867cd893d)中对应设置方法进行设置。
**取值范围：**布尔型
- on表示控制表达式expr = NULL（或NULL = expr）当做expr IS NULL处理。
- off表示不控制，即expr = NULL总是返回NULL（未知）。
**默认值：**off
![](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/public_sys-resources/note_3.0-zh-cn.png)
新用户经常在涉及NULL的表达式上语义混淆，故默认值设为off。
#### support_extended_features
**参数说明：**控制是否支持数据库的扩展特性。
该参数属于POSTMASTER类型参数，请参考[表2](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_1169.html#ZH-CN_TOPIC_0000002222152125__zh-cn_topic_0000002063779510_zh-cn_topic_0289899927_zh-cn_topic_0283137176_zh-cn_topic_0237121562_zh-cn_topic_0059777490_t290c8f15953843db8d8e53d867cd893d)中对应设置方法进行设置。
**取值范围：**布尔型
- on表示支持数据库的扩展特性。
- off表示不支持数据库的扩展特性。
**默认值：**off
#### sql_compatibility
**参数说明：**控制数据库的SQL语法和语句行为同哪一个主流数据库兼容。该参数属于INTERNAL类型参数，用户无法修改，只能查看。
**取值范围：**枚举型
- A表示同O数据库兼容。
- B表示同MY数据库兼容。
- C表示同TD数据库兼容。
- PG表示同POSTGRES数据库兼容。
**默认值：**A
![](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/public_sys-resources/notice_3.0-zh-cn.png)
- 该参数只能在执行CREATE DATABASE命令创建数据库的时候设置。
- 在数据库中，该参数只能是确定的一个值，要么始终设置为A，要么始终设置为B，请勿任意改动，否则会导致数据库行为不一致。
 
#### behavior_compat_options
**参数说明：**数据库兼容性行为配置项，该参数的值由若干个配置项用逗号隔开构成。
该参数属于USERSET类型参数，请参考[表1](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_1169.html#ZH-CN_TOPIC_0000002222152125__zh-cn_topic_0000002063779510_zh-cn_topic_0289899927_zh-cn_topic_0283137176_zh-cn_topic_0237121562_zh-cn_topic_0059777490_t91a6f212010f4503b24d7943aed6d846)中对应设置方法进行设置。
**取值范围：**字符串
**默认值：**""
![](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/public_sys-resources/note_3.0-zh-cn.png)
- 当前只支持[表1]。
- 配置多个兼容性配置项时，相邻配置项用逗号隔开，例如：set behavior_compat_options='end_month_calculate,display_leading_zero';
 
 表1兼容性配置项 
| **兼容性配置项**                      | **兼容性行为控制**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
|:---|:---|
| display_leading_zero            | 浮点数显示配置项。控制数值类型中char、character、nchar、varchar、character varying、varchar2、nvarchar2、text、clob等所有字符串类型和float4、float8、numeric等任意精度类型的小数点前零显示。并且length计算数字长度同步显示。 - 不设置此配置项时，对于-1\~0和0\~1之间的小数，不显示小数点前的0。比如： ``` openGauss=# select 0.1231243 as a, 0.1231243::numeric as b,0.1231243::integer(10,3) as c, length(0.1242343) as d; a     |    b     |  c   | d ----------+----------+------+--- .1231243 | .1231243 | .123 | 8 (1 row) ```   - 设置此配置项时，对于-1\~0和0\~1之间的小数，显示小数点前的0。比如： ``` openGauss=# select 0.1231243 as a, 0.1231243::numeric as b,0.1231243::integer(10,3) as c, length(0.1242343) as d; a     |     b     |   c   | d -----------+-----------+-------+--- 0.1231243 | 0.1231243 | 0.123 | 9 (1 row) ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| end_month_calculate             | add_months函数计算逻辑配置项。 假定函数add_months的两个参数分别为param1和param2，param1的月份和param2的和为月份result。 - 不设置此配置项时，如果param1的日期（Day字段）为月末，并且param1的日期（Day字段）比result月份的月末日期小，计算结果中的日期字段（Day字段）和param1的日期字段保持一致。比如， ``` openGauss=# select add_months('2018-02-28',3) from sys_dummy; add_months --------------------- 2018-05-28 00:00:00 (1 row) ```     - 设置此配置项时，如果param1的日期（Day字段）为月末，并且param1的日期（Day字段）比result月份的月末日期比小，计算结果中的日期字段（Day字段）和result的月末日期保持一致。比如， ``` openGauss=# select add_months('2018-02-28',3) from sys_dummy; add_months --------------------- 2018-05-31 00:00:00 (1 row) ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| compat_analyze_sample           | analyze采样行为配置项。 设置此配置项时，会优化analyze的采样行为，主要体现在analyze时全局采样会更精确的控制在3万条左右，更好地控制analyze时DBnode端的内存消耗，保证analyze性能的稳定性。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| bind_schema_tablespace          | 绑定模式与同名表空间配置项。 如果存在与模式名sche_name相同的表空间名，那么如果设置search_path为sche_name， default_tablespace也会同步切换到sche_name。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |
| bind_procedure_searchpath       | 未指定模式名的存储过程中的数据库对象的搜索路径配置项。 在存储过程中如果不显示指定模式名，会优先在存储过程所属的模式下搜索。 如果找不到，则有两种情况： - 若不设置此参数，报错退出。  - 若设置此参数，按照search_path中指定的顺序继续搜索。如果还是找不到，报错退出。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| correct_to_number               | 控制to_number()结果兼容性的配置项。 若不设置此配置项，则to_number()函数结果默认与A数据库保持一致。 ``` openGauss=# select '' AS to_number_14, to_number('34,50','999,99'); ERROR:  invalid data. CONTEXT:  referenced column: to_number ``` 若设置此配置项，则to_number()函数结果与pg11保持一致。 ``` openGauss=# select '' AS to_number_14, to_number('34,50','999,99'); to_number_14 | to_number --------------+----------- |      3450 (1 row) ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| unbind_divide_bound             | 控制对整数除法的结果进行范围校验。 若不设置此配置项，则会对除法结果做范围校验，例如，INT_MIN/(-1)会因为输出结果大于INT_MAX而报越界错误。 ``` openGauss=# select (-2147483648)::int4 / (-1)::int4; ERROR:  integer out of range ``` 若设置此配置项，则不需要对除法结果做范围校验，例如，INT_MIN/(-1)可以得到输出结果为INT_MAX+1。 ``` openGauss=# select (-2147483648)::int4 / (-1)::int4; ?column? ------------ 2147483648 (1 row) ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| convert_string_digit_to_numeric | 控制是否将表中以字符串形式表示的numeric常量和数字类型做比较时统一都转换为numeric类型再进行比较。 ``` openGauss=# create table test1 (c1 int, c2 varchar); openGauss=# insert into test1 values (2, '1.1'); openGauss=# set behavior_compat_options=''; openGauss=# select * from test1 where c2 > 1; ERROR:  invalid input syntax for type bigint: "1.1" openGauss=# set behavior_compat_options='convert_string_digit_to_numeric'; openGauss=# select * from test1 where c2 > 1; c1 | c2 ----+----- 2 | 1.1 (1 row) ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| return_null_string              | 控制函数lpad()和rpad()结果为空字符串''的显示配置项。 - 不设置此配置项时，空字符串显示为NULL。   ``` openGauss=# select length(lpad('123',0,'*')) from sys_dummy; length -------- (1 row) ``` - 设置此配置项时，空字符串显示为'0'。   ``` openGauss=# select length(lpad('123',0,'*')) from sys_dummy; length -------- 0 (1 row) ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| compat_concat_variadic          | 控制函数concat()和concat_ws()对variadic类型结果兼容性的配置项。由于B数据库无variadic类型，所以该选项对B数据库无影响。 若不设置此配置项，当concat函数参数为variadic类型时，默认A数据库和C数据库兼容模式下结果相同，且与A数据库保持一致。 ``` openGauss=# select concat(variadic NULL::int[]) is NULL; ?column? ---------- t (1 row) ``` 若设置此配置项，当concat函数参数为variadic类型时，保留A数据库和C数据库兼容模式下不同的结果形式。 ``` --A数据库下： openGauss=# select concat(variadic NULL::int[]) is NULL; ?column? ---------- t (1 row) --C数据库下： openGauss=# select concat(variadic NULL::int[]) is NULL; ?column? ---------- f (1 row) ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| merge_update_multi              | 控制在使用MERGE INTO ... WHEN MATCHED THEN UPDATE（参见《开发指南》中"SQL参考 \> SQL语法 \> MERGE INTO"章节） 和INSERT ... ON DUPLICATE KEY UPDATE（参见《开发指南》中"SQL参考 \> SQL语法 \> INSERT"章节）时，当目标表中一条目标数据与多条源数据冲突时UPDATE行为。 若设置此配置项，当存在上述场景时，该冲突行将会多次执行UPDATE；否则（默认）报错，即MERGE或INSERT操作失败。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| plstmt_implicit_savepoint       | 控制存储过程中更新语句的执行是否拥有独立的子事务。 若设置此配置项，存储过程中每条更新语句前开启隐式保存点，EXCEPTION块中默认回退到最近的保存点，从而保证只回退失败语句的修改。该选项是为了兼容O数据库的EXCEPTION行为。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| hide_tailing_zero               | numeric显示配置项。不设置此项时，numeric按照指定精度显示；设置此项时，所有输出numeric的场景均隐藏小数点后的末尾0，包括显示指定format精度情况。 例如： ``` openGauss=# set behavior_compat_options='hide_tailing_zero'; openGauss=# select cast(123.123 as numeric(15,10)) as a, to_char(cast(123.123 as numeric(15,10)), '999D999999'); a    | to_char ---------+---------- 123.123 |  123.123 (1 row) openGauss=# set behavior_compat_options=''; openGauss=# select cast(123.123 as numeric(15,10)) as a, to_char(cast(123.123 as numeric(15,10)), '999D999999'); a        |   to_char ----------------+------------- 123.1230000000 |  123.123000 (1 row) ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| rownum_type_compat              | 控制ROWNUM的类型，ROWNUM默认类型为BIGINT，设置此参数后，ROWNUM类型变更为NUMERIC类型。 ``` openGauss=# set behavior_compat_options=''; openGauss=# create table tb_test(c1 int,c2 varchar2,c3 varchar2); openGauss=# insert into tb_test values(1,'a','b'); openGauss=# create or replace view v_test as select rownum from tb_test; openGauss=# \d+ v_test View "public.v_test" Column |  Type  | Modifiers | Storage | Description --------+--------+-----------+---------+------------- rownum | bigint |           | plain   | View definition: SELECT ROWNUM AS "rownum" FROM tb_test; openGauss=# set behavior_compat_options = 'rownum_type_compat'; openGauss=# create or replace view v_test1 as select rownum from tb_test; openGauss=# \d+ v_test1 View "public.v_test1" Column |  Type   | Modifiers | Storage | Description --------+---------+-----------+---------+------------- rownum | numeric |           | main    | View definition: SELECT ROWNUM AS "rownum" FROM tb_test; ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| aformat_null_test               | 控制rowtype类型判空逻辑。 设置此项时，对于rowtype is not null的判断逻辑为当一行数据有一列不为空的时候返回true；不设置此项时，对于rowtype is not null的判断逻辑为当一行数据所有列不为空的时候返回true。该参数不影响rowtype is null的判断。 ``` openGauss=# set behavior_compat_options='aformat_null_test'; openGauss=# select r, r is null as isnull, r is not null as isnotnull from (values (1,row(1,2)), (1,row(null,null)), (1,null), (null,row(1,2)), (null,row(null,null)), (null,null) ) r(a,b); r      | isnull | isnotnull -------------+--------+----------- (1,"(1,2)") | f      | t (1,"(,)")   | f      | t (1,)        | f      | t (,"(1,2)")  | f      | t (,"(,)")    | f      | t (,)         | t      | f (6 rows) openGauss=# set behavior_compat_options=''; openGauss=# select r, r is null as isnull, r is not null as isnotnull from (values (1,row(1,2)), (1,row(null,null)), (1,null), (null,row(1,2)), (null,row(null,null)), (null,null) ) r(a,b); r      | isnull | isnotnull -------------+--------+----------- (1,"(1,2)") | f      | t (1,"(,)")   | f      | t (1,)        | f      | f (,"(1,2)")  | f      | f (,"(,)")    | f      | f (,)         | t      | f (6 rows) ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| aformat_regexp_match            | 控制正则表达式函数的匹配行为。 设置此项，且sql_compatibility参数的值为A或B时，正则表达式的flags参数支持的选项含义有变更： 1. 默认不能匹配 '\\n' 字符。  2. flags中包含n选项时， . 能够匹配 '\\n' 字符。  3. regexp_replace(source, pattern replacement) 函数替换所有匹配的子串。  4. regexp_replace(source, pattern, replacement, flags) 在 flags值为'' 或者null时，返回值为null。   否则，正则表达式的 flags 参数支持的选项含义： 1. 默认能匹配 '\\n' 字符。  2. flags 中的 n 选项表示按照多行模式匹配。  3. regexp_replace(source, pattern replacement) 函数仅替换第一个匹配到的子串。  4. regexp_replace(source, pattern, replacement, flags) 在 flags值为'' 或者null时，返回值为替换后的字符串。   |
| compat_cursor                   | 控制隐式游标状态兼容行为。设置此项，且兼容O，隐式游标状态（SQL%FOUND、SQL%NOTFOUND、SQL%ISOPNE、SQL%ROWCOUNT）由原先的仅在当前执行的函数有效，拓展到包括本函数调用的子函数有效。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |
| proc_outparam_override          | 控制存储过程出参的重载行为，打开该参数后，对于存储过程只有out出参部分不同的情况下，也可以正常创建和调用。目前只有gsql与jdbc连接数据库时可以使用该参数，对于其他工具打开该参数连接数据库时无法正常调用带有out的存储过程。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| proc_implicit_for_loop_variable | 控制存储过程中FOR_LOOP查询语句行为设置此项时，在FOR rec IN query LOOP语句中，若rec已经定义，不会复用已经定义的rec变量，而且重新建立一个新的变量。否则，会复用已经定义的rec变量，不会建立新的变量。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| allow_procedure_compile_check   | 控制存储过程中select语句和open cursor语句的编译检查。设置此项时，在存储过程中执行select语句、open cursor for语句、cursor%rowtype语句、for rec in语句时，若查询的表不存在，则无法创建存储过程，不支持trigger函数的编译检查，若查询的表存在，则成功创建存储过程。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| char_coerce_compat              | 控制char(n)类型向其它变长字符串类型转换时的行为。不设置该参数时，char(n)类型转换其它变长字符串类型时会省略尾部的空格，设置该参数时，转换时不再省略尾部的空格，并且在转换时如果char(n)类型的长度超过其它变长字符串类型时将会报错。该参数仅在sql_compatibility参数的值为A时生效，并且开启该参数后无论是隐式转换、显式转换还是通过调用text(bpchar)函数转换类型都不再省略尾部空格。 ``` openGauss=# set behavior_compat_options=''; openGauss=# create table tab_1(col1 varchar(3)); openGauss=# create table tab_2(col2 char(3)); openGauss=# insert into tab_2 values('   '); openGauss=# insert into tab_1 select col2 from tab_2; openGauss=# select * from tab_1 where col1 is null; col1 ------ (1 row) openGauss=# select * from tab_1 where col1='   '; col1 ------ (0 rows) openGauss=# delete from tab_1; openGauss=# set behavior_compat_options = 'char_coerce_compat'; openGauss=# insert into tab_1 select col2 from tab_2; openGauss=# select * from tab_1 where col1 is null; col1 ------ (0 rows) openGauss=# select * from tab_1 where col1='   '; col1 ------ (1 row) ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| truncate_numeric_tail_zero      | numeric显示配置项。不设置此项时，numeric按照默认精度显示；设置此项时，除去to_char(numeric, format)这种显示设置精度的情况，所有输出numeric的场景均会隐藏小数点后的末尾0。例如： ``` openGauss=#set behavior_compat_options='truncate_numeric_tail_zero'; openGauss=#select cast(123.123 as numeric(15,10)) as a, to_char(cast(123.123 as numeric(15,10)), '999D999999'); a    |   to_char ---------+------------- 123.123 |  123.123000 (1 row) openGauss=#set behavior_compat_options=''; openGauss=#select cast(123.123 as numeric(15,10)) as a, to_char(cast(123.123 as numeric(15,10)), '999D999999'); a        |   to_char ----------------+------------- 123.1230000000 |  123.123000 (1 row) ```                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| plsql_security_definer          | 开启此参数后，创建存储过程时默认为定义者权限。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| array_count_compat              | 控制array.count函数，开启参数时返回0，否则返回null。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |
| disable_emptystr2null           | 开启此参数后，关闭所有字符类型默认将空串转换为null功能。包括text、clob、blob、raw、bytea、varchar、nvarchar2、bpchar、char、name、byteawithoutorderwithqualcol、byteawithoutordercol类型。该参数为逃生参数，非必要用户不要自行设置。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |
| proc_uncheck_default_param      | 函数调用时不检查默认参数省略情况配置项。 - 不设置此配置项时，调用带有默认参数的函数时，入参从左往右排入函数，如果有非默认参数的入参缺失则会报错。比如： ``` openGauss=# create or replace function test(f1 int, f2 int default 20, f3 int, f4 int default 40, f5 int default 50) return int openGauss-# as openGauss$# begin openGauss$# raise info 'f1:%',f1; openGauss$# raise info 'f2:%',f2; openGauss$# raise info 'f3:%',f3; openGauss$# raise info 'f4:%',f4; openGauss$# raise info 'f5:%',f5; openGauss$# return 1; openGauss$# end; openGauss$# / CREATE FUNCTION openGauss=# select test(1,2); ERROR:  function test(integer, integer) does not exist LINE 1: select test(1,2); ^ HINT:  No function matches the given name and argument types. You might need to add explicit type casts. CONTEXT:  referenced column: test ```   - 设置此配置项时，调用带有默认参数的函数时，入参从左往右排入函数，允许缺省默认参数个入参，如果有非默认参数的入参缺失，则会用错位的默认值填充该参数。比如： ``` openGauss=# create or replace function test(f1 int, f2 int default 20, f3 int, f4 int default 40, f5 int default 50) return int openGauss-# as openGauss$# begin openGauss$# raise info 'f1:%',f1; openGauss$# raise info 'f2:%',f2; openGauss$# raise info 'f3:%',f3; openGauss$# raise info 'f4:%',f4; openGauss$# raise info 'f5:%',f5; openGauss$# return 1; openGauss$# end; openGauss$# / CREATE FUNCTION openGauss=# select test(1,2); INFO:  f1:1 CONTEXT:  referenced column: test INFO:  f2:2 CONTEXT:  referenced column: test INFO:  f3:20 CONTEXT:  referenced column: test INFO:  f4:40 CONTEXT:  referenced column: test INFO:  f5:50 CONTEXT:  referenced column: test test ------ 1 (1 row) ``` 如上，f3被错误的默认值填充。 警告： 该场景下，非默认参数会被错位的默认值填充。                                                                                                                                          |
| plsql_rollback_keep_user        | 控制在PL/SQL中rollback和rollback to savepoint是否回退当前用户。当开启此参数时，PL/SQL中rollback将不会修改当前用户。 示例： ``` openGauss=# CREATE USER plsql_rollback1 password 'huawei@123'; openGauss=# CREATE USER plsql_rollback2 password 'huawei@123'; openGauss=# GRANT plsql_rollback1 to plsql_rollback2; openGauss=# CREATE OR REPLACE procedure plsql_rollback1.p1 () authid definer openGauss-# as openGauss$# va int; openGauss$# begin openGauss$# raise info 'current usr:%', current_user; openGauss$# rollback; openGauss$# raise info 'current usr:%', current_user; openGauss$# end; openGauss$# / CREATE PROCEDURE openGauss=# SET session AUTHORIZATION plsql_rollback2 PASSWORD 'huawei@123'; SET openGauss=> SET behavior_compat_options = 'plsql_rollback_keep_user'; SET openGauss=> CALL plsql_rollback1.p1 (); INFO:  current usr:plsql_rollback1 INFO:  current usr:plsql_rollback1 p1 ---- (1 row) ``` 注意： 该参数仅在数据库兼容性为A下有效。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| dynamic_sql_check               | 开启参数后，对模板SQL中的模板参数个数和using子句中变量个数进行对比，不一致则报错。 ``` openGauss=# create table tb_t1(col1 varchar2,col2 varchar2,col3 varchar2); CREATE TABLE openGauss=# insert into tb_t1 select '1','1','2'; INSERT 0 1 openGauss=# create or replace procedure proc_test()as openGauss$# v_a varchar2; openGauss$# v_b varchar2; openGauss$# v_cnt int; openGauss$# v_sql varchar2; openGauss$# begin openGauss$# v_a = '1'; openGauss$# v_b = '2'; openGauss$# v_sql = 'select count(1) from tb_t1 where col1 = :va and col2 = :va and col3 = :vb;'; openGauss$# execute immediate v_sql into v_cnt using v_a,v_a,v_b; openGauss$# raise info 'v_cnt:%',v_cnt; openGauss$# end; openGauss$# / CREATE PROCEDURE openGauss=# call proc_test(); INFO:  v_cnt:0 proc_test ----------- (1 row) openGauss=# set behavior_compat_options='dynamic_sql_check'; SET openGauss=# call proc_test(); ERROR:  argnum not match in Dynamic SQL, using args num : 3 , actual sql args num : 2 CONTEXT:  SQL statement "select count(1) from tb_t1 where col1 = :va and col2 = :va and col3 = :vb;" PL/SQL function proc_test() line 10 at EXECUTE statemen ``` 注意： 不推荐同时使用dynamic_sql_check和dynamic_sql_compat选项，开启dynamic_sql_compat选项后，dynamic_sql_check选项将不再生效。                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
   
#### plsql_compile_check_options
**参数说明：**数据库兼容性行为配置项，该参数的值由若干个配置项用逗号隔开构成。
该参数属于USERSET类型参数，请参考[表1](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_1169.html#ZH-CN_TOPIC_0000002222152125__zh-cn_topic_0000002063779510_zh-cn_topic_0289899927_zh-cn_topic_0283137176_zh-cn_topic_0237121562_zh-cn_topic_0059777490_t91a6f212010f4503b24d7943aed6d846)中对应设置方法进行设置。
**取值范围：**字符串
**默认值：**""
![](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/public_sys-resources/note_3.0-zh-cn.png)
- 当前只支持[表1]。
- 配置多个兼容性配置项时，相邻配置项用逗号隔开，例如：set plsql_compile_check_options='for_loop,outparam';
 
表2兼容性配置项 
| **兼容性配置项** | **兼容性行为控制**                                                                                                                                                     |
|:---|:---|
| for_loop   | 控制存储过程中FOR_LOOP查询语句行为设置此项时，在FOR rec IN query LOOP语句中，若rec已经定义，不会复用已经定义的rec变量，而且重新建立一个新的变量。否则，会复用已经定义的rec变量，不会建立新的变量。(与proc_implicit_for_loop_variable相同，后续进行收编) |
| outparam   | out重载条件下，有重载函数；将对out出参常量进行检查，禁止out出参为常量。                                                                                                                        |
   
#### a_format_version
**参数说明：**数据库平台兼容性行为配置项，该参数的值为字符串枚举值。
该参数属于USERSET类型参数，请参考[表1](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_1169.html#ZH-CN_TOPIC_0000002222152125__zh-cn_topic_0000002063779510_zh-cn_topic_0289899927_zh-cn_topic_0283137176_zh-cn_topic_0237121562_zh-cn_topic_0059777490_t91a6f212010f4503b24d7943aed6d846)中对应设置方法进行设置。
**取值范围：**字符串
**默认值：**""
![](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/public_sys-resources/note_3.0-zh-cn.png)
- 当前只支持[表1]。
- 兼容性配置项时设置字符串，例如：set a_format_version='10c';
 
表3兼容性配置项 
| **兼容性配置项** | **兼容性行为控制** |
|:---|:---|
| 10c        | A平台兼容版本。    |
   
#### a_format_dev_version
**参数说明：**数据库平台迭代小版本兼容性行为配置项，该参数的值为字符串枚举值。
该参数属于USERSET类型参数，请参考[表1](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_1169.html#ZH-CN_TOPIC_0000002222152125__zh-cn_topic_0000002063779510_zh-cn_topic_0289899927_zh-cn_topic_0283137176_zh-cn_topic_0237121562_zh-cn_topic_0059777490_t91a6f212010f4503b24d7943aed6d846)中对应设置方法进行设置。
**取值范围：**字符串
**默认值：**""
![](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/public_sys-resources/note_3.0-zh-cn.png)
- 当前只支持[表1]。
- 兼容性配置项时设置字符串，例如：set a_format_dev_version='s1';
 
表4兼容性配置项 
| **兼容性配置项** | **兼容性行为控制**               |
|:---|:---|
| s1         | 开启参数后cast支持 text转int四舍五入。 |
   
#### plpgsql.variable_conflict
**参数说明**：设置同名的存储过程变量和表的列的使用优先级。
该参数属于USERSET类型参数，仅支持[表2](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_1169.html#ZH-CN_TOPIC_0000002222152125__zh-cn_topic_0000002063779510_zh-cn_topic_0289899927_zh-cn_topic_0283137176_zh-cn_topic_0237121562_zh-cn_topic_0059777490_t290c8f15953843db8d8e53d867cd893d)中对应设置方法3进行设置。
**取值范围**：字符串
- error表示遇到存储过程变量和表的列名同名则编译报错。
- use_variable表示存储过程变量和表的列名同名则优先使用变量。
- use_column表示存储过程变量和表的列名同名则优先使用列名。
**默认值**：error
#### td_compatible_truncation
**参数说明：**控制是否开启与Teradata数据库相应兼容的特征。该参数在用户连接上与TD兼容的数据库时，可以将参数设置成为on（即超长字符串自动截断功能启用），该功能启用后，在后续的insert语句中，对目标表中char和varchar类型的列插入超长字符串时，会按照目标表中相应列定义的最大长度对超长字符串进行自动截断。保证数据都能插入目标表中，而不是报错。
![](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/public_sys-resources/note_3.0-zh-cn.png)
超长字符串自动截断功能不适用于insert语句包含外表的场景。
如果向字符集为字节类型编码（SQL_ASCII、LATIN1等）的数据库中插入多字节字符数据（如汉字等），且字符数据跨越截断位置，这种情况下，按照字节长度自动截断，自动截断后会在尾部产生非预期结果。如果用户有对于截断结果正确性的要求，建议用户采用UTF8等能够按照字符截断的输入字符集作为数据库的编码集。
该参数属于USERSET类型参数，请参考[表2](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_1169.html#ZH-CN_TOPIC_0000002222152125__zh-cn_topic_0000002063779510_zh-cn_topic_0289899927_zh-cn_topic_0283137176_zh-cn_topic_0237121562_zh-cn_topic_0059777490_t290c8f15953843db8d8e53d867cd893d)中对应设置方法进行设置。
**取值范围：**布尔型
- on表示启动超长字符串自动截断功能。
- off表示停止超长字符串自动截断功能。
**默认值：**off
#### uppercase_attribute_name
**参数说明**：设置列名以大写形式返回给客户端。该参数仅限于ORA兼容模式和集中式环境下使用。
该参数属于USERSET类型参数，请参考[表2](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_1169.html#ZH-CN_TOPIC_0000002222152125__zh-cn_topic_0000002063779510_zh-cn_topic_0289899927_zh-cn_topic_0283137176_zh-cn_topic_0237121562_zh-cn_topic_0059777490_t290c8f15953843db8d8e53d867cd893d)中对应设置方法进行设置。
**取值范围：**布尔型
- on表示开启列名以大写形式返回给客户端。
- off表示关闭列名以大写形式返回给客户端。
**默认值**：off
#### lastval_supported
**参数说明：**控制是否可以使用lastval函数。
该参数属于POSTMASTER类型参数，请参考[表1](https://support.huaweicloud.com/centralized-devg-v2-gaussdb/gaussdb_42_1169.html#ZH-CN_TOPIC_0000002222152125__zh-cn_topic_0000002063779510_zh-cn_topic_0289899927_zh-cn_topic_0283137176_zh-cn_topic_0237121562_zh-cn_topic_0059777490_t91a6f212010f4503b24d7943aed6d846)中对应设置方法进行设置。
**取值范围：**布尔型
- on表示支持lastval函数，同时nextval函数不支持下推。
- off表示不支持lastval函数，同时nextval函数可以下推。
**默认值：**off
