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

version» Context lines:

pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:243: Inside #if !constant(__builtin.__SINGLE_PRECISION_FLOAT__)
   case FLOAT4OID:   #if !constant(__builtin.__SINGLE_PRECISION_FLOAT__)    case FLOAT8OID:   #endif    if (!stringp(value))    return 1;    }    return 0; // text   }    - private array timestamptotype = ({__builtin.Timestamp, 8, "usecs", 8}); - private array datetotype = ({__builtin.Date, 4, "days", 4}); + #define DAYSEPOCHTO2000 10957 // 2000/01/01 00:00:00 UTC + #define USEPOCHTO2000 (DAYSEPOCHTO2000*24*3600*1000000)    -  + private array timestamptotype +  = ({__builtin.Timestamp, 8, USEPOCHTO2000, "usecs", 8}); + private array datetotype = ({__builtin.Date, 4, DAYSEPOCHTO2000, "days", 4}); +    private mapping(int:array) oidtotype = ([    DATEOID: datetotype, -  TIMEOID: ({__builtin.Time, 8, "usecs", 8}), -  TIMETZOID: ({__builtin.TimeTZ, 12, "usecs", 8, "timezone", 4}), -  INTERVALOID: ({__builtin.Interval, 16, "usecs", 8, "days", 4, "months", 4}), +  TIMEOID: ({__builtin.Time, 8, 0, "usecs", 8}), +  TIMETZOID: ({__builtin.TimeTZ, 12, 0, "usecs", 8, "timezone", 4}), +  INTERVALOID:({__builtin.Interval, 16, 0, "usecs", 8, "days", 4, "months",4}),    TIMESTAMPOID: timestamptotype,    TIMESTAMPTZOID: timestamptotype,    INT4RANGEOID: ({0, 4}),    INT8RANGEOID: ({0, 8}),    DATERANGEOID: datetotype,    TSRANGEOID: timestamptotype,    TSTZRANGEOID: timestamptotype,    ]);      private inline mixed callout(function(mixed ...:void) f,
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:956:    case 1: from = till = 0;    break;    case 0x12: from = cr->read_hint(4);    break;    case 2: from = cr->read_hint(4);    case 8: till = cr->read_hint(4);    }    if (totype[0]) {    if (intp(from)) {    value = totype[0](); -  value[totype[2]] = from; +  value[totype[3]] = from + totype[2];    from = value;    }    if (intp(till)) {    value = totype[0](); -  value[totype[2]] = till; +  value[totype[3]] = till + totype[2];    till = value;    }    }    value = __builtin.Range(from, till);    if (alltext)    value = (string)value;    }    break;    case CIDROID:    case INETOID:
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:995:    case TIMESTAMPTZOID:    case INTERVALOID:    case TIMETZOID:    case TIMEOID:    case DATEOID:    if (_forcetext)    value = cr->read(collen);    else {    array totype = oidtotype[typ];    value = totype[0](); -  int i = 2; -  do +  value[totype[3]] = cr->read_sint(totype[4]) + totype[2]; +  int i = 5; +  while (i < sizeof(totype)) {    value[totype[i]] = cr->read_sint(totype[i+1]); -  while ((i += 2) < sizeof(totype)); +  i += 2; +  }    if (alltext)    value = (string)value;    }    break;    case INT8OID:case INT2OID:    case OIDOID:case INT4OID:    if (_forcetext) {    value = cr->read(collen);    if (!alltext)    value = (int)value;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1197:    if (stringp(value))    plugbuffer->add_hstring(value, 4);    else if (value->from >= value->till)    plugbuffer->add("\0\0\0\1\1");    else {    array totype = oidtotype[dtoid[i]];    int w = totype[1];    int from, till;    if (totype[0])    from = value->from, till = value->till; -  else -  from = value->from[totype[2]], till = value->till[totype[2]]; +  else { +  from = value->from[totype[3]] - totype[2]; +  till = value->till[totype[3]] - totype[2]; +  }    if (value->till == Math.inf)    if (value->from == -Math.inf)    plugbuffer->add("\0\0\0\1\30");    else    plugbuffer->add("\0\0\0", 1 + 4 + w, "\22\0\0\0", w)    ->add_int(from, w);    else {    if (value->from == -Math.inf)    plugbuffer->add("\0\0\0", 1 + 4 + w, 8);    else
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1240:    case TIMETZOID:    case INTERVALOID:    case TIMESTAMPOID:    case TIMESTAMPTZOID:    if (stringp(value))    plugbuffer->add_hstring(value, 4);    else {    array totype = oidtotype[dtoid[i]];    if (!objectp(value))    value = totype[0](value); -  plugbuffer->add_int32(totype[1]); -  int i = 2; -  do +  plugbuffer->add_int32(totype[1]) +  ->add_int(value[totype[3]] - totype[2], totype[4]); +  int i = 5; +  while (i < sizeof(totype)) {    plugbuffer->add_int(value[totype[i]], totype[i+1]); -  while ((i += 2) < sizeof(totype)); +  i += 2;    } -  +  }    break;    case FLOAT4OID:   #if !constant(__builtin.__SINGLE_PRECISION_FLOAT__)    case FLOAT8OID:   #endif    if (stringp(value))    plugbuffer->add_hstring(value, 4);    else {    int w = dtoid[i] == FLOAT4OID ? 4 : 8;    plugbuffer->add_int32(w)