"title":"Command to do complex queries on list commands",
"description":[
"The **sql** RPC command runs the given query across a sqlite3 database created from various list commands.",
"",
"When tables are accessed, it calls the below commands, so it's no faster than any other local access (though it goes to great length to cache `listnodes` and `listchannels`) which then processes the results.",
"A message if the database encounters an error partway through."
]
}
},
"pre_return_value_notes":[
"On success, an object containing **rows** is returned. It is an array. Each array entry contains an array of values, each an integer, real number, string or *null*, depending on the sqlite3 type.",
"",
"The object may contain **warning_db_failure** if the database fails partway through its operation."
]
},
"treatment_of_types":[
"The following types are supported in schemas, and this shows how they are presented in the database. This matters: a JSON boolean is represented as an integer in the database, so a query will return 0 or 1, not true or false.",
"",
"* *hex*. A hex string.",
" * JSON: a string",
" * sqlite3: BLOB",
"",
"* *hash*/*secret*/*pubkey*/*txid*: just like *hex*.",
"",
"* *msat*/*integer*/*u64*/*u32*/*u16*/*u8*. Normal numbers.",
" * JSON: an unsigned integer",
" * sqlite3: INTEGER",
"",
"* *boolean*. True or false.",
" * JSON: literal **true** or **false**",
" * sqlite3: INTEGER",
"",
"* *number*. A floating point number (used for times in some places).",
" * JSON: number",
" * sqlite3: REAL",
"",
"* *string*. Text.",
" * JSON: string",
" * sqlite3: TEXT",
"",
"* *short_channel_id*. A short-channel-id of form 1x2x3.",
" * JSON: string",
" * sqlite3: TEXT"
],
"permitted_sqlite3_functions":[
"Writing to the database is not permitted, and limits are placed on various other query parameters.",
"",
"Additionally, only the following functions are allowed:",
"Note that the first column of every table is a unique integer called `rowid`: this is used for related tables to refer to specific rows in their parent. sqlite3 usually has this as an implicit column, but we make it explicit as the implicit version is not allowed to be used as a foreign key.",
"SELECT nodeid FROM nodes WHERE nodeid IN (x'nodeid010101010101010101010101010101010101010101010101010101010101', x'nodeid030303030303030303030303030303030303030303030303030303030303')"