Merged in feature/parallellogqueries (pull request #132)
Testing Tweaks * parallel * slowestquery * split * cleanup * health * dynamiccores * go * profile * timeout * commitmychanges * taskfile * sqlcheckstart * client * cost * ctxtimeout
This commit is contained in:
@@ -29,17 +29,17 @@ func (q *Queries) AddActiveQueryVersion(ctx context.Context, arg *AddActiveQuery
|
||||
}
|
||||
|
||||
const addLatestQueryVersion = `-- name: AddLatestQueryVersion :one
|
||||
INSERT INTO queryVersions (queryId) VALUES ($1) RETURNING id
|
||||
INSERT INTO queryVersions (queryId) VALUES ($1) RETURNING versionId
|
||||
`
|
||||
|
||||
// AddLatestQueryVersion
|
||||
//
|
||||
// INSERT INTO queryVersions (queryId) VALUES ($1) RETURNING id
|
||||
// INSERT INTO queryVersions (queryId) VALUES ($1) RETURNING versionId
|
||||
func (q *Queries) AddLatestQueryVersion(ctx context.Context, queryid uuid.UUID) (int32, error) {
|
||||
row := q.db.QueryRow(ctx, addLatestQueryVersion, queryid)
|
||||
var id int32
|
||||
err := row.Scan(&id)
|
||||
return id, err
|
||||
var versionid int32
|
||||
err := row.Scan(&versionid)
|
||||
return versionid, err
|
||||
}
|
||||
|
||||
const addRequiredQuery = `-- name: AddRequiredQuery :exec
|
||||
@@ -61,16 +61,16 @@ func (q *Queries) AddRequiredQuery(ctx context.Context, arg *AddRequiredQueryPar
|
||||
}
|
||||
|
||||
const allQueriesExist = `-- name: AllQueriesExist :one
|
||||
SELECT COUNT(*) = COUNT(DISTINCT id) AS all_exist
|
||||
SELECT COUNT(*) = COUNT(DISTINCT queryId) AS all_exist
|
||||
FROM unnest($1::uuid[]) AS input_id
|
||||
LEFT JOIN queries ON input_id = queries.id
|
||||
LEFT JOIN queries ON input_id = queries.queryId
|
||||
`
|
||||
|
||||
// AllQueriesExist
|
||||
//
|
||||
// SELECT COUNT(*) = COUNT(DISTINCT id) AS all_exist
|
||||
// SELECT COUNT(*) = COUNT(DISTINCT queryId) AS all_exist
|
||||
// FROM unnest($1::uuid[]) AS input_id
|
||||
// LEFT JOIN queries ON input_id = queries.id
|
||||
// LEFT JOIN queries ON input_id = queries.queryId
|
||||
func (q *Queries) AllQueriesExist(ctx context.Context, dollar_1 []uuid.UUID) (bool, error) {
|
||||
row := q.db.QueryRow(ctx, allQueriesExist, dollar_1)
|
||||
var all_exist bool
|
||||
@@ -79,17 +79,17 @@ func (q *Queries) AllQueriesExist(ctx context.Context, dollar_1 []uuid.UUID) (bo
|
||||
}
|
||||
|
||||
const createQuery = `-- name: CreateQuery :one
|
||||
INSERT INTO queries (type) VALUES ($1) RETURNING id
|
||||
INSERT INTO queries (queryType) VALUES ($1) RETURNING queryId
|
||||
`
|
||||
|
||||
// CreateQuery
|
||||
//
|
||||
// INSERT INTO queries (type) VALUES ($1) RETURNING id
|
||||
func (q *Queries) CreateQuery(ctx context.Context, type_ Querytype) (uuid.UUID, error) {
|
||||
row := q.db.QueryRow(ctx, createQuery, type_)
|
||||
var id uuid.UUID
|
||||
err := row.Scan(&id)
|
||||
return id, err
|
||||
// INSERT INTO queries (queryType) VALUES ($1) RETURNING queryId
|
||||
func (q *Queries) CreateQuery(ctx context.Context, querytype Querytype) (uuid.UUID, error) {
|
||||
row := q.db.QueryRow(ctx, createQuery, querytype)
|
||||
var queryid uuid.UUID
|
||||
err := row.Scan(&queryid)
|
||||
return queryid, err
|
||||
}
|
||||
|
||||
const getActiveQueryConfig = `-- name: GetActiveQueryConfig :one
|
||||
@@ -107,18 +107,18 @@ func (q *Queries) GetActiveQueryConfig(ctx context.Context, queryid uuid.UUID) (
|
||||
}
|
||||
|
||||
const getQuery = `-- name: GetQuery :one
|
||||
SELECT id, type, activeversion, latestversion, config, requiredids FROM fullActiveQueries WHERE id = $1
|
||||
SELECT queryid, querytype, activeversion, latestversion, config, requiredids FROM fullActiveQueries WHERE queryId = $1
|
||||
`
|
||||
|
||||
// GetQuery
|
||||
//
|
||||
// SELECT id, type, activeversion, latestversion, config, requiredids FROM fullActiveQueries WHERE id = $1
|
||||
func (q *Queries) GetQuery(ctx context.Context, id uuid.UUID) (*Fullactivequery, error) {
|
||||
row := q.db.QueryRow(ctx, getQuery, id)
|
||||
// SELECT queryid, querytype, activeversion, latestversion, config, requiredids FROM fullActiveQueries WHERE queryId = $1
|
||||
func (q *Queries) GetQuery(ctx context.Context, queryid uuid.UUID) (*Fullactivequery, error) {
|
||||
row := q.db.QueryRow(ctx, getQuery, queryid)
|
||||
var i Fullactivequery
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Type,
|
||||
&i.Queryid,
|
||||
&i.Querytype,
|
||||
&i.Activeversion,
|
||||
&i.Latestversion,
|
||||
&i.Config,
|
||||
@@ -129,12 +129,12 @@ func (q *Queries) GetQuery(ctx context.Context, id uuid.UUID) (*Fullactivequery,
|
||||
|
||||
const getQueryWithVersion = `-- name: GetQueryWithVersion :one
|
||||
WITH query as (
|
||||
SELECT id, type FROM queries WHERE id = $1
|
||||
SELECT queryId, queryType FROM queries WHERE queryId = $1
|
||||
),
|
||||
config as (
|
||||
SELECT c.queryId, c.config
|
||||
FROM query AS q
|
||||
LEFT JOIN queryConfigs AS c ON q.id = c.queryId
|
||||
LEFT JOIN queryConfigs AS c ON q.queryId = c.queryId
|
||||
and isInVersion($2, c.addedVersion, c.removedVersion)
|
||||
),
|
||||
requiredIds as (
|
||||
@@ -145,19 +145,19 @@ requiredIds as (
|
||||
array[]::uuid[]
|
||||
)::uuid[] as requiredIds
|
||||
FROM query AS q
|
||||
LEFT JOIN requiredQueries AS r ON q.id = r.queryId
|
||||
LEFT JOIN requiredQueries AS r ON q.queryId = r.queryId
|
||||
and isInVersion($2, r.addedVersion, r.removedVersion)
|
||||
GROUP BY r.queryId
|
||||
)
|
||||
SELECT DISTINCT q.id, q.type,
|
||||
SELECT DISTINCT q.queryId, q.queryType,
|
||||
av.activeVersion,
|
||||
lv.latestVersion, c.config,
|
||||
r.requiredIds
|
||||
FROM query AS q
|
||||
JOIN queryCurrentActiveVersions as av on q.id = av.queryId
|
||||
JOIN queryLatestVersions as lv on lv.queryId = q.id
|
||||
LEFT JOIN config AS c ON q.id = c.queryId
|
||||
LEFT JOIN requiredIds AS r ON q.id = r.queryId
|
||||
JOIN queryCurrentActiveVersions as av on q.queryId = av.queryId
|
||||
JOIN queryLatestVersions as lv on lv.queryId = q.queryId
|
||||
LEFT JOIN config AS c ON q.queryId = c.queryId
|
||||
LEFT JOIN requiredIds AS r ON q.queryId = r.queryId
|
||||
`
|
||||
|
||||
type GetQueryWithVersionParams struct {
|
||||
@@ -166,8 +166,8 @@ type GetQueryWithVersionParams struct {
|
||||
}
|
||||
|
||||
type GetQueryWithVersionRow struct {
|
||||
ID uuid.UUID `db:"id"`
|
||||
Type Querytype `db:"type"`
|
||||
Queryid uuid.UUID `db:"queryid"`
|
||||
Querytype Querytype `db:"querytype"`
|
||||
Activeversion int32 `db:"activeversion"`
|
||||
Latestversion int32 `db:"latestversion"`
|
||||
Config []byte `db:"config"`
|
||||
@@ -177,12 +177,12 @@ type GetQueryWithVersionRow struct {
|
||||
// GetQueryWithVersion
|
||||
//
|
||||
// WITH query as (
|
||||
// SELECT id, type FROM queries WHERE id = $1
|
||||
// SELECT queryId, queryType FROM queries WHERE queryId = $1
|
||||
// ),
|
||||
// config as (
|
||||
// SELECT c.queryId, c.config
|
||||
// FROM query AS q
|
||||
// LEFT JOIN queryConfigs AS c ON q.id = c.queryId
|
||||
// LEFT JOIN queryConfigs AS c ON q.queryId = c.queryId
|
||||
// and isInVersion($2, c.addedVersion, c.removedVersion)
|
||||
// ),
|
||||
// requiredIds as (
|
||||
@@ -193,25 +193,25 @@ type GetQueryWithVersionRow struct {
|
||||
// array[]::uuid[]
|
||||
// )::uuid[] as requiredIds
|
||||
// FROM query AS q
|
||||
// LEFT JOIN requiredQueries AS r ON q.id = r.queryId
|
||||
// LEFT JOIN requiredQueries AS r ON q.queryId = r.queryId
|
||||
// and isInVersion($2, r.addedVersion, r.removedVersion)
|
||||
// GROUP BY r.queryId
|
||||
// )
|
||||
// SELECT DISTINCT q.id, q.type,
|
||||
// SELECT DISTINCT q.queryId, q.queryType,
|
||||
// av.activeVersion,
|
||||
// lv.latestVersion, c.config,
|
||||
// r.requiredIds
|
||||
// FROM query AS q
|
||||
// JOIN queryCurrentActiveVersions as av on q.id = av.queryId
|
||||
// JOIN queryLatestVersions as lv on lv.queryId = q.id
|
||||
// LEFT JOIN config AS c ON q.id = c.queryId
|
||||
// LEFT JOIN requiredIds AS r ON q.id = r.queryId
|
||||
// JOIN queryCurrentActiveVersions as av on q.queryId = av.queryId
|
||||
// JOIN queryLatestVersions as lv on lv.queryId = q.queryId
|
||||
// LEFT JOIN config AS c ON q.queryId = c.queryId
|
||||
// LEFT JOIN requiredIds AS r ON q.queryId = r.queryId
|
||||
func (q *Queries) GetQueryWithVersion(ctx context.Context, arg *GetQueryWithVersionParams) (*GetQueryWithVersionRow, error) {
|
||||
row := q.db.QueryRow(ctx, getQueryWithVersion, arg.ID, arg.Version)
|
||||
var i GetQueryWithVersionRow
|
||||
err := row.Scan(
|
||||
&i.ID,
|
||||
&i.Type,
|
||||
&i.Queryid,
|
||||
&i.Querytype,
|
||||
&i.Activeversion,
|
||||
&i.Latestversion,
|
||||
&i.Config,
|
||||
@@ -250,12 +250,12 @@ func (q *Queries) IsQueryInDependencyTree(ctx context.Context, arg *IsQueryInDep
|
||||
}
|
||||
|
||||
const listQueries = `-- name: ListQueries :many
|
||||
SELECT id, type, activeversion, latestversion, config, requiredids FROM fullActiveQueries
|
||||
SELECT queryid, querytype, activeversion, latestversion, config, requiredids FROM fullActiveQueries
|
||||
`
|
||||
|
||||
// ListQueries
|
||||
//
|
||||
// SELECT id, type, activeversion, latestversion, config, requiredids FROM fullActiveQueries
|
||||
// SELECT queryid, querytype, activeversion, latestversion, config, requiredids FROM fullActiveQueries
|
||||
func (q *Queries) ListQueries(ctx context.Context) ([]*Fullactivequery, error) {
|
||||
rows, err := q.db.Query(ctx, listQueries)
|
||||
if err != nil {
|
||||
@@ -266,8 +266,8 @@ func (q *Queries) ListQueries(ctx context.Context) ([]*Fullactivequery, error) {
|
||||
for rows.Next() {
|
||||
var i Fullactivequery
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Type,
|
||||
&i.Queryid,
|
||||
&i.Querytype,
|
||||
&i.Activeversion,
|
||||
&i.Latestversion,
|
||||
&i.Config,
|
||||
@@ -284,14 +284,14 @@ func (q *Queries) ListQueries(ctx context.Context) ([]*Fullactivequery, error) {
|
||||
}
|
||||
|
||||
const listQueriesById = `-- name: ListQueriesById :many
|
||||
SELECT id, type, activeversion, latestversion, config, requiredids FROM fullActiveQueries WHERE id = any($1)
|
||||
SELECT queryid, querytype, activeversion, latestversion, config, requiredids FROM fullActiveQueries WHERE queryId = any($1)
|
||||
`
|
||||
|
||||
// ListQueriesById
|
||||
//
|
||||
// SELECT id, type, activeversion, latestversion, config, requiredids FROM fullActiveQueries WHERE id = any($1)
|
||||
func (q *Queries) ListQueriesById(ctx context.Context, id []uuid.UUID) ([]*Fullactivequery, error) {
|
||||
rows, err := q.db.Query(ctx, listQueriesById, id)
|
||||
// SELECT queryid, querytype, activeversion, latestversion, config, requiredids FROM fullActiveQueries WHERE queryId = any($1)
|
||||
func (q *Queries) ListQueriesById(ctx context.Context, queryid []uuid.UUID) ([]*Fullactivequery, error) {
|
||||
rows, err := q.db.Query(ctx, listQueriesById, queryid)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -300,8 +300,8 @@ func (q *Queries) ListQueriesById(ctx context.Context, id []uuid.UUID) ([]*Fulla
|
||||
for rows.Next() {
|
||||
var i Fullactivequery
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Type,
|
||||
&i.Queryid,
|
||||
&i.Querytype,
|
||||
&i.Activeversion,
|
||||
&i.Latestversion,
|
||||
&i.Config,
|
||||
|
||||
Reference in New Issue
Block a user