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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql.pike:1048:    if (String.width(q) > 8)    ERROR("Don't know how to convert %O to %s encoding\n", q, cenc);    }    array(string|int) paramValues;    array from;    if (bindings) {    if (forcetext)    q = .sql_util.emulate_bindings(q, bindings, this),    paramValues = .pgsql_util.emptyarray;    else { -  int pi = 0, rep = 0; +  int pi = 0;    paramValues = allocate(sizeof(bindings));    from = allocate(sizeof(bindings)); -  array(string) to = allocate(sizeof(bindings)); +  array(string) litfrom, litto, to = allocate(sizeof(bindings)); +  litfrom = litto = .pgsql_util.emptyarray;    foreach (bindings; mixed name; mixed value) {    if (stringp(name)) { // Throws if mapping key is empty string    if (name[0] != ':')    name = ":" + name;    if (name[1] == '_') { // Special option parameter    switch(name) {    case ":_cache":    forcecache = (int)value;    break;    case ":_text":
pike.git/lib/modules/Sql.pmod/pgsql.pike:1073:    break;    case ":_sync":    syncparse = (int)value;    break;    }    continue;    }    if (!has_value(q, name))    continue;    } -  from[rep] = name; -  string rval; -  if (multisetp(value)) // multisets are taken literally -  rval = indices(value)*","; // and bypass the encoding logic -  else { -  paramValues[pi++] = value; -  rval = sprintf("$%d", pi); +  if (multisetp(value)) { // multisets are taken literally +  litto += ({indices(value)*","}); // and bypass the encoding logic +  litfrom += ({name}); +  } else { +  paramValues[pi] = value; +  to[pi] = sprintf("$%d", pi + 1); +  from[pi++] = name;    } -  to[rep++] = rval; +     } -  if(rep--) -  q = replace(q, from = from[..rep], to = to[..rep]); -  paramValues = pi ? paramValues[..pi-1] : .pgsql_util.emptyarray; +  if (pi--) { +  paramValues = paramValues[.. pi]; +  q = replace(q, litfrom += from = from[.. pi], litto += to = to[.. pi]); +  } else { +  paramValues = .pgsql_util.emptyarray; +  if (sizeof(litfrom)) +  q = replace(q, litfrom, litto); +  }    from = ({from, to, paramValues});    }    } else    paramValues = .pgsql_util.emptyarray;    if (String.width(q) > 8)    ERROR("Wide string literals in %O not supported\n", q);    if (has_value(q, "\0"))    ERROR("Querystring %O contains invalid literal nul-characters\n", q);    mapping(string:mixed) tp;    /*