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: task_status_and_result.go
    path of file: ./repos/dotenx/ao-api/stores/pipelineStore
    
    the code of the file until where you have to start completion: package pipelineStore

import (
	"context"
	"database/sql"
	"encoding/json"
	"errors"
	"log"
	"strings"

	"github.com/dotenx/dotenx/ao-api/db"
	"github.com/dotenx/dotenx/ao-api/models"
	"github.com/lib/pq"
)

func (ps *pipelineStore) SetTaskStatus(context context.Context, executionId int, taskId int, status string) (err error) {
	switch ps.db.Driver {
	case db.Postgres:
		conn := ps.db.Connection
		tx, _ := conn.BeginTx(context, nil)
		count := 0
		err = tx.QueryRow(checkIfTaskStatusAlreadySet, executionId, taskId).Scan(&count)
		if err != nil && err != sql.ErrNoRows {
			return err
		}
		var query string
		if count == 0 {
			query = addTaskResult
		} else {
			// NOTE: Currently we allow the result to be overwritten which should be only in case we have
			// for some reason received timeout before the result, but it doesn't care even if the current
			// result is sth other than timeout
			query = updateTaskStatus
		}
		_, err = tx.Exec(query, executionId, taskId, status)
		if
    
func (ps *pipelineStore) SetTaskStatus(context context.Context, executionId int, taskId int, status string) (err error) {
	switch ps.db.Driver {
	case db.Postgres:
		conn := ps.db.Connection
		tx, _ := conn.BeginTx(context, nil)
		count := 0
		err = tx.QueryRow(checkIfTaskStatusAlreadySet, executionId, taskId).Scan(&count)
		if err != nil && err != sql.ErrNoRows {
			return err
		}
		var query string
		if count == 0 {
			query = addTaskResult
		} else {
			// NOTE: Currently we allow the result to be overwritten which should be only in case we have
			// for some reason received timeout before the result, but it doesn't care even if the current
			// result is sth other than timeout
			query = updateTaskStatus
		}
		_, err = tx.Exec(query, executionId, taskId, status)
		if err != nil {
			log.Println(err.Error())
			if pgErr, isPGErr := err.(*pq.Error); isPGErr {
				if pgErr.Code == ForeignKeyViolationErrorCode {
					return errors.New("foreign key constraint violence")
				}
			}
			return err
		}
		err = tx.Commit()
		return err
	}
	return
}