diff --git a/mythtv/libs/libmyth/programinfo.cpp b/mythtv/libs/libmyth/programinfo.cpp
index 71277ea..57b87c5 100644
a
|
b
|
void ProgramInfo::SavePositionMap( |
3594 | 3594 | if (!query.exec()) |
3595 | 3595 | MythDB::DBError("position map clear", query); |
3596 | 3596 | |
| 3597 | // Use the multi-value insert syntax to reduce database I/O |
| 3598 | QStringList q("INSERT INTO "); |
| 3599 | QString qfields; |
3597 | 3600 | if (IsVideo()) |
3598 | 3601 | { |
3599 | | query.prepare( |
3600 | | "INSERT INTO " |
3601 | | "filemarkup (filename, mark, type, offset) " |
3602 | | "VALUES ( :PATH , :MARK , :TYPE , :OFFSET )"); |
3603 | | query.bindValue(":PATH", videoPath); |
| 3602 | q << "filemarkup (filename, type, mark, offset)"; |
| 3603 | qfields = QString("('%1',%2,") . |
| 3604 | // ideally, this should be escaped |
| 3605 | arg(videoPath) . |
| 3606 | arg(type); |
3604 | 3607 | } |
3605 | 3608 | else // if (IsRecording()) |
3606 | 3609 | { |
3607 | | query.prepare( |
3608 | | "INSERT INTO " |
3609 | | "recordedseek (chanid, starttime, mark, type, offset) " |
3610 | | " VALUES ( :CHANID , :STARTTIME , :MARK , :TYPE , :OFFSET )"); |
3611 | | query.bindValue(":CHANID", chanid); |
3612 | | query.bindValue(":STARTTIME", recstartts); |
| 3610 | q << "recordedseek (chanid, starttime, type, mark, offset)"; |
| 3611 | qfields = QString("(%1,'%2',%3,") . |
| 3612 | arg(chanid) . |
| 3613 | arg(recstartts.toString(Qt::ISODate)) . |
| 3614 | arg(type); |
3613 | 3615 | } |
3614 | | query.bindValue(":TYPE", type); |
| 3616 | q << " VALUES "; |
3615 | 3617 | |
| 3618 | bool add_comma = false; |
3616 | 3619 | frm_pos_map_t::iterator it; |
3617 | 3620 | for (it = posMap.begin(); it != posMap.end(); ++it) |
3618 | 3621 | { |
… |
… |
void ProgramInfo::SavePositionMap( |
3626 | 3629 | |
3627 | 3630 | uint64_t offset = *it; |
3628 | 3631 | |
3629 | | query.bindValue(":MARK", (quint64)frame); |
3630 | | query.bindValue(":OFFSET", (quint64)offset); |
3631 | | |
3632 | | if (!query.exec()) |
| 3632 | if (add_comma) |
3633 | 3633 | { |
3634 | | MythDB::DBError("position map insert", query); |
3635 | | break; |
| 3634 | q << ","; |
3636 | 3635 | } |
| 3636 | else |
| 3637 | { |
| 3638 | add_comma = true; |
| 3639 | } |
| 3640 | q << qfields << QString("%1,%2)").arg(frame).arg(offset); |
| 3641 | } |
| 3642 | query.prepare(q.join("")); |
| 3643 | if (!query.exec()) |
| 3644 | { |
| 3645 | MythDB::DBError("position map insert", query); |
3637 | 3646 | } |
3638 | 3647 | } |
3639 | 3648 | |
… |
… |
void ProgramInfo::SavePositionMapDelta( |
3652 | 3661 | return; |
3653 | 3662 | } |
3654 | 3663 | |
3655 | | MSqlQuery query(MSqlQuery::InitCon()); |
3656 | | |
| 3664 | // Use the multi-value insert syntax to reduce database I/O |
| 3665 | QStringList q("INSERT INTO "); |
| 3666 | QString qfields; |
3657 | 3667 | if (IsVideo()) |
3658 | 3668 | { |
3659 | | query.prepare( |
3660 | | "INSERT INTO " |
3661 | | "filemarkup (filename, mark, type, offset) " |
3662 | | "VALUES ( :PATH , :MARK , :TYPE , :OFFSET )"); |
3663 | | query.bindValue(":PATH", StorageGroup::GetRelativePathname(pathname)); |
| 3669 | q << "filemarkup (filename, type, mark, offset)"; |
| 3670 | qfields = QString("('%1',%2,") . |
| 3671 | // ideally, this should be escaped |
| 3672 | arg(StorageGroup::GetRelativePathname(pathname)) . |
| 3673 | arg(type); |
3664 | 3674 | } |
3665 | 3675 | else if (IsRecording()) |
3666 | 3676 | { |
3667 | | query.prepare( |
3668 | | "INSERT INTO " |
3669 | | "recordedseek (chanid, starttime, mark, type, offset) " |
3670 | | " VALUES ( :CHANID , :STARTTIME , :MARK , :TYPE , :OFFSET )"); |
3671 | | query.bindValue(":CHANID", chanid); |
3672 | | query.bindValue(":STARTTIME", recstartts); |
| 3677 | q << "recordedseek (chanid, starttime, type, mark, offset)"; |
| 3678 | qfields = QString("(%1,'%2',%3,") . |
| 3679 | arg(chanid) . |
| 3680 | arg(recstartts.toString(Qt::ISODate)) . |
| 3681 | arg(type); |
3673 | 3682 | } |
3674 | 3683 | else |
3675 | 3684 | { |
3676 | 3685 | return; |
3677 | 3686 | } |
3678 | | query.bindValue(":TYPE", type); |
| 3687 | q << " VALUES "; |
3679 | 3688 | |
| 3689 | bool add_comma = false; |
3680 | 3690 | frm_pos_map_t::iterator it; |
3681 | 3691 | for (it = posMap.begin(); it != posMap.end(); ++it) |
3682 | 3692 | { |
3683 | 3693 | uint64_t frame = it.key(); |
3684 | 3694 | uint64_t offset = *it; |
3685 | 3695 | |
3686 | | query.bindValue(":MARK", (quint64)frame); |
3687 | | query.bindValue(":OFFSET", (quint64)offset); |
3688 | | |
3689 | | if (!query.exec()) |
| 3696 | if (add_comma) |
3690 | 3697 | { |
3691 | | MythDB::DBError("delta position map insert", query); |
3692 | | break; |
| 3698 | q << ","; |
3693 | 3699 | } |
| 3700 | else |
| 3701 | { |
| 3702 | add_comma = true; |
| 3703 | } |
| 3704 | q << qfields << QString("%1,%2)").arg(frame).arg(offset); |
| 3705 | } |
| 3706 | |
| 3707 | MSqlQuery query(MSqlQuery::InitCon()); |
| 3708 | query.prepare(q.join("")); |
| 3709 | if (!query.exec()) |
| 3710 | { |
| 3711 | MythDB::DBError("delta position map insert", query); |
3694 | 3712 | } |
3695 | 3713 | } |
3696 | 3714 | |