Skip to content

Commit 10571f9

Browse files
readyset-client: allow ADD INDEX to not require resnapshot
This commit allows the `ADD INDEX` statement to not require a resnapshot. Those operations will not change the underlying table, so we can avoid the resnapshot. This is not the case for ADD PRIMARY KEY & ADD UNIQUE KEY. Change-Id: I66792a6fc57affb44c946816ef10993a11c30730 Reviewed-on: https://gerrit.readyset.name/c/readyset/+/9595 Tested-by: Buildkite CI Reviewed-by: Michael Zink <michael.z@readyset.io>
1 parent ff48d6a commit 10571f9

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

readyset-client/src/recipe/changelist.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ use readyset_errors::{internal, unsupported, ReadySetError, ReadySetResult};
4141
use readyset_sql::ast::{
4242
AlterTableDefinition, AlterTableStatement, CacheInner, CreateCacheStatement,
4343
CreateTableStatement, CreateViewStatement, DropTableStatement, DropViewStatement,
44-
NonReplicatedRelation, Relation, SelectStatement, SqlIdentifier, SqlQuery,
44+
NonReplicatedRelation, Relation, SelectStatement, SqlIdentifier, SqlQuery, TableKey,
4545
};
4646
use readyset_sql_parsing::parse_query;
4747
use readyset_sql_passes::adapter_rewrites::{self, AdapterRewriteParams};
@@ -393,10 +393,15 @@ impl Change {
393393
| AlterTableDefinition::DropColumn { .. }
394394
| AlterTableDefinition::ChangeColumn { .. }
395395
| AlterTableDefinition::RenameColumn { .. }
396-
| AlterTableDefinition::AddKey(_)
396+
| AlterTableDefinition::AddKey(TableKey::PrimaryKey { .. })
397+
| AlterTableDefinition::AddKey(TableKey::UniqueKey { .. })
397398
| AlterTableDefinition::DropForeignKey { .. }
398399
| AlterTableDefinition::DropConstraint { .. } => true,
399-
AlterTableDefinition::ReplicaIdentity(_) => false,
400+
AlterTableDefinition::ReplicaIdentity(_)
401+
| AlterTableDefinition::AddKey(TableKey::FulltextKey { .. })
402+
| AlterTableDefinition::AddKey(TableKey::Key { .. })
403+
| AlterTableDefinition::AddKey(TableKey::CheckConstraint { .. })
404+
| AlterTableDefinition::AddKey(TableKey::ForeignKey { .. }) => false,
400405
})
401406
} else {
402407
// We know it's an alter table, but we couldn't fully parse it.

0 commit comments

Comments
 (0)