Skip to content

Commit 7864a97

Browse files
authored
remove the use of max commit from the code where possible (treeverse#374)
Former-commit-id: c7a1f1944d52d56c79bac1c79a5b4151bcff8df9
1 parent 53c6871 commit 7864a97

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

catalog/cataloger_commit.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,9 @@ func (c *cataloger) Commit(ctx context.Context, repository, branch string, messa
8585
func commitUpdateCommittedEntriesWithMaxCommit(tx sqlx.Execer, branchID int64, commitID CommitID) (int64, error) {
8686
res, err := tx.Exec(`UPDATE catalog_entries_v SET max_commit = $2
8787
WHERE branch_id = $1 AND is_committed
88-
AND max_commit = $3
88+
AND max_commit = catalog_max_commit_id()
8989
AND path in (SELECT path FROM catalog_entries_v WHERE branch_id = $1 AND NOT is_committed)`,
90-
branchID, commitID, MaxCommitID)
90+
branchID, commitID)
9191
if err != nil {
9292
return 0, err
9393
}

catalog/cataloger_create_entry.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,9 @@ func insertEntry(tx db.Tx, branchID int64, entry *Entry) (string, error) {
5555
err := tx.Get(&ctid, `INSERT INTO catalog_entries (branch_id,path,physical_address,checksum,size,metadata,creation_date,is_expired)
5656
VALUES ($1,$2,$3,$4,$5,$6, COALESCE($7, NOW()), $8)
5757
ON CONFLICT (branch_id,path,min_commit)
58-
DO UPDATE SET physical_address=$3, checksum=$4, size=$5, metadata=$6, creation_date=EXCLUDED.creation_date, is_expired=EXCLUDED.is_expired, max_commit=$9
58+
DO UPDATE SET physical_address=$3, checksum=$4, size=$5, metadata=$6, creation_date=EXCLUDED.creation_date, is_expired=EXCLUDED.is_expired, max_commit=catalog_max_commit_id()
5959
RETURNING ctid`,
60-
branchID, entry.Path, entry.PhysicalAddress, entry.Checksum, entry.Size, entry.Metadata, dbTime, entry.Expired, MaxCommitID)
60+
branchID, entry.Path, entry.PhysicalAddress, entry.Checksum, entry.Size, entry.Metadata, dbTime, entry.Expired)
6161
if err != nil {
6262
return "", fmt.Errorf("insert entry: %w", err)
6363
}

catalog/cataloger_merge.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ func (c *cataloger) doMergeByRelation(tx db.Tx, relation RelationType, leftID, r
128128

129129
func (c *cataloger) mergeFromFather(tx db.Tx, previousMaxCommitID, nextCommitID CommitID, fatherID, sonID int64, committer string, msg string, metadata Metadata) error {
130130
_, err := tx.Exec(`UPDATE catalog_entries SET max_commit = $2
131-
WHERE branch_id = $1 AND max_commit = $3 AND path in (SELECT path FROM `+diffResultsTableName+` WHERE diff_type IN ($4,$5))`,
132-
sonID, previousMaxCommitID, MaxCommitID, DifferenceTypeRemoved, DifferenceTypeChanged)
131+
WHERE branch_id = $1 AND max_commit = catalog_max_commit_id() AND path in (SELECT path FROM `+diffResultsTableName+` WHERE diff_type IN ($3,$4))`,
132+
sonID, previousMaxCommitID, DifferenceTypeRemoved, DifferenceTypeChanged)
133133
if err != nil {
134134
return err
135135
}

0 commit comments

Comments
 (0)