← Back to team overview

drizzle-discuss team mailing list archive

DROP TABLE vs. DROP SCHEMA transaction_log messages for a table

 

Hi everyone,

Writing to get thoughts on this / wanting to make sure it is kosher.

The issue is that the transaction log records DROP TABLE statements
differently if there is an explicit DROP TABLE vs. a DROP SCHEMA (which
contains a table).
The output for each type of statement is below.  As we can see, dropping the
schema containing a table results in a statement that is RAW_SQL while a
direct DROP TABLE results in a slightly different message.

I just want to make sure this is good / won't be inconsistent.  Any
thoughts, information are most welcome.

The reason for the differing PRINT_TRANSACTION_MESSAGE() calls is that DROP
SCHEMA results in the actual DROP SCHEMA statement being last and we need to
directly use the transaction_id to see the DROP TABLE while a direct DROP
TABLE results in the last message being just that.

/* DROP SCHEMA containing table */
DROP SCHEMA my_test_schema;
Checking t1 DROP
SELECT PRINT_TRANSACTION_MESSAGE('transaction.log',(SELECT entry_offset FROM
DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS WHERE TRANSACTION_ID = 5));
PRINT_TRANSACTION_MESSAGE('transaction.log',(SELECT entry_offset FROM
DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS WHERE TRANSACTION_ID = 5))
transaction_context {
  server_id: 1
  transaction_id: 5
  START_TIMESTAMP
  END_TIMESTAMP
}
statement {
  type: RAW_SQL
  START_TIMESTAMP
  END_TIMESTAMP
  sql: "DROP TABLE IF EXISTS `my_test_schema`.`t1`"
}

/* DROP TABLE t1 */
PRINT_TRANSACTION_MESSAGE('transaction.log',(select max(entry_offset) from
DATA_DICTIONARY.TRANSACTION_LOG_TRANSACTIONS))
transaction_context {
  server_id: 1
  transaction_id: 1
  START_TIMESTAMP
  END_TIMESTAMP
}
statement {
  type: DROP_TABLE
  START_TIMESTAMP
  END_TIMESTAMP
  drop_table_statement {
    table_metadata {
      schema_name: "test"
      table_name: "t1"
    }
    if_exists_clause: true
  }
}