Updated on 2025-06-07 GMT+08:00

GaussDB (M-Compatible Mode)

For an M-compatible GaussDB database, you can set GUC parameters listed in Table 1 to enhance compatibility.

GaussDB provides many parameters, which determine how the database system works. Before modifying these parameters, you need to understand the impact on databases. Otherwise, unexpected results may occur.

Table 1 GUC parameters of GaussDB (M-compatible mode)

Behavior Configuration Item for GaussDB Centralized (M-Compatible Mode)

Compatibility Configuration Item

Description

Supported Database

Enabled

m_format_behavior_compat_options

enable_escape_string

Whether escape character control is enabled

If this item is disabled, escape character behaviors are controlled by the GUC parameters standard_conforming_strings, escape_string_warning, and backslash_quote related to the GaussDB escape character.

If this item is enabled, all MySQL escape characters except '\0' are supported by default. In addition, the output behavior of '\b', '\r', and '\Z' on the gsql client changes to be the same as that on the MySQL client.

Centralized GaussDB instance V2.0-8.200 and later

Yes

enable_conflict_funcs

Whether conflict functions are enabled

If this configuration item is disabled, the CEIL, FORMAT, INSTR, POSITION, ROW_NUMBER, RANK, DENSE_RANK, REGEXP_INSTR, REGEXP_LIKE, REGEXP_REPLACE, and REGEXP_SUBSTR functions retain the behavior of native system functions of GaussDB.

If this configuration item is enabled and the value of m_format_dev_version is 's2' or a later version, the CEIL, FORMAT, INSTR, POSITION, ROW_NUMBER, RANK, and DENSE_RANK functions are implemented by M-compatible GaussDB databases. When REGEXP_INSTR, REGEXP_LIKE, REGEXP_REPLACE, and REGEXP_SUBSTR are used, an error message is displayed, indicating that M-compatible GaussDB databases are not supported.

Centralized GaussDB instance V2.0-8.200 and later

Yes

select_column_name

Whether column names are displayed in the output. Currently, this function is only available to GaussDB (M-compatible mode). Set the same value for m_format_behavior_compat_options and select_column_name. This configuration item can be set by users and is disabled by default.

If this configuration item is disabled:

SELECT System function: The system function name is displayed.

SELECT Expression: ?column? is displayed.

SELECT Boolean value: The Boolean value is displayed.

If this configuration item is enabled, column names are displayed in all functions or expressions.

This configuration item is only available to GaussDB Centralized and can be tested using a commercial client.

If the displayed column name string contains escape characters, the escape characters are displayed only after the same value is set for m_format_behavior_compat_options and enable_escape_string. Otherwise, the escape characters are displayed. For example, SELECT"abc\tdef"; is displayed as abc\tdef when the preceding settings are disabled in GaussDB (M-compatible mode).

Centralized GaussDB instance V2.0-8.200 and later

Yes

enable_precision_decimal

Data type precision

If this configuration item is disabled:

The CREATE TABLE SELECT statement can be executed only for table columns. Expressions, functions, constants, or union types are not supported because return types need to be inferred.

If this configuration item is enabled:

The CREATE TABLE SELECT statement is not restricted by the preceding scenarios.

Centralized GaussDB instance V2.0-8.200 and later

Yes

forbid_none_space_comment

Whether "--" followed by a space can comment out a single line

If this configuration item is disabled, all characters after "--" in a single line will be commented out, no matter whether a space is added after "--".

If this configuration item is enabled, only characters after "--" followed by a space in a single line will be commented out.

Centralized/Distributed GaussDB instance V2.0-9.0

Yes

cast_as_new_json

Whether ::JSON can be used to convert a data type to JSON in M-compatible GaussDB databases.

If this configuration item is disabled, CREATE TABLE <Table name> AS <SELECT data types including JSON> and statements containing ::JSON will convert data types to JSON in non-M-compatible GaussDB databases

If this configuration item is enabled, CREATE TABLE <Table name> AS <SELECT data types including JSON> and statements containing ::JSON will convert data types to JSON in M-compatible GaussDB databases.

Centralized GaussDB instance V2.0-9.0

Yes

grant_database_nomapping

Syntax behavior of GRANT | REVOKE ON DATABASE in M-compatible GaussDB databases

If this configuration item is disabled, GRANT | REVOKE ON DATABASE is mapped to GRANT | REVOKE ON SCHEMA to grant or revoke the specified user's or role's permission to access schema objects.

If this configuration item is enabled, GRANT | REVOKE ON DATABASE retains the behavior of GRANT | REVOKE ON DATABASE in GaussDB databases with the default compatibility mode and grants or revokes the specified user's or role's permission to access database objects.

Centralized/Distributed GaussDB instance V2.0-9.0

Yes

disable_illegal_function_syntax

Controls invalid syntax in system functions.

If this item is disabled, system functions are available in the following scenarios:

System functions without input parameters can be called with (*).

Common system functions can be called with WITHIN GROUP.

Common system functions with input parameters can be called with ORDER BY.

Common system functions can be called with the OVER clause.

Aggregate functions can be called with WITHIN GROUP.

If this item is enabled, the preceding scenarios will be disabled.

Centralized GaussDB instance V2.0-9.0

Yes

m_format_dev_version

S1

Affects the following syntax:

SELECT FETCH FIRST ROWS ONLY will be disabled.

TRUNCATE CASCADE/RESTRICT will be disabled.

Tablespace names cannot be specified in USING INDEX TABLESPACE when a primary key is defined in CREATE TABLE.

CASCADE and RESTRICT in DROP TABLE/VIEW/COLUMN will be ignored, and the default behavior is RESTRICT.

When CREATE TABLE REFERENCES is used as a column constraint, the foreign key definition will be ignored.

Centralized/Distributed GaussDB instance V2.0-8.100

Yes

s2

Affects the following operator:

The default implicit conversion rule of the :: operator is used.

Affects the following views:

In the information_schema.statistics view, primary displayed in the INDEX_NAME column will change to PRIMARY when an index is defined as a primary key. The COLUMN_NAME and SUB_PART columns support prefix indexes. Temporary table indexes will not be displayed. System column indexes will not be displayed in some scenarios.

In the information_schema.global_variables view, only internal, postmaster, backend, and sighup in the context column in the pg_settings table will be displayed.

In the information_schema.columns view, the COLUMN_KEY column supports prefix indexes.

In the information_schema.table_constraints view, PRIMARY is displayed instead of the primary key constraint name in the CONSTRAINT_NAME column.

In the information_schema.character_sets view, information about all available character sets can be queried.

In the information_schema.collations view, information about all available collations can be queried.

In the information_schema.collation_character_set_applicability view, the mapping between all available collations and character sets can be queried.

Values of CHARACTER_SET_NAME in the information_schema.character_sets, information_schema.collations, and information_schema.collation_character_set_applicability views will be converted to lowercase. The query results are displayed in the utf8mb4 and utf8 format based on the collation.

Affects the following syntax:

The following statements set characteristics of the next transaction:

set @@transaction_isolation = value

set @@transaction_read_only = value

set transaction isolation level

set transaction {read write | read only}

set transaction sets characteristics of a transaction in a session.

set [local|session|@@session.] transaction_isolation = value

set [local|session|@@session.] transaction_read_only = value

show transaction_isolation shows a transaction's isolation level.

If the STORED and VIRTUAL keywords are not specified when a generated column is created, a virtual generated column is created by default.

The result set returned by SHOW CREATE TABLE will change:

The position of the column or table comment will change. The comment is returned in the COMMENT clause of the CREATE TABLE statement instead of the COMMENT ON statement.

The positions of the primary key and unique constraint will change. ALTER TABLE ADD CONSTRAINT returns the primary key and unique constraint. CREATE TABLE returns the primary key and unique constraint in the CONSTRAINT clause.

The USING INDEX TABLESPACE option in the primary key and unique constraint is no longer displayed. This option is disabled after the compatible version control switch is set to s1.

The position of the index comment will change. The comment is returned in the COMMENT clause of the CREATE INDEX statement instead of the COMMENT ON statement.

The ON COMMIT option for global temporary tables will be specified using the ON COMMIT clause in CREATE TABLE instead of using the on_commit_delete_rows parameter in the WITH clause of CREATE TABLE.

SHOW CHARACTER SET shows all available character sets from the information_schema.character_sets view. The query result varies depending on what the view contains.

SHOW COLLATION shows character set collations from the information_schema.collations view. The query result varies depending on what the view contains.

For UPDATE:

If an alias is specified for table_name, the table can be referenced only by the alias.

Only when there are multiple columns in a single table, the expression of each column is calculated from left to right. If a column name is referenced, updated data is used. A column name can be modified multiple times.

INSERT ... In ON DUPLICATE KEY UPDATE, when the ON DUPLICATE KEY UPDATE clause updates multiple columns, if a column name is referenced, the updated data is used. A column name can be modified multiple times.

Affects the following GUC parameter:

More values can be set for transaction_isolation.

Affects the following functions:

To delete the base column of a generated column, you need to delete the generated column first.

The SET NULL, SET DEFAULT, and CASCADE keywords cannot be associated with ON UPDATED and ON DELETE.

If ALTER TABLE is used to modify a table that involves storage generation columns, the CHECK constraint check on the generation columns takes effect.

Centralized GaussDB instance V2.0-8.200 and later

Yes

Set m_format_dev_version as follows:

  • For GaussDB V2.0-8.100 Enterprise Edition, set the value to s1.
  • For GaussDB V2.0-8.200 Enterprise Edition and GaussDB V2.0-9.0 Enterprise Edition, set the value to s2.

Procedure

Centralized

  1. Connect to the GaussDB database and switch to the GaussDB installation user.

    su - omm

    In the preceding command, omm is an example. Change it to the actual installation user.

  2. Run the following commands to configure the parameters:

    gs_guc reload -Z coordinator -Z datanode -N all -I all -c "m_format_behavior_compat_options='enable_escape_string,enable_conflict_funcs,select_column_name,enable_precision_decimal'"; ----Centralized GaussDB instance V2.0-8.200 and later

    gs_guc reload -Z coordinator -Z datanode -N all -I all -c "m_format_behavior_compat_options='enable_escape_string,enable_conflict_funcs,select_column_name,enable_precision_decimal,forbid_none_space_comment,enable_load_data_remote_transmission,cast_as_new_json,grant_database_nomapping,disable_illegal_function_syntax'"; ----Centralized GaussDB instance V2.0-9.0 and later

    gs_guc reload -Z coordinator -Z datanode -N all -I all -c "m_format_dev_version='s2'"; --s1 for GaussDB V2.0-8.100; s2 for GaussDB V2.0-8.200 to GaussDB V2.0-9.0