A gallery - the raised rail around the edge of a table top - is one of those details that began as pure function and stayed for its looks.
It appeared on bedside tables when rooms were lit by candles and lamps, and when the thing most often standing on that table at night was a full glass or a jug of water. In the dark, reaching for something on a small table means feeling for it, and feeling for it means pushing things across the surface. A raised edge at the back turns a knocked glass into a stopped glass.
The reason it survived into rooms with electric light is that it also solves a design problem. A small table has a small top, and a plain flat top on a heavily carved base looks unfinished - the carving simply stops. A gallery gives the top an edge to belong to, and lets the ornament run all the way to the highest point of the piece instead of dying at the moulding.
Shaping it is the fiddly part. The rail is cut from solid stock, waved along its upper edge, and has to return around the corners without the wave breaking rhythm as it turns. Our carvers set out the wave so a full curve, not a half one, sits at each corner - which means the spacing is decided by the width of the table rather than chosen freely.