Branch: Tag:

2017-06-18

2017-06-18 18:07:42 by Stephen R. van den Berg <srb@cuci.nl>

pgsql: Move sync point before parsing, to avoid race.

66:   private Thread.Mutex unnamedstatement;   private Thread.MutexKey termlock;   final int _portalsinflight; + final int _wasparallelisable;      private .pgsql_util.conxion c;   private string cancelsecret;
1302:    unnamedstatement=Thread.Mutex();    readyforquery_cb=recon?reconnect_cb:connect_cb;    _portalsinflight=0; +  _wasparallelisable = 0;    return 1;   }   
1888:    }    }    if(forcecache!=1 && .pgsql_util.createprefix->match(q)) { +  PD("Invalidate cache\n");    invalidatecache=1; // Flush cache on CREATE    tp=UNDEFINED;    } else
1919:    if(forcetext) { // FIXME What happens if portals are still open?    portal._unnamedportalkey=_unnamedportalmux->lock(1);    portal._portalname=""; -  portal->_openportal(); +  portal->_parseportal(); portal->_bindportal();    _readyforquerycount++;    Thread.MutexKey lock=unnamedstatement->lock(1);    .pgsql_util.conxsess cs = c->start(1);
1929:    PD("Simple query: %O\n",q);    } else {    object plugbuffer; +  portal->_parseportal();    if(!sizeof(preparedname) || !tp || !tp.preparedname) {    if(!sizeof(preparedname))    preparedname= -  (portal._unnamedstatementkey = -  (syncparse ? unnamedstatement->lock : unnamedstatement->trylock)(1)) +  (portal._unnamedstatementkey = unnamedstatement->trylock(1))    ? "" : PTSTMTPREFIX+int2hex(ptstmtcount++);    PD("Parse statement %O=%O\n",preparedname,q);    plugbuffer = c->start();