diff --git a/sql/swad.sql b/sql/swad.sql index 589e35064..768299a25 100644 --- a/sql/swad.sql +++ b/sql/swad.sql @@ -403,8 +403,8 @@ CREATE TABLE IF NOT EXISTS degrees ( DegTypCod INT NOT NULL, Status TINYINT NOT NULL DEFAULT 0, RequesterUsrCod INT NOT NULL DEFAULT -1, - ShortName VARCHAR(32) NOT NULL, - FullName VARCHAR(127) 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(DegCod), INDEX(CtrCod), diff --git a/swad_changelog.h b/swad_changelog.h index 73a5e3cf8..4278d755e 100644 --- a/swad_changelog.h +++ b/swad_changelog.h @@ -207,13 +207,18 @@ /****************************** Public constants *****************************/ /*****************************************************************************/ -#define Log_PLATFORM_VERSION "SWAD 16.155.7 (2017-03-11)" +#define Log_PLATFORM_VERSION "SWAD 16.155.8 (2017-03-11)" #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.8: Mar 11, 2017 Adjusting size of database fields. (216684 lines) + 2 changes necessary in database: +ALTER TABLE degrees CHANGE COLUMN ShortName ShortName VARCHAR(511) COLLATE latin1_spanish_ci NOT NULL; +ALTER TABLE degrees CHANGE COLUMN FullName FullName VARCHAR(2047) COLLATE latin1_spanish_ci NOT NULL; + Version 16.155.7: Mar 11, 2017 Adjusting size of database fields. (216682 lines) 1 change necessary in database: ALTER TABLE deg_types CHANGE COLUMN DegTypName DegTypName VARCHAR(511) NOT NULL; diff --git a/swad_constant.h b/swad_constant.h index da17eed03..e8c7fd036 100644 --- a/swad_constant.h +++ b/swad_constant.h @@ -37,9 +37,9 @@ #define Cns_MAX_BYTES_WWW Cns_MAX_CHARS_WWW // 255 #define Cns_MAX_CHARS_IP (3 + 1 + 3 + 1 + 3 + 1 + 3) // 15: max. number of chars of an IP address - // Example: 255.255.255.255 - // 3+1+3+1+3+1+3 - // 123456789012345 + // Example: 255.255.255.255 + // 3+1+3+1+3+1+3 + // 123456789012345 #define Cns_MAX_BYTES_IP Cns_MAX_CHARS_IP // 15 #define Cns_MAX_CHARS_DATE (4 + 1 + 2 + 1 + 2) diff --git a/swad_database.c b/swad_database.c index b1490f0ff..8bfdcc605 100644 --- a/swad_database.c +++ b/swad_database.c @@ -887,33 +887,33 @@ mysql> DESCRIBE deg_types; /***** Table degrees *****/ /* mysql> DESCRIBE degrees; -+-----------------+--------------+------+-----+---------+----------------+ -| Field | Type | Null | Key | Default | Extra | -+-----------------+--------------+------+-----+---------+----------------+ -| DegCod | int(11) | NO | PRI | NULL | auto_increment | -| CtrCod | int(11) | NO | MUL | NULL | | -| DegTypCod | int(11) | NO | MUL | NULL | | -| Status | tinyint(4) | NO | MUL | 0 | | -| RequesterUsrCod | int(11) | NO | | -1 | | -| ShortName | varchar(32) | NO | | NULL | | -| FullName | varchar(127) | NO | | NULL | | -| WWW | varchar(255) | NO | | NULL | | -+-----------------+--------------+------+-----+---------+----------------+ -8 rows in set (0.00 sec) ++-----------------+---------------+------+-----+---------+----------------+ +| Field | Type | Null | Key | Default | Extra | ++-----------------+---------------+------+-----+---------+----------------+ +| DegCod | int(11) | NO | PRI | NULL | auto_increment | +| CtrCod | int(11) | NO | MUL | NULL | | +| DegTypCod | 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 | | ++-----------------+---------------+------+-----+---------+----------------+ +8 rows in set (0,00 sec) */ DB_CreateTable ("CREATE TABLE IF NOT EXISTS degrees (" - "DegCod INT NOT NULL AUTO_INCREMENT," - "CtrCod INT NOT NULL," - "DegTypCod INT NOT NULL," - "Status TINYINT NOT NULL DEFAULT 0," - "RequesterUsrCod INT NOT NULL DEFAULT -1," - "ShortName VARCHAR(32) NOT NULL," - "FullName VARCHAR(127) NOT NULL," - "WWW VARCHAR(255) NOT NULL," - "UNIQUE INDEX(DegCod)," - "INDEX(CtrCod)," - "INDEX(DegTypCod)," - "INDEX(Status))"); + "DegCod INT NOT NULL AUTO_INCREMENT," + "CtrCod INT NOT NULL," + "DegTypCod 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(DegCod)," + "INDEX(CtrCod)," + "INDEX(DegTypCod)," + "INDEX(Status))"); /***** Table departments *****/ /* diff --git a/swad_degree.c b/swad_degree.c index 20d3039a9..78dcb45e9 100644 --- a/swad_degree.c +++ b/swad_degree.c @@ -591,7 +591,7 @@ static void Deg_PutIconsToPrintAndUpload (void) void Deg_WriteSelectorOfDegree (void) { extern const char *Txt_Degree; - char Query[512]; + char Query[256]; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned NumDegs; @@ -617,8 +617,7 @@ void Deg_WriteSelectorOfDegree (void) { /***** Get degrees belonging to the current centre from database *****/ sprintf (Query,"SELECT DegCod,ShortName FROM degrees" - " WHERE CtrCod='%ld'" - " ORDER BY ShortName", + " WHERE CtrCod='%ld' ORDER BY ShortName", Gbl.CurrentCtr.Ctr.CtrCod); NumDegs = (unsigned) DB_QuerySELECT (Query,&mysql_res,"can not get degrees of a centre"); @@ -1454,7 +1453,7 @@ void Deg_GetListAllDegsWithStds (struct ListDegrees *Degs) void Deg_GetListDegsOfCurrentCtr (void) { - char Query[512]; + char Query[256]; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned long NumRows; @@ -1666,7 +1665,7 @@ long Deg_GetAndCheckParamOtherDegCod (void) bool Deg_GetDataOfDegreeByCod (struct Degree *Deg) { - char Query[1024]; + char Query[256]; MYSQL_RES *mysql_res; MYSQL_ROW row; bool DegFound = false; @@ -1748,7 +1747,7 @@ static void Deg_GetDataOfDegreeFromRow (struct Degree *Deg,MYSQL_ROW row) void Deg_GetShortNameOfDegreeByCod (struct Degree *Deg) { - char Query[512]; + char Query[128]; MYSQL_RES *mysql_res; MYSQL_ROW row; @@ -1756,8 +1755,7 @@ void Deg_GetShortNameOfDegreeByCod (struct Degree *Deg) if (Deg->DegCod > 0) { /***** Get the short name of a degree from database *****/ - sprintf (Query,"SELECT ShortName FROM degrees" - " WHERE DegCod ='%ld'", + sprintf (Query,"SELECT ShortName FROM degrees WHERE DegCod ='%ld'", Deg->DegCod); if (DB_QuerySELECT (Query,&mysql_res,"can not get the short name of a degree") == 1) { @@ -1818,7 +1816,8 @@ long Deg_GetInsCodOfDegreeByCod (long DegCod) { /***** Get the institution code of a degree from database *****/ sprintf (Query,"SELECT centres.InsCod FROM degrees,centres" - " WHERE degrees.DegCod='%ld' AND degrees.CtrCod=centres.CtrCod", + " WHERE degrees.DegCod='%ld'" + " AND degrees.CtrCod=centres.CtrCod", DegCod); if (DB_QuerySELECT (Query,&mysql_res,"can not get the institution of a degree") == 1) { @@ -1841,7 +1840,7 @@ long Deg_GetInsCodOfDegreeByCod (long DegCod) void Deg_RemoveDegreeCompletely (long DegCod) { extern const char *Sco_ScopeDB[Sco_NUM_SCOPES]; - char Query[512]; + char Query[128]; MYSQL_RES *mysql_res; MYSQL_ROW row; unsigned long NumRow,NumRows; @@ -1849,8 +1848,8 @@ void Deg_RemoveDegreeCompletely (long DegCod) char PathDeg[PATH_MAX + 1]; /***** Get courses of a degree from database *****/ - sprintf (Query,"SELECT CrsCod FROM courses" - " WHERE DegCod='%ld'",DegCod); + sprintf (Query,"SELECT CrsCod FROM courses WHERE DegCod='%ld'", + DegCod); NumRows = DB_QuerySELECT (Query,&mysql_res,"can not get courses of a degree"); /* Get courses in this degree */ @@ -2214,7 +2213,7 @@ void Deg_ChangeDegStatus (void) { extern const char *Txt_The_status_of_the_degree_X_has_changed; struct Degree *Deg; - char Query[256]; + char Query[128]; Deg_Status_t Status; Deg_StatusTxt_t StatusTxt; @@ -2333,7 +2332,7 @@ void Deg_RemoveLogo (void) unsigned Deg_GetNumDegsTotal (void) { - char Query[256]; + char Query[128]; /***** Get total number of degrees from database *****/ sprintf (Query,"SELECT COUNT(*) FROM degrees"); @@ -2379,11 +2378,10 @@ unsigned Deg_GetNumDegsInIns (long InsCod) unsigned Deg_GetNumDegsInCtr (long CtrCod) { - char Query[512]; + char Query[128]; /***** Get number of degrees in a centre from database *****/ - sprintf (Query,"SELECT COUNT(*) FROM degrees" - " WHERE CtrCod='%ld'", + sprintf (Query,"SELECT COUNT(*) FROM degrees WHERE CtrCod='%ld'", CtrCod); return (unsigned) DB_QueryCOUNT (Query,"can not get the number of degrees in a centre"); } diff --git a/swad_degree.h b/swad_degree.h index f5b2c882c..c0d3015dd 100644 --- a/swad_degree.h +++ b/swad_degree.h @@ -66,15 +66,15 @@ typedef enum struct Degree { - long DegTypCod; // Degree type code - long DegCod; // Degree code - long CtrCod; // Centre code - Deg_Status_t Status; // Degree status - long RequesterUsrCod; // User code of the person who requested the creation of this degree + long DegTypCod; // Degree type code + long DegCod; // Degree code + long CtrCod; // Centre code + Deg_Status_t Status; // Degree status + long RequesterUsrCod; // User code of the person who requested the creation of this degree char ShrtName[Hie_MAX_BYTES_SHRT_NAME + 1]; // Short name of degree char FullName[Hie_MAX_BYTES_FULL_NAME + 1]; // Full name of degree char WWW[Cns_MAX_BYTES_WWW + 1]; - struct Course *LstCrss; // List of courses in this degree + struct Course *LstCrss; // List of courses in this degree }; struct ListDegrees