pike.git / lib / modules / Sql.pmod / pgsql.pike

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:642:    int msgtype=ci->read_int8();    if(!portal) {    portal=qportals->try_read();   #ifdef PG_DEBUG    showportal(msgtype);   #endif    }    int msglen=ci->read_int32();    _msgsreceived++;    _bytesreceived+=1+msglen; -  enum errortype { -  noerror=0, -  protocolerror, -  protocolunsupported -  }; -  errortype errtype=noerror; +  int errtype=NOERROR;    PD("%d",ci->socket->query_fd());    switch(msgtype) {    array(mapping) getcols() {    int bintext=ci->read_int8();    int cols=ci->read_int16();   #ifdef PG_DEBUG    array a;    msglen-=4+1+2+2*cols;    foreach(a=allocate(cols,([]));;mapping m)    m.type=ci->read_int16();   #else    ci->consume(cols<<1);   #endif // Discard column info, and make it line oriented    return ({(["type":bintext?BYTEAOID:TEXTOID,"name":"line"])});    };    array(string) reads() {   #ifdef PG_DEBUG    if(msglen<1) -  errtype=protocolerror; +  errtype=PROTOCOLERROR;   #endif    array ret=({}),aw=({0});    do {    string w=ci->read_cstring();    msglen-=sizeof(w)+1; aw[0]=w; ret+=aw;    } while(msglen);    return ret;    };    mapping(string:string) getresponse() {    mapping(string:string) msgresponse=([]);
pike.git/lib/modules/Sql.pmod/pgsql.pike:700:    case 0:    PD("Ok\n");    .pgsql_util.local_backend->remove_call_out(reconnect);    ci->gottimeout=cancelquery;    ci->timeout=timeout;    reconnectdelay=0;    cancelsecret="";    break;    case 2:    PD("KerberosV5\n"); -  errtype=protocolunsupported; +  errtype=PROTOCOLUNSUPPORTED;    break;    case 3:    PD("ClearTextPassword\n");    sendpass=pass;    break;    case 4:    PD("CryptPassword\n"); -  errtype=protocolunsupported; +  errtype=PROTOCOLUNSUPPORTED;    break;    case 5:    PD("MD5Password\n");   #ifdef PG_DEBUG    if(msglen<4) -  errtype=protocolerror; +  errtype=PROTOCOLERROR;   #endif   #define md5hex(x) String.string2hex(Crypto.MD5.hash(x))    sendpass=md5hex(pass+user);    sendpass="md5"+md5hex(sendpass+ci->read(msglen));   #ifdef PG_DEBUG    msglen=0;   #endif    break;    case 6:    PD("SCMCredential\n"); -  errtype=protocolunsupported; +  errtype=PROTOCOLUNSUPPORTED;    break;    case 7:    PD("GSS\n"); -  errtype=protocolunsupported; +  errtype=PROTOCOLUNSUPPORTED;    break;    case 9:    PD("SSPI\n"); -  errtype=protocolunsupported; +  errtype=PROTOCOLUNSUPPORTED;    break;    case 8:    PD("GSSContinue\n"); -  errtype=protocolunsupported; +  errtype=PROTOCOLUNSUPPORTED;    cancelsecret=ci->read(msglen); // Actually SSauthdata   #ifdef PG_DEBUG    if(msglen<1) -  errtype=protocolerror; +  errtype=PROTOCOLERROR;    msglen=0;   #endif    break;    default:    PD("Unknown Authentication Method %c\n",authtype); -  errtype=protocolunsupported; +  errtype=PROTOCOLUNSUPPORTED;    break;    }    switch(errtype) { -  case noerror: +  case NOERROR:    if(cancelsecret!="")    ci->start()->add_int8('p')->add_hstring(sendpass,4,5)    ->add_int8(0)->sendcmd(SENDOUT);    break; // No flushing here, PostgreSQL 9.4 disapproves    default: -  case protocolunsupported: +  case PROTOCOLUNSUPPORTED:    ERROR("Unsupported authenticationmethod %c\n",authtype);    break;    }    break;    }    case 'K':    msglen-=4+4;backendpid=ci->read_int32();    cancelsecret=ci->read(msglen);   #ifdef PG_DEBUG    PD("<BackendKeyData %O\n",cancelsecret);
pike.git/lib/modules/Sql.pmod/pgsql.pike:782:    PD("<ParameterStatus ");    msglen-=4;    array(string) ts=reads();   #ifdef PG_DEBUG    if(sizeof(ts)==2) {   #endif    _runtimeparameter[ts[0]]=ts[1];   #ifdef PG_DEBUG    PD("%O=%O\n",ts[0],ts[1]);    } else -  errtype=protocolerror; +  errtype=PROTOCOLERROR;   #endif    break;    }    case '3':   #ifdef PG_DEBUG    PD("<CloseComplete\n");    msglen-=4;   #endif    break;    case 'Z':
pike.git/lib/modules/Sql.pmod/pgsql.pike:956: Inside #if defined(PG_DEBUG)
  #ifdef PG_DEBUG    PD("<%O PortalSuspended\n",portal._portalname);    msglen-=4;   #endif    portal=0;    break;    case 'C': {    msglen-=4;   #ifdef PG_DEBUG    if(msglen<1) -  errtype=protocolerror; +  errtype=PROTOCOLERROR;   #endif    string s=ci->read(msglen-1);    portal->_storetiming();    PD("<%O CommandComplete %O\n",portal._portalname,s);   #ifdef PG_DEBUG    if(ci->read_int8()) -  errtype=protocolerror; +  errtype=PROTOCOLERROR;    msglen=0;   #else    ci->consume(1);   #endif    portal->_releasesession(s);    portal=0;    break;    }    case 'I':   #ifdef PG_DEBUG
pike.git/lib/modules/Sql.pmod/pgsql.pike:986:   #endif    portal->_releasesession();    portal=0;    break;    case 'd':    PD("<%O CopyData\n",portal._portalname);    portal->_storetiming();    msglen-=4;   #ifdef PG_DEBUG    if(msglen<0) -  errtype=protocolerror; +  errtype=PROTOCOLERROR;   #endif    portal->_processdataready(({ci->read(msglen)}),msglen);   #ifdef PG_DEBUG    msglen=0;   #endif    break;    case 'G':    portal->_setrowdesc(getcols());    PD("<%O CopyInResponse\n",portal._portalname);    portal._state=COPYINPROGRESS;
pike.git/lib/modules/Sql.pmod/pgsql.pike:1031:    case "P0001":    lastmessage=({sprintf("%s: %s",msgresponse.S,msgresponse.M)});    USERERROR(a2nls(lastmessage    +({pinpointerror(portal._query,msgresponse.P)})    +showbindings(portal)));    case "53000":case "53100":case "53200":case "53300":case "53400":    case "57P01":case "57P02":case "57P03":case "57P04":case "3D000":    preplastmessage(msgresponse);    PD(a2nls(lastmessage));throw(0);    case "08P01":case "42P05": -  errtype=protocolerror; +  errtype=PROTOCOLERROR;    case "XX000":case "42883":case "42P01":    invalidatecache=1;    default:    preplastmessage(msgresponse);    if(msgresponse.D)    lastmessage+=({msgresponse.D});    if(msgresponse.H)    lastmessage+=({msgresponse.H});    lastmessage+=({    pinpointerror(objectp(portal)&&portal._query,msgresponse.P)+
pike.git/lib/modules/Sql.pmod/pgsql.pike:1080:    case 'A': {    PD("<NotificationResponse\n");    msglen-=4+4;    int pid=ci->read_int32();    string condition,extrainfo=UNDEFINED;    {    array(string) ts=reads();    switch(sizeof(ts)) {   #if PG_DEBUG    case 0: -  errtype=protocolerror; +  errtype=PROTOCOLERROR;    break;    default: -  errtype=protocolerror; +  errtype=PROTOCOLERROR;   #endif    case 2:    extrainfo=ts[1];    case 1:    condition=ts[0];    }    }    PD("%d %s\n%s\n",pid,condition,extrainfo);    runcallback(pid,condition,extrainfo);    break;    }    default:    if(msgtype!=-1) {    string s;    PD("Unknown message received %c\n",msgtype);    s=ci->read(msglen-=4);PD("%O\n",s);   #ifdef PG_DEBUG    msglen=0;   #endif -  errtype=protocolunsupported; +  errtype=PROTOCOLUNSUPPORTED;    } else {    lastmessage+=({    sprintf("Connection lost to database %s@%s:%d/%s %d\n",    user,_host,_port,database,backendpid)});    if(!waitforauthready)    throw(0);    USERERROR(a2nls(lastmessage));    }    break;    }   #ifdef PG_DEBUG    if(msglen) -  errtype=protocolerror; +  errtype=PROTOCOLERROR;   #endif    {    string msg;    switch(errtype) { -  case protocolunsupported: +  case PROTOCOLUNSUPPORTED:    msg=sprintf("Unsupported servermessage received %c\n",msgtype);    break; -  case protocolerror: +  case PROTOCOLERROR:    msg=sprintf("Protocol error with database %s",host_info());    break; -  case noerror: +  case NOERROR:    continue; // Normal production loop    }    ERROR(a2nls(lastmessage+=({msg})));    }    }; // We only get here if there is an error    if(err==MAGICTERMINATE) { // Announce connection termination to server    ci->start()->add("X\0\0\0\4")->sendcmd(SENDOUT);    terminating=1;    if(!sizeof(ci))    break;