/adei/trunk

To get this branch, use:
bzr branch http://darksoft.org/webbzr/adei/trunk

« back to all changes in this revision

Viewing changes to classes/cache/cachedb.php

  • Committer: Suren A. Chilingaryan
  • Date: 2020-02-25 12:31:09 UTC
  • Revision ID: csa@suren.me-20200225123109-pkjghsau3zgepk03
Fix creating new cache tables because of DetectSubseconds failure on the non existing table

Show diffs side-by-side

added added

removed removed

Lines of Context:
1094
1094
    }
1095
1095
*/
1096
1096
 
1097
 
    if (($resolution)||(!$this->DetectSubseconds($postfix)))
1098
 
        $req = "SELECT EXTENDED_UNIX_TIMESTAMP(MIN(time)) AS first, EXTENDED_UNIX_TIMESTAMP(MAX(time)) AS last${extra} FROM `$table`";
1099
 
    else {
1100
 
            // Querying 'ns' like this would be significantly slower
1101
 
        //$req = "ADEI_TIMESTAMP(EXTENDED_UNIX_TIMESTAMP(MIN(time)),ns) AS first, ADEI_TIMESTAMP(EXTENDED_UNIX_TIMESTAMP(MAX(time)),ns) AS last";
1102
 
        $req = "SELECT (SELECT ADEI_TIMESTAMP(EXTENDED_UNIX_TIMESTAMP(time),ns)/1000000000 FROM `$table` ORDER BY id LIMIT 1) as first, (SELECT ADEI_TIMESTAMP(EXTENDED_UNIX_TIMESTAMP(time),ns)/1000000000 FROM `$table` ORDER BY id DESC LIMIT 1) as last${extra}";
 
1097
    $req = "SELECT EXTENDED_UNIX_TIMESTAMP(MIN(time)) AS first, EXTENDED_UNIX_TIMESTAMP(MAX(time)) AS last${extra} FROM `$table`";
 
1098
    try {
 
1099
        // DetectSubseconds will fail if caching table is not present yet. However, we would not refer to it during the caching process. Only Admin interface uses PREFER_EXACTINFO at the moment
 
1100
        if ((!$resolution)&&($flags&REQUEST::PREFER_EXACTINFO)) {
 
1101
                // In fact there could be difference between configuration & already existing caching tables. The best thing we can do is to fail with the error. If this gets a repeated problem, we will need to provide both values to the Admin interface
 
1102
            if (($postfix)||(!isset($this->use_subseconds)))
 
1103
                $use_subseconds = $this->DetectSubseconds($postfix);
 
1104
            else
 
1105
                $use_subseconds = $this->use_subseconds;
 
1106
                
 
1107
                // Querying 'ns' like this would be significantly slower
 
1108
            if ($use_subseconds)
 
1109
                $req = "SELECT (SELECT ADEI_TIMESTAMP(EXTENDED_UNIX_TIMESTAMP(time),ns)/1000000000 FROM `$table` ORDER BY id LIMIT 1) as first, (SELECT ADEI_TIMESTAMP(EXTENDED_UNIX_TIMESTAMP(time),ns)/1000000000 FROM `$table` ORDER BY id DESC LIMIT 1) as last${extra}";
 
1110
        }
 
1111
    } catch (ADEIException $ae) {
 
1112
        // Just use non-subsecond version in this case
1103
1113
    }
1104
1114
        
1105
1115
    $res = mysql_query($req, $this->dbh);