MCPcopy Create free account
hub / github.com/ElementsProject/lightning / add_sub_object

Function add_sub_object

plugins/sql.c:1570–1593  ·  view source on GitHub ↗

Adds a sub_object to this sql statement (and sub-sub etc) */

Source from the content-addressed store, hash-verified

1568
1569/* Adds a sub_object to this sql statement (and sub-sub etc) */
1570static void add_sub_object(char **insert_stmt, char **create_stmt,
1571 const char **sep, struct table_desc *sub)
1572{
1573 /* sub-arrays are a completely separate table. */
1574 if (!sub->is_subobject)
1575 return;
1576
1577 /* sub-objects are folded into this table. */
1578 for (size_t j = 0; j < tal_count(sub->columns); j++) {
1579 const struct column *subcol = sub->columns[j];
1580
1581 if (subcol->sub) {
1582 add_sub_object(insert_stmt, create_stmt, sep,
1583 subcol->sub);
1584 continue;
1585 }
1586 tal_append_fmt(insert_stmt, "%s?", *sep);
1587 tal_append_fmt(create_stmt, "%s%s %s",
1588 *sep,
1589 subcol->dbname,
1590 fieldtypemap[subcol->ftype].sqltype);
1591 *sep = ",";
1592 }
1593}
1594
1595/* We use created_index as INTEGER PRIMARY KEY, if it exists.
1596 * Otherwise, we make an explicit rowid (implicit rowids cannot be

Callers 1

finish_tdFunction · 0.85

Calls 1

tal_append_fmtFunction · 0.85

Tested by

no test coverage detected