| 1857 | } |
| 1858 | |
| 1859 | static struct table_desc *new_table_desc(const tal_t *ctx, |
| 1860 | tablemap *tablemap, |
| 1861 | struct table_desc *parent, |
| 1862 | const jsmntok_t *cmd, |
| 1863 | const jsmntok_t *arrname, |
| 1864 | bool is_subobject) |
| 1865 | { |
| 1866 | struct table_desc *td; |
| 1867 | const char *name; |
| 1868 | const struct refresh_funcs *refresh_func; |
| 1869 | |
| 1870 | td = tal(ctx, struct table_desc); |
| 1871 | td->cmdname = json_strdup(td, schemas, cmd); |
| 1872 | name = db_table_name(tmpctx, td->cmdname); |
| 1873 | if (!parent) |
| 1874 | td->name = tal_steal(td, name); |
| 1875 | else |
| 1876 | td->name = tal_fmt(td, "%s_%s", parent->name, name); |
| 1877 | td->parent = parent; |
| 1878 | td->is_subobject = is_subobject; |
| 1879 | td->arrname = json_strdup(td, schemas, arrname); |
| 1880 | td->columns = tal_arr(td, struct column *, 0); |
| 1881 | td->last_created_index = 0; |
| 1882 | td->last_updated_index = 0; |
| 1883 | td->has_created_index = false; |
| 1884 | td->refresh_needs = REFRESH_ALWAYS; |
| 1885 | td->refreshing = false; |
| 1886 | td->populated = false; |
| 1887 | list_head_init(&td->refresh_waiters); |
| 1888 | |
| 1889 | /* Only top-levels have refresh functions */ |
| 1890 | if (!parent) { |
| 1891 | refresh_func = find_command_refresh(td->cmdname); |
| 1892 | td->refresh = refresh_func->refresh; |
| 1893 | td->waitname = refresh_func->waitname; |
| 1894 | } |
| 1895 | |
| 1896 | /* sub-objects are a JSON thing, not a real table! */ |
| 1897 | if (!td->is_subobject) |
| 1898 | strmap_add(tablemap, td->name, td); |
| 1899 | |
| 1900 | return td; |
| 1901 | } |
| 1902 | |
| 1903 | /* Recursion */ |
| 1904 | static void add_table_object(tablemap *tablemap, |
no test coverage detected