func (c postgresDB) ExecTx(ctx context.Context, ql []xsql.Query) error {
	d, err := sql.Open("postgres", c.dsn)
	if err != nil {
		return err
	}
	tx, err := d.BeginTx(ctx, nil)
	if err != nil {
		return err
	}
	defer func() {
		defer d.Close()  
		if err != nil {
			tx.Rollback()  
			return
		}
		err = tx.Commit()
	}()
	for _, q := range ql {
		if _, err = tx.Exec(q.String, q.Parameters...); err != nil {
			return err
		}
	}
	return err
}
ExecTx executes an array of queries, committing if all are successful and
rolling back immediately on failure.
package postgresql
import (
	"context"
	"database/sql"
	"github.com/crossplane-contrib/provider-sql/pkg/clients/xsql"
	"github.com/lib/pq"
	xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1"
	"github.com/crossplane/crossplane-runtime/pkg/reconciler/managed"
)
const (
	pqInvalidCatalog = pq.ErrorCode("3D000")
)
type postgresDB struct {
	dsn      string
	endpoint string
	port     string
}
func New(creds map[string][]byte, database string) xsql.DB {
	endpoint := string(creds[xpv1.ResourceCredentialsSecretEndpointKey])
	port := string(creds[xpv1.ResourceCredentialsSecretPortKey])
	return postgresDB{
		dsn: "postgres://" +
			string(creds[xpv1.ResourceCredentialsSecretUserKey]) + ":" +
			string(creds[xpv1.ResourceCredentialsSecretPasswordKey]) + "@" +
			endpoint + ":" +
			port + "/" +
			database,
		endpoint: endpoint,
		port:     port,
	}
}