# Path: oslo_db/sqlalchemy/types.py
# class String(_String):
#     """String subclass that implements oslo_db specific options.
# 
#     Initial goal is to support ndb-specific flags.
# 
#     mysql_ndb_type is used to override the String with another data type.
#     mysql_ndb_size is used to adjust the length of the String.
# 
#     """
# 
#     def __init__(
#             self, length, mysql_ndb_length=None, mysql_ndb_type=None, **kw):
#         """Initialize options."""
#         super(String, self).__init__(length, **kw)
#         self.mysql_ndb_type = mysql_ndb_type
#         self.mysql_ndb_length = mysql_ndb_length


import re
from oslo_db.sqlalchemy.types import String
from sqlalchemy import event, schema
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.types import String as _String
from sqlalchemy.types import to_instance
    def before_cursor_execute(conn, cursor, statement, parameters, context,
                              executemany):
        """Listen for specific SQL strings and replace automatically.

        Function will intercept any raw execute calls and automatically
        convert InnoDB to NDBCLUSTER, drop SAVEPOINT requests, drop
        ROLLBACK requests, and drop RELEASE SAVEPOINT requests.
        """
        if ndb_status(engine):
            statement = engine_regex.sub("ENGINE=NDBCLUSTER", statement)
            if re.match(trans_regex, statement):
                statement = "SET @oslo_db_ndb_savepoint_rollback_disabled = 0;"

        return statement, parameters


@compiles(schema.CreateTable, "mysql")
def prefix_inserts(create_table, compiler, **kw):
    """Replace InnoDB with NDBCLUSTER automatically.

    Function will intercept CreateTable() calls and automatically
    convert InnoDB to NDBCLUSTER. Targets compiler events.
    """
    existing = compiler.visit_create_table(create_table, **kw)
    if ndb_status(compiler):
        existing = engine_regex.sub("ENGINE=NDBCLUSTER", existing)

    return existing



# Path: oslo_db/sqlalchemy/types.py
# class String(_String):
#     """String subclass that implements oslo_db specific options.
# 
#     Initial goal is to support ndb-specific flags.
# 
#     mysql_ndb_type is used to override the String with another data type.
#     mysql_ndb_size is used to adjust the length of the String.
# 
#     """
# 
#     def __init__(
#             self, length, mysql_ndb_length=None, mysql_ndb_type=None, **kw):
#         """Initialize options."""
#         super(String, self).__init__(length, **kw)
#         self.mysql_ndb_type = mysql_ndb_type
#         self.mysql_ndb_length = mysql_ndb_length


# Path: oslo_db/sqlalchemy/ndb.py
import re
from oslo_db.sqlalchemy.types import String
from sqlalchemy import event, schema
from sqlalchemy.ext.compiler import compiles
from sqlalchemy.types import String as _String
from sqlalchemy.types import to_instance

    def before_cursor_execute(conn, cursor, statement, parameters, context,
                              executemany):
        """Listen for specific SQL strings and replace automatically.

        Function will intercept any raw execute calls and automatically
        convert InnoDB to NDBCLUSTER, drop SAVEPOINT requests, drop
        ROLLBACK requests, and drop RELEASE SAVEPOINT requests.
        """
        if ndb_status(engine):
            statement = engine_regex.sub("ENGINE=NDBCLUSTER", statement)
            if re.match(trans_regex, statement):
                statement = "SET @oslo_db_ndb_savepoint_rollback_disabled = 0;"

        return statement, parameters


@compiles(schema.CreateTable, "mysql")
def prefix_inserts(create_table, compiler, **kw):
    """Replace InnoDB with NDBCLUSTER automatically.

    Function will intercept CreateTable() calls and automatically
    convert InnoDB to NDBCLUSTER. Targets compiler events.
    """
    existing = compiler.visit_create_table(create_table, **kw)
    if ndb_status(compiler):
        existing = engine_regex.sub("ENGINE=NDBCLUSTER", existing)

    return existing



@compiles(String, "mysql")