    # File lib/active_record/vendor/simple.rb, line 462
        def commit_transaction(name = nil)
          if @__transaction_checkpoint__.nil?
            raise TransactionError, Messages[:cannot_commit_no_transaction]
          end
          @__transaction_block__ ||= nil

            # Check to see if we are trying to commit a transaction that is
            # outside of the current transaction block. Otherwise, raise
            # TransactionCommitted if they are the same.
          if @__transaction_block__ and name
            nix = @__transaction_names__.index(name) + 1
            if nix < @__transaction_block__
              raise TransactionError, Messages[:cannot_commit_transaction_before_block]
            end

            raise TransactionCommitted if @__transaction_block__ == nix
          end

          raise TransactionCommitted if @__transaction_block__ == @__transaction_level__

          if name.nil?
            ss = "" if Transaction::Simple.debugging?
            __commit_transaction
            if Transaction::Simple.debugging?
              Transaction::Simple.debug_io << "#{'<' * @__transaction_level__} " <<
                "Commit Transaction#{ss}\n"
            end
          else
            unless @__transaction_names__.include?(name)
              raise TransactionError, Messages[:cannot_commit_named_transaction] % name.inspect
            end
            ss = "(#{name})" if Transaction::Simple.debugging?

            while @__transaction_names__[-1] != name
              if Transaction::Simple.debugging?
                Transaction::Simple.debug_io << "#{'<' * @__transaction_level__} " <<
                  "Commit Transaction#{ss}\n"
              end
              __commit_transaction
            end
            if Transaction::Simple.debugging?
              Transaction::Simple.debug_io << "#{'<' * @__transaction_level__} " <<
                "Commit Transaction#{ss}\n"
            end
            __commit_transaction
          end

          self
        end