Commit fee90f43 authored by phenigma's avatar phenigma

Merge branch 'iss2648' - Merge all sqlCVS changes required for newer mysql servers

parents 82315fc1 3fc0b020
......@@ -99,7 +99,7 @@ RunSQL "$Q"
Q="
UPDATE Orbiter
SET Regen=1, Modification_LastGen=0
SET Regen=1, Modification_LastGen='1970-01-01 00:00:00'
WHERE PK_Orbiter IN ($OrbiterIDs)
"
RunSQL "$Q"
......@@ -6,12 +6,24 @@ require "/usr/pluto/bin/config_ops.pl";
# We try the regular LinuxMCE/Pluto credentials. If they fail, we try a local connection
$db = DBI->connect(&read_pluto_cred()) or $db = DBI->connect("DBI:mysql:") or die "Couldn't connect to database: $DBI::errstr\n";
@databases = ("pluto_main","pluto_media","pluto_telecom","asterisk","asteriskcdrdb","mythconverg","pluto_mediatomb","pluto_myth","pluto_security","pluto_telecom","pluto_vdr");
#@databases = ("pluto_main","pluto_media","pluto_telecom","asterisk","asteriskcdrdb","mythconverg","pluto_mediatomb","pluto_myth","pluto_security","pluto_telecom","pluto_vdr");
@databases = ("asterisk","asteriskcdrdb","mythconverg","pluto_mediatomb","pluto_vdr");
# fix calldate in asterisk.cdr, sqlCVS takes care of lmce databases
$sql = "UPDATE asterisk.cdr set calldate='1970-01-01 00:00:00' WHERE calldate=0;";
$st = $db->prepare($sql) or die "Error in prepare $sql\n";
$st->execute() or die "Error on execute $sql\n";
$sql = "ALTER TABLE asterisk.cdr MODIFY calldate datetime NULL DEFAULT NULL;";
$st = $db->prepare($sql) or die "Error in prepare $sql\n";
$st->execute() or die "Error on execute $sql\n";
$sql = "UPDATE asterisk.cdr set calldate=NULL WHERE calldate=0 OR calldate='1970-01-01 00:00:00';";
$st = $db->prepare($sql) or die "Error in prepare $sql\n";
$st->execute() or die "Error on execute $sql\n";
foreach $dbname (@databases) {
# Select all tbles that don't have utf8_general_ci as there collation
$sql = "SELECT TABLE_NAME FROM information_schema.TABLES Where TABLE_SCHEMA = '$dbname' AND TABLE_NAME != 'Schema' AND TABLE_COLLATION != 'utf8_general_ci';";
# print "$sql\n";
# print "$sql\n";
$st = $db->prepare($sql) or die "Error in prepare $sql\n";
$st->execute() or die "Error on execute $sql\n";
$first = 1;
......@@ -30,7 +42,7 @@ foreach $dbname (@databases) {
}
$st->finish();
# Select all columns that have a specific character set, and reset them to default
# Select all columns that have a specific character set, and reset them to default
$sql_column = "SELECT TABLE_NAME,COLUMN_NAME, COLUMN_TYPE, IS_NULLABLE, COLUMN_DEFAULT, COLUMN_KEY FROM information_schema.COLUMNS where TABLE_SCHEMA = '$dbname' ";
$sql_column .= " AND (DATA_TYPE = 'varchar' OR DATA_TYPE = 'text' OR DATA_TYPE = 'char' OR DATA_TYPE = 'longtext') ";
$sql_column .= " AND CHARACTER_SET_NAME IS NOT NULL";
......
......@@ -7,7 +7,7 @@ echo 'DELETE FROM CachedScreens;' | mysql pluto_main 2>/dev/null || err=$?; :
if [[ "$err" = "0" ]] ; then
echo 'DELETE FROM CachedScreens;' | mysql pluto_main || /bin/true
echo 'UPDATE Device JOIN DeviceTemplate ON FK_DeviceTemplate=PK_DeviceTemplate JOIN DeviceCategory ON FK_DeviceCategory=PK_DeviceCategory SET NeedConfigure=1 WHERE FK_DeviceCategory=5 OR FK_DeviceCategory_Parent=5;' | mysql pluto_main || /bin/true
echo 'UPDATE Orbiter set Modification_LastGen=0,Regen=1,RegenInProgress=0;' | mysql pluto_main || /bin/true
echo 'UPDATE Orbiter set Modification_LastGen="1970-01-01 00:00:00",Regen=1,RegenInProgress=0;' | mysql pluto_main || /bin/true
# Disable OrbiterGen for m/d's since as of .28 it's done on the core
echo 'UPDATE Device_StartupScript JOIN Device on FK_Device=PK_Device JOIN DeviceTemplate on FK_DeviceTemplate=PK_DeviceTemplate SET Enabled=0 WHERE FK_DeviceCategory=8 AND FK_Device_ControlledVia IS NULL AND FK_StartupScript=27' | mysql pluto_main || /bin/true
......
......@@ -2429,7 +2429,7 @@ class DataGridTable *Telecom_Plugin::SpeedDialGrid(string GridID,string Parms,vo
sql_buff += " JOIN CommandGroup_Command ON CommandGroup_Command.FK_CommandGroup=PK_CommandGroup";
sql_buff += " JOIN CommandGroup_Command_CommandParameter ON FK_CommandGroup_Command=PK_CommandGroup_Command";
sql_buff += " JOIN CommandGroup_Room ON CommandGroup_Room.FK_CommandGroup=PK_CommandGroup";
sql_buff += " WHERE AutoGeneratedDate=0";
sql_buff += " WHERE AutoGeneratedDate IS NULL"; // =0
sql_buff += " AND FK_Array="+StringUtils::itos(ARRAY_Communication_Scenarios_CONST);
sql_buff += " AND FK_Room="+room;
sql_buff += " ORDER BY PK_CommandGroup,FK_CommandParameter";
......
......@@ -3,7 +3,7 @@ echo
/usr/pluto/bin/Debug_LogKernelModules.sh "$0" || :
PROCESS="upgrade"
# Check if we have an existing install, by verifying the DeviceTemplate table exists
mysql $MYSQL_DB_CRED pluto_security -e "Select 1"||PROCESS="install"
mysql $MYSQL_DB_CRED pluto_security -e "Select * From AlertType Limit 0,1"||PROCESS="install"
if [ $PROCESS = "install" ]; then
(
cd /usr/pluto/database
......@@ -21,4 +21,12 @@ if [ $PROCESS = "install" ]; then
Q="FLUSH PRIVILEGES;"
mysql $MYSQL_DB_CRED -e "$Q"
fi
if [ $PROCESS = "upgrade" ]; then
echo
echo Updating system database using sqlCVS
echo Please be patient...
## FIXME - schema.linuxmce.org is hard coded
/usr/pluto/bin/sqlCVS -R 6999 -H schema.linuxmce.org $PLUTO_DB_CRED -n -d anonymous -U anonymous~nopass -D pluto_security -r security -A -e update || exit $?
fi
......@@ -44,7 +44,7 @@ if [ $PROCESS = "upgrade" ]; then
/usr/pluto/bin/sqlCVS -R 3999 -H schema.linuxmce.org $PLUTO_DB_CRED -n -d anonymous -U anonymous~nopass -D $MySqlDBName -r constants,dce,designer,document,ir,website -A -e update || exit $?
fi
# Make sure Text_LS has the correct character set (UTF-8)
/usr/bin/perl /usr/pluto/bin/update2utf8.pl
/usr/bin/perl /usr/pluto/bin/update2utf8.pl || :
# update quick start icons
/bin/bash /usr/pluto/bin/UpdateQuickStartIcons.sh || /bin/true
......
......@@ -22,4 +22,11 @@ if [ $PROCESS = "install" ]; then
Q="FLUSH PRIVILEGES;"
mysql $MYSQL_DB_CRED -e "$Q"
fi
if [ $PROCESS = "upgrade" ]; then
echo
echo Updating media database using sqlCVS
echo Please be patient...
## FIXME - schema.linuxmce.org is hard coded
/usr/pluto/bin/sqlCVS -R 7999 -H schema.linuxmce.org $PLUTO_DB_CRED -n -d anonymous -U anonymous~nopass -D pluto_telecom -r telecom -A -e update || exit $?
fi
lmce-asterisk (0+0.3.6-1) unstable; urgency=low
* updates for mysql >v5.5 datetime/timestamp handling
-- phenigma <phenigma@linuxmce.org> Mon, 27 Sep 2016 20:08:00 -0500
lmce-asterisk (0+0.3.5-1) unstable; urgency=low
* update configs for chan_sccp-v4.2
......
......@@ -19,6 +19,7 @@ if [[ "$1" == configure ]]; then
mysql -f -h "$MySqlHost" -u "$MySqlUser" $PassParm -e "use asterisk; ALTER TABLE phonelines ADD dtmfmode VARCHAR(10) NOT NULL DEFAULT 'auto' AFTER protocol" 2>>/dev/null
mysql -f -h "$MySqlHost" -u "$MySqlUser" $PassParm -e "use asterisk; ALTER TABLE extensions MODIFY appdata VARCHAR(150);" 2>>/dev/null
mysql -f -h "$MySqlHost" -u "$MySqlUser" $PassParm -e "use asterisk; ALTER TABLE sip_devices CHANGE qualify qualify CHAR(5) NULL DEFAULT 'no'" 2>>/dev/null
mysql -f -h "$MySqlHost" -u "$MySqlUser" $PassParm -e "use asterisk; ALTER TABLE cdr MODIFY calldate datetime NULL DEFAULT NULL;" 2>>/dev/null
fi
# recreate asterisk database (except tables which contains user data)
......
......@@ -2,6 +2,7 @@
* Create LinuxMCE asterisk database
* and realtime tables
*
* v0.4 - 27/09/2016 - phenigma - updates for mysql >v5.5 datetime/timestamp changes
* v0.3 - 16/11/2015 - phenigma - updates for chan_sccp-v4.2
* v0.2 - 15/04/2012 - foxi352 - removed asteriskcdrdb and created cdr table in asterisk db
* v0.1 - 22/09/2011 - foxi352 - initial version
......@@ -376,7 +377,7 @@ CREATE TABLE IF NOT EXISTS `fax_list` (
-- Table for calls details records (cdr)
--
CREATE TABLE IF NOT EXISTS `cdr` (
`calldate` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`calldate` datetime DEFAULT NULL,
`clid` varchar(80) NOT NULL DEFAULT '',
`src` varchar(80) NOT NULL DEFAULT '',
`dst` varchar(80) NOT NULL DEFAULT '',
......
......@@ -141,8 +141,7 @@ m_FK_DesignObj = 0;
is_null[1] = false;
m_Version = 0;
is_null[2] = false;
m_Modification_LastGen = "0000-00-00 00:00:00";
is_null[3] = false;
is_null[3] = true;
m_ContainsArrays = 0;
is_null[4] = false;
m_Schema = 1;
......@@ -155,8 +154,7 @@ is_null[8] = true;
m_psc_user = 0;
m_psc_frozen = 0;
is_null[9] = false;
m_psc_mod = "0000-00-00 00:00:00";
is_null[10] = false;
is_null[10] = true;
is_null[11] = true;
m_psc_restrict = 0;
......@@ -242,6 +240,9 @@ void Row_CachedScreens::psc_restrict_set(long int val){PLUTO_SAFETY_LOCK_ERRORSO
m_psc_restrict = val; is_modified=true; is_null[11]=false;}
bool Row_CachedScreens::Modification_LastGen_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[3];}
bool Row_CachedScreens::ContainsArrays_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[4];}
......@@ -260,11 +261,18 @@ return is_null[8];}
bool Row_CachedScreens::psc_frozen_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[9];}
bool Row_CachedScreens::psc_mod_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[10];}
bool Row_CachedScreens::psc_restrict_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[11];}
void Row_CachedScreens::Modification_LastGen_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
is_null[3]=val;
is_modified=true;
}
void Row_CachedScreens::ContainsArrays_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
is_null[4]=val;
is_modified=true;
......@@ -289,6 +297,10 @@ void Row_CachedScreens::psc_frozen_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONL
is_null[9]=val;
is_modified=true;
}
void Row_CachedScreens::psc_mod_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
is_null[10]=val;
is_modified=true;
}
void Row_CachedScreens::psc_restrict_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
is_null[11]=val;
is_modified=true;
......
......@@ -139,21 +139,25 @@ void psc_mod_set(string val);
void psc_restrict_set(long int val);
bool ContainsArrays_isNull();
bool Modification_LastGen_isNull();
bool ContainsArrays_isNull();
bool Schema_isNull();
bool psc_id_isNull();
bool psc_batch_isNull();
bool psc_user_isNull();
bool psc_frozen_isNull();
bool psc_mod_isNull();
bool psc_restrict_isNull();
void ContainsArrays_setNull(bool val);
void Modification_LastGen_setNull(bool val);
void ContainsArrays_setNull(bool val);
void Schema_setNull(bool val);
void psc_id_setNull(bool val);
void psc_batch_setNull(bool val);
void psc_user_setNull(bool val);
void psc_frozen_setNull(bool val);
void psc_mod_setNull(bool val);
void psc_restrict_setNull(bool val);
......
......@@ -170,8 +170,7 @@ is_null[11] = true;
m_AltID = 0;
is_null[12] = true;
m_FK_Icon = 0;
m_AutoGeneratedDate = "0000-00-00 00:00:00";
is_null[13] = false;
is_null[13] = true;
m_Disabled = 0;
is_null[14] = false;
is_null[15] = true;
......@@ -188,8 +187,7 @@ is_null[20] = true;
m_psc_user = 0;
m_psc_frozen = 0;
is_null[21] = false;
m_psc_mod = "0000-00-00 00:00:00";
is_null[22] = false;
is_null[22] = true;
is_null[23] = true;
m_psc_restrict = 0;
......@@ -395,6 +393,9 @@ return is_null[20];}
bool Row_CommandGroup::psc_frozen_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[21];}
bool Row_CommandGroup::psc_mod_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[22];}
bool Row_CommandGroup::psc_restrict_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[23];}
......@@ -464,6 +465,10 @@ void Row_CommandGroup::psc_frozen_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY
is_null[21]=val;
is_modified=true;
}
void Row_CommandGroup::psc_mod_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
is_null[22]=val;
is_modified=true;
}
void Row_CommandGroup::psc_restrict_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
is_null[23]=val;
is_modified=true;
......
......@@ -189,6 +189,7 @@ bool psc_id_isNull();
bool psc_batch_isNull();
bool psc_user_isNull();
bool psc_frozen_isNull();
bool psc_mod_isNull();
bool psc_restrict_isNull();
......@@ -208,6 +209,7 @@ void psc_id_setNull(bool val);
void psc_batch_setNull(bool val);
void psc_user_setNull(bool val);
void psc_frozen_setNull(bool val);
void psc_mod_setNull(bool val);
void psc_restrict_setNull(bool val);
......
......@@ -162,8 +162,7 @@ is_null[12] = true;
m_psc_user = 0;
m_psc_frozen = 0;
is_null[13] = false;
m_psc_mod = "0000-00-00 00:00:00";
is_null[14] = false;
is_null[14] = true;
is_null[15] = true;
m_psc_restrict = 0;
......@@ -312,6 +311,9 @@ return is_null[12];}
bool Row_Orbiter::psc_frozen_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[13];}
bool Row_Orbiter::psc_mod_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[14];}
bool Row_Orbiter::psc_restrict_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[15];}
......@@ -369,6 +371,10 @@ void Row_Orbiter::psc_frozen_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,t
is_null[13]=val;
is_modified=true;
}
void Row_Orbiter::psc_mod_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
is_null[14]=val;
is_modified=true;
}
void Row_Orbiter::psc_restrict_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
is_null[15]=val;
is_modified=true;
......
......@@ -162,6 +162,7 @@ bool psc_id_isNull();
bool psc_batch_isNull();
bool psc_user_isNull();
bool psc_frozen_isNull();
bool psc_mod_isNull();
bool psc_restrict_isNull();
......@@ -178,6 +179,7 @@ void psc_id_setNull(bool val);
void psc_batch_setNull(bool val);
void psc_user_setNull(bool val);
void psc_frozen_setNull(bool val);
void psc_mod_setNull(bool val);
void psc_restrict_setNull(bool val);
......
......@@ -142,8 +142,7 @@ is_null[1] = true;
m_FK_AlertType = 0;
m_EK_Device = 0;
is_null[2] = false;
m_DetectionTime = "0000-00-00 00:00:00";
is_null[3] = false;
is_null[3] = true;
is_null[4] = true;
is_null[5] = true;
m_ResetBeforeExpiration = 0;
......@@ -291,6 +290,9 @@ m_psc_restrict = val; is_modified=true; is_null[17]=false;}
bool Row_Alert::FK_AlertType_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[1];}
bool Row_Alert::DetectionTime_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[3];}
bool Row_Alert::ExpirationTime_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[4];}
......@@ -339,6 +341,10 @@ void Row_Alert::FK_AlertType_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,t
is_null[1]=val;
is_modified=true;
}
void Row_Alert::DetectionTime_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
is_null[3]=val;
is_modified=true;
}
void Row_Alert::ExpirationTime_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
is_null[4]=val;
is_modified=true;
......
......@@ -156,6 +156,7 @@ void psc_restrict_set(long int val);
bool FK_AlertType_isNull();
bool DetectionTime_isNull();
bool ExpirationTime_isNull();
bool ResetBeforeExpiration_isNull();
bool Benign_isNull();
......@@ -173,6 +174,7 @@ bool psc_restrict_isNull();
void FK_AlertType_setNull(bool val);
void DetectionTime_setNull(bool val);
void ExpirationTime_setNull(bool val);
void ResetBeforeExpiration_setNull(bool val);
void Benign_setNull(bool val);
......
......@@ -139,8 +139,7 @@ m_EK_HouseMode = 0;
is_null[1] = false;
is_null[2] = true;
m_EK_DeviceGroup = 0;
m_ChangeTime = "0000-00-00 00:00:00";
is_null[3] = false;
is_null[3] = true;
is_null[4] = true;
m_EK_Users = 0;
is_null[5] = true;
......@@ -234,6 +233,9 @@ m_psc_restrict = val; is_modified=true; is_null[10]=false;}
bool Row_ModeChange::EK_DeviceGroup_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[2];}
bool Row_ModeChange::ChangeTime_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[3];}
bool Row_ModeChange::EK_Users_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[4];}
......@@ -261,6 +263,10 @@ void Row_ModeChange::EK_DeviceGroup_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSON
is_null[2]=val;
is_modified=true;
}
void Row_ModeChange::ChangeTime_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
is_null[3]=val;
is_modified=true;
}
void Row_ModeChange::EK_Users_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
is_null[4]=val;
is_modified=true;
......
......@@ -135,6 +135,7 @@ void psc_restrict_set(long int val);
bool EK_DeviceGroup_isNull();
bool ChangeTime_isNull();
bool EK_Users_isNull();
bool psc_id_isNull();
bool psc_batch_isNull();
......@@ -145,6 +146,7 @@ bool psc_restrict_isNull();
void EK_DeviceGroup_setNull(bool val);
void ChangeTime_setNull(bool val);
void EK_Users_setNull(bool val);
void psc_id_setNull(bool val);
void psc_batch_setNull(bool val);
......
......@@ -138,8 +138,7 @@ void Row_Notification::SetDefaultValues()
is_null[0] = false;
m_FK_Alert = 0;
is_null[1] = false;
m_NotificationTime = "0000-00-00 00:00:00";
is_null[2] = false;
is_null[2] = true;
is_null[3] = true;
is_null[4] = true;
is_null[5] = true;
......@@ -230,6 +229,9 @@ void Row_Notification::psc_restrict_set(long int val){PLUTO_SAFETY_LOCK_ERRORSON
m_psc_restrict = val; is_modified=true; is_null[10]=false;}
bool Row_Notification::NotificationTime_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[2];}
bool Row_Notification::Info_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
return is_null[3];}
......@@ -256,6 +258,10 @@ bool Row_Notification::psc_restrict_isNull() {PLUTO_SAFETY_LOCK_ERRORSONLY(sl,ta
return is_null[10];}
void Row_Notification::NotificationTime_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
is_null[2]=val;
is_modified=true;
}
void Row_Notification::Info_setNull(bool val){PLUTO_SAFETY_LOCK_ERRORSONLY(sl,table->database->m_DBMutex);
is_null[3]=val;
is_modified=true;
......
......@@ -134,7 +134,8 @@ void psc_mod_set(string val);
void psc_restrict_set(long int val);
bool Info_isNull();
bool NotificationTime_isNull();
bool Info_isNull();
bool Result_isNull();
bool psc_id_isNull();
bool psc_batch_isNull();
......@@ -144,7 +145,8 @@ bool psc_mod_isNull();
bool psc_restrict_isNull();
void Info_setNull(bool val);
void NotificationTime_setNull(bool val);
void Info_setNull(bool val);
void Result_setNull(bool val);
void psc_id_setNull(bool val);
void psc_batch_setNull(bool val);
......
......@@ -1378,7 +1378,7 @@ void Database::Reset_all()
while ( row = mysql_fetch_row( result_set.r ) )
{
sql.str("");
sql << "UPDATE `" << pTable->Name_get() << "` SET psc_mod=0,psc_id=" << RowCount++ << " WHERE ";
sql << "UPDATE `" << pTable->Name_get() << "` SET psc_mod=NULL,psc_id=" << RowCount++ << " WHERE ";
int FieldCount=0;
bool bFirst=true;
for(ListField::iterator it=pTable->m_listField_PrimaryKey.begin();it!=pTable->m_listField_PrimaryKey.end();++it)
......@@ -1753,7 +1753,7 @@ void Database::ListBatchContents()
if( atoi(row2[1])==toc_Delete && strcmp(result_set2.r->fields[iField].name,"psc_id")!=0 )
continue;
if( strcmp(result_set2.r->fields[iField].name,"psc_batch")==0 ||
strcmp(result_set2.r->fields[iField].name,"psc_mod")==0 ||
// strcmp(result_set2.r->fields[iField].name,"psc_mod")==0 ||
strcmp(result_set2.r->fields[iField].name,"psc_toc")==0 )
continue;
......
......@@ -931,13 +931,7 @@ void Repository::ImportTable(string sTableName,SerializeableStrings &str,size_t
string sDefault = str.m_vectString[pos++];
string sExtra = str.m_vectString[pos++];
// don't add a psc_mod field that has the default set to NULL
// a psc_mod defaulting to NULL didn't exist in the original table to begin with
// seems to be a bug in the dumping algorithm, but it's earier to hack it in than to fix it :D
if (sField == "psc_mod" && sDefault == NULL_TOKEN)
sDefault = "";
// Don't allow defaulting to NULL and importing with NULL as not allowed. This worked in 0710, but not in 0804
// Don't allow defaulting to NULL when importing with NULL as not allowed. This worked in 0710, but not in 0804
if( sNULL!="YES" && sDefault == NULL_TOKEN )
sDefault = "";
......@@ -955,8 +949,12 @@ void Repository::ImportTable(string sTableName,SerializeableStrings &str,size_t
sSQL << ", ";
if( sIndex=="PRI" )
sPrimaryKey += ( sPrimaryKey.length( ) ? "," : "" ) + string( "`" ) + sField + "`";
sSQL << "`" << sField << "` " << sType
<< ( sNULL!="YES" ? " NOT NULL " : "" );
sSQL << "`" << sField << "` " << sType;
if ( sField=="psc_mod" )
sSQL << " NULL ";
else
sSQL << ( sNULL!="YES" ? " NOT NULL " : "" );
if( sDefault.length( ) )
{
string sQuotedDefault;
......@@ -971,6 +969,14 @@ void Repository::ImportTable(string sTableName,SerializeableStrings &str,size_t
sSQL << " default " << ( sDefault==NULL_TOKEN ? "NULL" : sQuotedDefault );
}
// need to ensure that NOT NULL varchar fields have a default or db import will fail.
else
{
if( sNULL!="YES" && sType.find("varchar")!=string::npos )
{
sSQL << " default ''";
}
}
sSQL << " " << sExtra;
}
if( sPrimaryKey.length( ) )
......@@ -1173,6 +1179,8 @@ int k=2;
sSQL << ",";
string Value = str.m_vectString[pos++];
if ( *it == "psc_mod" )
Value = NULL_TOKEN;
if( bUpdate )
sSQL << " `" << *it << "`=";
......
This diff is collapsed.
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