diff --git a/sql/swad.sql b/sql/swad.sql index 67dccb709..06d208a12 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -596,8 +596,8 @@ CREATE TABLE IF NOT EXISTS institutions ( CtyCod INT NOT NULL, Status TINYINT NOT NULL DEFAULT 0, RequesterUsrCod INT NOT NULL DEFAULT -1, - ShortName VARCHAR(32) NOT NULL, - FullName TEXT NOT NULL, + ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL, + FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL, WWW VARCHAR(255) NOT NULL, UNIQUE INDEX(InsCod), INDEX(CtyCod), diff --git a/swad_changelog.h b/swad_changelog.h index 93532df4c..23d24f30d 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -207,13 +207,18 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.155.13 (2017-03-12)" +#define Log_PLATFORM_VERSION "SWAD 16.155.14 (2017-03-12)" #define CSS_FILE "swad16.147.css" #define JS_FILE "swad16.144.js" // Number of lines (includes comments but not blank lines) has been got with the following command: // nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*?.h sql/swad*.sql | tail -1 /* + Version 16.155.14:Mar 11, 2017 Adjusting size of database fields. (? lines) + 2 changes necessary in database: +ALTER TABLE institutions CHANGE COLUMN ShortName ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL; +ALTER TABLE institutions CHANGE COLUMN FullName FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL; + Version 16.155.13:Mar 11, 2017 Adjusting size of database fields. (216734 lines) 1 change necessary in database: ALTER TABLE holidays CHANGE COLUMN Name Name VARCHAR(2047) NOT NULL; diff --git a/swad_database.c b/swad_database.c index 8c407b4ac..c96f2529e 100644 --- a/swad_database.c +++ b/swad_database.c @@ -1283,30 +1283,30 @@ mysql> DESCRIBE holidays; /***** Table institutions *****/ /* mysql> DESCRIBE institutions; -+-----------------+--------------+------+-----+---------+----------------+ -| Field | Type | Null | Key | Default | Extra | -+-----------------+--------------+------+-----+---------+----------------+ -| InsCod | int(11) | NO | PRI | NULL | auto_increment | -| CtyCod | int(11) | NO | MUL | NULL | | -| Status | tinyint(4) | NO | MUL | 0 | | -| RequesterUsrCod | int(11) | NO | | -1 | | -| ShortName | varchar(32) | NO | | NULL | | -| FullName | text | NO | | NULL | | -| WWW | varchar(255) | NO | | NULL | | -+-----------------+--------------+------+-----+---------+----------------+ -7 rows in set (0.00 sec) ++-----------------+---------------+------+-----+---------+----------------+ +| Field | Type | Null | Key | Default | Extra | ++-----------------+---------------+------+-----+---------+----------------+ +| InsCod | int(11) | NO | PRI | NULL | auto_increment | +| CtyCod | int(11) | NO | MUL | NULL | | +| Status | tinyint(4) | NO | MUL | 0 | | +| RequesterUsrCod | int(11) | NO | | -1 | | +| ShortName | varchar(511) | NO | | NULL | | +| FullName | varchar(2047) | NO | | NULL | | +| WWW | varchar(255) | NO | | NULL | | ++-----------------+---------------+------+-----+---------+----------------+ +7 rows in set (0,00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS institutions (" - "InsCod INT NOT NULL AUTO_INCREMENT," - "CtyCod INT NOT NULL," - "Status TINYINT NOT NULL DEFAULT 0," - "RequesterUsrCod INT NOT NULL DEFAULT -1," - "ShortName VARCHAR(32) NOT NULL," - "FullName TEXT NOT NULL," - "WWW VARCHAR(255) NOT NULL," - "UNIQUE INDEX(InsCod)," - "INDEX(CtyCod)," - "INDEX(Status))"); + "InsCod INT NOT NULL AUTO_INCREMENT," + "CtyCod INT NOT NULL," + "Status TINYINT NOT NULL DEFAULT 0," + "RequesterUsrCod INT NOT NULL DEFAULT -1," + "ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL," // Hie_MAX_BYTES_SHRT_NAME + "FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL," // Hie_MAX_BYTES_FULL_NAME + "WWW VARCHAR(255) NOT NULL," // Cns_MAX_BYTES_WWW + "UNIQUE INDEX(InsCod)," + "INDEX(CtyCod)," + "INDEX(Status))"); /***** Table links *****/ /* diff --git a/swad_institution.c b/swad_institution.c index 0d75b1d2e..2aa967eb5 100644 --- a/swad_institution.c +++ b/swad_institution.c @@ -1209,8 +1209,7 @@ void Ins_GetShortNameOfInstitutionByCod (struct Instit *Ins) if (Ins->InsCod != Cached.InsCod) // If not cached... { /***** Get the short name of an institution from database *****/ - sprintf (Query,"SELECT ShortName FROM institutions" - " WHERE InsCod ='%ld'", + sprintf (Query,"SELECT ShortName FROM institutions WHERE InsCod='%ld'", Ins->InsCod); if (DB_QuerySELECT (Query,&mysql_res,"can not get the short name of an institution") == 1) { @@ -1240,7 +1239,7 @@ static void Ins_GetFullNameAndCtyOfInstitutionByCod (struct Instit *Ins, char CtyName[Hie_MAX_BYTES_FULL_NAME + 1]) { extern const char *Txt_STR_LANG_ID[1 + Txt_NUM_LANGUAGES]; - char Query[256]; + char Query[512]; MYSQL_RES *mysql_res; MYSQL_ROW row; static struct @@ -1267,7 +1266,7 @@ static void Ins_GetFullNameAndCtyOfInstitutionByCod (struct Instit *Ins, /***** Get the short name of an institution from database *****/ sprintf (Query,"SELECT institutions.FullName,countries.Name_%s" " FROM institutions,countries" - " WHERE institutions.InsCod ='%ld'" + " WHERE institutions.InsCod='%ld'" " AND institutions.CtyCod=countries.CtyCod", Txt_STR_LANG_ID[Gbl.Prefs.Language],Ins->InsCod); if (DB_QuerySELECT (Query,&mysql_res,"can not get the full name of an institution") == 1) @@ -2018,7 +2017,7 @@ void Ins_ChangeInsWWWInConfig (void) static void Ins_UpdateInsWWWDB (long InsCod,const char NewWWW[Cns_MAX_BYTES_WWW + 1]) { - char Query[256 + Cns_MAX_BYTES_WWW]; + char Query[128 + Cns_MAX_BYTES_WWW]; /***** Update database changing old WWW by new WWW *****/ sprintf (Query,"UPDATE institutions SET WWW='%s' WHERE InsCod='%ld'", @@ -2034,7 +2033,7 @@ void Ins_ChangeInsStatus (void) { extern const char *Txt_The_status_of_the_institution_X_has_changed; struct Instit *Ins; - char Query[256]; + char Query[128]; Ins_Status_t Status; Ins_StatusTxt_t StatusTxt; @@ -2443,8 +2442,8 @@ unsigned Ins_GetNumInssInCty (long CtyCod) char Query[128]; /***** Get number of degrees of a place from database *****/ - sprintf (Query,"SELECT COUNT(*) FROM institutions" - " WHERE CtyCod='%ld'",CtyCod); + sprintf (Query,"SELECT COUNT(*) FROM institutions WHERE CtyCod='%ld'", + CtyCod); return (unsigned) DB_QueryCOUNT (Query,"can not get the number of institutions in a country"); } @@ -2505,7 +2504,7 @@ unsigned Ins_GetNumInssWithCrss (const char *SubQuery) unsigned Ins_GetNumInssWithUsrs (Rol_Role_t Role,const char *SubQuery) { - char Query[512]; + char Query[1024]; /***** Get number of institutions with users from database *****/ sprintf (Query,"SELECT COUNT(DISTINCT institutions.InsCod)"