feat(storage): add native PostgreSQL runtime and verified offline application import
Build and publish container images / images (push) Failing after 12m29s
Build and publish container images / images (push) Failing after 12m29s
This commit is contained in:
1 parent
96065d1e89
commit
0ba1dcfef0
243 files changed
+21441
-3090
No files matched your search
@@ -14,10 +14,12 @@ type RevisionPage struct {
|
||||
Next string
|
||||
}
|
||||
|
||||
// ListRevisionPage is metadata-only and keeps insertion-order tie breaking.
|
||||
// ListRevisionPage is metadata-only. SQLite keeps rowid tie breaking; native
|
||||
// PostgreSQL uses UUID with monotonically increasing per-language save times.
|
||||
// The cursor is a visible Revision UUID in the same Object, never a global
|
||||
// row counter or an OFFSET that shifts when newer revisions arrive.
|
||||
func (s *Store) ListRevisionPage(ctx context.Context, objectUUID, before string, limit int) (RevisionPage, error) {
|
||||
func (s *Store) ListRevisionPage(ctx context.Context, objectUUID, before string, limit int) (_ RevisionPage, resultErr error) {
|
||||
defer func() { resultErr = s.sqlError("revision history page", resultErr) }()
|
||||
page := RevisionPage{Items: []RevisionListItem{}}
|
||||
if limit <= 0 {
|
||||
limit = 100
|
||||
@@ -27,29 +29,34 @@ func (s *Store) ListRevisionPage(ctx context.Context, objectUUID, before string,
|
||||
}
|
||||
ctx, cancel := context.WithTimeout(ctx, 2*time.Second)
|
||||
defer cancel()
|
||||
tx, err := s.DB.BeginTx(ctx, &sql.TxOptions{ReadOnly: true})
|
||||
tx, err := s.DB.BeginTx(ctx, s.policyReadOptions())
|
||||
if err != nil {
|
||||
return page, err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
where := ""
|
||||
tieColumn := "rowid"
|
||||
if s.sqlBackend == storePostgreSQL {
|
||||
tieColumn = "uuid"
|
||||
}
|
||||
args := []any{objectUUID}
|
||||
if before != "" {
|
||||
var createdMS, rowID int64
|
||||
if err := tx.QueryRowContext(ctx, `SELECT created_at_ms,rowid FROM revisions WHERE uuid=? AND object_uuid=?`, before, objectUUID).Scan(&createdMS, &rowID); err != nil {
|
||||
var createdMS int64
|
||||
var tie any
|
||||
if err := tx.QueryRowContext(ctx, `SELECT created_at_ms,`+tieColumn+` FROM revisions WHERE uuid=`+s.sqlParam(1)+` AND object_uuid=`+s.sqlParam(2), before, objectUUID).Scan(&createdMS, &tie); err != nil {
|
||||
if errors.Is(err, sql.ErrNoRows) {
|
||||
return page, ErrRevisionCursor
|
||||
}
|
||||
return page, err
|
||||
}
|
||||
where = ` AND (created_at_ms,rowid) < (?,?)`
|
||||
args = append(args, createdMS, rowID)
|
||||
where = ` AND (created_at_ms,` + tieColumn + `) < (` + s.sqlParam(2) + `,` + s.sqlParam(3) + `)`
|
||||
args = append(args, createdMS, tie)
|
||||
}
|
||||
args = append(args, limit+1)
|
||||
rows, err := tx.QueryContext(ctx, `SELECT uuid,object_uuid,COALESCE(document_hash,''),COALESCE(NULLIF(lang,''),'und'),
|
||||
COALESCE(NULLIF(content_type,''),'text/html; charset=utf-8'),substr(COALESCE(filename,''),1,4096),
|
||||
substr(COALESCE(message,''),1,4096),COALESCE(created_at,0),created_at_ms
|
||||
FROM revisions WHERE object_uuid=?`+where+` ORDER BY created_at_ms DESC,rowid DESC LIMIT ?`, args...)
|
||||
FROM revisions WHERE object_uuid=`+s.sqlParam(1)+where+` ORDER BY created_at_ms DESC,`+tieColumn+` DESC LIMIT `+s.sqlParam(len(args)), args...)
|
||||
if err != nil {
|
||||
return page, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user