You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: transaction.go
    path of file: ./repos/chai/internal/database
    
    the code of the file until where you have to start completion: package database

import (
	"sync"
	"time"

	"github.com/chaisql/chai/internal/engine"
	"github.com/cockroachdb/errors"
)

// Transaction repr
    
func (tx *Transaction) CatalogWriter() *CatalogWriter {
	if !tx.Writable {
		panic("cannot get catalog writer from read-only transaction")
	}

	if tx.catalogWriter == nil {
		tx.Catalog = tx.db.Catalog().Clone()
		// clone the catalog so that it can be modified without affecting the original one.
		tx.catalogWriter = NewCatalogWriter(tx.Catalog)
	}

	return tx.catalogWriter
}