* Changed unknown value of 'language' field from NULL to ''. The reason

is that it turned out that in MyISAM tables a unique index does not
  guarantee uniqueness if a field in the index can have a NULL value.


git-svn-id: http://svn.berlios.de/svnroot/repos/sems/trunk@358 8eb893ce-cfd4-0310-b710-fb5ebe64c474
sayer/1.4-spce2.6
Juha Heinanen 19 years ago
parent edf165425d
commit d46ba25419

@ -2,6 +2,7 @@
* $Id$
*
* Copyright (C) 2002-2003 Fhg Fokus
* Copyright (C) 2007 Juha Heinanen (USE_MYSQL parts)
*
* This file is part of sems, a free SIP media server.
*
@ -74,11 +75,11 @@ int get_audio_file(string message, string domain, string language,
if (language.empty()) {
if (domain.empty()) {
*audio_file = string("/tmp/") + APP_NAME + "_" + message + ".wav";
query_string = "select audio from " + string(DEFAULT_AUDIO_TABLE) + " where application='" + APP_NAME + "' and message='" + message + "' and language is null";
query_string = "select audio from " + string(DEFAULT_AUDIO_TABLE) + " where application='" + APP_NAME + "' and message='" + message + "' and language=''";
} else {
*audio_file = "/tmp/" + domain + "_" + APP_NAME + "_" +
message + ".wav";
query_string = "select audio from " + string(DOMAIN_AUDIO_TABLE) + " where application='" + APP_NAME + "' and message='" + message + "' and domain='" + domain + "' and language is null";
query_string = "select audio from " + string(DOMAIN_AUDIO_TABLE) + " where application='" + APP_NAME + "' and message='" + message + "' and domain='" + domain + "' and language=''";
}
} else {
if (domain.empty()) {

@ -93,11 +93,11 @@ int get_audio_file(string message, string domain, string user,
if (domain.empty()) {
*audio_file = string("/tmp/") + MOD_NAME + "_" + message +
".wav";
query_string = "select audio from " + string(DEFAULT_AUDIO_TABLE) + " where application='" + MOD_NAME + "' and message='" + message + "' and language is null";
query_string = "select audio from " + string(DEFAULT_AUDIO_TABLE) + " where application='" + MOD_NAME + "' and message='" + message + "' and language=''";
} else {
*audio_file = string("/tmp/") + domain + "_" + MOD_NAME +
"_" + message + ".wav";
query_string = "select audio from " + string(DOMAIN_AUDIO_TABLE) + " where application='" + MOD_NAME + "' and message='" + message + "' and domain='" + domain + "' and language is null";
query_string = "select audio from " + string(DOMAIN_AUDIO_TABLE) + " where application='" + MOD_NAME + "' and message='" + message + "' and domain='" + domain + "' and language=''";
}
} else {
if (domain.empty()) {
@ -175,7 +175,7 @@ int AnswerMachineFactory::loadEmailTemplatesFromMySQL()
unsigned long length = row["template"].size();
string tmp_file, tmpl_name;
row = res.at(i);
if (string(row["language"]) == "NULL") {
if (string(row["language"]) == "") {
tmp_file = "/tmp/voicemail_email.template";
tmpl_name = DEFAULT_MAIL_TMPL;
} else {
@ -217,7 +217,7 @@ int AnswerMachineFactory::loadEmailTemplatesFromMySQL()
unsigned long length = row["template"].size();
string tmp_file, tmpl_name;
row = res.at(i);
if (string(row["language"]) == "NULL") {
if (string(row["language"]) == "") {
tmp_file = "/tmp/" + string(row["domain"]) +
"_voicemail_email.template";
tmpl_name = string(row["domain"]);

@ -73,7 +73,7 @@ CREATE TABLE default_audio (
id int(10) unsigned NOT NULL auto_increment,
application varchar(32) NOT NULL,
message varchar(32) NOT NULL,
`language` char(2) default NULL,
`language` char(2) NOT NULL default '',
audio mediumblob NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY application (application,message,`language`)
@ -84,7 +84,7 @@ CREATE TABLE domain_audio (
application varchar(32) NOT NULL,
message varchar(32) NOT NULL,
domain varchar(128) NOT NULL,
`language` char(2) default NULL,
`language` char(2) NOT NULL default '',
audio mediumblob NOT NULL,
PRIMARY KEY (id),
UNIQUE KEY application (application,message,domain,`language`)
@ -92,7 +92,8 @@ CREATE TABLE domain_audio (
The first one stores default audio files and the latter domain specific
audio files. Application value must be 'conference' and message values
are 'first_participant_msg', 'join_snd', and 'drop_snd'.
are 'first_participant_msg', 'join_snd', and 'drop_snd'. Language value
is a two letter code of a language or '' if language is unknown.
When an audio file is fetched from database, it is stored in /tmp
directory.

@ -127,7 +127,7 @@ CREATE TABLE domain_template (
application varchar(32) NOT NULL,
message varchar(32) NOT NULL,
domain varchar(128) NOT NULL,
`language` char(2) default NULL,
`language` char(2) NOT NULL default '',
template text NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@ -136,12 +136,14 @@ CREATE TABLE default_template (
id int(10) unsigned NOT NULL auto_increment,
application varchar(32) NOT NULL,
message varchar(32) NOT NULL,
`language` char(2) default NULL,
`language` char(2) NOT NULL default '',
template text NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
Application value is 'voicemail' and message value is 'email_tmpl'.
Language value is a two letter code of a language or '' if language is
unknown.
When an audio file is fetched from database, it is stored in /tmp
directory.

Loading…
Cancel
Save