Introduce new structures for storing SQL statements.
Review Request #5187 — Created Jan. 3, 2014 and submitted — Latest diff uploaded
Introduce new structures for storing SQL statements.
This introduces
SQLResult
andAlterTableSQLResult
, which are used to
return and store lists of SQL statements.
SQLResult
has three fields:pre_sql
,sql
, andpost_sql
.pre_sql
and
post_sql
are used to store SQL statements that should be executed
before/after sql. These can be converted to a single list of SQL
statements with theto_sql()
function.
AlterTableSQLResult
extends this to also have analter_table
field that
contains a list ofALTER TABLE
rules. When callingto_sql()
, these are
turned intoALTER TABLE
statements.Where these structures come into play is with the next round of
optimizations. By knowing up-front what SQL statements must be executed
before/after a main set of statements, and whichALTER TABLE
rules are
going to be executed, a post-processor will be able to batch operations
in an intelligent way. For example, joining all the results together to
drop all indexes before a batch of statements, combiningALTER TABLE
rules into a singleALTER TABLE
statement, and then creating all new
indexes after they execute.That will come in the next big change.
All unit tests pass for all supported database types.
The SQL result of an upgrade from RB 1.7.x to 2.0 remained unchanged,
since optimizations aren't added yet.