Skip to content
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .unreleased/allow-alter-extension-in-transaction
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fixes: #10313 Allow running ALTER EXTENSION timescaledb UPDATE inside a transaction block
23 changes: 23 additions & 0 deletions src/loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,27 @@ should_load_on_create_extension(Node const *const utility_stmt, TsExtension cons
return false;
}

static bool
should_load_on_transaction(Node const *const utility_stmt)
{
TransactionStmt *stmt = (TransactionStmt *) utility_stmt;

/*
* Do not load the extension just to open a transaction. This lets ALTER
* EXTENSION ... UPDATE run as the first extension-touching command inside
* a transaction block instead of failing because BEGIN already loaded the
* old version.
*/
switch (stmt->kind)
{
case TRANS_STMT_BEGIN:
case TRANS_STMT_START:
return false;
default:
return true;
}
}

static bool
load_utility_cmd(Node const *const utility_stmt, TsExtension const *const ext)
{
Expand All @@ -403,6 +424,8 @@ load_utility_cmd(Node const *const utility_stmt, TsExtension const *const ext)
return should_load_on_alter_extension(utility_stmt, ext);
case T_CreateExtensionStmt:
return should_load_on_create_extension(utility_stmt, ext);
case T_TransactionStmt:
return should_load_on_transaction(utility_stmt);
case T_DropStmt:
return !drop_statement_drops_extension((DropStmt *) utility_stmt, ext);
default:
Expand Down
Loading
Loading