Skip to content

Commit

Permalink
[MySQL Conformance] fix tree size bug
Browse files Browse the repository at this point in the history
This returns the logic back to how it was before #281. This addresses part of #364, but I think only fixes a special case for full tiles. I think this needs more to address requesting partial sizes slightly larger than the current tree size.
  • Loading branch information
mhutchinson committed Dec 5, 2024
1 parent 26d8567 commit a3ffa83
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions storage/mysql/mysql.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ func (s *Storage) writeTreeState(ctx context.Context, tx *sql.Tx, size uint64, r
return nil
}

// ReadTile returns a full tile or a partial tile at the given level, index and width.
// ReadTile returns a full tile or a partial tile at the given level, index and treeSize.
// If the tile is not found, nil is returned with no error.
//
// TODO: Handle the following scenarios:
Expand All @@ -243,7 +243,7 @@ func (s *Storage) writeTreeState(ctx context.Context, tx *sql.Tx, size uint64, r
// 3. Partial tile request with full/larger partial tile output: Return trimmed partial tile with correct tile width.
// 4. Partial tile request with partial tile (same width) output: Return partial tile.
// 5. Partial tile request with smaller partial tile output: Return error.
func (s *Storage) ReadTile(ctx context.Context, level, index, width uint64) ([]byte, error) {
func (s *Storage) ReadTile(ctx context.Context, level, index, treeSize uint64) ([]byte, error) {
row := s.db.QueryRowContext(ctx, selectSubtreeByLevelAndIndexSQL, level, index)
if err := row.Err(); err != nil {
return nil, err
Expand All @@ -258,8 +258,9 @@ func (s *Storage) ReadTile(ctx context.Context, level, index, width uint64) ([]b
return nil, fmt.Errorf("scan tile: %v", err)
}

width := treeSize % 256
// Return nil when returning a partial tile on a full tile request.
if width == 256 && uint64(len(tile)/32) != width {
if width == 0 && uint64(len(tile)/32) != width {
return nil, nil
}

Expand Down

0 comments on commit a3ffa83

Please sign in to comment.