Branch: Tag:

2014-07-24

2014-07-24 09:53:27 by 0

Increase maximum URL length in <insert#cached-href> from 256 to 768 bytes.

303:      /* This class represents the database in which the data of the URL:s are stored */   class HrefDatabase { -  private constant request_table_def = "url VARCHAR(255) NOT NULL," +  private constant request_table_def = "url VARCHAR(768) NOT NULL,"    "fetch_interval INT UNSIGNED NOT NULL,"    "fresh_time INT UNSIGNED NOT NULL,"    "ttl INT UNSIGNED NOT NULL,"
315:    "PRIMARY KEY (url, fetch_interval, "    "fresh_time, ttl, timeout, time_of_day)";    -  private constant data_table_def = "url VARCHAR(255) NOT NULL," +  private constant data_table_def = "url VARCHAR(768) NOT NULL,"    "data LONGBLOB,"    "latest_write INT UNSIGNED,"    "PRIMARY KEY (url)";
335:    sql_query("ALTER TABLE " + request_table + " ADD COLUMN out_of_date INT UNSIGNED;");    sql_query("ALTER TABLE " + request_table + " ADD INDEX " + request_table + "(out_of_date);");    } +  +  // Upgrade url field to hold longer strings. We must still respect a +  // limit of the PRIMARY KEY on 1000 bytes, so 768 is a good amount. +  if (request_table) { +  array(mapping) tbl_def = sql_query("DESCRIBE " + request_table + " url"); +  if (sizeof(tbl_def) && lower_case(tbl_def[0]->Type) != "varchar(768)") +  sql_query("ALTER TABLE " + request_table + +  " MODIFY url VARCHAR(768) NOT NULL");    } -  +  if (data_table) { +  array(mapping) tbl_def = sql_query("DESCRIBE " + data_table + " url"); +  if (sizeof(tbl_def) && lower_case(tbl_def[0]->Type) != "varchar(768)") +  sql_query("ALTER TABLE " + data_table + +  " MODIFY url VARCHAR(768) NOT NULL"); +  } +  }       public void empty_db() {    /*