mirror of
https://github.com/apache/sqoop.git
synced 2025-05-09 03:59:46 +08:00
SQOOP-2250: Sqoop2: SQ_LINK_INPUT is missing a foreign key constraint
(Veena Basavaraj via Abraham Elmahrek)
This commit is contained in:
parent
816374bd0d
commit
a3362a2563
@ -1638,7 +1638,6 @@ private List<MLink> loadLinks(PreparedStatement stmt,
|
||||
|
||||
connectorConfigFetchStatement.setLong(1, connectorId);
|
||||
connectorConfigInputStatement.setLong(1, id);
|
||||
connectorConfigInputStatement.setLong(3, id);
|
||||
|
||||
List<MConfig> connectorLinkConfig = new ArrayList<MConfig>();
|
||||
List<MConfig> fromConfig = new ArrayList<MConfig>();
|
||||
@ -1704,7 +1703,6 @@ private List<MJob> loadJobs(PreparedStatement stmt,
|
||||
driverConfigfetchStmt.setLong(1, driverId);
|
||||
|
||||
jobInputFetchStmt.setLong(1, id);
|
||||
jobInputFetchStmt.setLong(3, id);
|
||||
|
||||
// FROM entity configs
|
||||
List<MConfig> fromConnectorLinkConfig = new ArrayList<MConfig>();
|
||||
|
@ -213,7 +213,6 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
|
||||
+ " ON " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_INPUT) + " = " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID)
|
||||
+ " AND " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + " = ?"
|
||||
+ " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_CONFIG) + " = ?"
|
||||
+ " AND (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + " = ?" + " OR " + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + " IS NULL)"
|
||||
+ " ORDER BY " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_INDEX);
|
||||
|
||||
/**
|
||||
@ -237,7 +236,6 @@ public class CommonRepositoryInsertUpdateDeleteSelectQuery {
|
||||
+ " ON " + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_INPUT) + " = " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID)
|
||||
+ " AND " + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB) + " = ?"
|
||||
+ " WHERE " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_CONFIG) + " = ?"
|
||||
+ " AND (" + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB) + " = ? OR " + CommonRepoUtils.escapeColumnName(COLUMN_SQBI_JOB) + " IS NULL)"
|
||||
+ " ORDER BY " + CommonRepoUtils.escapeColumnName(COLUMN_SQI_INDEX);
|
||||
|
||||
/**
|
||||
|
@ -43,8 +43,9 @@ public final class DerbyRepoConstants {
|
||||
* 4 - Version 1.99.4
|
||||
* Changed to FROM/TO design.
|
||||
* 5 - Version 1.99.5
|
||||
* 6 - Version 1.99.6
|
||||
*/
|
||||
public static final int LATEST_DERBY_REPOSITORY_VERSION = 5;
|
||||
public static final int LATEST_DERBY_REPOSITORY_VERSION = 6;
|
||||
|
||||
private DerbyRepoConstants() {
|
||||
// Disable explicit object creation
|
||||
|
@ -299,7 +299,7 @@ public void createOrUpgradeRepository(Connection conn) {
|
||||
derbyUpgradeGenericJdbcConnectorConfigAndInputNames.execute();
|
||||
}
|
||||
}
|
||||
|
||||
// 1.99.5 release changes
|
||||
if (repositoryVersion < 5) {
|
||||
runQuery(QUERY_UPGRADE_TABLE_SQ_CONFIG_ADD_UNIQUE_CONSTRAINT_NAME_TYPE_AND_CONFIGURABLE_ID, conn);
|
||||
runQuery(QUERY_UPGRADE_TABLE_SQ_INPUT_ADD_UNIQUE_CONSTRAINT_NAME_TYPE_AND_CONFIG_ID, conn);
|
||||
@ -311,6 +311,10 @@ public void createOrUpgradeRepository(Connection conn) {
|
||||
// create a new table for SQ_INPUT relationships
|
||||
runQuery(QUERY_CREATE_TABLE_SQ_INPUT_RELATION, conn);
|
||||
}
|
||||
// 1.99.6 release changes
|
||||
if (repositoryVersion < 6) {
|
||||
runQuery(QUERY_UPGRADE_ADD_TABLE_SQ_LINK_INPUT_CONSTRAINT_2, conn);
|
||||
}
|
||||
|
||||
// last step upgrade the repository version to the latest value in the code
|
||||
upgradeRepositoryVersion(conn);
|
||||
|
@ -325,6 +325,10 @@ public final class DerbySchemaUpgradeQuery {
|
||||
+ CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_INPUT_NAME) + " ADD CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_LNKI_SQ_LNK_NAME) + " "
|
||||
+ "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_LINK) + ") " + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_NAME) + " ("
|
||||
+ CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNK_ID) + ")";
|
||||
public static final String QUERY_UPGRADE_ADD_TABLE_SQ_LINK_INPUT_CONSTRAINT_2 = "ALTER TABLE "
|
||||
+ CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_LINK_INPUT_NAME) + " ADD CONSTRAINT " + CommonRepoUtils.getConstraintName(SCHEMA_SQOOP, CONSTRAINT_SQ_LNKI_SQI_NAME) + " "
|
||||
+ "FOREIGN KEY (" + CommonRepoUtils.escapeColumnName(COLUMN_SQ_LNKI_INPUT) + ") " + "REFERENCES " + CommonRepoUtils.getTableName(SCHEMA_SQOOP, TABLE_SQ_INPUT_NAME) + " ("
|
||||
+ CommonRepoUtils.escapeColumnName(COLUMN_SQI_ID) + ")";
|
||||
|
||||
// table rename for FORM-> CONFIG
|
||||
public static final String QUERY_UPGRADE_DROP_TABLE_SQ_FORM_CONSTRAINT = "ALTER TABLE "
|
||||
|
@ -220,6 +220,8 @@ protected void createOrUpgradeSchema(int version) throws Exception {
|
||||
// SQOOP-1804
|
||||
runQuery(QUERY_UPGRADE_TABLE_SQ_INPUT_ADD_COLUMN_SQI_EDITABLE);
|
||||
runQuery(QUERY_CREATE_TABLE_SQ_INPUT_RELATION);
|
||||
runQuery(QUERY_UPGRADE_ADD_TABLE_SQ_LINK_INPUT_CONSTRAINT_2);
|
||||
|
||||
}
|
||||
|
||||
// deprecated repository version
|
||||
@ -523,7 +525,7 @@ protected void loadConnectorAndDriverConfigVersion4() throws Exception {
|
||||
// Connector job (TO) config: 8-11
|
||||
// Driver JOB config: 12-15
|
||||
for (int i = 0; i < 4; i++) {
|
||||
// First config
|
||||
// First config inputs with config ids 1,3, 5, 7
|
||||
runInsertQuery("INSERT INTO SQOOP.SQ_INPUT"
|
||||
+ "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH, SQI_EDITABLE)"
|
||||
+ " VALUES('I1', " + (i * 2 + 1) + ", 0, 'STRING', false, 30, 'USER_ONLY')");
|
||||
@ -531,7 +533,7 @@ protected void loadConnectorAndDriverConfigVersion4() throws Exception {
|
||||
+ "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH, SQI_EDITABLE)"
|
||||
+ " VALUES('I2', " + (i * 2 + 1) + ", 1, 'MAP', false, 30, 'CONNECTOR_ONLY')");
|
||||
|
||||
// Second config
|
||||
// Second config inputs with config ids 2, 4,,6 8
|
||||
runInsertQuery("INSERT INTO SQOOP.SQ_INPUT"
|
||||
+ "(SQI_NAME, SQI_CONFIG, SQI_INDEX, SQI_TYPE, SQI_STRMASK, SQI_STRLENGTH, SQI_EDITABLE)"
|
||||
+ " VALUES('I3', " + (i * 2 + 2) + ", 0, 'STRING', false, 30, 'USER_ONLY')");
|
||||
@ -556,6 +558,7 @@ protected void loadConnectorAndDriverConfig(int version) throws Exception {
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
loadConnectorAndDriverConfigVersion4();
|
||||
break;
|
||||
|
||||
@ -583,7 +586,7 @@ public void loadConnectionsOrLinks(int version) throws Exception {
|
||||
runQuery("INSERT INTO SQOOP.SQ_CONNECTION(SQN_NAME, SQN_CONNECTOR) " + "VALUES('CB', 1)");
|
||||
|
||||
for (String ci : new String[] { "1", "2" }) {
|
||||
for (String i : new String[] { "1", "3", "13", "15" }) {
|
||||
for (String i : new String[] { "1", "3", "15" }) {
|
||||
runQuery("INSERT INTO SQOOP.SQ_CONNECTION_INPUT"
|
||||
+ "(SQNI_CONNECTION, SQNI_INPUT, SQNI_VALUE) " + "VALUES(" + ci + ", " + i
|
||||
+ ", 'Value" + i + "')");
|
||||
@ -593,7 +596,9 @@ public void loadConnectionsOrLinks(int version) throws Exception {
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
// Insert two links - CA and CB
|
||||
// Connector 1 has one link config
|
||||
runQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONFIGURABLE) " + "VALUES('CA', 1)");
|
||||
runQuery("INSERT INTO SQOOP.SQ_LINK(SQ_LNK_NAME, SQ_LNK_CONFIGURABLE) " + "VALUES('CB', 1)");
|
||||
|
||||
@ -652,6 +657,7 @@ public void loadJobs(int version) throws Exception {
|
||||
|
||||
case 4:
|
||||
case 5:
|
||||
case 6:
|
||||
for (String name : new String[] { "JA", "JB", "JC", "JD" }) {
|
||||
runQuery("INSERT INTO SQOOP.SQ_JOB(SQB_NAME, SQB_FROM_LINK, SQB_TO_LINK)" + " VALUES('"
|
||||
+ name + index + "', 1, 1)");
|
||||
|
Loading…
Reference in New Issue
Block a user