更新时间:2024-05-31 GMT+08:00
分享

平台和客户端兼容性

很多平台都使用数据库系统,数据库系统的对外兼容性给平台提供了很大的方便。

a_format_date_timestamp

参数说明:控制返回日期时间。

在ORA模式下,当事务开启时,函数current_date、current_timestamp、localtimestamp返回当前SQL启动的时间戳。

参数类型:布尔型

参数单位:

取值范围

  • on:返回当前SQL启动的时间戳
  • off:返回事务开启的日期或日期及时间

默认值:off

设置方式:该参数属于USERSET类型参数,请参见表1中对应设置方法进行设置。

设置建议:推荐使用默认值。在开启事务需要返回系统时间时可开启该参数。

transform_null_equals

参数说明:控制表达式expr = NULL(或NULL = expr)当做expr IS NULL处理。如果expr得出NULL值则返回真,否则返回假。

  • 正确的SQL标准兼容的expr = NULL总是返回NULL(未知)。
  • Microsoft Access里的过滤表单生成的查询使用expr = NULL来测试空值。打开这个选项,可以使用该接口来访问数据库。

该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

取值范围:布尔型

  • on表示控制表达式expr = NULL(或NULL = expr)当做expr IS NULL处理。
  • off表示不控制,即expr = NULL总是返回NULL(未知)。

默认值:off

新用户经常在涉及NULL的表达式上语义混淆,故默认值设为off。

support_extended_features

参数说明:控制是否支持数据库的扩展特性。

该参数属于POSTMASTER类型参数,请参考表1中对应设置方法进行设置。

取值范围:布尔型

  • on表示支持数据库的扩展特性。
  • off表示不支持数据库的扩展特性。

默认值:off

character_set_connection

参数说明:用于设置常量字符串的字符集。修改该参数会同步将collation_connection修改成该字符集的默认字符序。仅在sql_compatibility = 'MySQL'兼容模式下,并在设置b_format_version='5.7'、b_format_dev_version='s2'时生效。

参数类型:字符型

参数单位:

取值范围:sql_compatibility = 'MySQL'兼容性模式下支持的字符集。参见《开发者指南》中“SQL参考 > SQL语法 >C > CREATE TABLE”章节中的“COLLATE collation”。暂不支持设置成与当前数据库字符集不同的值。

默认值:与当前server_encoding保持一致。

设置方式:该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置(但不支持通过GUC工具设置)。

设置建议:

collation_connection

参数说明:用于设置常量字符串的字符序。修改该参数会同步将character_set_connection修改成该字符序的默认字符集。仅在sql_compatibility = 'MySQL'兼容模式下,并在设置b_format_version='5.7'、set b_format_dev_version='s2'时生效。

参数类型:字符型

参数单位:

取值范围:sql_compatibility = 'MySQL'兼容性模式下支持的字符序。参见《开发者指南》中“SQL参考 > SQL语法 >C > CREATE TABLE”章节中的“COLLATE collation”。暂不支持设置成当前数据库字符集对应字符序之外的值。

默认值:当前server_encoding的默认字符序,若没有server_encoding的默认字符序,则为default。

设置方式:该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置(但不支持通过GUC工具设置)。

设置建议:

character_set_results

参数说明:用于设置返回结果的字符集。仅在sql_compatibility = 'MySQL'兼容模式下,并在设置b_format_version='5.7'、b_format_dev_version='s2'时生效。

参数类型:字符型

参数单位:

取值范围:sql_compatibility = 'MySQL'兼容性模式下支持的字符集。参见《开发者指南》中“SQL参考 > SQL语法 >C > CREATE TABLE”章节中的“COLLATE collation”。还可以设置成null或'',此时直接以数据库的字符集输出。

默认值:与当前server_encoding保持一致。

设置方式:该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置(但不支持通过GUC工具设置)。

设置建议:

lastval_supported

参数说明:控制是否可以使用lastval函数。

该参数属于POSTMASTER类型参数,请参考表1中对应设置方法进行设置。

取值范围:布尔型

  • on表示支持lastval函数,同时nextval函数不支持下推。
  • off表示不支持lastval函数,同时nextval函数可以下推。

默认值:off

group_concat_max_len

参数说明:搭配函数GROUP_CONCAT使用,限制其返回值长度,超长截断。

参数类型:整型

参数单位:

取值范围:0~9223372036854775807,目前实际生效的最大长度是1073741823,超出此长度后会有out of memory的报错。

默认值:1024

设置方式:该参数属于USERSET类型参数,请参见表1中对应设置方法进行设置。

设置建议:推荐使用默认值。

sql_compatibility

参数说明:控制数据库的SQL语法和语句行为同哪一个主流数据库兼容。该参数属于INTERNAL类型参数,用户无法修改,只能查看。

取值范围:枚举型

  • ORA表示同oracle兼容。
  • TD表示同Teradata兼容。
  • MYSQL表示同MySQL兼容。
  • PG表示同PostgreSQL兼容。

默认值:MYSQL

  • 该参数只能在执行CREATE DATABASE命令(详见《开发者指南》的“SQL参考 > SQL语法 > CREATE DATABASE”章节)创建数据库的时候设置。
  • 在数据库中,该参数只能是确定的一个值,要么始终设置为ORA,要么始终设置为TD,请勿任意改动,否则会导致数据库行为不一致。

b_format_behavior_compat_options

参数说明:数据库MYSQL模式兼容性行为配置项。

参数类型:字符串

参数单位:

取值范围:当前只支持表1 B模式兼容性配置项,当设置多个兼容性配置项时,相邻配置项之间用逗号隔开。

默认值:""

此参数在b_format_version参数设置不为''时,b_format_behavior_compat_options会被设置为"all",而且不能被修改。

表1 MYSQL模式兼容性配置项

兼容性配置项

兼容性行为控制

default_collation

默认字符序前向兼容开关。

  • 若不设置此配置项,在未显式指定字符类型字段的字符集或字符序且表级字符序也为空时,字段为default字符序。
  • 若设置此配置项,字符类型字段的字符序当表级字符序不为空时继承表级字符序,为空时设置为数据库编码对应的默认字符序。

all

打开所有语法控制开关。

all不能同时和其他配置项一起指定。表格中除all外所有配置项逗号隔开的含义和取值为all含义相同。

设置方式:该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

设置建议:控制一些MYSQL兼容性特性是否可用,若要更改,请在理解参数含义后谨慎操作,避免因误操作产生意料之外的风险。

behavior_compat_options

参数说明:数据库兼容性行为配置项。

参数类型:字符串

参数单位:

取值范围:当前只支持表2,当设置多个兼容性配置项时,相邻配置项之间用逗号隔开,例如:set behavior_compat_options='end_month_calculate,display_leading_zero';。

默认值:"enable_bpcharlikebpchar_compare,enable_crosstype_integer_operator"

表2 兼容性配置项

兼容性配置项

兼容性行为控制

display_leading_zero

浮点数显示配置项。控制数值类型中char、character、nchar、varchar、character varying、varchar2、nvarchar2、text、clob等所有字符串类型和float4、float8、numeric等任意精度类型的小数点前零的显示,length计算数字长度同步显示。

  • 不设置此配置项时,对于-1~0和0~1之间的小数,不显示小数点前的0。比如:
    1
    2
    3
    4
    5
    gaussdb=# 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。比如:
    1
    2
    3
    4
    5
    gaussdb=# 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的日期字段保持一致。比如,
    1
    2
    3
    4
    5
    gaussdb=# 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的月末日期保持一致。比如,
    1
    2
    3
    4
    5
    gaussdb=# 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时Coordinator端的内存消耗,保证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()函数结果默认与ORA数据库保持一致。
    1
    2
    3
    gaussdb=# select '' AS to_number_14, to_number('34,50','999,99');
    ERROR:  invalid data.
    CONTEXT:  referenced column: to_number
    
  • 若设置此配置项,则to_number()函数结果与pg11保持一致。
    1
    2
    3
    4
    5
    gaussdb=# 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而报越界错误。
    1
    2
    gaussdb=# select (-2147483648)::int4 / (-1)::int4;
    ERROR:  integer out of range
    
  • 若设置此配置项,则不需要对除法结果做范围校验,例如,INT_MIN/(-1)可以得到输出结果为INT_MAX+1。
    1
    2
    3
    4
    5
    gaussdb=# select (-2147483648)::int4 / (-1)::int4;
      ?column?  
    ------------
     2147483648
    (1 row)
    

convert_string_digit_to_numeric

控制当表中以字符串形式表示的numeric常量和数字类型做比较时,是否都统一转换为numeric类型再进行比较。

  • 若不设置此配置项,不会将以字符串形式表示的numeric常量转换为numeric类型。
  • 若设置此配置项,会将以字符串形式表示的numeric常量转换为numeric类型。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
gaussdb=# create table test1 (c1 int, c2 varchar);
gaussdb=# insert into test1 values (2, '1.1');
gaussdb=#  set behavior_compat_options='';
gaussdb=#  select * from test1 where c2 > 1;
ERROR:  invalid input syntax for type bigint: "1.1"

gaussdb=#  set behavior_compat_options='convert_string_digit_to_numeric';
gaussdb=#  select * from test1 where c2 > 1;
 c1 | c2  
----+-----
  2 | 1.1 
(1 row)

return_null_string

控制函数lpad()和rpad()结果为空字符串''的显示配置项。

  • 不设置此配置项时,空字符串显示为NULL。
    1
    2
    3
    4
    5
    gaussdb=# select length(lpad('123',0,'*')) from sys_dummy;
    length
    --------
    
    (1 row)
    
  • 设置此配置项时,空字符串显示为''。
    1
    2
    3
    4
    5
    gaussdb=# select length(lpad('123',0,'*')) from sys_dummy;
    length
    --------
    0
    (1 row)
    

compat_concat_variadic

控制函数concat()和concat_ws()对variadic类型结果兼容性的配置项。由于MYSQL数据库无variadic类型,所以该选项对MY数据库无影响。

  • 若不设置此配置项,当concat函数参数为variadic类型时,默认ORA数据库和TD数据库兼容模式下结果相同,且与ORA数据库保持一致。
    1
    2
    3
    4
    5
    gaussdb=# select concat(variadic NULL::int[]) is NULL;
     ?column? 
    ----------
     t
    (1 row)
    
  • 若设置此配置项,当concat函数参数为variadic类型时,保留ORA数据库和TD数据库兼容模式下不同的结果形式。
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    --ORA数据库下:
    gaussdb=# select concat(variadic NULL::int[]) is NULL;
     ?column? 
    ----------
     t
    (1 row)
    --TD数据库下:
    gaussdb=# 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块中默认回退到最近的保存点,从而保证只回退失败语句的修改。该选项是为了兼容ORA数据库的EXCEPTION行为。

hide_tailing_zero

numeric显示配置项。

  • 若设置此配置项,所有输出numeric的场景均隐藏小数点后的末尾0,包括显示指定format精度情况。
  • 若不设置此配置项,numeric按照指定精度显示;

例如:

gaussdb=# set behavior_compat_options='hide_tailing_zero';
gaussdb=# 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)
gaussdb=# set behavior_compat_options='';
gaussdb=# 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

开启此参数后,创建存储过程时默认为定义者权限。

char_coerce_compat

控制char(n)类型向其它变长字符串类型转换时的行为。该参数仅在sql_compatibility参数的值为ORA时生效,并且开启该参数后无论是隐式转换、显式转换还是通过调用text(bpchar)函数转换类型都不再省略尾部空格。

  • 若设置此配置项,转换时不再省略尾部的空格,并且如果char(n)类型的长度超过其它变长字符串类型,将会报错。
  • 若不设置此配置项,char(n)类型转换其它变长字符串类型时,会省略尾部的空格。
gaussdb=# set behavior_compat_options='';
gaussdb=# create table tab_1(col1 varchar(3)); 
gaussdb=# create table tab_2(col2 char(3));
gaussdb=# insert into tab_2 values('   ');
gaussdb=# insert into tab_1 select col2 from tab_2;
gaussdb=# select * from tab_1 where col1 is null;
 col1 
------
 
(1 row)
gaussdb=# select * from tab_1 where col1='   ';
 col1 
------
(0 rows)
gaussdb=# delete from tab_1;
gaussdb=# set behavior_compat_options = 'char_coerce_compat';
gaussdb=# insert into tab_1 select col2 from tab_2;
gaussdb=# select * from tab_1 where col1 is null;
 col1 
------
(0 rows)
gaussdb=# select * from tab_1 where col1='   ';
 col1 
------
    
(1 row)

truncate_numeric_tail_zero

numeric显示配置项。

  • 若设置此配置项,除to_char(numeric, format)这种显示设置精度的情况外,所有输出numeric的场景均会隐藏小数点后的末尾0。
  • 若不设置此配置项,numeric按照默认精度显示。

例如:

gaussdb=# set behavior_compat_options='truncate_numeric_tail_zero';
gaussdb=# 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)
gaussdb=# set behavior_compat_options='';
gaussdb=# 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)

plpgsql_dependency

已废弃。

disable_rewrite_nesttable

分布式不支持。

proc_outparam_override

控制存储过程出参的重载行为,打开该参数后,对于存储过程只有out出参部分不同的情况,也可以正常创建和调用。目前只有gsql与jdbc连接数据库时可以使用该参数,对于其他工具打开该参数连接数据库时无法正常调用带有out的存储过程。

支持out出参正常赋值。

aformat_regexp_match

控制正则表达式函数的匹配行为。

设置此项,且sql_compatibility参数的值为ORA或MYSQL时,正则表达式的 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时,返回值为替换后的字符串。

disable_emptystr2null

A兼容模式绑参场景中,开启此参数后,关闭默认将字符类型传参的值从空串转换为null功能。包括text、clob、blob、raw、bytea、varchar、nvarchar2、bpchar、char、name、byteawithoutorderwithqualcol、byteawithoutordercol类型。该参数为逃生参数,非必要用户不要自行设置。

select_into_return_null

该参数在分布式场景下无效。

proc_uncheck_default_param

函数调用时不检查默认参数省略情况配置项。

  • 若不设置此配置项,调用带有默认参数的函数时,入参从左往右排入函数,如果有非默认参数的入参缺失则会报错。比如:
    gaussdb=# create or replace function test(f1 int, f2 int default 20, f3 int, f4 int default 40, f5 int default 50) return int
    gaussdb-# as
    gaussdb$# begin
    gaussdb$# raise info 'f1:%',f1;
    gaussdb$# raise info 'f2:%',f2;
    gaussdb$# raise info 'f3:%',f3;
    gaussdb$# raise info 'f4:%',f4;
    gaussdb$# raise info 'f5:%',f5;
    gaussdb$# return 1;
    gaussdb$# end;
    gaussdb$# /
    CREATE FUNCTION
    gaussdb=# 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
  • 若设置此配置项,调用带有默认参数的函数时,入参从左往右排入函数,允许缺省默认参数个入参,如果有非默认参数的入参缺失,则会用错位的默认值填充该参数。比如:
    gaussdb=# create or replace function test(f1 int, f2 int default 20, f3 int, f4 int default 40, f5 int default 50) return int
    gaussdb-# as
    gaussdb$# begin
    gaussdb$# raise info 'f1:%',f1;
    gaussdb$# raise info 'f2:%',f2;
    gaussdb$# raise info 'f3:%',f3;
    gaussdb$# raise info 'f4:%',f4;
    gaussdb$# raise info 'f5:%',f5;
    gaussdb$# return 1;
    gaussdb$# end;
    gaussdb$# /
    CREATE FUNCTION
    gaussdb=# 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被错误的默认值填充。

    警告:

    该场景下,非默认参数会被错位的默认值填充。

dynamic_sql_compat

开启此参数后:

1. 动态语句不会将模板SQL中的同名模板参数视为同一个变量,而是按照顺序依次匹配using子句中的变量值。

2. 动态语句执行语句时调用存储过程的场景,会对存储过程中参数的IN/OUT属性和using子句中的IN/OUT属性进行检查。

注意:

动态语句执行匿名块语句时调用存储过程的场景,只针对IN参数进行矫正,如果需要对OUT参数进行检查需要设置proc_outparam_override选项。

dynamic_sql_check

开启此参数后,动态语句模板SQL中的不同模板参数个数与using子句中的变量个数不同时,将会在动态语句执行期间报错。

注意:
  • 不推荐同时使用dynamic_sql_check选项和dynamic_sql_compat选项,开启dynamic_sql_compat选项后dynamic_sql_check选项将不再生效。
  • 动态语句执行匿名块语句时调用存储过程的场景,只针对IN参数进行检查,如果需要对OUT参数进行检查需要设置proc_outparam_override选项。
  • 动态语句执行匿名块语句时调用存储过程的场景,开启参数后不会对存储过程中参数的IN/OUT属性和using子句中的IN/OUT属性进行检查。

enable_funcname_with_argsname

开启参数后,使用select调用函数时投影别名显示完整函数。

  • 若不设置此配置项,使用select调用函数时投影别名仅显示函数名。比如:
    gaussdb=# SELECT power(2,3);
     power 
    -------
         8
    (1 row)
    
    gaussdb=# SELECT count(*) FROM db_ind_columns;
     count 
    -------
       611
    (1 row)
    
    gaussdb=# SELECT count(index_name) FROM db_ind_columns;
     count 
    -------
       611
    (1 row)
    
    gaussdb=# SELECT left('abcde', 2);
     left 
    ------
     ab
    (1 row)
    
    gaussdb=# SELECT pg_client_encoding();
     pg_client_encoding 
    --------------------
     UTF8
    (1 row)
  • 若设置此配置项,使用select调用函数时投影别名显示完整函数。比如,
    gaussdb=# SET behavior_compat_options = 'enable_funcname_with_argsname';
    SET
    gaussdb=# SELECT power(2,3);
     power(2,3) 
    ------------
              8
    (1 row)
    
    gaussdb=# SELECT count(*) FROM db_ind_columns;
     count(*) 
    ----------
          611
    (1 row)
    
    gaussdb=# SELECT count(index_name) FROM db_ind_columns;
     count(index_name) 
    -------------------
                   611
    (1 row)
    
    gaussdb=# SELECT left('abcde', 2);
     left('abcde',2) 
    -----------------
     ab
    (1 row)
    
    gaussdb=# SELECT pg_client_encoding();
     pg_client_encoding() 
    ----------------------
     UTF8
    (1 row)
    注意:
    • 目前仅支持func_name(args_list)、func_name()、func_name(*)三种形式投影别名显示完整函数,且参数args类型仅支持字符类型、数值类型、列名、函数。函数名支持带有schema、包名。不支持参数带有其他子句(如order by子句)、不支持参数为表达式、仅支持参数带有DISTINCT关键字,不支持带有其他关键字时显示完整函数。
    • 一些特殊函数不支持投影别名显示完整函数,包括函数:COLLATION FOR、CURRENT_DATE、CURRENT_TIME、CURRENT_TIMESTAMP、DBTIMEZONE、LOCALTIME、LOCALTIMESTAMP、SYSDATE、SESSIONTIMEZONE、ROWNUM、CURRENT_ROLE、CURRENT_USER、SESSION_USER、USER、CURRENT_CATALOG、CURRENT_SCHEMA、CAST、EXTRACT、TIMESTAMPDIFF、OVERLAY、POSITION、SUBSTRING、TREAT、TRIM、NULLIF、NVL、NVL2、COALESCE、GREATEST、LEAST、LNNVL、REGEXP_LIKE以及XML函数。
    • 一些安全加解密函数、脱敏函数,投影别名显示完整函数可能存在安全问题,在这里就还是仅显示函数名。包括函数:gs_encrypt_aes128、gs_decrypt_aes128、gs_encrypt、gs_decrypt、gs_encrypt_bytea、gs_decrypt_bytea、aes_encrypt、aes_decrypt、pg_create_physical_replication_slot_extern、dblink_connect、creditcardmasking、basicemailmasking、fullemailmasking、alldigitsmasking、shufflemasking、randommasking、regexpmasking、gs_digest。
    • 不支持=>传参方式调用函数是投影别名显示完整函数,不支持投影别名显示"",如:select "power"(2,3)。
    • 为了让投影别名显示完整函数,本功能不受去除末尾0等参数影响。

proc_outparam_transfer_length

开启此参数后,存储过程和函数支持out出参长度传递,会在内层存储过程或者函数中报错。例如:

gaussdb=# SET behavior_compat_options='proc_outparam_override,proc_outparam_transfer_length';
SET
gaussdb=# CREATE OR REPLACE PROCEDURE out_param_test1(m in int, v inout varchar2,v1 inout varchar2) is
gaussdb$# begin
gaussdb$#     v := 'aaaddd';
gaussdb$# v1 := 'aaaddd';
gaussdb$# end;
gaussdb$# /
CREATE PROCEDURE
gaussdb=# CREATE OR REPLACE PROCEDURE call_out_param_test1 is
gaussdb$#     v varchar2(5) := 'aabbb';
gaussdb$# v1 varchar2(6) := 'aabb';
gaussdb$# begin
gaussdb$#     out_param_test1(5,v,v1);
gaussdb$# end;
gaussdb$# /
CREATE PROCEDURE
gaussdb=# CALL call_out_param_test1();
ERROR:  value too long for type character varying(5)
CONTEXT:  PL/SQL function out_param_test1(integer,character varying,character varying) line 3 at assignment
PL/SQL function call_out_param_test1() line 4 at SQL statement

varray_compat

该参数在分布式场景下无效。

allow_rownum_alias

开启此参数后,将允许ROWNUM在SQL语句中通过AS语法用作列的别名,ROWNUM将作为普通标识符使用,不再能够作为伪列使用。

警告:

不建议在执行业务期间变更该参数的状态。开启参数的状态下,在数据库中用ROWNUM作为名称创建的数据库对象(如表名,列名,数据库名等)只能在开启参数的情况下使用,否则将会产生歧义,行为不可预期。关闭参数的状态下,在数据库中ROWNUM作为伪列使用的行为将在开启参数后失效,行为不可预期。

current_sysdate

开启此参数后,执行sysdate时,会获取当前操作系统时间。

gaussdb=# set behavior_compat_options='current_sysdate';
SET
gaussdb=# select sysdate;
current_sysdate
---------------------
2023-06-20 20:15:27
(1 row)

allow_function_procedure_replace

默认场景下,对于ORA和PG兼容模式,当有一个包外的存储过程(或函数)时,创建一个同名的函数(或存储过程),与已有对象类型不同,不支持创建并报错。开启此参数后,通过create or replace的方式可以实现包外同名的存储过程和函数对象之间的类型替换。

gaussdb=# create or replace function proc_test return varchar2 as
gaussdb$# begin
gaussdb$# return '1';
gaussdb$# end;
gaussdb$# /
CREATE FUNCTION
gaussdb=# create or replace procedure proc_test as
gaussdb$# begin
gaussdb$# null;
gaussdb$# end;
gaussdb$# /
ERROR:  cannot change routine kind
DETAIL:  "proc_test" is a function.
gaussdb=# \df+ proc_test
                                                                             List of functions
 Schema |   Name    | Result data type  | Argument data types |  Type  | Volatility |   Owner   | Language | Source code | Description | fencedmode | propackage | prokind
--------+-----------+-------------------+---------------------+--------+------------+-----------+----------+-------------+-------------+------------+------------+---------
 public | proc_test | character varying |                     | normal | volatile   | wangxinyu | plpgsql  |  DECLARE   +|             | f          | f          | f
        |           |                   |                     |        |            |           |          | begin      +|             |            |            |
        |           |                   |                     |        |            |           |          | return '1';+|             |            |            |
        |           |                   |                     |        |            |           |          | end         |             |            |            |
(1 row)

-- 设置参数后允许替换类型
gaussdb=# set behavior_compat_options='allow_function_procedure_replace';
SET
gaussdb=# create or replace procedure proc_test as
gaussdb$# begin
gaussdb$# null;
gaussdb$# end;
gaussdb$# /
CREATE PROCEDURE
gaussdb=# \df+ proc_test
                                                                            List of functions
 Schema |   Name    | Result data type | Argument data types |  Type  | Volatility |   Owner   | Language | Source code | Description | fencedmode | propackage | prokind
--------+-----------+------------------+---------------------+--------+------------+-----------+----------+-------------+-------------+------------+------------+---------
 public | proc_test | void             |                     | normal | volatile   | wangxinyu | plpgsql  |  DECLARE   +|             | f          | f          | p
        |           |                  |                     |        |            |           |          | begin      +|             |            |            |
        |           |                  |                     |        |            |           |          | null;      +|             |            |            |
        |           |                  |                     |        |            |           |          | end         |             |            |            |
(1 row)

collection_exception_backcompat

控制在PL/SQL中集合类型相关报错抛出的异常值,当前控制3种异常值,对应关系如下:

未开启该参数 开启该参数

collection_is_null program_limit_exceeded

subscript_beyond_count program_limit_exceeded

subscript_outside_limit program_limit_exceeded

用例:

gaussdb=# create or replace procedure p1 is
gaussdb$#     type t1 is table of int;
gaussdb$#     v t1;
gaussdb$#     v_int int;
gaussdb$# begin
gaussdb$#     v_int := v.count();
gaussdb$# exception when collection_is_null then
gaussdb$#     raise info '%', sqlerrm;
gaussdb$# end;
gaussdb$# /
CREATE PROCEDURE

gaussdb=# call p1();
INFO:  Reference to uninitialized collection
 p1 
----

(1 row)

gaussdb=# create or replace procedure p1 is
gaussdb$#     type t1 is table of int;
gaussdb$#     v t1 := t1(1, 2, 3);
gaussdb$#     v_int int;
gaussdb$# begin
gaussdb$#     v_int := v(4);
gaussdb$# exception when subscript_beyond_count then
gaussdb$#     raise info '%', sqlerrm;
gaussdb$# end;
gaussdb$# /
CREATE PROCEDURE
gaussdb=# 
gaussdb=# call p1();
INFO:  Subscript beyond count
 p1 
----

(1 row)

gaussdb=# create or replace procedure p1 is
gaussdb$#     type t1 is table of int;
gaussdb$#     v t1 := t1(1, 2, 3);
gaussdb$#     v_int int;
gaussdb$# begin
gaussdb$#     v_int := v(-1);
gaussdb$# exception when subscript_outside_limit then
gaussdb$#     raise info '%', sqlerrm;
gaussdb$# end;
gaussdb$# /
CREATE PROCEDURE
gaussdb=# 
gaussdb=# call p1();
INFO:  Subscript outside of limit
 p1 
----

(1 row)

gaussdb=# set behavior_compat_options = 'collection_exception_backcompat';
SET
gaussdb=# create or replace procedure p1 is
gaussdb$#     type t1 is table of int;
gaussdb$#     v t1;
gaussdb$#     v_int int;
gaussdb$# begin
gaussdb$#     v_int := v.count();
gaussdb$# exception when program_limit_exceeded then
gaussdb$#     raise info '%', sqlerrm;
gaussdb$# end;
gaussdb$# /
CREATE PROCEDURE

gaussdb=# call p1();
INFO:  Reference to uninitialized collection
 p1 
----

(1 row)

gaussdb=# create or replace procedure p1 is
gaussdb$#     type t1 is table of int;
gaussdb$#     v t1 := t1(1, 2, 3);
gaussdb$#     v_int int;
gaussdb$# begin
gaussdb$#     v_int := v(4);
gaussdb$# exception when program_limit_exceeded then
gaussdb$#     raise info '%', sqlerrm;
gaussdb$# end;
gaussdb$# /
CREATE PROCEDURE
gaussdb=# 
gaussdb=# call p1();
INFO:  Subscript beyond count
 p1 
----

(1 row)

gaussdb=# create or replace procedure p1 is
gaussdb$#     type t1 is table of int;
gaussdb$#     v t1 := t1(1, 2, 3);
gaussdb$#     v_int int;
gaussdb$# begin
gaussdb$#     v_int := v(-1);
gaussdb$# exception when program_limit_exceeded then
gaussdb$#     raise info '%', sqlerrm;
gaussdb$# end;
gaussdb$# /
CREATE PROCEDURE
gaussdb=# 
gaussdb=# call p1();
INFO:  Subscript outside of limit
 p1 
----

(1 row)

enable_case_when_alias

开启该参数后,case when和decode语法的别名为以__unnamed_开头的字符串

用例:

gaussdb=# set behavior_compat_options='enable_case_when_alias';
SET
gaussdb=# create table test(c1 varchar2);
CREATE TABLE
gaussdb=# insert into test values('x');
INSERT 0 1
gaussdb=# select decode(c1,'x','0','default') from test;
 __unnamed_decode__ 
--------------------
 0
(1 row)

gaussdb=# select (case c1 when 'x' then '0' else 'default' end) from test;
 __unnamed_case_when__ 
-----------------------
 0
(1 row)

plsql_rollback_keep_user

控制在PL/SQL中rollback和rollback to savepoint是否回退当前用户。当开启此参数时,PL/SQL中rollback将不会修改当前用户。

用例:

gaussdb=# create user plsql_rollback1 password 'huawei@123';
gaussdb=# create user plsql_rollback2 password 'huawei@123';
gaussdb=# grant plsql_rollback1 to plsql_rollback2;
gaussdb=# create or replace procedure plsql_rollback1.p1 () authid definer
gaussdb-# as
gaussdb$# va int;
gaussdb$# begin
gaussdb$# raise info 'current usr:%', current_user;
gaussdb$# rollback;
gaussdb$# raise info 'current usr:%', current_user;
gaussdb$# end;
gaussdb$# /
CREATE PROCEDURE
gaussdb=# set session AUTHORIZATION plsql_rollback2 PASSWORD 'huawei@123';
SET
gaussdb=> set behavior_compat_options = 'plsql_rollback_keep_user';
SET
gaussdb=> call plsql_rollback1.p1 ();
INFO:  current usr:plsql_rollback1
INFO:  current usr:plsql_rollback1
p1
----

(1 row)
注意:
  • 该参数仅在数据库兼容性为ORA下有效。

enable_bpcharlikebpchar_compare

启用/关闭bpcharlikebpchar和bpcharnlikebpchar操作符。

  • 新安装的数据库默认开启该参数。
  • 505.1.0版本之前的数据库通过升级操作后,该参数默认关闭。
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
gaussdb=# SELECT bpcharlikebpchar('455'::BPCHAR(10), '455  '::BPCHAR);
 bpcharlikebpchar 
------------------
 f
(1 row)
gaussdb=# SELECT bpcharlikebpchar('455 '::BPCHAR(10), '455 '::BPCHAR(10));
 bpcharlikebpchar 
------------------
 t
(1 row)
gaussdb=# SELECT bpcharlikebpchar('455 '::BPCHAR(10), '455'::BPCHAR(10));
 bpcharlikebpchar 
------------------
 t
(1 row)
gaussdb=# SELECT bpcharlikebpchar('455 '::BPCHAR(10), '455'::BPCHAR(11));
 bpcharlikebpchar 
------------------
 f
(1 row)
gaussdb=# CREATE TABLE op_test (
  col BPCHAR(2) DEFAULT NULL
 );
CREATE TABLE
gaussdb=# CREATE INDEX op_index ON op_test(col);
CREATE INDEX
gaussdb=# INSERT INTO op_test VALUES ('a');
INSERT 0 1
gaussdb=# INSERT INTO op_test VALUES ('1');
INSERT 0 1
gaussdb=# INSERT INTO op_test VALUES ('11');
INSERT 0 1
gaussdb=# INSERT INTO op_test VALUES ('12');
INSERT 0 1
gaussdb=# INSERT INTO op_test VALUES ('sd');
INSERT 0 1
gaussdb=# INSERT INTO op_test VALUES ('aa');
INSERT 0 1
gaussdb=# SHOW behavior_compat_options;
 behavior_compat_options 
-------------------------
(1 row)
--当behavior_compat_options不包含enable_bpcharlikebpchar_compare时,则未启用最新bpcharlikebpchar操作符,其bpchar匹配bpchar返回结果集非预期(正常应返回全部数据)。
gaussdb=# EXPLAIN (COSTS OFF) SELECT * FROM op_test WHERE col LIKE col::BPCHAR ORDER BY col;
              QUERY PLAN              
--------------------------------------
 Sort
   Sort Key: col
   ->  Seq Scan on op_test
         Filter: (col ~~ (col)::text)
(4 rows)
gaussdb=# SELECT * FROM op_test WHERE col LIKE col::BPCHAR ORDER BY col;
 col 
-----
 11
 12
 aa
 sd
(4 rows)
gaussdb=# SET behavior_compat_options = 'enable_bpcharlikebpchar_compare';
SET
gaussdb=# SHOW behavior_compat_options;
     behavior_compat_options     
---------------------------------
 enable_bpcharlikebpchar_compare
(1 row)
--开启参数后,将启用最新bpcharlikebpchar操作符,其匹配时返回行为符合预期行为。
gaussdb=# EXPLAIN (COSTS OFF) SELECT * FROM op_test WHERE col LIKE col::BPCHAR ORDER BY col;
          QUERY PLAN          
------------------------------
 Sort
   Sort Key: col
   ->  Seq Scan on op_test
         Filter: (col ~~ col)
(4 rows)
gaussdb=# SELECT * FROM op_test WHERE col LIKE col::BPCHAR ORDER BY col;
 col 
-----
 1 
 11
 12
 a 
 aa
 sd
(6 rows)
gaussdb=# DROP TABLE op_test;
DROP TABLE
说明:
  • 该参数仅在sql_compatibility兼容性参数设置为ORA时生效。
  • 启用该参数,会影响BPCHAR类型之间进行LIKE或NOT LIKE模式匹配时的结果集与执行计划。

cursor_asensitive

打开该参数后,游标数据敏感行为兼容505.1之前版本。默认关闭该参数,数据库实现数据非敏感游标。

  • 若设置此配置项,游标数据敏感行为兼容505.1之前版本,某些游标可以看到OPEN后的修改。
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    gaussdb=# set behavior_compat_options='cursor_asensitive';
    SET
    gaussdb=# create table t1(c1 int, c2 varchar,c3 varchar) distribute by hash(c1);
    CREATE TABLE
    gaussdb=# insert into t1 values(1,'Tom','Jones');
    INSERT 0 1
    gaussdb=# create or replace function func1() returns sys_refcursor
    gaussdb-# as $$
    gaussdb$# declare
    gaussdb$# x sys_refcursor;
    gaussdb$# cursor cur1 for select count(1) from t1 where c2 = 'Joe';
    gaussdb$# begin
    gaussdb$# open cur1;
    gaussdb$# update t1 set c2='Joe' where c3='Jones';
    gaussdb$# fetch cur1 into x;
    gaussdb$# close cur1;
    gaussdb$# return x;
    gaussdb$# end;$$
    gaussdb-# LANGUAGE plpgsql;
    CREATE FUNCTION
    gaussdb=# call func1();
     func1
    -------
     1
    (1 row)
    
  • 若不设置此配置项,游标OPEN确定游标的结果集,看不到OPEN后的修改。
     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    gaussdb=# show behavior_compat_options;
     behavior_compat_options
    -------------------------
    
    (1 row)
    gaussdb=# create table t1(c1 int, c2 varchar,c3 varchar) distribute by hash(c1);
    CREATE TABLE
    gaussdb=# insert into t1 values(1,'Tom','Jones');
    INSERT 0 1
    gaussdb=# create or replace function func1() returns sys_refcursor
    gaussdb-# as $$
    gaussdb$# declare
    gaussdb$# x sys_refcursor;
    gaussdb$# cursor cur1 for select count(1) from t1 where c2 = 'Joe';
    gaussdb$# begin
    gaussdb$# open cur1;
    gaussdb$# update t1 set c2='Joe' where c3='Jones';
    gaussdb$# fetch cur1 into x;
    gaussdb$# close cur1;
    gaussdb$# return x;
    gaussdb$# end;$$
    gaussdb-# LANGUAGE plpgsql;
    CREATE FUNCTION
    gaussdb=# call func1();
     func1
    -------
     0
    (1 row)
    

enable_crosstype_integer_operator

启用/关闭跨类型整型操作符。

  • 全新安装的数据库默认开启该参数。
  • 505.1.0版本之前的数据库通过升级操作后,该参数默认关闭。
  • 涉及操作符范围=、<>、<、>、<=、>=
  • 开启该参数后,涉及的跨类型整型比较,不再需要隐式转换,可直接进行比较。如下以(int1 op int2)举例:
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
gaussdb=# CREATE TABLE implicit_index(c1 int1);
CREATE TABLE
gaussdb=# CREATE INDEX idx1 ON implicit_index(c1);
CREATE INDEX
gaussdb=# SET behavior_compat_options='enable_crosstype_integer_operator';
SET
gaussdb=# EXPLAIN SELECT * FROM implicit_index WHERE c1 = 1::int2;
                                   QUERY PLAN                                    
---------------------------------------------------------------------------------
 [Bypass]
 Index Only Scan using idx1 on implicit_index  (cost=0.00..4.48 rows=13 width=1)
   Index Cond: (c1 = 1::smallint)
(3 rows)

gaussdb=# SET behavior_compat_options='';
SET
gaussdb=# EXPLAIN SELECT * FROM implicit_index WHERE c1 = 1::int2;
                           QUERY PLAN                           
----------------------------------------------------------------
 Seq Scan on implicit_index  (cost=0.00..49.52 rows=13 width=1)
   Filter: ((c1)::bigint = 1::smallint)
(2 rows)

gaussdb=# DROP TABLE implicit_index;
DROP TABLE
说明:
  • 该参数仅在sql_compatibility兼容性参数设置为ORA时生效。
  • 启用该参数,会影响涉及如下场景的操作符的执行计划:
    • (int1 op int2)
    • (int1 op int4)
    • (int1 op int8)
    • (int1 op int16)
    • (int1 op numeric)
    • (int2 op int1)
    • (int2 op int16)
    • (int2 op numeric)
    • (int4 op int1)
    • (in4 op int16)
    • (int4 op numeric)
    • (int8 op int1)
    • (int8 op int16)
    • (int8 op numeric)
    • (int16 op int1)
    • (int16 op int2)
    • (int16 op int4)
    • (int16 op int8)
    • (numeric op int1)
    • (numeric op int2)
    • (numeric op int4)
    • (numeric op int8)

time_constexpr_compact

打开该参数后,执行时间表达式场景,会根据常量是否含有时区,自动返回with timezone类型或without timezone类型。

目前支持timestamp类型、time类型。

--执行不带时区的时间戳表达式。
gaussdb=# SELECT timestamp '1999-03-15 8:00:00';
      timestamp      
---------------------
 1999-03-15 08:00:00
(1 row)
--执行带时区的时间戳表达式 返回timestamp with time zone类型。
gaussdb=# SELECT timestamp '1999-03-15 8:00:00 -8:00:00';
      timestamptz       
------------------------
 1999-03-16 00:00:00+08
(1 row)

设置方式:该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

设置建议:根据数据库兼容对象进行调整。

a_format_version

参数说明:数据库平台兼容性行为配置项,该参数的值为字符串枚举值。

该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

取值范围:字符串

默认值:""

  • 当前只支持兼容性配置项如表3所示。
  • 兼容性配置项时设置字符串,例如:set a_format_version='10c';
表3 兼容性配置项

兼容性配置项

兼容性行为控制

10c

ORA平台兼容10C版本

a_format_dev_version

参数说明:数据库平台迭代小版本兼容性行为配置项,该参数的值为字符串枚举值。

该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

取值范围:字符串

默认值:""

  • 当前只支持兼容性配置项如表4所示。
  • 兼容性配置项时设置字符串,例如:set a_format_dev_version='s1';
表4 兼容性配置项

兼容性配置项

兼容性行为控制

s1

  • ORA平台兼容迭代小版本,影响函数(TRUNC(date, fmt),ROUND(date, fmt),NVL2,LPAD,RPAD,ADD_MONTHS,MONTHS_BETWEEN,REGEXP_REPLACE,REGEXP_COUNT,TREAT,EMPTY_CLOB,INSTRB,trunc(number),greatest,least,mod,round(number),cast,to_date,to_timestamp,chr,rtrim,translate,to_char,to_number,to_timestamp_tz)。
  • 数据类型转换:小数字符串转换成整数类型(int1/int2/int4/int8/int16)时进行四舍五入。
  • 数据类型转换:支持timestamp with time zone到timestamp without time zone的隐式转换。

s2

  • ORA平台兼容迭代小版本,影响函数(dump, to_single_byte, to_multi_byte, nls_upper, nls_lower, initcap, ascii2, asciistr, unistr, vsize, cosh, remainder, sinh, tanh, nanvl, current_date, current_timestamp, dbtimezone, numtodsinterval, numtoyminterval, new_time, sessiontimezone, sys_extract_utc, tz_offset, to_binary_double, to_binary_float, to_dsinterval, to_yminterval, lnnvl, ora_hash)。
  • 兼容配置项为s1时的所有行为。

s3

  • ORA平台兼容迭代小版本,开启参数,支持无参函数嵌套调用。
  • 兼容配置项为s2时的所有行为。

s4

  • ORA平台兼容迭代小版本,影响函数nchr(cvalue int|bigint)、to_timestamp_tz、getclobval(xml)、getstringval(xml)。
  • 兼容配置项为s3时的所有行为。

s5

  • ORA平台兼容迭代小版本,开启参数,支持复合类型与函数同名,优先解析为复合类型,影响函数sys_guid()。
  • 兼容配置项为s4时的所有行为。

b_format_version

参数说明:数据库平台兼容性行为配置项,用于控制MySQL兼容模式下的前向兼容性。

  • 仅当sql_compatibility兼容性参数设置为MySQL时,b_format_version参数才会生效。
  • 当该参数设置不为空字符串生效时,会同时设置参数b_format_behavior_compat_options为'ALL'值,参数bytea_output为'escape'值。当该参数重新设置为空字符串生效时,会将b_format_behavior_compat_options、bytea_output参数设为原来的值。

参数类型:字符串

参数单位:

取值范围:空字符串''或 '5.7'

默认值:空字符串''

设置方式:该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

设置建议:

b_format_dev_version

参数说明:数据库平台迭代小版本兼容性行为配置项。

依赖sql_compatibility兼容性参数设置为MYSQL且b_format_version设置为5.7时,b_format_dev_version才会生效。

参数类型:字符串

参数单位:

取值范围:空字符串''或表5中的兼容性配置项。

表5 兼容性配置项

兼容性配置项

兼容性行为控制

s1

  1. 影响如下参数:

    参数打开会将disable_keyword_options参数中的datetime选项去除,表示datetime作为非保留关键字使用。datetime可以作为表名、列名、别名使用,但不能作为函数名、存储过程名、函数或存储过程的参数名使用。

  2. 影响如下函数:

    curdate,from_days,date_format,str_to_date,current_date,datediff,timestampdiff,date_add,subtime,month,time_to_sec,to_days,to_seconds,dayname,monthname,convert_tz,sec_to_time,addtime,adddate,date_sub,timediff,last_day,weekday,from_unixtime,unix_timestamp,subdate,day,year,weekofyear,dayofmonth,dayofyear,week,yearweek,dayofweek,time_format,hour,minute,second,microsecond,quarter,utc_date,get_format,extract,makedate,period_add,timestamppadd,period_diff,utc_time,utc_timestamp,sysdate,current_timestamp,maketime,curtime,current_time,localtime,localtimestamp,now,lc_time_names,default_week_format,json_object。

  3. 影响如下类型:
    1. 兼容整型类型tinyint,范围变更为-128-127。
    2. 兼容字符串类型char、varchar,char(n)和varchar(n)的精度n有字节长度变为字符长度。
    3. 兼容文本类型tinytext、mediumtext和longtext。这些类型在开启参数后会被映射为text类型。
    4. 兼容二进制类型tinyblob、blob、mediumblob和longblob。这些类型在开启参数后会被映射为bytea类型。
    5. 兼容浮点类型double、float和real。double映射为float8类型,double(p, s)映射为numeric类型,float(p, s)映射为numeric类型,real映射为float8,real(p, s)映射为numeric类型。
    6. 兼容高精度类型numeric、dec和decimal。未指定精度和标度时变更默认精度为10,标度为0。
    7. 兼容时间类型datetime、timestamp、time和date。datetime[(p)]替换成timestamp without time zone[(p)]类型。timestamp[(p)] 替换成timestamp with time zone[(p)]类型。这些类型的输入输出、范围、精度等规格有变更,具体见《开发者指南》中“SQL参考 > 数据类型”相关章节。
    8. 兼容整型类型tinyint、smallint、int、bigint,这些类型在开启参数后显示宽度和ZEROFILL属性功能生效。
  4. 影响如下语法:

    支持指定列约束ON UPDATE update_expr。

  5. 影响如下操作符:
    1. 使用bytea类型间的||操作符报错。
    2. 支持REGEXP操作符。

s2

包含s1控制的兼容性行为,此外还包含以下影响:

  1. 影响如下语法:
    1. 支持“CREATE TABLE table_name LIKE source_table”语法。
    2. “CREATE TABLE table_name LIKE source_table”和“CREATE TABLE table_name (LIKE source_table)”语法不支持指定INCLUDING和EXCLUDING选项,缺省等同于指定INCLUDING ALL。
    3. 支持LOAD DATA语法,gs_loader中部分与LOAD DATA语法一致的语法功能会发生变化。
    4. 涉及ALTER TABLE,RENAME TABLE等更改表名的语法,影响场景如下:

      新表名对应字符串开头为"#MySQL50#",且其后有其他字符,"#MySQL50#"将被忽略;如果新旧表名一致,不会报错。

    5. 支持set names指定collate子句。
  2. 影响如下参数:
    1. 此选项打开时,standard_conforming_strings、escape_string_warning参数被置为off。
    2. 此选项打开时,collation_connection、character_set_connection参数功能才会生效。
  3. 影响如下功能:
    1. like操作符对于匹配串末尾是转义符的场景不再报错。
    2. 字符集、字符序的排序规则优先级将发生变更,详见分布式开发者指南的7.4.7章节。
    3. 打开参数后,不支持外键字符序和列上字符序不一致。

默认值:空字符串''

设置方式:该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

设置建议:

sql_mode

参数说明:MYSQL兼容模式下SQL行为控制配置项。

依赖sql_compatibility兼容性参数设置为MYSQL、b_format_version设置为'5.7'、b_format_dev_version 设置为's1'时,sql_mode才会生效。

参数类型:字符串

参数单位:

取值范围:空字符串''或 'strict_trans_tables,only_full_group_by,no_zero_in_date,no_zero_date,error_for_division_by_zero,no_auto_create_user,no_engine_substitution,pad_char_to_full_length'中的选项值。每个选项值的含义如表6所述。

表6 兼容性配置项

兼容性配置项

兼容性行为控制

参数配置说明

strict_trans_tables

当前仅支持对MYSQL兼容数据库下数据类型及系统函数做校验。

设置时,对输入的参数格式和范围做严格校验。无效值输入或者超过范围时,解析报error。

不设置时,对输入的参数格式和范围做宽松校验,无效值输入或者超过范围时,解析报warning,返回对应数据的0值。

strict_trans_tables、only_full_group_by、no_zero_in_date、no_zero_date、error_for_division_by_zero 这五个选项只支持同时设置和取消,不支持只设置其中部分选项。

only_full_group_by

不允许出现非group by的key值、且不是常量和聚集函数的投影列。

no_zero_in_date

不允许日期中的年、月、日是0值。

no_zero_date

不允许日期是0值(0000-00-00)。

error_for_division_by_zero

不允许被0除。

no_auto_create_user

无实际作用,仅用作 SET SQL_MODE 语句包含此选项时不报错的兼容作用。

可独立设置和取消。

no_engine_substitution

无实际作用,仅用作 SET SQL_MODE 语句包含此选项时不报错的兼容作用。

可独立设置和取消。

pad_char_to_full_length

用于表中的char类型列格式化输出,包含时输出带有尾部空格的字符串,否则输出不带尾部空格字符串。

可独立设置和取消。

no_auto_value_on_zero

包含此选项后,向AUTO_INCREMENT自动增长列插入0值将不会自增。

可独立设置和取消。

默认值:'strict_trans_tables,only_full_group_by,no_zero_in_date,no_zero_date,error_for_division_by_zero,no_auto_create_user,no_engine_substitution'

设置方式:该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

设置建议:

auto_increment_increment

参数说明:AUTO_INCREMENT自动增长列的自增步长,自增值将由auto_increment_offset + N × auto_increment_increment计算而来,N为正整数。若参数值小于auto_increment_offset,自动增长列自增时会产生错误。

参数类型:整型

参数单位:

取值范围:1 ~ 65535

默认值:1

设置方式:该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

设置建议:

auto_increment_offset

参数说明:AUTO_INCREMENT自动增长列的起始值,自增值将由auto_increment_offset + N × auto_increment_increment计算而来,N为正整数。若参数值大于auto_increment_increment,自动增长列自增时会产生错误。

参数类型:整型

参数单位:

取值范围:1 ~ 65535

默认值:1

设置方式:该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

设置建议:

auto_increment_cache

参数说明:对自动增长列批量插入或导入触发自增时,预留自增缓存值的个数。预留自增值时,刷新自增计数器为自增缓存值的最大值,缓存值使用完毕之前,自增计数器值不变,触发自增使用缓存的值。

  • 预留的缓存值仅在语句内有效,若预留的自增缓存值没有全部被使用,后续插入语句基于自增计数器触发自增,会出现表中自动增长列的值不连续的情况。
  • 并行导入或插入自动增长列触发自增时,每个并行线程预留的缓存值也只在其线程中使用,未完全使用完毕的话,也会出现表中自动增长列的值不连续的情况。
  • 对已有数据的表添加自动增长列或修改某列为自动增长列时,已有数据触发自增,预留自增缓存值也受此参数影响。
  • 此参数不影响本地临时表中的自动增长列。

默认值:0

参数类型:整型

参数单位:

取值范围:0 ~ INT_MAX

  • 参数值为0时,自动预留自增缓存值。
    • 第一次触发自增时,若已知即将插入自动增长列的行数,预留已知数量的值。
      • 例如:“INSERT INTO table SELECT ...”和COPY FROM触发自增值无法获取即将插入的行数。ALTER TABLE命令表数据重写时,若触发自增,使用统计信息中的reltuples作为即将预留的行数。 “INSERT INTO table VALUES(...),(...),...”由于要分布到不同DN,在某些执行计划中,DN获取不到即将插入的行数。
    • 若行数未知,每次预留2^n个值,例如,第一次自增预留1个值,第二次自增预留2个值,第三次预留4个值,第四次预留8个值,以此类推,若预留值个数超过65535,预留65535个值。
  • 参数值不为0时,预留缓存值的数量为参数值。
    • 第一次触发自增时,若已知即将插入自动增长列的行数,预留已知数量的值。
    • 若行数未知,每次预留auto_increment_cache数量的自增值。

默认值:0

设置方式:该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

设置建议:推荐使用默认值,若默认情况产生自增值不连续的情况,可以根据用户即将批量插入数据量调整参数值。参数值越大,批量插入性能越优,也更可能产生不连续的自增值。

disable_keyword_options

参数说明:数据库兼容性行为配置项,该参数的值由若干个配置项用逗号隔开构成。设置该参数的标识符将不会作为关键字使用。

该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

取值范围:字符串,支持设置以下关键字:auto_increment、change、charset、columns、compile、completion、containing、convert、csn、datetime、db4aishot、dbtimezone、discard_path、distributed、dumpfile、ends、entityescaping、escaped、evalname、event、events、expdp、gsiusable、gsivalid、gsiwaitall、finish、ilm_pidx_list、impdp、ifnull、invisible、json_object、lines、link、lnnvl、load_discard、locked、mark、nocache、noentityescaping、noextend、noscale、nvl2、ordinality、outfile、pivot、performance、public、recover、regexp_like、scale、schedule、separator、sessiontimezone、shrink、slave、specification、starting、starts、subpartitions、substr、unpivot、verify、visible、wellformed、xmltype、regexp、rlike、zerofill。

默认值:"datetime、regexp、rlike、zerofill"

该参数打开后,作为关键字使用的部分功能会失效,请谨慎使用。

disable_plsql_keyword_options

参数说明:用于将设置的标识符当作非关键字使用。数据库兼容性行为配置项,该参数的值由若干个配置项用逗号隔开构成。

参数类型:字符串

参数单位:

取值范围:
  • PIPE
  • PIPELINED
  • RANGE
  • REPLACE
  • SUBTYPE
  • ''

默认值:''

设置方式:该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置

设置建议:

  • 该参数打开后,作为关键字使用的部分功能会失效,请谨慎使用。
  • 如需取消屏蔽plsql关键字功能,请将该参数设置为空值。

plpgsql.variable_conflict

参数说明:设置同名的存储过程变量和表的列的使用优先级。

该参数属于USERSET类型参数,仅支持表1中对应设置方法3进行设置。

取值范围:字符串

  • error表示遇到存储过程变量和表的列名同名则编译报错。
  • use_variable表示存储过程变量和表的列名同名则优先使用变量。
  • use_column表示存储过程变量和表的列名同名则优先使用列名。

默认值:error

td_compatible_truncation

参数说明:控制是否开启与Teradata数据库相应兼容的特征。该参数在用户连接上与TD兼容的数据库时,可以将参数设置成为on(即超长字符串自动截断功能启用),该功能启用后,在后续的insert语句中,对目标表中char和varchar类型的列插入超长字符串时,会按照目标表中相应列定义的最大长度对超长字符串进行自动截断。保证数据都能插入目标表中,而不是报错。

超长字符串自动截断功能不适用于insert语句包含外表的场景。

如果向字符集为字节类型编码(SQL_ASCII,LATIN1等)的数据库中插入多字节字符数据(如汉字等),且字符数据跨越截断位置,这种情况下,按照字节长度自动截断,自动截断后会在尾部产生非预期结果。如果用户有对于截断结果正确性的要求,建议用户采用UTF8等能够按照字符截断的输入字符集作为数据库的编码集。

该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

取值范围:布尔型

  • on表示启动超长字符串自动截断功能。
  • off表示停止超长字符串自动截断功能。

默认值:off

nls_timestamp_format

参数说明:设置时间戳默认格式。

该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

取值范围:字符串

默认值:DD-Mon-YYYY HH:MI:SS.FF AM

nls_timestamp_tz_format

参数说明:设置带时区时间戳默认格式。

该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

取值范围:字符串,支持格式同nls_timestamp_format。

默认值:DD-Mon-YYYY HH:MI:SS.FF AM

此参数在参数a_format_version值为10c和a_format_dev_version值为s1的情况下有效。

nls_nchar_characterset

参数说明:搭配nchr(cvalue int|bigint)系统函数使用,设置国家字符集,该参数的值为字符串枚举值。

参数类型:字符串

参数单位:无

取值范围:'AL16UTF16'和'UTF8',不区分大小写。

默认值:'AL16UTF16'

设置方式:该参数属于USERSET类型参数,请参见表1中对应设置方法进行设置。

设置建议:推荐使用默认值。

  • 数据库不支持国家字符集,该参数只是为了兼容ORA数据库,获取用户想使用的国家字符集。
  • 该GUC参数仅限于nchr(cvalue int|bigint)函数的使用。

max_function_args

参数说明:函数参数最大个数。

该参数属于INTERNAL类型参数,为固定参数,用户无法修改此参数,只能查看。

取值范围:整型

默认值:8192

max_subpro_nested_layers

参数说明:嵌套子程序的最大嵌套深度。

参数类型:整型

参数单位:

取值范围:0~100

当设置为0时,不允许使用嵌套子程序。

默认值:3

设置方式:该参数属于USERSET类型参数,请参见表1中对应设置方法进行设置。

设置建议:根据最大嵌套情况设置。

convert_string_to_digit

参数说明:设置隐式转换优先级,是否优先将字符串转为数字。

该参数属于USERSET类型参数,请参考表1中对应设置方法进行设置。

取值范围:布尔型

  • on表示优先将字符串转为数字。
  • off表示不优先将字符串转为数字。

默认值:on

该参数调整会修改内部数据类型转换规则,导致不可预期的行为,请谨慎调操作。

enable_object_special_character

参数说明:控制执行CREATE EXTENSION语句时,若脚本文件中使用"@extschema@",此时control文件中schema参数的值是否可以包含["$'\]中任意特殊字符。

该参数属于SIGHUP类型参数,请参考表1中对应设置方法进行设置。

取值范围:布尔型

  • on表示开启,可以包含["$'\]中任意特殊字符。
  • off表示关闭,不可以包含["$'\]中任意特殊字符。

默认值:off

扩展功能为内部使用功能,不建议用户使用。

a_format_disable_func

参数说明:禁用指定的系统函数。该参数的值由若干个系统函数OID值用逗号隔开组成。设置该参数的系统函数将不能被调用。

当某一系统函数不能满足用户需求并且需要使用相同函数名的自定义函数时可使用该功能。

参数类型:字符串

参数单位:

取值范围:字符串,由若干个系统函数OID值用逗号隔开组成。

该参数仅支持禁用数据库平台兼容性行为配置项(a_format_version,a_format_dev_version)对应新增的系统函数,请参考表7

表7 支持被禁用的系统函数

数据库平台兼容性行为配置项

支持被禁用的系统函数

10c,s1

anyarray array_extendnull(anyarray,int4,int4); -- funcoid: 6018

clob empty_clob(); -- funcoid: 3825

int4 instrb(text,text); -- funcoid: 3240

int4 instrb(text,text,int4); -- funcoid: 3241

int4 instrb(text,text,int4,int4); -- funcoid: 3242

numeric months_between(timestamp,timestamp); -- funcoid: 1522

timestamp round(timestamp); -- funcoid: 通过查询语句获取 select oid from pg_proc where proname='round' and pronamespace=11 and pronargs=1 and allargtypes[0]=1114;

timestamp round(timestamp,text); -- funcoid: 4465

timestamp to_date(text,text,bool); -- funcoid: 1524

timestamp to_date(text,text,text,bool); -- funcoid: 1525

numeric to_number(text,text,bool); -- funcoid: 1787

numeric to_number(text,text,text,bool); -- funcoid: 1788

timestamp to_timestamp(text,text,bool); -- funcoid: 606

timestamp to_timestamp(text,text,text,bool); -- funcoid: 607

timestamptz to_timestamp_tz(text); -- funcoid: 1806

timestamptz to_timestamp_tz(text,text); -- funcoid: 1807

timestamptz to_timestamp_tz(text,text,bool); -- funcoid: 1808

timestamptz to_timestamp_tz(text,text,text,bool); -- funcoid: 1809

10c,s2

text DBTimezone(); -- funcoid: 5562

int8 ascii2(text); -- funcoid: 1625

text asciistr(text); -- funcoid: 1626

text asciistr(blob); -- funcoid: 1629

int4 bit2coding(text); -- funcoid: 9311

int4 bit4coding(text); -- funcoid: 9325

float8 cosh(float8); -- funcoid: 1548

numeric cosh(numeric); -- funcoid: 1549

timestamptz current_timestamp(numeric); -- funcoid: 3257

text dump(any); -- funcoid: 9086

text dump(any,int4); -- funcoid: 9088

text dump(any,int4,int4); -- funcoid: 9089

text dump(any,int4,int4,int4); -- funcoid: 9090

float4 nanvl(float4,float4); -- funcoid: 7112

float4 nanvl(float4,numeric); -- funcoid: 7115

float8 nanvl(float8,float8); -- funcoid: 7113

float4 nanvl(numeric,float4); -- funcoid: 7116

numeric nanvl(numeric,numeric); -- funcoid: 7114

timestamp new_time(timestamp,text,text); -- funcoid: 374

text nls_lower(text); -- funcoid: 4082

text nls_lower(text,text); -- funcoid: 4083

text nls_upper(text); -- funcoid: 4084

text nls_upper(text,text); -- funcoid: 4085

interval numtoyminterval(numeric,text); -- funcoid: 9333

int8 ora_hash(any); -- funcoid: 6127

int8 ora_hash(any,int8); -- funcoid: 6128

text rawtohex2(any); -- funcoid: 9540

numeric remainder(int8,int8); -- funcoid: 9767

numeric remainder(int2,int2); -- funcoid: 9765

numeric remainder(int4,int4); -- funcoid: 9766

float4 remainder(float4,float4); -- funcoid: 9771

float4 remainder(float4,numeric); -- funcoid: 9768

float8 remainder(float8,float8); -- funcoid: 9770

float4 remainder(numeric,float4); -- funcoid: 9769

numeric remainder(numeric,numeric); -- funcoid: 9761

numeric remainder(int1,int1); -- funcoid: 9764

text session_time_zone(); -- funcoid: 9571

float8 sinh(float8); -- funcoid: 1546

numeric sinh(numeric); -- funcoid: 1547

timestamp sys_extract_utc(timestamp); -- funcoid: 5258

timestamp sys_extract_utc(timestamptz); -- funcoid: 5259

float8 tanh(float8); -- funcoid: 9762

numeric tanh(numeric); -- funcoid: 9763

float8 to_binary_double(text); -- funcoid: 9669

float8 to_binary_double(text,text); -- funcoid: 9670

float8 to_binary_double(text,text,bool); -- funcoid: 9671

float8 to_binary_double(text,text,text,bool); -- funcoid: 9672

float4 to_binary_float(text); -- funcoid: 9673

float4 to_binary_float(text,text); -- funcoid: 9674

float4 to_binary_float(text,text,bool); -- funcoid: 9675

float4 to_binary_float(text,text,text,bool); -- funcoid: 9676

blob to_blob(any); -- funcoid: 6990

interval to_dsinterval(text); -- funcoid: 9126

interval to_dsinterval(text,text,bool); -- funcoid: 9127

text to_multi_byte(text); -- funcoid: 9537

text to_multi_byte(blob); -- funcoid: 9539

varchar to_nchar(int8); -- funcoid: 通过查询语句获取 select oid from pg_proc where proname='to_nchar' and pronamespace=11 and pronargs=1 and allargtypes[0]=20;

varchar to_nchar(int2); -- funcoid: 通过查询语句获取 select oid from pg_proc where proname='to_nchar' and pronamespace=11 and pronargs=1 and allargtypes[0]=21;

varchar to_nchar(int4); -- funcoid: 通过查询语句获取 select oid from pg_proc where proname='to_nchar' and pronamespace=11 and pronargs=1 and allargtypes[0]=23;

text to_nchar(text); -- funcoid: 通过查询语句获取 select oid from pg_proc where proname='to_nchar' and pronamespace=11 and pronargs=1 and allargtypes[0]=25;

varchar to_nchar(float4); -- funcoid: 通过查询语句获取 select oid from pg_proc where proname='to_nchar' and pronamespace=11 and pronargs=1 and allargtypes[0]=700;

varchar to_nchar(float8); -- funcoid: 通过查询语句获取 select oid from pg_proc where proname='to_nchar' and pronamespace=11 and pronargs=1 and allargtypes[0]=701;

varchar to_nchar(numeric); -- funcoid: 通过查询语句获取 select oid from pg_proc where proname='to_nchar' and pronamespace=11 and pronargs=1 and allargtypes[0]=1700;

text to_nchar(timestamp); -- funcoid: 5698

text to_nchar(timestamptz); -- funcoid: 5699

text to_nchar(anyset); -- funcoid: 5700

text to_nchar(int8,text); -- funcoid: 5694

text to_nchar(int4,text); -- funcoid: 5693

text to_nchar(float4,text); -- funcoid: 5695

text to_nchar(float8,text); -- funcoid: 5696

text to_nchar(timestamp,text); -- funcoid: 5697

text to_nchar(timestamptz,text); -- funcoid: 5691

text to_nchar(interval,text); -- funcoid: 5690

text to_nchar(numeric,text); -- funcoid: 5692

text to_single_byte(text); -- funcoid: 9536

text to_single_byte(blob); -- funcoid: 9538

interval to_yminterval(text); -- funcoid: 9124

interval to_yminterval(text,text,bool); -- funcoid: 9125

text tz_offset(text); -- funcoid: 706

text unistr(text); -- funcoid: 9081

text unistr(blob); -- funcoid: 9082

int4 vsize(any); -- funcoid: 9083

10c,s4

clob getclobval(xml); -- funcoid: 8011

varchar getstringval(xml); -- funcoid: 6976

nvarchar2 nchr(int8); -- funcoid: 1694

timestamptz to_timestamp_tz(text,text,text); -- funcoid: 1804

timestamptz to_timestamp_tz(text,text,text,text,bool); -- funcoid: 1805

10c,s5

sys_guid();--funcoid:2974

默认值:''

设置方式:该参数属于SUSET类型参数,请参见18.2-表2 GUC参数设置方式中对应设置方法进行设置。

设置建议:数据库平台兼容性行为配置项(a_format_version,a_format_dev_version)未开启时其对应新增的系统函数默认不可用,无须使用该参数进行禁用。

enable_convert_illegal_char

参数说明:对输出结果中的非法编码是否设置不进行校验并以占位符替换显示。

参数类型:布尔型

参数单位:

取值范围:

  • on:表示开启,非法编码将替换为convert_illegal_char_mode参数指定符号的编码。
  • off:表示关闭,查询结果中包含的非法编码会校验后报错。

默认值:off

设置方式:该参数属于USERSET类型参数,请参见表1中对应设置方法进行设置。

设置建议:设置为默认值,仅在数据中存在特殊字符且需要对特殊字符进行强制不报错处理时开启该参数。

  1. 当数据库字符集为:utf8、zhs16gbk、gb18030、gb18030-2022、latin1时,enable_convert_illegal_char = on时生效,且在数据库客户端与服务端字符集不相同时,非法编码将以占位符形式显示。
  2. 特殊字符范围:本文所指的特殊字符范围仅包括完全编码异常和混合编码,不支持\u0000字符。若字符编码中包含\u0000字符,在使用时通常会在\u0000处截断,无法保证数据的完整性。
  3. 若数据库客户端与服务端字符集不相同,在enable_convert_illegal_char = off时,数据库将超出当前字符集编码外的特殊字符(不包含\x0000字符)替换为\x3F(即显示为?)编码写入数据库中;当enable_convert_illegal_char = on时,只能使用函数dbe_raw.cast_to_varchar2()将非法编码原编码插入数据库中,并以占位符形式显示。
  4. 当开启GUC参数时,特殊字符在下表所列的函数、高级包函数中的表现为:
    • 在客户端与服务端字符集一致时:特殊字符在查询时不报错,与开启GUC参数前的行为保持一致。
    • 在客户端与服务端字符集不一致时:特殊字符在查询时显示为占位符(默认为?)。
    • 不建议客户使用函数处理包含特殊字符的字符串,下表所列函数处理包含特殊字符的字符串不会产生报错,但不保证结果的正确性。
表8 特殊字符支持的函数及高级包函数

序号

函数名/高级包函数名

1

bit_length(string)

2

btrim(string text [, characters text])

3

char_length(string)

character_length(string)

4

chr(cvalue int|bigint)

chr(integer)

5

concat(str1,str2)

6

concat_ws(sep text, str"any" [, str"any" [, ...] ])

7

decode(string text, format text)

8

dump(expr[, return_fmt [, start_position [, length ] ] ])

9

encode(data bytea, format text)

10

find_in_set(text, set)

11

format(formatstr text [, str"any" [, ...] ])

12

left(str text, n int)

13

length(string)

14

lengthb(text/bpchar)

15

ltrim(string [, characters])

16

md5(string)

17

notlike(x bytea name text, y bytea text)

18

octet_length(string)

19

overlay(string placing string FROM int [for int])

20

quote_ident(string text)

21

quote_literal(string text)

22

quote_nullable(string text)

23

rawcat(raw,raw)

24

regexp_count(string text, pattern text [, position int [, flags text]])

25

regexp_instr(string text, pattern text [, position int [, occurrence int [, return_opt int [, flags text]]]])

26

regexp_like(source_string, pattern [, match_parameter])

regexp_like(text,text,text)

27

regexp_matches(string text, pattern text [, flags text])

28

regexp_replace(string, pattern, replacement [,flags ])

29

regexp_split_to_array(string text, pattern text [, flags text ])

30

regexp_split_to_table(string text, pattern text [, flags text])

31

regexp_substr(source_char, pattern)

regexp_substr(string text, pattern text [, position int [, occurrence int [, flags text]]])

32

repeat(string text, number int )

33

repexp_replace(string text, pattern text [, replacement text [, position int [, occurrence int [, flags text]]]])

34

replace(string text, from text, to text)

35

replace(string, substring)

36

reverse(str)

37

right(str text, n int)

38

rtrim(string [, characters])

39

sha(string)

40

sha1(string)

41

sha2(string,hash_length)

42

split_part(string text, delimiter text, field int)

43

substring(string [from int] [for int])

substring(string from pattern for escape)

substring(string from pattern)

44

substring_inner(string [from int] [for int])

45

tconvert(key text, value text)

46

to_single_byte(char)

47

translate(string text, from text, to text)

48

trim([leading |trailing |both] [characters] from string)

49

unistr(string)

50

vsize(expr)

51

PKG_UTIL.RAW_CAST_FROM_VARCHAR2

52

PKG_UTIL.LOB_CONVERTTOCLOB

53

PKG_UTIL.LOB_RAWTOTEXT

54

PKG_UTIL.LOB_TEXTTORAW

55

PKG_UTIL.RAW_CAST_TO_VARCHAR2

56

DBE_OUTPUT.PUT

57

DBE_OUTPUT.PUT_LINE

fix_func_selection

参数说明:是否优化函数匹配策略。

catlist顺序问题:当用户自定义函数与系统函数存在冲突,数据库系统在选择函数时,会受该系统函数在数据库系统中的注册顺序影响,从而导致选择函数结果不同。

参数类型:字符串

参数单位:

取值范围:''、catlist。

  • '':不进行优化,与505.1.0版本之前的版本保持一致。
  • catlist :优化catlist顺序问题(对于非MYSQL兼容模式进行优化,非MYSQL兼容模式下始终优先选择系统函数并执行。MYSQL兼容模式与505.1.0版本之前的版本保持一致,可能提示函数不唯一的错误,也可能选中系统函数进行执行)。

默认值:

  • catlist:新安装的数据库的默认值
  • '':505.1.0版本之前的数据库升级后的默认值

设置方式:该参数属于USERSET类型参数,请参见表2中对应设置方法进行设置。

gs_format_behavior_compat_options

参数说明:gs_format_behavior_compat_options用于选择GaussDB内部系统函数配置项。

参数类型:字符串

参数单位:

取值范围:当前只支持表9中的兼容性配置项,当设置多个兼容性配置项时,相邻配置项之间用逗号隔开。

默认值:'sqrt_karatsuba'

表9 gs_format_behavior兼容性配置项

兼容性配置项

兼容性行为控制

'sqrt_karatsuba'

  • 设置此参数:表示在调用sqrt平方根函数时使用Karatsuba平方根算法,karatsuba算法性能更高但是在极少数情况下精度可能会和牛顿迭代算法不一致。
  • 不设置此参数:在计算sqrt平方根算法时会使用默认的牛顿迭代算法进行平方根的计算。

'allow_textconcat_null'

  • 设置此参数:在PG兼容模式下字符串和null值拼接会返回对应的字符串的值。
    -- 在PG兼容模式下执行
    gaussdb=# set gs_format_behavior_compat_options='allow_textconcat_null';
    SET
    gaussdb=# select 'a' || null || 'b';
     ?column?
    ----------
     ab
    (1 row)
    
  • 不设置此参数:在PG兼容模式下字符串和null值拼接会返回NULL。

设置方式:该参数属于USERSET类型参数,请参考表2中对应设置方法进行设置。

设置建议:控制一些兼容性特性是否可用,若要更改,请在理解参数含义后谨慎操作,避免因误操作产生意料之外的风险。

分享:

    相关文档

    相关产品