Documentation
¶
Overview ¶
Code generated by gen-db-wrappers. DO NOT EDIT.
Code generated by gen-db-wrappers. DO NOT EDIT.
Code generated by gen-db-wrappers. DO NOT EDIT.
Code generated by gen-db-wrappers. DO NOT EDIT.
Code generated by gen-db-wrappers. DO NOT EDIT.
Index ¶
- Variables
- func IsDeadlockError(err error) bool
- func IsDuplicateKeyError(err error) bool
- func IsNotFoundError(err error) bool
- type AddNarInfoReferenceParams
- type AddNarInfoReferencesParams
- type AddNarInfoSignatureParams
- type AddNarInfoSignaturesParams
- type Chunk
- type Config
- type CreateChunkParams
- type CreateConfigParams
- type CreateNarFileParams
- type CreateNarInfoParams
- type DeleteNarFileByHashParams
- type GetChunkByNarFileIDAndIndexParams
- type GetChunkByNarFileIDAndIndexRow
- type GetCompressedNarInfosParams
- type GetMigratedNarInfoHashesPaginatedParams
- type GetNarFileByHashAndCompressionAndQueryParams
- type GetNarFilesToChunkRow
- type GetNarInfoHashesToChunkRow
- type GetNarInfoURLByNarFileHashParams
- type GetOldCompressedNarFilesParams
- type GetOrphanedChunksRow
- type LinkNarFileToChunkParams
- type LinkNarFileToChunksParams
- type LinkNarInfoToNarFileParams
- type LinkNarInfosByURLToNarFileParams
- type NarFile
- type NarInfo
- type PoolConfig
- type Querier
- type SetConfigParams
- type TouchNarFileParams
- type Type
- type UpdateNarFileFileSizeParams
- type UpdateNarFileTotalChunksParams
- type UpdateNarInfoCompressionAndURLParams
- type UpdateNarInfoFileHashParams
- type UpdateNarInfoFileSizeParams
- type UpdateNarInfoParams
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is returned when a query returns no rows. ErrNotFound = errors.New("not found") // ErrUnsupportedDriver is returned when the database driver is not recognized. ErrUnsupportedDriver = errors.New("unsupported database driver") // ErrInvalidPostgresUnixURL is returned when a postgres+unix URL is invalid. ErrInvalidPostgresUnixURL = errors.New("invalid postgres+unix URL") // ErrInvalidMySQLUnixURL is returned when a mysql+unix URL is invalid. ErrInvalidMySQLUnixURL = errors.New("invalid mysql+unix URL") // ErrMismatchedSlices is returned when bulk operations receive slices of different lengths. ErrMismatchedSlices = errors.New("mismatched slice lengths") )
Functions ¶
func IsDeadlockError ¶ added in v0.8.0
IsDeadlockError checks if the error is a deadlock or a "database busy" error. Works across SQLite, PostgreSQL, and MySQL.
func IsDuplicateKeyError ¶ added in v0.6.0
func IsNotFoundError ¶ added in v0.6.0
IsNotFoundError checks if the error indicates a row was not found.
Types ¶
type AddNarInfoReferenceParams ¶ added in v0.8.0
type AddNarInfoReferencesParams ¶ added in v0.8.0
type AddNarInfoSignatureParams ¶ added in v0.8.0
type AddNarInfoSignaturesParams ¶ added in v0.8.0
type CreateChunkParams ¶ added in v0.9.0
type CreateConfigParams ¶ added in v0.6.0
type CreateNarFileParams ¶ added in v0.6.0
type CreateNarInfoParams ¶ added in v0.8.0
type CreateNarInfoParams struct {
Hash string
StorePath sql.NullString
URL sql.NullString
Compression sql.NullString
FileHash sql.NullString
FileSize sql.NullInt64
NarHash sql.NullString
NarSize sql.NullInt64
Deriver sql.NullString
System sql.NullString
Ca sql.NullString
}
type DeleteNarFileByHashParams ¶ added in v0.8.0
type GetChunkByNarFileIDAndIndexParams ¶ added in v0.9.0
type GetChunkByNarFileIDAndIndexRow ¶ added in v0.9.0
type GetMigratedNarInfoHashesPaginatedParams ¶ added in v0.8.0
type GetNarFileByHashAndCompressionAndQueryParams ¶ added in v0.8.0
type GetNarFilesToChunkRow ¶ added in v0.9.0
type GetNarInfoHashesToChunkRow ¶
type GetNarInfoHashesToChunkRow struct {
Hash string
URL sql.NullString
}
type GetNarInfoURLByNarFileHashParams ¶ added in v0.8.5
type GetOrphanedChunksRow ¶ added in v0.9.0
type LinkNarFileToChunkParams ¶ added in v0.9.0
type LinkNarFileToChunksParams ¶ added in v0.9.0
type LinkNarInfoToNarFileParams ¶ added in v0.6.0
type LinkNarInfosByURLToNarFileParams ¶ added in v0.9.0
type LinkNarInfosByURLToNarFileParams struct {
NarFileID int64
URL sql.NullString
}
type NarInfo ¶ added in v0.0.13
type NarInfo struct {
ID int64
Hash string
CreatedAt time.Time
UpdatedAt sql.NullTime
LastAccessedAt sql.NullTime
StorePath sql.NullString
URL sql.NullString
Compression sql.NullString
FileHash sql.NullString
FileSize sql.NullInt64
NarHash sql.NullString
NarSize sql.NullInt64
Deriver sql.NullString
System sql.NullString
Ca sql.NullString
}
type PoolConfig ¶ added in v0.6.0
type PoolConfig struct {
// MaxOpenConns is the maximum number of open connections to the database.
// If <= 0, defaults are used based on database type.
MaxOpenConns int
// MaxIdleConns is the maximum number of connections in the idle connection pool.
// If <= 0, defaults are used based on database type.
MaxIdleConns int
}
PoolConfig holds database connection pool settings.
type Querier ¶ added in v0.6.0
type Querier interface {
//AddNarInfoReference
//
// INSERT INTO narinfo_references (
// narinfo_id, reference
// ) VALUES (
// $1, $2
// )
// ON CONFLICT (narinfo_id, reference) DO NOTHING
AddNarInfoReference(ctx context.Context, arg AddNarInfoReferenceParams) error
// @bulk-for AddNarInfoReference
//
// INSERT INTO narinfo_references (
// narinfo_id, reference
// )
// SELECT $1, unnest($2::text[]) ON CONFLICT (narinfo_id, reference) DO NOTHING
AddNarInfoReferences(ctx context.Context, arg AddNarInfoReferencesParams) error
//AddNarInfoSignature
//
// INSERT INTO narinfo_signatures (
// narinfo_id, signature
// ) VALUES (
// $1, $2
// )
// ON CONFLICT (narinfo_id, signature) DO NOTHING
AddNarInfoSignature(ctx context.Context, arg AddNarInfoSignatureParams) error
// @bulk-for AddNarInfoSignature
//
// INSERT INTO narinfo_signatures (
// narinfo_id, signature
// )
// SELECT $1, unnest($2::text[]) ON CONFLICT (narinfo_id, signature) DO NOTHING
AddNarInfoSignatures(ctx context.Context, arg AddNarInfoSignaturesParams) error
//CreateChunk
//
// INSERT INTO chunks (
// hash, size, compressed_size
// ) VALUES (
// $1, $2, $3
// )
// ON CONFLICT(hash) DO UPDATE SET
// updated_at = CURRENT_TIMESTAMP
// RETURNING id, hash, size, compressed_size, created_at, updated_at
CreateChunk(ctx context.Context, arg CreateChunkParams) (Chunk, error)
//CreateConfig
//
// INSERT INTO config (
// key, value
// ) VALUES (
// $1, $2
// )
// RETURNING id, key, value, created_at, updated_at
CreateConfig(ctx context.Context, arg CreateConfigParams) (Config, error)
//CreateNarFile
//
// INSERT INTO nar_files (
// hash, compression, query, file_size, total_chunks
// ) VALUES (
// $1, $2, $3, $4, $5
// )
// ON CONFLICT (hash, compression, query) DO UPDATE SET
// updated_at = EXCLUDED.updated_at
// RETURNING
// id,
// hash,
// compression,
// file_size,
// query,
// created_at,
// updated_at,
// last_accessed_at,
// total_chunks,
// chunking_started_at
CreateNarFile(ctx context.Context, arg CreateNarFileParams) (NarFile, error)
//CreateNarInfo
//
// INSERT INTO narinfos (
// hash, store_path, url, compression, file_hash, file_size, nar_hash, nar_size, deriver, system, ca
// ) VALUES (
// $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11
// )
// ON CONFLICT (hash) DO UPDATE SET
// store_path = EXCLUDED.store_path,
// url = EXCLUDED.url,
// compression = EXCLUDED.compression,
// file_hash = EXCLUDED.file_hash,
// file_size = EXCLUDED.file_size,
// nar_hash = EXCLUDED.nar_hash,
// nar_size = EXCLUDED.nar_size,
// deriver = EXCLUDED.deriver,
// system = EXCLUDED.system,
// ca = EXCLUDED.ca,
// updated_at = CURRENT_TIMESTAMP
// WHERE narinfos.url IS NULL
// RETURNING id, hash, created_at, updated_at, last_accessed_at, store_path, url, compression, file_hash, file_size, nar_hash, nar_size, deriver, system, ca
CreateNarInfo(ctx context.Context, arg CreateNarInfoParams) (NarInfo, error)
//DeleteChunkByID
//
// DELETE FROM chunks
// WHERE id = $1
DeleteChunkByID(ctx context.Context, id int64) error
//DeleteNarFileByHash
//
// DELETE FROM nar_files
// WHERE hash = $1 AND compression = $2 AND query = $3
DeleteNarFileByHash(ctx context.Context, arg DeleteNarFileByHashParams) (int64, error)
//DeleteNarFileByID
//
// DELETE FROM nar_files
// WHERE id = $1
DeleteNarFileByID(ctx context.Context, id int64) (int64, error)
//DeleteNarFileChunksByNarFileID
//
// DELETE FROM nar_file_chunks
// WHERE nar_file_id = $1
DeleteNarFileChunksByNarFileID(ctx context.Context, narFileID int64) error
//DeleteNarInfoByHash
//
// DELETE FROM narinfos
// WHERE hash = $1
DeleteNarInfoByHash(ctx context.Context, hash string) (int64, error)
//DeleteNarInfoByID
//
// DELETE FROM narinfos
// WHERE id = $1
DeleteNarInfoByID(ctx context.Context, id int64) (int64, error)
//DeleteOrphanedNarFiles
//
// DELETE FROM nar_files
// WHERE id NOT IN (
// SELECT DISTINCT nar_file_id
// FROM narinfo_nar_files
// )
DeleteOrphanedNarFiles(ctx context.Context) (int64, error)
//DeleteOrphanedNarInfos
//
// DELETE FROM narinfos
// WHERE id NOT IN (
// SELECT DISTINCT narinfo_id
// FROM narinfo_nar_files
// )
DeleteOrphanedNarInfos(ctx context.Context) (int64, error)
//GetChunkByHash
//
// SELECT id, hash, size, compressed_size, created_at, updated_at
// FROM chunks
// WHERE hash = $1
GetChunkByHash(ctx context.Context, hash string) (Chunk, error)
//GetChunkByID
//
// SELECT id, hash, size, compressed_size, created_at, updated_at
// FROM chunks
// WHERE id = $1
GetChunkByID(ctx context.Context, id int64) (Chunk, error)
//GetChunkByNarFileIDAndIndex
//
// SELECT c.id, c.hash, c.size, c.created_at, c.updated_at
// FROM chunks c
// INNER JOIN nar_file_chunks nfc ON c.id = nfc.chunk_id
// WHERE nfc.nar_file_id = $1 AND nfc.chunk_index = $2
GetChunkByNarFileIDAndIndex(ctx context.Context, arg GetChunkByNarFileIDAndIndexParams) (GetChunkByNarFileIDAndIndexRow, error)
//GetChunkCount
//
// SELECT CAST(COUNT(*) AS BIGINT) AS count
// FROM chunks
GetChunkCount(ctx context.Context) (int64, error)
//GetChunksByNarFileID
//
// SELECT c.id, c.hash, c.size, c.compressed_size, c.created_at, c.updated_at
// FROM chunks c
// INNER JOIN nar_file_chunks nfc ON c.id = nfc.chunk_id
// WHERE nfc.nar_file_id = $1
// ORDER BY nfc.chunk_index
GetChunksByNarFileID(ctx context.Context, narFileID int64) ([]Chunk, error)
//GetCompressedNarInfos
//
// SELECT id, hash, created_at, updated_at, last_accessed_at, store_path, url, compression, file_hash, file_size, nar_hash, nar_size, deriver, system, ca
// FROM narinfos
// WHERE compression NOT IN (”, 'none')
// ORDER BY id
// LIMIT $1 OFFSET $2
GetCompressedNarInfos(ctx context.Context, arg GetCompressedNarInfosParams) ([]NarInfo, error)
//GetConfigByID
//
// SELECT id, key, value, created_at, updated_at
// FROM config
// WHERE id = $1
GetConfigByID(ctx context.Context, id int64) (Config, error)
//GetConfigByKey
//
// SELECT id, key, value, created_at, updated_at
// FROM config
// WHERE key = $1
GetConfigByKey(ctx context.Context, key string) (Config, error)
// NOTE: This query uses a correlated subquery which is not optimal for performance.
// The ideal implementation would use a window function (SUM OVER), but sqlc v1.30.0
// does not properly support filtering on window function results in subqueries.
//
// SELECT n1.id, n1.hash, n1.compression, n1.file_size, n1.query, n1.created_at, n1.updated_at, n1.last_accessed_at, n1.total_chunks, n1.chunking_started_at
// FROM nar_files n1
// WHERE (
// SELECT SUM(n2.file_size)
// FROM nar_files n2
// WHERE n2.last_accessed_at < n1.last_accessed_at
// OR (n2.last_accessed_at = n1.last_accessed_at AND n2.id <= n1.id)
// ) <= $1
GetLeastUsedNarFiles(ctx context.Context, fileSize uint64) ([]NarFile, error)
// NOTE: This query uses a correlated subquery which is not optimal for performance.
// The ideal implementation would use a window function (SUM OVER), but sqlc v1.30.0
// does not properly support filtering on window function results in subqueries.
// Gets the least-used narinfos up to a certain total file size (accounting for their nar_files).
//
// SELECT ni1.id, ni1.hash, ni1.created_at, ni1.updated_at, ni1.last_accessed_at, ni1.store_path, ni1.url, ni1.compression, ni1.file_hash, ni1.file_size, ni1.nar_hash, ni1.nar_size, ni1.deriver, ni1.system, ni1.ca
// FROM narinfos ni1
// WHERE (
// SELECT COALESCE(SUM(nf.file_size), 0)
// FROM nar_files nf
// WHERE nf.id IN (
// SELECT DISTINCT nnf.nar_file_id
// FROM narinfo_nar_files nnf
// INNER JOIN narinfos ni2 ON nnf.narinfo_id = ni2.id
// WHERE ni2.last_accessed_at < ni1.last_accessed_at
// OR (ni2.last_accessed_at = ni1.last_accessed_at AND ni2.id <= ni1.id)
// )
// ) <= $1
GetLeastUsedNarInfos(ctx context.Context, fileSize uint64) ([]NarInfo, error)
// Get all narinfo hashes that have a URL (migrated).
//
// SELECT hash
// FROM narinfos
// WHERE url IS NOT NULL
GetMigratedNarInfoHashes(ctx context.Context) ([]string, error)
// Get migrated narinfo hashes with pagination support.
//
// SELECT hash
// FROM narinfos
// WHERE url IS NOT NULL
// ORDER BY hash
// LIMIT $1 OFFSET $2
GetMigratedNarInfoHashesPaginated(ctx context.Context, arg GetMigratedNarInfoHashesPaginatedParams) ([]string, error)
//GetNarFileByHashAndCompressionAndQuery
//
// SELECT id, hash, compression, file_size, query, created_at, updated_at, last_accessed_at, total_chunks, chunking_started_at
// FROM nar_files
// WHERE hash = $1 AND compression = $2 AND query = $3
GetNarFileByHashAndCompressionAndQuery(ctx context.Context, arg GetNarFileByHashAndCompressionAndQueryParams) (NarFile, error)
//GetNarFileByID
//
// SELECT id, hash, compression, file_size, query, created_at, updated_at, last_accessed_at, total_chunks, chunking_started_at
// FROM nar_files
// WHERE id = $1
GetNarFileByID(ctx context.Context, id int64) (NarFile, error)
//GetNarFileByNarInfoID
//
// SELECT nf.id, nf.hash, nf.compression, nf.file_size, nf.query, nf.created_at, nf.updated_at, nf.last_accessed_at, nf.total_chunks, nf.chunking_started_at
// FROM nar_files nf
// INNER JOIN narinfo_nar_files nnf ON nf.id = nnf.nar_file_id
// WHERE nnf.narinfo_id = $1
GetNarFileByNarInfoID(ctx context.Context, narinfoID int64) (NarFile, error)
//GetNarFileCount
//
// SELECT CAST(COUNT(*) AS BIGINT) AS count
// FROM nar_files
GetNarFileCount(ctx context.Context) (int64, error)
// Get all NAR files that are not yet chunked.
//
// SELECT id, hash, compression, query, file_size
// FROM nar_files
// WHERE total_chunks = 0
// ORDER BY id
GetNarFilesToChunk(ctx context.Context) ([]GetNarFilesToChunkRow, error)
// Get the count of NAR files that are not yet chunked.
//
// SELECT COUNT(*)
// FROM nar_files
// WHERE total_chunks = 0
GetNarFilesToChunkCount(ctx context.Context) (int64, error)
//GetNarInfoByHash
//
// SELECT id, hash, created_at, updated_at, last_accessed_at, store_path, url, compression, file_hash, file_size, nar_hash, nar_size, deriver, system, ca
// FROM narinfos
// WHERE hash = $1
GetNarInfoByHash(ctx context.Context, hash string) (NarInfo, error)
//GetNarInfoByID
//
// SELECT id, hash, created_at, updated_at, last_accessed_at, store_path, url, compression, file_hash, file_size, nar_hash, nar_size, deriver, system, ca
// FROM narinfos
// WHERE id = $1
GetNarInfoByID(ctx context.Context, id int64) (NarInfo, error)
//GetNarInfoCount
//
// SELECT CAST(COUNT(*) AS BIGINT) AS count
// FROM narinfos
GetNarInfoCount(ctx context.Context) (int64, error)
//GetNarInfoHashByNarURL
//
// SELECT hash
// FROM narinfos
// WHERE url = $1
// LIMIT 1
GetNarInfoHashByNarURL(ctx context.Context, url sql.NullString) (string, error)
//GetNarInfoHashesByNarFileID
//
// SELECT ni.hash
// FROM narinfos ni
// INNER JOIN narinfo_nar_files nnf ON ni.id = nnf.narinfo_id
// WHERE nnf.nar_file_id = $1
GetNarInfoHashesByNarFileID(ctx context.Context, narFileID int64) ([]string, error)
//GetNarInfoHashesByURL
//
// SELECT hash
// FROM narinfos
// WHERE url = $1
GetNarInfoHashesByURL(ctx context.Context, url sql.NullString) ([]string, error)
// Get all narinfo hashes that have a URL (migrated) but whose NAR is not yet chunked.
//
// SELECT ni.hash, ni.url
// FROM narinfos ni
// LEFT JOIN narinfo_nar_files nnf ON ni.id = nnf.narinfo_id
// LEFT JOIN nar_files nf ON nnf.nar_file_id = nf.id
// WHERE ni.url IS NOT NULL
// AND (nf.id IS NULL OR nf.total_chunks = 0)
// ORDER BY ni.hash
GetNarInfoHashesToChunk(ctx context.Context) ([]GetNarInfoHashesToChunkRow, error)
//GetNarInfoReferences
//
// SELECT reference
// FROM narinfo_references
// WHERE narinfo_id = $1
GetNarInfoReferences(ctx context.Context, narinfoID int64) ([]string, error)
//GetNarInfoSignatures
//
// SELECT signature
// FROM narinfo_signatures
// WHERE narinfo_id = $1
GetNarInfoSignatures(ctx context.Context, narinfoID int64) ([]string, error)
//GetNarInfoURLByNarFileHash
//
// SELECT ni.url
// FROM narinfos ni
// INNER JOIN narinfo_nar_files nnf ON ni.id = nnf.narinfo_id
// INNER JOIN nar_files nf ON nf.id = nnf.nar_file_id
// WHERE nf.hash = $1 AND nf.compression = $2 AND nf.query = $3
// LIMIT 1
GetNarInfoURLByNarFileHash(ctx context.Context, arg GetNarInfoURLByNarFileHashParams) (sql.NullString, error)
//GetNarTotalSize
//
// SELECT CAST(COALESCE(SUM(file_size), 0) AS BIGINT) AS total_size
// FROM nar_files
GetNarTotalSize(ctx context.Context) (int64, error)
//GetOldCompressedNarFiles
//
// SELECT id, hash, compression, file_size, query, created_at, updated_at, last_accessed_at, total_chunks, chunking_started_at
// FROM nar_files
// WHERE compression NOT IN (”, 'none')
// AND created_at < $1
// ORDER BY id
// LIMIT $2 OFFSET $3
GetOldCompressedNarFiles(ctx context.Context, arg GetOldCompressedNarFilesParams) ([]NarFile, error)
//GetOrphanedChunks
//
// SELECT c.id, c.hash, c.size, c.created_at, c.updated_at
// FROM chunks c
// LEFT JOIN nar_file_chunks nfc ON c.id = nfc.chunk_id
// WHERE nfc.chunk_id IS NULL
GetOrphanedChunks(ctx context.Context) ([]GetOrphanedChunksRow, error)
// Find files that have no relationship to any narinfo
//
// SELECT nf.id, nf.hash, nf.compression, nf.file_size, nf.query, nf.created_at, nf.updated_at, nf.last_accessed_at, nf.total_chunks, nf.chunking_started_at
// FROM nar_files nf
// LEFT JOIN narinfo_nar_files ninf ON nf.id = ninf.nar_file_id
// WHERE ninf.narinfo_id IS NULL
GetOrphanedNarFiles(ctx context.Context) ([]NarFile, error)
//GetTotalChunkSize
//
// SELECT CAST(COALESCE(SUM(size), 0) AS BIGINT) AS total_size
// FROM chunks
GetTotalChunkSize(ctx context.Context) (int64, error)
// Get all narinfo hashes that have no URL (unmigrated).
//
// SELECT hash
// FROM narinfos
// WHERE url IS NULL
GetUnmigratedNarInfoHashes(ctx context.Context) ([]string, error)
// Check if a narinfo hash has been migrated (has a URL).
//
// SELECT EXISTS(
// SELECT 1
// FROM narinfos
// WHERE hash = $1 AND url IS NOT NULL
// ) AS is_migrated
IsNarInfoMigrated(ctx context.Context, hash string) (bool, error)
//LinkNarFileToChunk
//
// INSERT INTO nar_file_chunks (
// nar_file_id, chunk_id, chunk_index
// ) VALUES (
// $1, $2, $3
// )
// ON CONFLICT (nar_file_id, chunk_index) DO NOTHING
LinkNarFileToChunk(ctx context.Context, arg LinkNarFileToChunkParams) error
// @bulk-for LinkNarFileToChunk
//
// INSERT INTO nar_file_chunks (
// nar_file_id, chunk_id, chunk_index
// )
// SELECT $1, unnest($2::bigint[]), unnest($3::bigint[])
// ON CONFLICT (nar_file_id, chunk_index) DO NOTHING
LinkNarFileToChunks(ctx context.Context, arg LinkNarFileToChunksParams) error
//LinkNarInfoToNarFile
//
// INSERT INTO narinfo_nar_files (
// narinfo_id, nar_file_id
// ) VALUES (
// $1, $2
// )
// ON CONFLICT (narinfo_id, nar_file_id) DO NOTHING
LinkNarInfoToNarFile(ctx context.Context, arg LinkNarInfoToNarFileParams) error
//LinkNarInfosByURLToNarFile
//
// INSERT INTO narinfo_nar_files (narinfo_id, nar_file_id)
// SELECT id, $1
// FROM narinfos
// WHERE url = $2
// ON CONFLICT (narinfo_id, nar_file_id) DO NOTHING
LinkNarInfosByURLToNarFile(ctx context.Context, arg LinkNarInfosByURLToNarFileParams) error
//SetConfig
//
// INSERT INTO config (
// key, value
// ) VALUES (
// $1, $2
// )
// ON CONFLICT(key)
// DO UPDATE SET
// value = EXCLUDED.value,
// updated_at = CURRENT_TIMESTAMP
SetConfig(ctx context.Context, arg SetConfigParams) error
//SetNarFileChunkingStarted
//
// UPDATE nar_files
// SET chunking_started_at = CURRENT_TIMESTAMP, updated_at = CURRENT_TIMESTAMP
// WHERE id = $1
SetNarFileChunkingStarted(ctx context.Context, id int64) error
//TouchNarFile
//
// UPDATE nar_files
// SET
// last_accessed_at = CURRENT_TIMESTAMP,
// updated_at = CURRENT_TIMESTAMP
// WHERE hash = $1 AND compression = $2 AND query = $3
TouchNarFile(ctx context.Context, arg TouchNarFileParams) (int64, error)
//TouchNarInfo
//
// UPDATE narinfos
// SET
// last_accessed_at = CURRENT_TIMESTAMP,
// updated_at = CURRENT_TIMESTAMP
// WHERE hash = $1
TouchNarInfo(ctx context.Context, hash string) (int64, error)
//UpdateNarFileFileSize
//
// UPDATE nar_files
// SET file_size = $1, updated_at = CURRENT_TIMESTAMP
// WHERE id = $2
UpdateNarFileFileSize(ctx context.Context, arg UpdateNarFileFileSizeParams) error
//UpdateNarFileTotalChunks
//
// UPDATE nar_files
// SET total_chunks = $1, file_size = $2, updated_at = CURRENT_TIMESTAMP, chunking_started_at = NULL
// WHERE id = $3
UpdateNarFileTotalChunks(ctx context.Context, arg UpdateNarFileTotalChunksParams) error
//UpdateNarInfo
//
// UPDATE narinfos
// SET
// store_path = $2,
// url = $3,
// compression = $4,
// file_hash = $5,
// file_size = $6,
// nar_hash = $7,
// nar_size = $8,
// deriver = $9,
// system = $10,
// ca = $11,
// updated_at = CURRENT_TIMESTAMP
// WHERE hash = $1
// RETURNING id, hash, created_at, updated_at, last_accessed_at, store_path, url, compression, file_hash, file_size, nar_hash, nar_size, deriver, system, ca
UpdateNarInfo(ctx context.Context, arg UpdateNarInfoParams) (NarInfo, error)
// Update narinfo compression and URL after CDC migration.
//
// UPDATE narinfos
// SET compression = $1, url = $2, updated_at = CURRENT_TIMESTAMP
// WHERE url = $3
UpdateNarInfoCompressionAndURL(ctx context.Context, arg UpdateNarInfoCompressionAndURLParams) (int64, error)
//UpdateNarInfoFileHash
//
// UPDATE narinfos
// SET file_hash = $2, updated_at = CURRENT_TIMESTAMP
// WHERE hash = $1
UpdateNarInfoFileHash(ctx context.Context, arg UpdateNarInfoFileHashParams) error
//UpdateNarInfoFileSize
//
// UPDATE narinfos
// SET file_size = $2, updated_at = CURRENT_TIMESTAMP
// WHERE hash = $1
UpdateNarInfoFileSize(ctx context.Context, arg UpdateNarInfoFileSizeParams) error
WithTx(tx *sql.Tx) Querier
DB() *sql.DB
}
func Open ¶
func Open(dbURL string, poolCfg *PoolConfig) (Querier, error)
Open opens a database connection and returns a Querier implementation. The database type is determined from the URL scheme:
- sqlite:// or sqlite3:// for SQLite
- postgres:// or postgresql:// for PostgreSQL
- mysql:// for MySQL/MariaDB
The poolCfg parameter is optional. If nil, sensible defaults are used based on the database type. SQLite uses MaxOpenConns=1, PostgreSQL and MySQL use higher values.
type SetConfigParams ¶ added in v0.6.0
type TouchNarFileParams ¶ added in v0.8.0
type Type ¶ added in v0.6.0
type Type uint8
func DetectFromDatabaseURL ¶ added in v0.6.0
DetectFromDatabaseURL detects the database type given a database url.
type UpdateNarFileFileSizeParams ¶ added in v0.9.0
type UpdateNarFileTotalChunksParams ¶ added in v0.9.0
type UpdateNarInfoCompressionAndURLParams ¶ added in v0.9.0
type UpdateNarInfoCompressionAndURLParams struct {
Compression sql.NullString
NewUrl sql.NullString
OldUrl sql.NullString
}
type UpdateNarInfoFileHashParams ¶ added in v0.9.0
type UpdateNarInfoFileHashParams struct {
Hash string
FileHash sql.NullString
}
type UpdateNarInfoFileSizeParams ¶ added in v0.9.0
type UpdateNarInfoParams ¶ added in v0.9.0
type UpdateNarInfoParams struct {
Hash string
StorePath sql.NullString
URL sql.NullString
Compression sql.NullString
FileHash sql.NullString
FileSize sql.NullInt64
NarHash sql.NullString
NarSize sql.NullInt64
Deriver sql.NullString
System sql.NullString
Ca sql.NullString
}