public ParameterList createParameterList() { if (fragments.length == 1) return NO_PARAMETERS; return new SimpleParameterList(fragments.length - 1, protoConnection); }
public void setBinaryParameter(int index, byte[] value, int oid) throws SQLException { bind(index, value, oid, BINARY); }
public void checkAllParametersSet() throws SQLException { for (SimpleParameterList subparam : subparams) { subparam.checkAllParametersSet(); } }
@Override public void appendAll(ParameterList list) throws SQLException { if (list instanceof org.postgresql.core.v3.SimpleParameterList ) { /* only v3.SimpleParameterList is compatible with this type we need to create copies of our parameters, otherwise the values can be changed */ SimpleParameterList spl = (SimpleParameterList) list; int inParamCount = spl.getInParameterCount(); if ((pos + inParamCount) > paramValues.length) { throw new PSQLException( GT.tr("Added parameters index out of range: {0}, number of columns: {1}.", (pos + inParamCount), paramValues.length), PSQLState.INVALID_PARAMETER_VALUE); } System.arraycopy(spl.getValues(), 0, this.paramValues, pos, inParamCount); System.arraycopy(spl.getParamTypes(), 0, this.paramTypes, pos, inParamCount); System.arraycopy(spl.getFlags(), 0, this.flags, pos, inParamCount); System.arraycopy(spl.getEncoding(), 0, this.encoded, pos, inParamCount); pos += inParamCount; } }
private void sendFastpathCall(int fnid, SimpleParameterList params) throws SQLException, IOException { if (LOGGER.isLoggable(Level.FINEST)) { LOGGER.log(Level.FINEST, " FE=> FunctionCall({0}, {1} params)", new Object[]{fnid, params.getParameterCount()}); int paramCount = params.getParameterCount(); int encodedSize = 0; for (int i = 1; i <= paramCount; ++i) { if (params.isNull(i)) { encodedSize += 4; } else { encodedSize += 4 + params.getV3Length(i); pgStream.sendInteger2(paramCount); for (int i = 1; i <= paramCount; ++i) { pgStream.sendInteger2(params.isBinary(i) ? 1 : 0); if (params.isNull(i)) { pgStream.sendInteger4(-1); } else { pgStream.sendInteger4(params.getV3Length(i)); // Parameter size params.writeV3Value(i, pgStream);
private void sendParse(SimpleQuery query, SimpleParameterList params, boolean oneShot) throws IOException { int[] typeOIDs = params.getTypeOIDs(); if (query.isPreparedFor(typeOIDs, deallocateEpoch)) { return; sbuf.append(nativeSql); sbuf.append("\",oids={"); for (int i = 1; i <= params.getParameterCount(); ++i) { if (i != 1) { sbuf.append(","); sbuf.append(params.getTypeOID(i)); + (encodedStatementName == null ? 0 : encodedStatementName.length) + 1 + queryUtf8.length + 1 + 2 + 4 * params.getParameterCount(); pgStream.sendInteger2(params.getParameterCount()); // # of parameter types specified for (int i = 1; i <= params.getParameterCount(); ++i) { pgStream.sendInteger4(params.getTypeOID(i));
boolean paramsHasUnknown = params.hasUnresolvedTypes(); int paramOIDs[] = params.getTypeOIDs(); for (int i=0; i<paramOIDs.length; i++) { params.setResolvedType(i+1, queryOIDs[i]);
params.setResolvedType(i, typeOid); || (origStatementName != null && origStatementName.equals(query.getStatementName()))) { query.setPrepareTypes(params.getTypeOIDs());
public int[] getTypeOIDs() { int[] oids = new int[total]; for (int i = 0; i < offsets.length; i++) { int[] subOids = subparams[i].getTypeOIDs(); System.arraycopy(subOids, 0, oids, offsets[i], subOids.length); } return oids; }
public void clear() { for (SimpleParameterList subparam : subparams) { subparam.clear(); } }
public ParameterList copy() { SimpleParameterList[] copySub = new SimpleParameterList[subparams.length]; for (int sub = 0; sub < subparams.length; ++sub) { copySub[sub] = (SimpleParameterList) subparams[sub].copy(); } return new CompositeParameterList(copySub, offsets); }
CompositeParameterList(SimpleParameterList[] subparams, int[] offsets) { this.subparams = subparams; this.offsets = offsets; this.total = offsets[offsets.length - 1] + subparams[offsets.length - 1].getInParameterCount(); }
public void convertFunctionOutParameters() { for (SimpleParameterList subparam : subparams) { subparam.convertFunctionOutParameters(); } }
private void sendFastpathCall(int fnid, SimpleParameterList params) throws SQLException, IOException { if (logger.logDebug()) logger.debug(" FE=> FunctionCall(" + fnid + ", " + params.getParameterCount() + " params)"); int paramCount = params.getParameterCount(); int encodedSize = 0; for (int i = 1; i <= paramCount; ++i) if (params.isNull(i)) encodedSize += 4; else encodedSize += 4 + params.getV3Length(i); pgStream.SendInteger2(paramCount); for (int i = 1; i <= paramCount; ++i) pgStream.SendInteger2(params.isBinary(i) ? 1 : 0); pgStream.SendInteger2(paramCount); for (int i = 1; i <= paramCount; i++) if (params.isNull(i)) pgStream.SendInteger4(params.getV3Length(i)); // Parameter size params.writeV3Value(i, pgStream);
private void sendParse(SimpleQuery query, SimpleParameterList params, boolean oneShot) throws IOException { int[] typeOIDs = params.getTypeOIDs(); if (query.isPreparedFor(typeOIDs)) return; for (int i = 1; i <= params.getParameterCount(); ++i) sbuf.append("" + params.getTypeOID(i)); + (encodedStatementName == null ? 0 : encodedStatementName.length) + 1 + encodedSize + 1 + 2 + 4 * params.getParameterCount(); pgStream.SendInteger2(params.getParameterCount()); // # of parameter types specified for (int i = 1; i <= params.getParameterCount(); ++i) pgStream.SendInteger4(params.getTypeOID(i));
boolean paramsHasUnknown = params.hasUnresolvedTypes(); int[] paramOIDs = params.getTypeOIDs(); for (int i = 0; i < paramOIDs.length; i++) { params.setResolvedType(i + 1, queryOIDs[i]);
params.setResolvedType(i, typeOid); query.setStatementTypes((int[])params.getTypeOIDs().clone());
public int[] getTypeOIDs() { int oids[] = new int[total]; for (int i=0; i<offsets.length; i++) { int subOids[] = subparams[i].getTypeOIDs(); System.arraycopy(subOids, 0, oids, offsets[i], subOids.length); } return oids; }
public void clear() { for (int sub = 0; sub < subparams.length; ++sub) { subparams[sub].clear(); } }
public ParameterList copy() { SimpleParameterList[] copySub = new SimpleParameterList[subparams.length]; for (int sub = 0; sub < subparams.length; ++sub) copySub[sub] = (SimpleParameterList)subparams[sub].copy(); return new CompositeParameterList(copySub, offsets); }