Skip to content

Commit

Permalink
feat(sqlite): add support for legacy_alter_table flag
Browse files Browse the repository at this point in the history
Closes: #481
  • Loading branch information
talha970 authored Mar 11, 2023
1 parent 12f2113 commit 26df15f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/main/java/org/sqlite/SQLiteConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ public enum Pragma {
"journal_size_limit",
"Limit the size of rollback-journal and WAL files left in the file-system after transactions or checkpoints",
null),
LEGACY_ALTER_TABLE("legacy_alter_table", "Use legacy alter table behavior", OnOff),
LEGACY_FILE_FORMAT("legacy_file_format", "No-op", OnOff),
LOCKING_MODE(
"locking_mode",
Expand Down Expand Up @@ -855,6 +856,19 @@ public void useLegacyFileFormat(boolean use) {
set(Pragma.LEGACY_FILE_FORMAT, use);
}

/**
* Sets the value of the legacy_alter_table flag. When this flag is on, the ALTER TABLE RENAME
* command (for changing the name of a table) works as it did in SQLite 3.24.0 (2018-06-04) and
* earlier.When the flag is off, using the ALTER TABLE RENAME command will mean that all
* references to the table anywhere in the schema will be converted to the new name.
*
* @param flag True to turn on legacy alter table behaviour; false to turn off.
* @see <a href="https://www.sqlite.org/pragma.html#pragma_legacy_alter_table</a>
*/
public void setLegacyAlterTable(boolean flag) {
set(Pragma.LEGACY_ALTER_TABLE, flag);
}

public enum LockingMode implements PragmaValue {
NORMAL,
EXCLUSIVE;
Expand Down
13 changes: 13 additions & 0 deletions src/main/java/org/sqlite/SQLiteDataSource.java
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,19 @@ public void setLegacyFileFormat(boolean use) {
config.useLegacyFileFormat(use);
}

/**
* Sets the value of the legacy_alter_table flag. When this flag is on, the ALTER TABLE RENAME
* command (for changing the name of a table) works as it did in SQLite 3.24.0 (2018-06-04) and
* earlier.When the flag is off, using the ALTER TABLE RENAME command will mean that all
* references to the table anywhere in the schema will be converted to the new name.
*
* @param flag True to turn on legacy alter table behaviour; false to turn off.
* @see <a href="https://www.sqlite.org/pragma.html#pragma_legacy_alter_table</a>
*/
public void setLegacyAlterTable(boolean flag) {
config.setLegacyAlterTable(flag);
}

/**
* Sets the database connection locking-mode.
*
Expand Down

0 comments on commit 26df15f

Please sign in to comment.