mirror of
https://github.com/matrix-org/dendrite.git
synced 2025-12-26 08:13:09 -06:00
Use COALESCE in PostgreSQL
This commit is contained in:
parent
fc1d6bc5e6
commit
94f3de2798
|
|
@ -51,10 +51,10 @@ func UpStateBlocksRefactor(tx *sql.Tx) error {
|
|||
if err := tx.QueryRow(`SELECT COUNT(DISTINCT state_snapshot_nid) FROM roomserver_state_snapshots;`).Scan(&snapshotcount); err != nil {
|
||||
return fmt.Errorf("tx.QueryRow.Scan (count snapshots): %w", err)
|
||||
}
|
||||
if err := tx.QueryRow(`SELECT MAX(state_snapshot_nid) FROM roomserver_state_snapshots;`).Scan(&maxsnapshotid); err != nil {
|
||||
if err := tx.QueryRow(`SELECT COALESCE(MAX(state_snapshot_nid),0) FROM roomserver_state_snapshots;`).Scan(&maxsnapshotid); err != nil {
|
||||
return fmt.Errorf("tx.QueryRow.Scan (count snapshots): %w", err)
|
||||
}
|
||||
if err := tx.QueryRow(`SELECT MAX(state_block_nid) FROM roomserver_state_block;`).Scan(&maxblockid); err != nil {
|
||||
if err := tx.QueryRow(`SELECT COALESCE(MAX(state_block_nid),0) FROM roomserver_state_block;`).Scan(&maxblockid); err != nil {
|
||||
return fmt.Errorf("tx.QueryRow.Scan (count snapshots): %w", err)
|
||||
}
|
||||
maxsnapshotid++
|
||||
|
|
|
|||
Loading…
Reference in a new issue