Commit a38031e1 authored by Ronan's avatar Ronan

fix(MainDb): conference_event_view is compatible with mysql

parent 02662051
......@@ -138,10 +138,10 @@ private:
return (mMask & value) == value && (value || mMask == 0);
}
// On CentOs 7 GCC 4.8.5 have issue with array-bounds
// On CentOs 7 GCC 4.8.5 have issue with array-bounds.
#if __GNUC__ == 4 && __GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ == 5
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
static constexpr StorageType init (
......@@ -152,7 +152,7 @@ private:
}
#if __GNUC__ == 4 && __GNUC_MINOR__ == 8 && __GNUC_PATCHLEVEL__ == 5
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#endif
StorageType mMask;
......
......@@ -24,22 +24,48 @@
LINPHONE_BEGIN_NAMESPACE
namespace Statements {
using Backend = AbstractDb::Backend;
struct Statement {
template<size_t N>
constexpr Statement (Backend _backend, const char (&_sql)[N]) : backend(_backend), sql(_sql) {}
Backend backend;
const char *sql;
};
struct AbstractStatement {
public:
template<size_t N>
constexpr AbstractStatement (const char (&_sql)[N]) : mSql{ _sql, nullptr } {}
constexpr AbstractStatement (const Statement &a, const Statement &b) : mSql{ a.sql, b.sql } {}
const char *getSql (Backend backend) const {
return backend == Backend::Mysql && mSql[1] ? mSql[1] : mSql[0];
}
private:
const char *mSql[2];
};
// ---------------------------------------------------------------------------
// Create statements.
// ---------------------------------------------------------------------------
constexpr const char *create[CreateCount] = {
[CreateConferenceEventView] = R"(
CREATE TEMP VIEW conference_event_view AS
SELECT id, type, creation_time, chat_room_id, from_sip_address_id, to_sip_address_id, time, imdn_message_id, state, direction, is_secured, notify_id, device_sip_address_id, participant_sip_address_id, subject
FROM event
LEFT JOIN conference_event ON conference_event.event_id = event.id
LEFT JOIN conference_chat_message_event ON conference_chat_message_event.event_id = event.id
LEFT JOIN conference_notified_event ON conference_notified_event.event_id = event.id
LEFT JOIN conference_participant_device_event ON conference_participant_device_event.event_id = event.id
LEFT JOIN conference_participant_event ON conference_participant_event.event_id = event.id
LEFT JOIN conference_subject_event ON conference_subject_event.event_id = event.id
)"
constexpr AbstractStatement create[CreateCount] = {
[CreateConferenceEventView] =
R"(
CREATE VIEW IF NOT EXISTS conference_event_view AS
SELECT id, type, creation_time, chat_room_id, from_sip_address_id, to_sip_address_id, time, imdn_message_id, state, direction, is_secured, notify_id, device_sip_address_id, participant_sip_address_id, subject
FROM event
LEFT JOIN conference_event ON conference_event.event_id = event.id
LEFT JOIN conference_chat_message_event ON conference_chat_message_event.event_id = event.id
LEFT JOIN conference_notified_event ON conference_notified_event.event_id = event.id
LEFT JOIN conference_participant_device_event ON conference_participant_device_event.event_id = event.id
LEFT JOIN conference_participant_event ON conference_participant_event.event_id = event.id
LEFT JOIN conference_subject_event ON conference_subject_event.event_id = event.id
)"
};
// ---------------------------------------------------------------------------
......@@ -64,7 +90,7 @@ namespace Statements {
const char *get (Create createStmt, AbstractDb::Backend backend) {
(void)backend;
return createStmt >= Create::CreateCount ? nullptr : create[createStmt];
return createStmt >= Create::CreateCount ? nullptr : create[createStmt].getSql(backend);
}
const char *get (Select selectStmt, AbstractDb::Backend backend) {
......
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment