[db] Make loading of playlistitem count optional

This commit is contained in:
chme 2016-02-21 18:05:11 +01:00
parent 29dbc6bd9d
commit c1dcc0a937
5 changed files with 40 additions and 37 deletions

View File

@ -1698,7 +1698,7 @@ db_query_fetch_file(struct query_params *qp, struct db_media_file_info *dbmfi)
} }
int int
db_query_fetch_pl(struct query_params *qp, struct db_playlist_info *dbpli) db_query_fetch_pl(struct query_params *qp, struct db_playlist_info *dbpli, int with_itemcount)
{ {
int ncols; int ncols;
char **strcol; char **strcol;
@ -1751,6 +1751,8 @@ db_query_fetch_pl(struct query_params *qp, struct db_playlist_info *dbpli)
*strcol = (char *)sqlite3_column_text(qp->stmt, i); *strcol = (char *)sqlite3_column_text(qp->stmt, i);
} }
if (with_itemcount)
{
type = sqlite3_column_int(qp->stmt, 2); type = sqlite3_column_int(qp->stmt, 2);
switch (type) switch (type)
@ -1789,6 +1791,7 @@ db_query_fetch_pl(struct query_params *qp, struct db_playlist_info *dbpli)
strcpy(qp->buf2, "0"); strcpy(qp->buf2, "0");
} }
}
return 0; return 0;
} }

View File

@ -417,7 +417,7 @@ int
db_query_fetch_file(struct query_params *qp, struct db_media_file_info *dbmfi); db_query_fetch_file(struct query_params *qp, struct db_media_file_info *dbmfi);
int int
db_query_fetch_pl(struct query_params *qp, struct db_playlist_info *dbpli); db_query_fetch_pl(struct query_params *qp, struct db_playlist_info *dbpli, int with_itemcount);
int int
db_query_fetch_group(struct query_params *qp, struct db_group_info *dbgri); db_query_fetch_group(struct query_params *qp, struct db_group_info *dbgri);

View File

@ -1670,7 +1670,7 @@ daap_reply_playlists(struct evhttp_request *req, struct evbuffer *evbuf, char **
} }
npls = 0; npls = 0;
while (((ret = db_query_fetch_pl(&qp, &dbpli)) == 0) && (dbpli.id)) while (((ret = db_query_fetch_pl(&qp, &dbpli, 1)) == 0) && (dbpli.id))
{ {
plid = 1; plid = 1;
if (safe_atoi32(dbpli.id, &plid) != 0) if (safe_atoi32(dbpli.id, &plid) != 0)

View File

@ -394,7 +394,7 @@ rsp_reply_db(struct evhttp_request *req, char **uri, struct evkeyvalq *query)
mxmlNewTextf(node, 0, "%d", qp.results); mxmlNewTextf(node, 0, "%d", qp.results);
/* Playlists block (all playlists) */ /* Playlists block (all playlists) */
while (((ret = db_query_fetch_pl(&qp, &dbpli)) == 0) && (dbpli.id)) while (((ret = db_query_fetch_pl(&qp, &dbpli, 1)) == 0) && (dbpli.id))
{ {
/* Playlist block (one playlist) */ /* Playlist block (one playlist) */
pl = mxmlNewElement(pls, "playlist"); pl = mxmlNewElement(pls, "playlist");

View File

@ -2237,7 +2237,7 @@ mpd_command_listplaylists(struct evbuffer *evbuf, int argc, char **argv, char **
return ACK_ERROR_UNKNOWN; return ACK_ERROR_UNKNOWN;
} }
while (((ret = db_query_fetch_pl(&qp, &dbpli)) == 0) && (dbpli.id)) while (((ret = db_query_fetch_pl(&qp, &dbpli, 0)) == 0) && (dbpli.id))
{ {
if (safe_atou32(dbpli.db_timestamp, &time_modified) != 0) if (safe_atou32(dbpli.db_timestamp, &time_modified) != 0)
{ {
@ -2752,7 +2752,7 @@ mpd_add_directory(struct evbuffer *evbuf, int directory_id, int listall, int lis
DPRINTF(E_LOG, L_MPD, "Out of memory\n"); DPRINTF(E_LOG, L_MPD, "Out of memory\n");
return ACK_ERROR_UNKNOWN; return ACK_ERROR_UNKNOWN;
} }
while (((ret = db_query_fetch_pl(&qp, &dbpli)) == 0) && (dbpli.id)) while (((ret = db_query_fetch_pl(&qp, &dbpli, 0)) == 0) && (dbpli.id))
{ {
if (safe_atou32(dbpli.db_timestamp, &time_modified) != 0) if (safe_atou32(dbpli.db_timestamp, &time_modified) != 0)
{ {