Skip to content

Commit

Permalink
0002010: Initial load failing on Firebird because of "Implementation …
Browse files Browse the repository at this point in the history
…limit exceeded. Block size exceeds implementation restriction"
  • Loading branch information
chenson42 committed Oct 17, 2014
1 parent 8b2ac6c commit a6d5865
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public FirebirdTriggerTemplate(ISymmetricDialect symmetricDialect) {
"select $(columns) from $(schemaName)$(tableName) t where $(whereClause) " );
}

protected boolean requiresTriggerTemplatesToBeUsedDuringInitialLoad() {
public boolean useTriggerTemplateForColumnTemplatesDuringInitialLoad() {
return false;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,14 @@ protected AbstractTriggerTemplate(ISymmetricDialect symmetricDialect) {
this.symmetricDialect = symmetricDialect;
}

protected boolean requiresTriggerTemplatesToBeUsedDuringInitialLoad() {
/**
* When {@link ParameterConstants#INITIAL_LOAD_CONCAT_CSV_IN_SQL_ENABLED} is false
* most dialects are going to want to still use the trigger templates because they
* have type translation details (like geometry templates). However, some dialects
* cannot handle the complex SQL generated (Firebird). We needed a way to tell
* the dialect that we want to select the columns straight up.
*/
public boolean useTriggerTemplateForColumnTemplatesDuringInitialLoad() {
return true;
}

Expand Down Expand Up @@ -159,7 +166,7 @@ public String createInitalLoadSql(Node node, TriggerRouter triggerRouter, Table
if (!(isLob && triggerRouter.getTrigger().isUseStreamLobs())) {

String columnExpression = null;
if (requiresTriggerTemplatesToBeUsedDuringInitialLoad()) {
if (useTriggerTemplateForColumnTemplatesDuringInitialLoad()) {
ColumnString columnString = fillOutColumnTemplate(tableAlias,
tableAlias, "", column, DataEventType.INSERT, false, channel,
triggerRouter.getTrigger());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1587,21 +1587,31 @@ protected void closeCursor() {

protected void startNewCursor(final TriggerHistory triggerHistory,
final TriggerRouter triggerRouter, String overrideSelectSql) {
final int expectedCommaCount = triggerHistory.getParsedColumnNames().length - 1;
final String initialLoadSql = symmetricDialect.createInitialLoadSqlFor(
this.currentInitialLoadEvent.getNode(), triggerRouter, sourceTable,
triggerHistory,
configurationService.getChannel(triggerRouter.getTrigger().getChannelId()),
overrideSelectSql);

final int expectedCommaCount = triggerHistory.getParsedColumnNames().length - 1;
final boolean selectedAsCsv = symmetricDialect.getParameterService().is(
ParameterConstants.INITIAL_LOAD_CONCAT_CSV_IN_SQL_ENABLED);
final boolean objectValuesWillNeedEscaped = !symmetricDialect.getTriggerTemplate()
.useTriggerTemplateForColumnTemplatesDuringInitialLoad();

this.cursor = sqlTemplate.queryForCursor(initialLoadSql, new ISqlRowMapper<Data>() {
public Data mapRow(Row row) {

String csvRow = null;
if (symmetricDialect.getParameterService().is(
ParameterConstants.INITIAL_LOAD_CONCAT_CSV_IN_SQL_ENABLED)) {
String csvRow = null;
if (selectedAsCsv) {
csvRow = row.stringValue();
} else if (objectValuesWillNeedEscaped) {
String[] rowData = platform.getStringValues(
symmetricDialect.getBinaryEncoding(), sourceTable.getColumns(),
row, false);
csvRow = CsvUtils.escapeCsvData(rowData, '\0', '"');
} else {
csvRow = row.csvValue();
csvRow = row.csvValue();

}
int commaCount = StringUtils.countMatches(csvRow, ",");
if (expectedCommaCount <= commaCount) {
Expand Down

0 comments on commit a6d5865

Please sign in to comment.