Skip to content

Add 'character set' specification for XRAS ingestors #122

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 4, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions classes/DB/PDODBMultiIngestor.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,20 @@ public function ingest()
&& $sourceRows % 250000 == 0
|| $rowsTotal == $sourceRows
) {
// From https://dev.mysql.com/doc/refman/5.5/en/load-data.html
//
// The server uses the character set indicated by the
// character_set_database system variable to interpret the information in
// the file. **SET NAMES and the setting of character_set_client do not
// affect interpretation of input**. If the contents of the input file use
// a character set that differs from the default, it is usually preferable
// to specify the character set of the file by using the CHARACTER SET
// clause.

$load_statement = 'load data local infile \'' . $infile_name
. '\' replace into table ' . $this->_insert_table
// Only set the character set for XRAS ingestors to minimize potential impact
. ( 0 === strpos(get_class($this), 'XRAS') ? ' character set \'utf8mb4\'' : '' )
. ' fields terminated by 0x1e optionally enclosed by 0x1f'
. ' lines terminated by 0x1d ('
. implode(',', $this->_insert_fields) . ')';
Expand Down Expand Up @@ -320,7 +332,7 @@ public function ingest()
'records_examined' => $rowsTotal,
'records_loaded' => $sourceRows,
));

}

public function setLogger(Log $logger)
Expand Down Expand Up @@ -353,7 +365,7 @@ public function checkForChanges()
$primarykeys = $stmt->fetchAll();

$constraints = array();
foreach($primarykeys as $keydata)
foreach($primarykeys as $keydata)
{
$constraints[] = sprintf(" b.%s = c.%s ", $keydata['COLUMN_NAME'], $keydata['COLUMN_NAME']);
}
Expand Down Expand Up @@ -468,4 +480,3 @@ protected function addCommonProcessingStepToStatements(
}
}
}