All Products
Search
Document Center

PolarDB:1.0 to 2.0 migration preparation and FAQs

Last Updated:Jul 12, 2025

This document provides detailed information about key preparation items and solutions to common issues when migrating from version 1.0 to version 2.0. It covers issues related to drivers, cluster parameters, Sequence values, stored procedure OUT parameter calls, and provides migration best practices. This will help you avoid compatibility issues and ensure a smooth migration process.

Driver replacement

Important

Version 1.0 and version 2.0 use completely different driver systems. When migrating, you must completely replace the version 1.0 drivers in your application with version 2.0 specific drivers to ensure your application runs properly.

version 2.0 provides comprehensive driver support covering mainstream development languages and platforms:

Database connection methods

Both version 1.0 and version 2.0 use standard PostgreSQL protocol for database connections, achieving 100% PostgreSQL protocol compatibility. You can continue to use familiar database client tools for connection and management without additional handling. Common client tools include the following:

Parameter change verification

After migration, you must check and confirm relevant parameter configurations, especially for parameters that were manually modified in version 1.0. The following is a comparison table of key parameter changes:

1.0 parameter name

1.0 default value

2.0 parameter name

2.0 default value

Parameter function description

polar_comp_stmt_level_tx

off

polar_enable_stmt_transaction_rollback

on

Controls whether to enable statement-level transaction rollback functionality.

polar_empty_string_is_null_enable

on

polar_enable_empty_string_is_null

on

Controls whether empty strings are treated as NULL values.

By carefully checking and appropriately adjusting these parameters, you can ensure that the migrated system both takes full advantage of the new features in version 2.0 and maintains compatibility with existing business logic.

FAQ

Sequence value synchronization issue

Problem description:

After migration, Sequence values in the destination database might lag behind the source database, causing duplicate or discontinuous values generated by the sequences.

Solution: Manually synchronize the current Sequence values from the source database to the destination database:

  1. Retrieve source database Sequences: Execute the following SQL statement in the source database to obtain Sequence values.

    DO LANGUAGE plpgsql $$
    DECLARE
      nsp name;
      rel name;
      val int8;
    BEGIN
      FOR nsp, rel IN 
        SELECT nspname, relname 
        FROM pg_class t2, pg_namespace t3 
        WHERE t2.relnamespace = t3.oid 
          AND t2.relkind = 'S' 
          AND t2.relowner != 10
      LOOP
        EXECUTE format($_$select last_value from %I.%I$_$, nsp, rel) into val;
        RAISE NOTICE '%',
        format($_$select setval('%I.%I'::regclass, %s);$_$, nsp, rel, val+1);
      END LOOP;
    END;
    $$;
  2. Execute synchronization operation: Copy the above results to the destination database and execute them.

  3. Verify synchronization results: Confirm that the Sequence values in the destination database are consistent with the source database.

Stored procedure OUT parameter call issue

Problem description: In version 2.0, when calling stored procedures or functions with OUT parameters, you must pass a value at the OUT parameter position, otherwise the call will fail.

Problem example:

-- Stored procedure definition
CREATE PROCEDURE p(a OUT INT) IS
BEGIN
  a := 1;
END;

-- Call method in PolarDB-O 1.0 (will fail in 2.0)
CALL p();

-- Call method compatible with PolarDB-O 2.0 and Oracle
CALL p(100); -- Parameter value can be any integer, only used for type detection

Solution: Business code needs to be modified. This is a kernel-level compatibility change that cannot be resolved through configuration. You must modify the application code. When calling stored procedures with OUT parameters, you must pass a placeholder value at the OUT parameter position (this value will not be actually used, it is only for parameter type detection).

Object lookup and Search Path issues

Problem description: After migration, tables, views, stored procedures, and other database objects might not be found, usually related to the search_path configuration.

Solution:

  • Preferred solution: Set database-level search_path.

    Note

    If you use JDBC to connect to the database, you need to set currentSchema=schema1 in the JDBC connection string to specify the namespace.

    ALTER DATABASE database_name SET search_path = 'schema1,schema2,public';
  • Fallback solution: Create public synonyms When adjusting the search_path cannot solve the problem, you can resolve object access issues by creating public synonyms:

    -- Script to generate synonym creation statements in batch
    DO $$
    DECLARE
        relation_name VARCHAR(100);
        relation_nsp VARCHAR(100);
    BEGIN
        -- Query all tables and views created by the specified user
        FOR relation_name, relation_nsp IN 
            SELECT relname, relnamespace::regnamespace 
            FROM pg_class 
            WHERE relkind IN ('r', 'v') 
            AND relowner = '<actual object creator username>'::regrole::oid 
        LOOP
            -- Generate SQL statements to create public synonyms
            RAISE NOTICE 'CREATE PUBLIC SYNONYM % FOR %.%;', 
                         relation_name, relation_nsp, relation_name;
        END LOOP;
    END $$;
    Note
    • Replace <actual object creator username> in the above script with the actual username.

    • After executing the script, copy the output CREATE PUBLIC SYNONYM statements, confirm the SQL statements are correct, and manually execute these statements to create synonyms.

Table and view permission issues

Problem description: After migration, there might be insufficient access permissions for tables or views.

Solution: Manually add necessary permissions using the GRANT statement:

-- Grant query permission on a table to a user
GRANT SELECT ON table_name TO user_name;

-- Grant query permission on a view to a user
GRANT SELECT ON view_name TO user_name;

-- Grant usage permission on a schema to a user
GRANT USAGE ON SCHEMA schema_name TO user_name;

Case sensitivity issues

Problem description: If you created objects in version 1.0 using double quotes with alternating case, you might encounter issues where objects cannot be found in version 2.0.

Important

This issue is rare. If you are unsure whether you have triggered this issue, please contact us for confirmation before proceeding.

Problem cause: The application code depends on a bug behavior from early versions of 1.0.

Solution: Enable the case ignore parameter in version 2.0:

-- Enable case interleaving ignore functionality
SET polar_enable_ignore_case_interleaving = on;

Best practices in job migration

To ensure a smooth migration process, we recommend following these best practices:

  • Thorough testing: Before migrating to the production environment, you must fully verify all functionality in a test environment.

  • Step-by-step troubleshooting: Check and resolve issues one by one according to the problem checklist above.

  • Back up important data: Ensure important data is fully backed up before migration.

  • Compatibility testing: Comprehensively test the compatibility of applications with the new version.

  • Performance optimization: Utilize the new features of version 2.0 to optimize database access performance for applications.

  • Technical support: When encountering complex issues, please contact us promptly for assistance.

  • Documentation: Record all modifications and adjustments for future maintenance.

By systematically addressing these common issues, you can ensure a smooth version migration and fully leverage the new features and performance advantages of 2.0.

References