pike.git
/
lib
/
modules
/
Sql.pmod
/
pgsql_util.pmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:162:
parent->untolderror = 0; else if (parent->pgsqlsess) parent->pgsqlsess->untolderror = 0; parent.delayederror = 0; if (stringp(err)) err = ({err, backtrace()[..<2]}); throw(err); } }
-
private int
oidformat
(int oid) {
+
private int
readoidformat
(int oid) {
switch (oid) { case BOOLOID: case BYTEAOID: case CHAROID: case INT8OID: case INT2OID: case INT4OID:
-
+
case FLOAT4OID:
+
#if !constant(__builtin.__SINGLE_PRECISION_FLOAT__)
+
case FLOAT8OID:
+
#endif
case TEXTOID: case OIDOID: case XMLOID: case MACADDROID: case BPCHAROID: case VARCHAROID: case CTIDOID: case UUIDOID: return 1; //binary } return 0; // text }
-
+
private int writeoidformat(int oid, array(string|int) paramValues,
+
array(int) ai) {
+
mixed value = paramValues[ai[0]++];
+
switch (oid) {
+
case BOOLOID:
+
case BYTEAOID:
+
case CHAROID:
+
case INT8OID:
+
case INT2OID:
+
case INT4OID:
+
case TEXTOID:
+
case OIDOID:
+
case XMLOID:
+
case MACADDROID:
+
case BPCHAROID:
+
case VARCHAROID:
+
case CTIDOID:
+
case UUIDOID:
+
return 1; //binary
+
case FLOAT4OID:
+
#if !constant(__builtin.__SINGLE_PRECISION_FLOAT__)
+
case FLOAT8OID:
+
#endif
+
if (!stringp(value))
+
return 1;
+
}
+
return 0; // text
+
}
+
private inline mixed callout(function(mixed ...:void) f, float|int delay, mixed ... args) { return cb_backend->call_out(f, delay, @args); } // Some pgsql utility functions class bufcon { inherit Stdio.Buffer; private Thread.ResourceCountKey dirty;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:826:
#endif foreach (datarowtypes; int i; int typ) { int collen = cr->read_sint(4); if (collen > 0) { #ifdef PG_DEBUG msglen -= collen; #endif mixed value; switch (typ) { case FLOAT4OID:
-
#if
SIZEOF
_FLOAT
>=8
+
#if
!constant(
_
_builtin.__SINGLE_PRECISION_
FLOAT
__)
case FLOAT8OID: #endif
-
+
if (_forcetext) {
if (!alltext) { value = (float)cr->read(collen); break; }
-
+
} else {
+
[ value ] = cr->sscanf(collen == 4 ? "%4F" : "%8F");
+
if (alltext)
+
value = (string)value;
+
break;
+
}
default:value = cr->read(collen); break; case CHAROID: value = alltext ? cr->read(1) : cr->read_int8(); break; case BOOLOID:value = cr->read_int8(); switch (value) { case 'f':value = 0; break; case 't':value = 1;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:916:
+ (string)(c->socket->query_fd()) + "_" #endif + String.int2hex(pgsqlsess.pportalcount++); lock = 0; #ifdef PG_DEBUGMORE PD("ParamValues to bind: %O\n", paramValues); #endif Stdio.Buffer plugbuffer = Stdio.Buffer(); { array dta = ({sizeof(dtoid)}); plugbuffer->add(_portalname, 0, _preparedname, 0)
-
->add_ints(dta + map(dtoid,
oidformat
) + dta, 2);
+
->add_ints(dta
+
+ map(dtoid,
writeoidformat, paramValues, ({0}
)
)
+ dta, 2);
} string cenc = pgsqlsess.runtimeparameter[CLIENT_ENCODING]; foreach (paramValues; int i; mixed value) { if (undefinedp(value) || objectp(value) && value->is_val_null) plugbuffer->add_int32(-1); // NULL else if (stringp(value) && !sizeof(value)) { int k = 0; switch (dtoid[i]) { default: k = -1; // cast empty strings to NULL for non-string types
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1034:
SUSERERROR( "\"char\" types must be 1 byte wide, got %O\n", value); case 0: plugbuffer->add_int32(-1); // NULL break; case 1: plugbuffer->add_hstring(value[0], 4); } } 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)
+
->sprintf(w == 4 ? "%4F" : "%8F", value);
+
}
+
break;
case INT8OID: plugbuffer->add_int32(8)->add_int((int)value, 8); break; case OIDOID: case INT4OID: plugbuffer->add_int32(4)->add_int32((int)value); break; case INT2OID: plugbuffer->add_int32(2)->add_int16((int)value); break;
pike.git/lib/modules/Sql.pmod/pgsql_util.pmod:1056:
if (!datarowtypes) { if (_tprepared && dontcacheprefix->match(_query)) m_delete(pgsqlsess->prepareds, _query), _tprepared = 0; waitfordescribe(); } if (_state >= CLOSING) lock = _unnamedstatementkey = 0; else { plugbuffer->add_int16(sizeof(datarowtypes)); if (sizeof(datarowtypes))
-
plugbuffer->add_ints(map(datarowtypes,
oidformat
), 2);
+
plugbuffer->add_ints(map(datarowtypes,
readoidformat
), 2);
else if (syncparse < 0 && !pgsqlsess->wasparallelisable && !pgsqlsess->statementsinflight->drained(1)) { lock = pgsqlsess->shortmux->lock(); PD("Commit waiting for statements to finish\n"); catch(PT(pgsqlsess->statementsinflight->wait_till_drained(lock, 1))); } lock = 0; PD("Bind portal %O statement %O\n", _portalname, _preparedname); _fetchlimit = pgsqlsess->_fetchlimit; _bindportal();