Escape transaction names

pull/3174/head
Philip Dubé 2019-11-07 18:13:47 +00:00 committed by Philip Dubé
parent 9fb897a074
commit e8ecbbfcb3
2 changed files with 14 additions and 14 deletions

View File

@ -236,8 +236,8 @@ StartRemoteTransactionCommit(MultiConnection *connection)
StringInfoData command;
initStringInfo(&command);
appendStringInfo(&command, "COMMIT PREPARED '%s'",
transaction->preparedName);
appendStringInfo(&command, "COMMIT PREPARED %s",
quote_literal_cstr(transaction->preparedName));
transaction->transactionState = REMOTE_TRANS_2PC_COMMITTING;
@ -371,8 +371,8 @@ StartRemoteTransactionAbort(MultiConnection *connection)
ForgetResults(connection);
initStringInfo(&command);
appendStringInfo(&command, "ROLLBACK PREPARED '%s'",
transaction->preparedName);
appendStringInfo(&command, "ROLLBACK PREPARED %s",
quote_literal_cstr(transaction->preparedName));
if (!SendRemoteCommand(connection, command.data))
{
@ -497,8 +497,8 @@ StartRemoteTransactionPrepare(struct MultiConnection *connection)
}
initStringInfo(&command);
appendStringInfo(&command, "PREPARE TRANSACTION '%s'",
transaction->preparedName);
appendStringInfo(&command, "PREPARE TRANSACTION %s",
quote_literal_cstr(transaction->preparedName));
if (!SendRemoteCommand(connection, command.data))
{
@ -1314,8 +1314,6 @@ CheckRemoteTransactionsHealth(void)
* The connection number is used to distinguish connections made to a node
* within the same transaction.
*
* NB: we rely on the fact that we don't need to do full escaping on the names
* generated here.
*/
static void
Assign2PCIdentifier(MultiConnection *connection)
@ -1431,13 +1429,13 @@ WarnAboutLeakedPreparedTransaction(MultiConnection *connection, bool commit)
if (commit)
{
appendStringInfo(&command, "COMMIT PREPARED '%s'",
transaction->preparedName);
appendStringInfo(&command, "COMMIT PREPARED %s",
quote_literal_cstr(transaction->preparedName));
}
else
{
appendStringInfo(&command, "ROLLBACK PREPARED '%s'",
transaction->preparedName);
appendStringInfo(&command, "ROLLBACK PREPARED %s",
quote_literal_cstr(transaction->preparedName));
}
/* log a warning so the user may abort the transaction later */

View File

@ -499,12 +499,14 @@ RecoverPreparedTransactionOnWorker(MultiConnection *connection, char *transactio
if (shouldCommit)
{
/* should have committed this prepared transaction */
appendStringInfo(command, "COMMIT PREPARED '%s'", transactionName);
appendStringInfo(command, "COMMIT PREPARED %s",
quote_literal_cstr(transactionName));
}
else
{
/* should have aborted this prepared transaction */
appendStringInfo(command, "ROLLBACK PREPARED '%s'", transactionName);
appendStringInfo(command, "ROLLBACK PREPARED %s",
quote_literal_cstr(transactionName));
}
executeCommand = ExecuteOptionalRemoteCommand(connection, command->data, &result);