mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged HEAD-BUG-FIX (5.0/Cloud) to HEAD (4.3/Cloud)
71613: Merged V4.2-BUG-FIX (4.2.3) to HEAD-BUG-FIX (4.3/Cloud) 71277: Merged V4.1-BUG-FIX (4.1.9) to V4.2-BUG-FIX (4.2.3) 70543: Merged DEV to V4.1-BUG-FIX (4.1.9) 70393 : MNT-11231 : SchemaBootstrap SQL Script execution cannot handle complex SQL statements - Custom sql statements delimeter directive was implemtned for SchemaBootstrap and ScriptExecutorImpl. - Unit tests added. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@74702 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -160,6 +160,8 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
private static final String ERR_STATEMENT_VAR_ASSIGNMENT_BEFORE_SQL = "schema.update.err.statement_var_assignment_before_sql";
|
||||
private static final String ERR_STATEMENT_VAR_ASSIGNMENT_FORMAT = "schema.update.err.statement_var_assignment_format";
|
||||
private static final String ERR_STATEMENT_TERMINATOR = "schema.update.err.statement_terminator";
|
||||
private static final String ERR_DELIMITER_SET_BEFORE_SQL = "schema.update.err.delimiter_set_before_sql";
|
||||
private static final String ERR_DELIMITER_INVALID = "schema.update.err.delimiter_invalid";
|
||||
private static final String DEBUG_SCHEMA_COMP_NO_REF_FILE = "system.schema_comp.debug.no_ref_file";
|
||||
private static final String INFO_SCHEMA_COMP_ALL_OK = "system.schema_comp.info.all_ok";
|
||||
private static final String WARN_SCHEMA_COMP_PROBLEMS_FOUND = "system.schema_comp.warn.problems_found";
|
||||
@@ -1257,6 +1259,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
int batchUpperLimit = 0;
|
||||
int batchSize = 1;
|
||||
Map<String, Object> varAssignments = new HashMap<String, Object>(13);
|
||||
String delimiter = ";";
|
||||
// Special variable assignments:
|
||||
if (dialect instanceof PostgreSQLDialect)
|
||||
{
|
||||
@@ -1360,6 +1363,22 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
connection.setAutoCommit(true);
|
||||
continue;
|
||||
}
|
||||
else if (sql.startsWith("--SET-DELIMITER:"))
|
||||
{
|
||||
if (sb.length() > 0)
|
||||
{
|
||||
// This can only be set before a new SQL statement
|
||||
throw AlfrescoRuntimeException.create(ERR_DELIMITER_SET_BEFORE_SQL, (line - 1), scriptUrl);
|
||||
}
|
||||
|
||||
// We're good...so set the new delimiter
|
||||
String newDelim = sql.substring(16).trim();
|
||||
if (newDelim.length() == 0)
|
||||
{
|
||||
throw AlfrescoRuntimeException.create(ERR_DELIMITER_INVALID, (line - 1), scriptUrl);
|
||||
}
|
||||
delimiter = newDelim;
|
||||
}
|
||||
|
||||
// Check for comments
|
||||
if (sql.length() == 0 ||
|
||||
@@ -1370,7 +1389,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
if (sb.length() > 0)
|
||||
{
|
||||
// we have an unterminated statement
|
||||
throw AlfrescoRuntimeException.create(ERR_STATEMENT_TERMINATOR, (line - 1), scriptUrl);
|
||||
throw AlfrescoRuntimeException.create(ERR_STATEMENT_TERMINATOR, delimiter, (line - 1), scriptUrl);
|
||||
}
|
||||
// there has not been anything to execute - it's just a comment line
|
||||
continue;
|
||||
@@ -1378,7 +1397,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
// have we reached the end of a statement?
|
||||
boolean execute = false;
|
||||
boolean optional = false;
|
||||
if (sql.endsWith(";"))
|
||||
if (sql.endsWith(delimiter))
|
||||
{
|
||||
sql = sql.substring(0, sql.length() - 1);
|
||||
execute = true;
|
||||
@@ -1387,7 +1406,7 @@ public class SchemaBootstrap extends AbstractLifecycleBean
|
||||
else if (sql.endsWith("(optional)") || sql.endsWith("(OPTIONAL)"))
|
||||
{
|
||||
// Get the end of statement
|
||||
int endIndex = sql.lastIndexOf(';');
|
||||
int endIndex = sql.lastIndexOf(delimiter);
|
||||
if (endIndex > -1)
|
||||
{
|
||||
sql = sql.substring(0, endIndex);
|
||||
|
Reference in New Issue
Block a user