feat(storage): add native PostgreSQL runtime and verified offline application import
Build and publish container images / images (push) Failing after 12m29s

This commit is contained in:
Anya Tokugawa committed 2026-11-15 05:47:14 +09:00
1 parent 96065d1e89
commit 0ba1dcfef0
243 files changed
+21441 -3090

No files matched your search

+20 -9
View File
@@ -56,11 +56,19 @@ func pathMutationTransactionError(err error) error {
// Unlike LIKE, neither percent, underscore, backslash nor case changes can
// expand the requested subtree. The range can use the Domain/Path index.
func listMutationPaths(q pathQueryer, domainUUID, root string, recursive bool) ([]pathRename, error) {
return (&Store{}).listMutationPaths(q, domainUUID, root, recursive)
}
func (s *Store) listMutationPaths(q pathQueryer, domainUUID, root string, recursive bool) ([]pathRename, error) {
collation := "BINARY"
if s.sqlBackend == storePostgreSQL {
collation = `"C"`
}
prefix := strings.TrimRight(root, "/") + "/"
upper := strings.TrimSuffix(prefix, "/") + "0"
query := `
SELECT path, object_uuid, created_at, COALESCE(is_primary, 0)
FROM paths WHERE domain_uuid = ? AND path = ?`
FROM paths WHERE domain_uuid = ` + s.sqlParam(1) + ` AND path = ` + s.sqlParam(2)
args := []any{domainUUID, root}
if recursive {
// Separate indexed arms avoid the Domain-wide scan SQLite may choose
@@ -68,12 +76,13 @@ func listMutationPaths(q pathQueryer, domainUUID, root string, recursive bool) (
// puts each parent before its children without a full length sort.
query += ` UNION ALL
SELECT path, object_uuid, created_at, COALESCE(is_primary, 0)
FROM paths WHERE domain_uuid = ?
AND path >= ? COLLATE BINARY AND path < ? COLLATE BINARY AND path != ?`
FROM paths WHERE domain_uuid = ` + s.sqlParam(3) + `
AND path >= ` + s.sqlParam(4) + ` COLLATE ` + collation + ` AND path < ` + s.sqlParam(5) + ` COLLATE ` + collation + ` AND path != ` + s.sqlParam(6)
args = append(args, domainUUID, prefix, upper, root)
}
query += ` ORDER BY path COLLATE BINARY LIMIT ?`
args = append(args, MaxPathMutationPaths+1)
// ORDER BY a named output column is portable across compound SELECTs.
query = `SELECT * FROM (` + query + `) mutation_paths ORDER BY path COLLATE ` + collation + ` LIMIT ` + s.sqlParam(len(args))
rows, err := q.Query(query, args...)
if err != nil {
return nil, err
@@ -98,7 +107,7 @@ func listMutationPaths(q pathQueryer, domainUUID, root string, recursive bool) (
func (s *Store) SnapshotPathsInDomain(domainUUID, root string, recursive bool) (*PathMutationSnapshot, error) {
root = normalizePath(root)
bindings, err := listMutationPaths(s.DB, domainUUID, root, recursive)
bindings, err := s.listMutationPaths(s.DB, domainUUID, root, recursive)
if err != nil {
return nil, err
}
@@ -125,14 +134,16 @@ func (snapshot *PathMutationSnapshot) validate(domainUUID, root string, recursiv
// Every scope is revalidated before the first DELETE, including overlapping
// selections. SQLite rejects an upgrade of a stale read snapshot to a write;
// do not retry this transaction without taking and authorizing a new snapshot.
func (s *Store) RemovePathsInDomainChecked(domainUUID string, snapshots []*PathMutationSnapshot) (int, error) {
func (s *Store) RemovePathsInDomainChecked(domainUUID string, snapshots []*PathMutationSnapshot) (_ int, resultErr error) {
defer func() { resultErr = s.sqlError("remove checked paths", resultErr) }()
if err := s.ensureLocalDomain(domainUUID); err != nil {
return 0, err
}
if len(snapshots) == 0 {
return 0, ErrPathNotFound
}
tx, err := s.DB.Begin()
tx, cancel, err := s.beginPathMutation(domainUUID)
defer cancel()
if err != nil {
return 0, err
}
@@ -142,7 +153,7 @@ func (s *Store) RemovePathsInDomainChecked(domainUUID string, snapshots []*PathM
if snapshot == nil || snapshot.domainUUID != domainUUID || snapshot.root == "/" {
return 0, ErrPathSnapshotChanged
}
current, err := listMutationPaths(tx, domainUUID, snapshot.root, snapshot.recursive)
current, err := s.listMutationPaths(tx, domainUUID, snapshot.root, snapshot.recursive)
if err != nil {
return 0, err
}
@@ -157,7 +168,7 @@ func (s *Store) RemovePathsInDomainChecked(domainUUID string, snapshots []*PathM
}
}
for _, binding := range bindings {
if _, err := tx.Exec(`DELETE FROM paths WHERE domain_uuid=? AND path=? AND object_uuid=?`, domainUUID, binding.OldPath, binding.ObjectUUID); err != nil {
if _, err := tx.Exec(`DELETE FROM paths WHERE domain_uuid=`+s.sqlParam(1)+` AND path=`+s.sqlParam(2)+` AND object_uuid=`+s.sqlParam(3), domainUUID, binding.OldPath, binding.ObjectUUID); err != nil {
return 0, pathMutationTransactionError(err)
}
}