Skip to content
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

Incident#567732673 - Add provision to set SQLServerBulkCopy options in PreparedStatement #2555

Merged
merged 25 commits into from
Jan 24, 2025
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
8e6ea89
Add provision to set SQLServerBulkCopy options in PreparedStatement
machavan Dec 4, 2024
684dab5
Reanmed test
machavan Dec 4, 2024
85cdfa9
Renamed bcCopyOptions to bcOptions
machavan Dec 4, 2024
1c0ed12
Fixed indentation
machavan Dec 4, 2024
0dd56f4
Fail the test that enables consraint checking when exception is not
machavan Dec 4, 2024
4f4fa19
Added connection string options for all the available bulk copy options
machavan Dec 12, 2024
c5972bc
Added test case for bulkCopyOptionDefaultsBatchSize, bulkCopyOptionDe…
muskan124947 Dec 18, 2024
51142cd
Added test case for bulkCopty options in Prepared Statement
muskan124947 Dec 18, 2024
2306130
Updated failures in test case
muskan124947 Dec 18, 2024
df2a292
Added test case testBulkCopyOptionDefaultsTimeoutLowerValue
muskan124947 Dec 19, 2024
9693541
Added test case for bulkCopyOptionDefaultsAllowEncryptedValueModifica…
muskan124947 Dec 19, 2024
85f9243
Fixed failures
muskan124947 Dec 19, 2024
151fcf8
Added test scenario for bulkCopyOptionDefaultsAllowEncryptedValueModi…
muskan124947 Dec 20, 2024
f61cd29
Improved messages.
machavan Jan 7, 2025
193b9a2
Merge remote-tracking branch 'origin/main' into dev/machavan/batchbco…
divang Jan 9, 2025
03ce6d7
Remove the setBulkCopyOptions method from PreparedStatement
machavan Jan 10, 2025
fee3149
Fixed indent issue.
machavan Jan 10, 2025
0f08eba
Update name for bulk copy batchSize option
muskan124947 Jan 17, 2025
6d91b6d
Update name for bulk copy timeout option
muskan124947 Jan 17, 2025
c999c30
Update name for bulk copy check constraints option
muskan124947 Jan 17, 2025
93a38ac
Update name for bulk copy fireTrigger, keepIdentity, keepNulls, table…
muskan124947 Jan 17, 2025
96fa336
Remove timeout option as configured already in bulk copy option
muskan124947 Jan 17, 2025
9106cb4
Updated value of bulkCopyForBatchInsertTimeout to 60s
muskan124947 Jan 17, 2025
18df027
Removed timeout and internal transaction option
muskan124947 Jan 20, 2025
a698c02
removed local changes
muskan124947 Jan 20, 2025
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
135 changes: 135 additions & 0 deletions src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -547,4 +547,139 @@ CallableStatement prepareCall(String sql, int nType, int nConcur, int nHold,
* @return cacheBulkCopyMetadata boolean value
*/
boolean getcacheBulkCopyMetadata();

/**
* Specifies the default batch size for bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertBatchSize
* integer value for bulkCopyForBatchInsertBatchSize.
*/
void setBulkCopyForBatchInsertBatchSize(int bulkCopyForBatchInsertBatchSize);

/**
* Returns the default batch size for bulk copy operations created from batch insert operations.
*
* @return integer value for bulkCopyForBatchInsertBatchSize.
*/
int getBulkCopyForBatchInsertBatchSize();

/**
* Specifies the default timeout for bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertTimeout
* integer value for bulkCopyForBatchInsertTimeout.
*/
void setBulkCopyForBatchInsertTimeout(int bulkCopyForBatchInsertTimeout);

/**
* Returns the default timeout for bulk copy operations created from batch insert operations.
*
* @return integer value for bulkCopyForBatchInsertTimeout.
*/
int getBulkCopyForBatchInsertTimeout();

/**
* Specifies the default check constraints for bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertCheckConstraints
* boolean value for bulkCopyForBatchInsertCheckConstraints.
*/
void setBulkCopyForBatchInsertCheckConstraints(boolean bulkCopyForBatchInsertCheckConstraints);

/**
* Returns the default check constraints for bulk copy operations created from batch insert operations.
*
* @return boolean value for bulkCopyForBatchInsertCheckConstraints.
*/
boolean getBulkCopyForBatchInsertCheckConstraints();

/**
* Specifies the default fire triggers for bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertFireTriggers
* boolean value for bulkCopyForBatchInsertFireTriggers.
*/
void setBulkCopyForBatchInsertFireTriggers(boolean bulkCopyForBatchInsertFireTriggers);

/**
* Returns the default fire triggers for bulk copy operations created from batch insert operations.
*
* @return boolean value for bulkCopyForBatchInsertFireTriggers.
*/
boolean getBulkCopyForBatchInsertFireTriggers();

/**
* Specifies the default keep identity for bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertKeepIdentity
* boolean value for bulkCopyForBatchInsertKeepIdentity.
*/
void setBulkCopyForBatchInsertKeepIdentity(boolean bulkCopyForBatchInsertKeepIdentity);

/**
* Returns the default keep identity for bulk copy operations created from batch insert operations.
*
* @return boolean value for bulkCopyForBatchInsertKeepIdentity.
*/
boolean getBulkCopyForBatchInsertKeepIdentity();

/**
* Specifies the default keep nulls for bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertKeepNulls
* boolean value for bulkCopyForBatchInsertKeepNulls.
*/
void setBulkCopyForBatchInsertKeepNulls(boolean bulkCopyForBatchInsertKeepNulls);

/**
* Returns the default keep nulls for bulk copy operations created from batch insert operations.
*
* @return boolean value for bulkCopyForBatchInsertKeepNulls.
*/
boolean getBulkCopyForBatchInsertKeepNulls();

/**
* Specifies the default table lock for bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertTableLock
* boolean value for bulkCopyForBatchInsertTableLock.
*/
void setBulkCopyForBatchInsertTableLock(boolean bulkCopyForBatchInsertTableLock);

/**
* Returns the default table lock for bulk copy operations created from batch insert operations.
*
* @return boolean value for bulkCopyForBatchInsertTableLock.
*/
boolean getBulkCopyForBatchInsertTableLock();

/**
* Specifies the default use internal transaction for bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertUseInternalTransaction
* boolean value for bulkCopyForBatchInsertUseInternalTransaction.
*/
void setBulkCopyForBatchInsertUseInternalTransaction(boolean bulkCopyForBatchInsertUseInternalTransaction);

/**
* Returns the default use internal transaction for bulk copy operations created from batch insert operations.
*
* @return boolean value for bulkCopyForBatchInsertUseInternalTransaction.
*/
boolean getBulkCopyForBatchInsertUseInternalTransaction();

/**
* Specifies the default allow encrypted value modifications for bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertAllowEncryptedValueModifications
* boolean value for bulkCopyForBatchInsertAllowEncryptedValueModifications.
*/
void setBulkCopyForBatchInsertAllowEncryptedValueModifications(boolean bulkCopyForBatchInsertAllowEncryptedValueModifications);

/**
* Returns the default allow encrypted value modifications for bulk copy operations created from batch insert operations.
*
* @return boolean value for bulkCopyForBatchInsertAllowEncryptedValueModifications.
*/
boolean getBulkCopyForBatchInsertAllowEncryptedValueModifications();
}
135 changes: 135 additions & 0 deletions src/main/java/com/microsoft/sqlserver/jdbc/ISQLServerDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,141 @@ public interface ISQLServerDataSource extends javax.sql.CommonDataSource {
*/
void setUseBulkCopyForBatchInsert(boolean useBulkCopyForBatchInsert);

/**
* Sets the default batch size for bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertBatchSize
* the default batch size for bulk copy operations created from batch insert operations.
*/
void setBulkCopyForBatchInsertBatchSize(int bulkCopyForBatchInsertBatchSize);

/**
* Returns the default batch size for bulk copy operations created from batch insert operations.
*
* @return the default batch size for bulk copy operations created from batch insert operations.
*/
int getBulkCopyForBatchInsertBatchSize();

/**
* Sets the default timeout for bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertTimeout
* the default timeout for bulk copy operations created from batch insert operations.
*/
void setBulkCopyForBatchInsertTimeout(int bulkCopyForBatchInsertTimeout);

/**
* Returns the default timeout for bulk copy operations created from batch insert operations.
*
* @return the default timeout for bulk copy operations created from batch insert operations.
*/
int getBulkCopyForBatchInsertTimeout();

/**
* Sets whether to check constraints during bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertCheckConstraints
* indicates whether to check constraints during bulk copy operations created from batch insert operations.
*/
void setBulkCopyForBatchInsertCheckConstraints(boolean bulkCopyForBatchInsertCheckConstraints);

/**
* Returns whether to check constraints during bulk copy operations created from batch insert operations.
*
* @return whether to check constraints during bulk copy operations created from batch insert operations.
*/
boolean getBulkCopyForBatchInsertCheckConstraints();

/**
* Sets whether to fire triggers during bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertFireTriggers
* indicates whether to fire triggers during bulk copy operations created from batch insert operations.
*/
void setBulkCopyForBatchInsertFireTriggers(boolean bulkCopyForBatchInsertFireTriggers);

/**
* Returns whether to fire triggers during bulk copy operations created from batch insert operations.
*
* @return whether to fire triggers during bulk copy operations created from batch insert operations.
*/
boolean getBulkCopyForBatchInsertFireTriggers();

/**
* Sets whether to keep identity values during bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertKeepIdentity
* indicates whether to keep identity values during bulk copy operations created from batch insert operations.
*/
void setBulkCopyForBatchInsertKeepIdentity(boolean bulkCopyForBatchInsertKeepIdentity);

/**
* Returns whether to keep identity values during bulk copy operations created from batch insert operations.
*
* @return whether to keep identity values during bulk copy operations created from batch insert operations.
*/
boolean getBulkCopyForBatchInsertKeepIdentity();

/**
* Sets whether to keep null values during bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertKeepNulls
* indicates whether to keep null values during bulk copy operations created from batch insert operations.
*/
void setBulkCopyForBatchInsertKeepNulls(boolean bulkCopyForBatchInsertKeepNulls);

/**
* Returns whether to keep null values during bulk copy operations created from batch insert operations.
*
* @return whether to keep null values during bulk copy operations created from batch insert operations.
*/
boolean getBulkCopyForBatchInsertKeepNulls();

/**
* Sets whether to use table lock during bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertTableLock
* indicates whether to use table lock during bulk copy operations created from batch insert operations.
*/
void setBulkCopyForBatchInsertTableLock(boolean bulkCopyForBatchInsertTableLock);

/**
* Returns whether to use table lock during bulk copy operations created from batch insert operations.
*
* @return whether to use table lock during bulk copy operations created from batch insert operations.
*/
boolean getBulkCopyForBatchInsertTableLock();

/**
* Sets whether to use internal transaction during bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertUseInternalTransaction
* indicates whether to use internal transaction during bulk copy operations created from batch insert operations.
*/
void setBulkCopyForBatchInsertUseInternalTransaction(boolean bulkCopyForBatchInsertUseInternalTransaction);

/**
* Returns whether to use internal transaction during bulk copy operations created from batch insert operations.
*
* @return whether to use internal transaction during bulk copy operations created from batch insert operations.
*/
boolean getBulkCopyForBatchInsertUseInternalTransaction();

/**
* Sets whether to allow encrypted value modifications during bulk copy operations created from batch insert operations.
*
* @param bulkCopyForBatchInsertAllowEncryptedValueModifications
* indicates whether to allow encrypted value modifications during bulk copy operations created from batch insert operations.
*/
void setBulkCopyForBatchInsertAllowEncryptedValueModifications(boolean bulkCopyForBatchInsertAllowEncryptedValueModifications);

/**
* Returns whether to allow encrypted value modifications during bulk copy operations created from batch insert operations.
*
* @return whether to allow encrypted value modifications during bulk copy operations created from batch insert operations.
*/
boolean getBulkCopyForBatchInsertAllowEncryptedValueModifications();

/**
* Sets the client id to be used to retrieve the access token for a user-assigned Managed Identity.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,22 @@ public SQLServerBulkCopyOptions() {
useInternalTransaction = false;
allowEncryptedValueModifications = false;
}

/**
* Constructs a SQLServerBulkCopySettings class using defaults from given connection
*/
SQLServerBulkCopyOptions(SQLServerConnection conn) {
machavan marked this conversation as resolved.
Show resolved Hide resolved
batchSize = conn.getBulkCopyForBatchInsertBatchSize();
bulkCopyTimeout = conn.getBulkCopyForBatchInsertTimeout();
checkConstraints = conn.getBulkCopyForBatchInsertCheckConstraints();
fireTriggers = conn.getBulkCopyForBatchInsertFireTriggers();
keepIdentity = conn.getBulkCopyForBatchInsertKeepIdentity();
keepNulls = conn.getBulkCopyForBatchInsertKeepNulls();
tableLock = conn.getBulkCopyForBatchInsertTableLock();
useInternalTransaction = conn.getBulkCopyForBatchInsertUseInternalTransaction();
allowEncryptedValueModifications = conn.getBulkCopyForBatchInsertAllowEncryptedValueModifications();
}


/**
* Returns the number of rows in each batch. At the end of each batch, the rows in the batch are sent to the server.
Expand Down
Loading
Loading