|
12 | 12 | #ifndef RMGRDESC_UTILS_H_
|
13 | 13 | #define RMGRDESC_UTILS_H_
|
14 | 14 |
|
| 15 | +/* |
| 16 | + * Guidelines for rmgrdesc routine authors: |
| 17 | + * |
| 18 | + * The goal of these guidelines is to avoid gratuitous inconsistencies across |
| 19 | + * each rmgr, and to allow users to parse desc output strings without too much |
| 20 | + * difficulty. This is not an API specification or an interchange format. |
| 21 | + * (Only heapam and nbtree desc routines follow these guidelines at present, |
| 22 | + * in any case.) |
| 23 | + * |
| 24 | + * Record descriptions are similar to JSON style key/value objects. However, |
| 25 | + * there is no explicit "string" type/string escaping. Top-level { } brackets |
| 26 | + * should be omitted. For example: |
| 27 | + * |
| 28 | + * snapshotConflictHorizon: 0, flags: 0x03 |
| 29 | + * |
| 30 | + * Record descriptions may contain variable-length arrays. For example: |
| 31 | + * |
| 32 | + * nunused: 5, unused: [1, 2, 3, 4, 5] |
| 33 | + * |
| 34 | + * Nested objects are supported via { } brackets. They generally appear |
| 35 | + * inside variable-length arrays. For example: |
| 36 | + * |
| 37 | + * ndeleted: 0, nupdated: 1, deleted: [], updated: [{ off: 45, nptids: 1, ptids: [0] }] |
| 38 | + * |
| 39 | + * Try to output things in an order that faithfully represents the order of |
| 40 | + * fields from the underlying physical WAL record struct. Key names should be |
| 41 | + * unique (at the same nesting level) to make parsing easy. It's a good idea |
| 42 | + * if the number of items in the array appears before the array. |
| 43 | + * |
| 44 | + * It's okay for individual WAL record types to invent their own conventions. |
| 45 | + * For example, Heap2's PRUNE record descriptions use a custom array format |
| 46 | + * for the record's "redirected" field: |
| 47 | + * |
| 48 | + * ... redirected: [1->4, 5->9], dead: [10, 11], unused: [3, 7, 8] |
| 49 | + * |
| 50 | + * Arguably the desc routine should be using object notation for this instead. |
| 51 | + * However, there is value in using a custom format when it conveys useful |
| 52 | + * information about the underlying physical data structures. |
| 53 | + * |
| 54 | + * This ad-hoc format has the advantage of being close to the format used for |
| 55 | + * the "dead" and "unused" arrays (which follow the standard desc convention |
| 56 | + * for page offset number arrays). It suggests that the "redirected" elements |
| 57 | + * shown are just pairs of page offset numbers (which is how it really works). |
| 58 | + */ |
15 | 59 | extern void array_desc(StringInfo buf, void *array, size_t elem_size, int count,
|
16 | 60 | void (*elem_desc) (StringInfo buf, void *elem, void *data),
|
17 | 61 | void *data);
|
|
0 commit comments