Branch: Tag:

2014-11-15

2014-11-15 00:59:42 by Stephen R. van den Berg <srb@cuci.nl>

pgsql: Properly terminate the connection if the database does not exist.

113:    string res=UNDEFINED;    switch(type) {    case 'O': -  res=sprintf(DRIVERNAME"(%s@%s:%d/%s,%d)", -  user,_host,_port,database,backendpid); +  res=sprintf(DRIVERNAME"(%s@%s:%d/%s,%d,%d)", +  user,_host,_port,database,c?->socket?->query_fd(),backendpid);    break;    }    return res;
343:   //! @[get_charset()], @[create()],   //! @url{http://www.postgresql.org/search/?u=%2Fdocs%2Fcurrent%2F&q=character+sets@}   void set_charset(string charset) { +  if(charset)    big_query(sprintf("SET CLIENT_ENCODING TO '%s'",quote(charset)));   }   
588:      private void waitauthready() {    if(waitforauthready) { -  PD("Wait for auth ready %O\n",backtrace()[-2]); +  PD("%d Wait for auth ready %O\n",c?->socket?->query_fd(),backtrace()[-2]);    Thread.MutexKey lock=waitforauth->lock();    catch(waitforauthready->wait(lock));    lock=0; -  PD("Wait for auth ready released.\n"); +  PD("%d Wait for auth ready released.\n",c?->socket?->query_fd());    }   }   
630: Inside #if defined(PG_DEBUG)
      void showportal(int msgtype) {    if(objectp(portal)) -  PD("<%O %d %c switch portal\n", -  portal._portalname,++ci->queueinidx,msgtype); +  PD("%d<%O %d %c switch portal\n", +  ci->socket->query_fd(),portal._portalname,++ci->queueinidx,msgtype);    else if(portal>0) -  PD("<Sync %d %d %c portal\n",++ci->queueinidx,portal,msgtype); +  PD("%d<Sync %d %d %c portal\n", +  ci->socket->query_fd(),++ci->queueinidx,portal,msgtype);    };   #endif    for(;;) {
660:    protocolunsupported    };    errortype errtype=noerror; +  PD("%d",ci->socket->query_fd());    switch(msgtype) {    array(mapping) getcols() {    int bintext=ci->read_int8();
1119:    +({pinpointerror(portal._query,msgresponse.P)})    +showbindings(portal)));    case "53000":case "53100":case "53200":case "53300":case "53400": -  case "57P01":case "57P02":case "57P03": +  case "57P01":case "57P02":case "57P03":case "57P04":case "3D000":    preplastmessage(msgresponse);    PD(a2nls(lastmessage));throw(0);    case "08P01":case "42P05":
1269:   //! This function is PostgreSQL-specific, and thus it is not available   //! through the generic SQL-interface.   void close() { -  cancelquery(); -  if(c) -  c->sendterminate(); +  catch(cancelquery()); +  catch(c->sendterminate());    c=0; -  +  if(waitforauthready) +  destruct(waitforauthready);   }      protected void destroy() { -  close(); +  catch(close());    .pgsql_util.unregister_backend();   }      void _connectfail(void|mixed err) {    PD("Connect failed %O reconnectdelay %d\n",err,reconnectdelay); -  +  catch {    if(waitforauthready)    destruct(waitforauthready); -  +  };    if(!err || reconnectdelay) {    int tdelay;    switch(tdelay=reconnectdelay) {
1419:    ERROR(a2nls(lastmessage));    err = catch {    PD("Portalsinflight: %d\n",_portalsinflight); +  if(!waitforauthready) {    readyforquery_cb=resync_cb;    sendsync(); -  +  }    return;    };    PD("%O\n",err);