pike.git / lib / modules / Search.pmod / Queue.pmod / MySQL.pike

version» Context lines:

pike.git/lib/modules/Search.pmod/Queue.pmod/MySQL.pike:27:    stats = _stats; policy = _policy;    allow=_allow; deny=_deny;    table = _table;       db = Sql.Sql( _url );    perhaps_create_table( );   }      static void perhaps_create_table( )   { -  catch { +     db->query(   #" -  create table "+table+#" ( +  create table IF NOT EXISTS "+table+#" (    uri blob not null,    uri_md5 char(32) not null default '',    template varchar(255) not null default '',    md5 char(32) not null default '',    recurse tinyint not null,    stage tinyint not null, -  INDEX uri_ind (uri_md5), +  UNIQUE(uri_md5),    INDEX stage (stage)    ) -  " -  ); -  }; +  ");   }      mapping hascache = ([]);   static int has_uri( string|Standards.URI uri )   {    uri = (string)uri;    if( sizeof(hascache) > 100000 ) hascache = ([]);    return hascache[uri]||    (hascache[uri]=    sizeof(db->query("select stage from "+table+" where uri_md5=%s",
pike.git/lib/modules/Search.pmod/Queue.pmod/MySQL.pike:73:    // Remove any trailing index filename       string rpath=reverse(r->path);    // FIXME: Make these configurable?    foreach( ({"index.xml", "index.html", "index.htm"}),    string index)    if(search(rpath,reverse(index))==0)    rpath=rpath[sizeof(index)..];    r->path=reverse(rpath);    -  if( force || (check_link(uri, allow, deny) && !has_uri( r ) )) +  if( (force || (check_link(uri, allow, deny))) && !has_uri( r ) ) +  { +  mixed err = catch(    db->query( "insert into "+table+    " (uri,uri_md5,recurse,template) values (%s,%s,%d,%s)",    string_to_utf8((string)r), -  to_md5((string)r), recurse, (template||"") ); +  to_md5((string)r), recurse, (template||"") ) ); +  if(err) +  { +  werror("Error inserting %s into queue.\n", (string)r); +  werror("hascache: %O\n", hascache); +  throw(err);    } -  +  } + }      void set_md5( Standards.URI uri, string md5 )   {    db->query( "update "+table+    " set md5=%s WHERE uri_md5=%s", md5, to_md5((string)uri) );   }      mapping(string:mapping(string:string)) extra_data = ([]);   mapping get_extra( Standards.URI uri )   {
pike.git/lib/modules/Search.pmod/Queue.pmod/MySQL.pike:185:    int called )   {    if( called )    set_stage( uri, 2 );    else    set_stage( uri, 5 );   }      void clear()   { +  hascache = ([ ]);    db->query("delete from "+table);   }         void clear_stage( int ... stages )   {    foreach( stages, int s )    db->query( "update "+table+" set stage=0 where stage=%d", s );   }