HomeMogDBMogDB StackUqbar
v5.0

Documentation:v5.0

Supported Versions:

Other Versions:

MySQL Syntax Compatibility Assessment Tool

This tool can use the existing MogDB node to assess the compatibility of data SQL text in MogDB. The restrictions include but are not limited to the following:

  • Only SQL text files are supported, and SQL statements are separated by semicolons (;).
  • If compatible plug-ins such as Dolphin and Whale are not used, the error information about incompatible statements may be inaccurate. If the corresponding plug-in is used, comply with the plug-in usage restrictions.
  • The comment tag (#) is not supported currently. Replace the comment tag (#) in the text with -- or delete it.
  • Stored procedures and function statements support only the validity check of the creation body and the syntax compatibility check of the function body.
  • Accuracy of assessment results:
    • Fully compatible: MogDB fully supports this syntax. The compatibility result may depend on the pre-processing result of the input SQL statement. Therefore, the statements may not be fully compatible when being executed in MogDB.
    • Syntax compatible: MogDB supports this syntax. However, in actual use, problems may occur, for example, the column type is not supported or the function does not exist.
    • Statement incompatible: MogDB does not support this syntax.
    • Assessment not supported: Statements are not considered. Statement assessment (for example, cross-database impact statements such as CREATE DATABASE) will be supported in the future.
    • Ignored statements: such as comments.

For an A-compatible database, you are advised to perform the following settings in advance when exporting SQL statements:

EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SEGMENT_ATTRIBUTES',false);
EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'SQLTERMINATOR',true);
EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'STORAGE',false);
EXECUTE DBMS_METADATA.SET_TRANSFORM_PARAM(DBMS_METADATA.SESSION_TRANSFORM,'TABLESPACE',false);

Compiling Plug-ins

  • Mandatory Plug-ins
Mandatory Plug-in Description
contrib/assessment Assessment plug-in, including the plug-in SO and executable files
  • The following plug-in can be used to improve the overall compatibility when the database is running:
Optional Plug-in (Compatibility Plug-in) Description
contrib/dolphin B-compatible database plug-in
  1. Download the MogDB source code and compile the MogDB source code according to the READMD.md file.
  2. Copy the preceding plug-ins to the contrib directory in the MogDB source code path. Run the cd command to go to the corresponding directory and run the make install -sj command.
  3. Copy the files required by the plug-in to the corresponding binary path. Generally, the files are extesion.so, extension.sql, and extension.control. The assessment plug-in contains the executable file assessment_database. In this example, the following files are involved: If the binary in step 1 is used, skip this step.

Dependency files of assessment

Binary path
├── bin
│   └── ***assessment_database***
├── lib
│   └── postgresql
│       └── ***assessment.so***
└── share
    └── postgresql
        └── extension
            ├── ***assessment--1.0.sql***
            └── ***assessment.control***

Dependency files of Dolphin

Binary path
├── lib
│   └── postgresql
│       └── ***dolphin.so***
└── share
    └── postgresql
        └── extension
            ├── ***dolphin--1.0.sql***
            └── ***dolphin.control***

Running

  1. Ensure that a database is running and can be connected using the gsql command.

  2. Run the assessment_database [args] command, where args contains the following parameters:

    Parameter Description Usage
    Connection parameters p (Mandatory) Port -p 5432
    d (Optional) Database -d evaluation
    U (Optional) User name. If local connection is supported, leave this parameter blank. -U user
    W (Optional) Password. If local connection is supported, leave this parameter blank. -W ******
    Compatibility assessment c Specifies the compatibility type (A\B\C\PG). If the d parameter is specified, this parameter cannot be set. -c B
    File parameters f (Mandatory) Assesses the SQL file. -f intput.sql
    o (Mandatory) Output file. Generally, an HTML file is entered. -o result.html

Examples

case 1:

Use gs_initdb to initialize the database and start it. Assume that the startup port is 5432. In this case, you can run the gsql -dpostgres -p5432 command to connect to the database. Assume that the input file is test.sql, the output report path is result.html, and the source database to be assessed is B. The command used for evaluation is as follows:

assessment_database -p5432 -cB -ftest.sql -oresult.html

The following information is displayed:

assessment_database: create database "assessment_197561" automatically.
assessment_database: Create plugin[dolphin] automatically.
assessment_database: Create extension[assessment] automatically.
assessment_database: parse[100.00%]:35/35
assessment_database: Create database assessment_197561 automatically, clear it manually!

case 2:

Assume that a database node already exists remotely. You can connect to the database through gsql -dpostgres -p5432 -h127.0.0.2 -Utest -W* on the compatibility assessment node. Assume that the input file is test.sql, the output report path is result.html, and the source database to be assessed is B. The command used for assessment is as follows:

assessment_database -p5432 -cB -h127.0.0.2 -Utest -W***** -ftest.sql -oresult.html

case 3:

Assume that a remote database node exists and the evaluation database has been created for compatibility assessment. On the compatibility assessment node, you can connect to the database through gsql -devalution -p5432 -h127.0.0.2 -Utest -W*. Assume that the input file is test.sql and the output report path is result.html. The assessment command is as follows:

assessment_database -p5432 -devaluation -h127.0.0.2 -Utest -W***** -ftest.sql -oresult.html

That is, replace -cB in case 2 with -devaluation to specify the database.

Results

The assessment tool generates an assessment report in HTML format. The information includes the statement, compatibility type, and failure cause. The compatibility types include syntax compatible, fully compatible, syntax incompatible, and assessment not supported. The details are as follows:

  • Fully compatible: MogDB fully supports this syntax. The execution result depends on the existing tables, functions, and stored procedures in the database.
  • Syntax compatible: MogDB supports this syntax. However, in actual use, problems may occur, for example, the column type is not supported or the function does not exist.
  • Statement incompatible: MogDB does not support this syntax.
  • Assessment not supported: Statements are not considered. Statement assessment (for example, cross-database impact statements such as CREATE DATABASE) will be supported in the future.

Principle

  1. A database node is running properly and can be initialized using gs_initdb.
  2. The connection parameters are configured. The connection parameters are the same as those of the gsql connection mode of MogDB.
  3. If the -c compatibility type is specified, the tool uses the preceding connection parameters to connect to the database. You need to manually create the corresponding compatibility assessment database, and then run the CREATE EXTENSION command to create necessary plug-ins (such as assessment and dolphin).
  4. If -d database is specified, the tool creates a plug-in in the corresponding database.
  5. The assessment is performed in the corresponding assessment database. The assessment types include syntax tree compatibility assessment and statement compatibility assessment.
Copyright © 2011-2024 www.enmotech.com All rights reserved.