Top Description Fields Constructors Methods
org.postgresql.core.v3

pack-priv Class SimpleParameterList

extends Object
implements V3ParameterList
Class Inheritance
All Implemented Interfaces
org.postgresql.core.v3.V3ParameterList, org.postgresql.core.ParameterList
Imports
org.postgresql.core.Oid, .PGStream, .ParameterList, .Utils, org.postgresql.geometric.PGbox, .PGpoint, org.postgresql.jdbc.UUIDArrayAssistant, org.postgresql.util.ByteConverter, .ByteStreamWriter, .GT, .PSQLException, .PSQLState, .StreamWrapper, org.checkerframework.checker.index.qual.NonNegative, .Positive, org.checkerframework.checker.nullness.qual.Nullable, java.io.IOException, .InputStream, java.nio.charset.StandardCharsets, java.sql.SQLException, java.util.Arrays

Parameter list for a single-statement V3 query.
Author
Oliver Jowett ([email protected])

Field Summary

Modifier and TypeField and Description
private static final byte
private final @Nullable byte[][]
private final byte[]
private static final byte
private static final byte
private static final Object
NULL_OBJECT

Marker object representing NULL; this distinguishes "parameter never set" from "parameter set to null".

private static final byte
private final int[]
private final @Nullable Object[]
private int
private static final byte
private final @Nullable TypeTransferModeRegistry

Constructor Summary

AccessConstructor and Description
pack-priv
SimpleParameterList(int paramCount, @Nullable TypeTransferModeRegistry transferModeRegistry)

Method Summary

Modifier and TypeMethod and Description
public void
appendAll(ParameterList
of parameters to append with.
list
)

Implements org.postgresql.core.ParameterList.appendAll.

Use this operation to append more parameters to the current list.

private void
bind(int index, Object value, int oid, byte binary)

public void
checkAllParametersSet()

Implements org.postgresql.core.v3.V3ParameterList.checkAllParametersSet.

Ensure that all parameters in this list have been assigned values.

public void
clear()

Implements org.postgresql.core.ParameterList.clear.

Unbind all parameter values bound in this list.

public void
convertFunctionOutParameters()

Implements org.postgresql.core.v3.V3ParameterList.convertFunctionOutParameters.

Convert any function output parameters to the correct type (void) and set an ignorable value for it.

public ParameterList
copy()

Implements org.postgresql.core.ParameterList.copy.

Perform a shallow copy of this ParameterList, returning a new instance (still suitable for passing to the owning Query).

private byte
direction(@Positive int index)

public @Nullable byte[][]
getEncoding()

Implements org.postgresql.core.v3.V3ParameterList.getEncoding.

Return the encoding for each parameter.

public byte[]
getFlags()

Implements org.postgresql.core.v3.V3ParameterList.getFlags.

Return the flags for each parameter.

public @NonNegative int
getInParameterCount()

Implements org.postgresql.core.ParameterList.getInParameterCount.

Get the number of IN parameters in this list.

public @NonNegative int
getOutParameterCount()

Implements org.postgresql.core.ParameterList.getOutParameterCount.

Get the number of OUT parameters in this list.

public @NonNegative int
getParameterCount()

Implements org.postgresql.core.ParameterList.getParameterCount.

Get the number of parameters in this list.

public int[]
getParamTypes()

Implements org.postgresql.core.v3.V3ParameterList.getParamTypes.

Return the parameter type information.

public @Nullable SimpleParameterList[]
getSubparams()

Implements org.postgresql.core.v3.V3ParameterList.getSubparams.

Return a list of the SimpleParameterList objects that make up this parameter list.

pack-priv int
getTypeOID(@Positive int index)

public int[]
getTypeOIDs()

Implements org.postgresql.core.ParameterList.getTypeOIDs.

Return the oids of the parameters in this list.

pack-priv int
public @Nullable Object[]
getValues()

Implements org.postgresql.core.ParameterList.getValues.

Returns the bound parameter values.

pack-priv boolean
pack-priv boolean
isBinary(@Positive int index)

pack-priv boolean
isNull(@Positive int index)

private static String
quoteAndCast(String text, @Nullable String type, boolean standardConformingStrings)

Escapes a given text value as a literal, wraps it in single quotes, casts it to the to the given data type, and finally wraps the whole thing in parentheses.

public void
registerOutParameter(int index, int sqlType)

public void
setBinaryParameter(@Positive int index, byte[] value, int oid)

public void
setBytea(@Positive int index, byte[] data, int offset, @NonNegative int length)

public void
setBytea(@Positive int index, InputStream stream, @NonNegative int length)

public void
setBytea(@Positive int index, InputStream stream)

public void
setBytea(@Positive int index, ByteStreamWriter writer)

public void
setIntParameter(@Positive int index, int value)

public void
setLiteralParameter(@Positive int index, String value, int oid)

public void
setNull(@Positive int index, int oid)

pack-priv void
setResolvedType(@Positive int index, int oid)

public void
setStringParameter(@Positive int index, String value, int oid)

public void
setText(@Positive int index, InputStream stream)

private static void
streamBytea(PGStream pgStream, StreamWrapper wrapper)

private static void
public String
toString(@Positive int index, boolean standardConformingStrings)

public String

Returns:

String representation of the list values
toString
()

Overrides java.lang.Object.toString.

Useful implementation of toString.

pack-priv void
writeV3Value(@Positive int index, PGStream pgStream)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

BINARYback to summary
private static final byte BINARY
encodedback to summary
private final @Nullable byte[][] encoded
flagsback to summary
private final byte[] flags
INback to summary
private static final byte IN
INOUTback to summary
private static final byte INOUT
NULL_OBJECTback to summary
private static final Object NULL_OBJECT

Marker object representing NULL; this distinguishes "parameter never set" from "parameter set to null".

OUTback to summary
private static final byte OUT
paramTypesback to summary
private final int[] paramTypes
paramValuesback to summary
private final @Nullable Object[] paramValues
posback to summary
private int pos
TEXTback to summary
private static final byte TEXT
transferModeRegistryback to summary
private final @Nullable TypeTransferModeRegistry transferModeRegistry

Constructor Detail

SimpleParameterListback to summary
pack-priv SimpleParameterList(int paramCount, @Nullable TypeTransferModeRegistry transferModeRegistry)

Method Detail

appendAllback to summary
public void appendAll(ParameterList list) throws SQLException

Implements org.postgresql.core.ParameterList.appendAll.

Doc from org.postgresql.core.ParameterList.appendAll.

Use this operation to append more parameters to the current list.

Parameters
list:ParameterList

of parameters to append with.

Annotations
@Override
Exceptions
SQLException:
fault raised if driver or back end throw an exception
bindback to summary
private void bind(int index, Object value, int oid, byte binary) throws SQLException
checkAllParametersSetback to summary
public void checkAllParametersSet() throws SQLException

Implements org.postgresql.core.v3.V3ParameterList.checkAllParametersSet.

Doc from org.postgresql.core.v3.V3ParameterList.checkAllParametersSet.

Ensure that all parameters in this list have been assigned values. Return silently if all is well, otherwise throw an appropriate exception.

Annotations
@Override
Exceptions
SQLException:
if not all parameters are set.
clearback to summary
public void clear()

Implements org.postgresql.core.ParameterList.clear.

Doc from org.postgresql.core.ParameterList.clear.

Unbind all parameter values bound in this list.

Annotations
@Override
convertFunctionOutParametersback to summary
public void convertFunctionOutParameters()

Implements org.postgresql.core.v3.V3ParameterList.convertFunctionOutParameters.

Doc from org.postgresql.core.v3.V3ParameterList.convertFunctionOutParameters.

Convert any function output parameters to the correct type (void) and set an ignorable value for it.

Annotations
@Override
copyback to summary
public ParameterList copy()

Implements org.postgresql.core.ParameterList.copy.

Doc from org.postgresql.core.ParameterList.copy.

Perform a shallow copy of this ParameterList, returning a new instance (still suitable for passing to the owning Query). If this ParameterList is immutable, copy() may return the same immutable object.

Returns:ParameterList

a new ParameterList instance

Annotations
@Override
directionback to summary
private byte direction(@Positive int index)
getEncodingback to summary
public @Nullable byte[][] getEncoding()

Implements org.postgresql.core.v3.V3ParameterList.getEncoding.

Doc from org.postgresql.core.v3.V3ParameterList.getEncoding.

Return the encoding for each parameter.

Returns:@Nullable byte[][]

nested byte array of bytes with encoding information.

Annotations
@Override
getFlagsback to summary
public byte[] getFlags()

Implements org.postgresql.core.v3.V3ParameterList.getFlags.

Doc from org.postgresql.core.v3.V3ParameterList.getFlags.

Return the flags for each parameter.

Returns:byte[]

an array of bytes used to store flags.

Annotations
@Override
getInParameterCountback to summary
public @NonNegative int getInParameterCount()

Implements org.postgresql.core.ParameterList.getInParameterCount.

Doc from org.postgresql.core.ParameterList.getInParameterCount.

Get the number of IN parameters in this list.

Returns:@NonNegative int

the number of IN parameters in this list

Annotations
@Override
getOutParameterCountback to summary
public @NonNegative int getOutParameterCount()

Implements org.postgresql.core.ParameterList.getOutParameterCount.

Doc from org.postgresql.core.ParameterList.getOutParameterCount.

Get the number of OUT parameters in this list.

Returns:@NonNegative int

the number of OUT parameters in this list

Annotations
@Override
getParameterCountback to summary
public @NonNegative int getParameterCount()

Implements org.postgresql.core.ParameterList.getParameterCount.

Doc from org.postgresql.core.ParameterList.getParameterCount.

Get the number of parameters in this list. This value never changes for a particular instance, and might be zero.

Returns:@NonNegative int

the number of parameters in this list.

Annotations
@Override
getParamTypesback to summary
public int[] getParamTypes()

Implements org.postgresql.core.v3.V3ParameterList.getParamTypes.

Doc from org.postgresql.core.v3.V3ParameterList.getParamTypes.

Return the parameter type information.

Returns:int[]

an array of org.postgresql.core.Oid type information

Annotations
@Override
getSubparamsback to summary
public @Nullable SimpleParameterList[] getSubparams()

Implements org.postgresql.core.v3.V3ParameterList.getSubparams.

Doc from org.postgresql.core.v3.V3ParameterList.getSubparams.

Return a list of the SimpleParameterList objects that make up this parameter list. If this object is already a SimpleParameterList, returns null (avoids an extra array construction in the common case).

Returns:@Nullable SimpleParameterList[]

an array of single-statement parameter lists, or null if this object is already a single-statement parameter list.

Annotations
@Override
getTypeOIDback to summary
pack-priv int getTypeOID(@Positive int index)
getTypeOIDsback to summary
public int[] getTypeOIDs()

Implements org.postgresql.core.ParameterList.getTypeOIDs.

Doc from org.postgresql.core.ParameterList.getTypeOIDs.

Return the oids of the parameters in this list. May be null for a ParameterList that does not support typing of parameters.

Returns:int[]

oids of the parameters

Annotations
@Override
getV3Lengthback to summary
pack-priv int getV3Length(@Positive int index)
getValuesback to summary
public @Nullable Object[] getValues()

Implements org.postgresql.core.ParameterList.getValues.

Doc from org.postgresql.core.ParameterList.getValues.

Returns the bound parameter values.

Returns:@Nullable Object[]

Object array containing the parameter values.

Annotations
@Override
hasUnresolvedTypesback to summary
pack-priv boolean hasUnresolvedTypes()
isBinaryback to summary
pack-priv boolean isBinary(@Positive int index)
isNullback to summary
pack-priv boolean isNull(@Positive int index)
quoteAndCastback to summary
private static String quoteAndCast(String text, @Nullable String type, boolean standardConformingStrings)

Escapes a given text value as a literal, wraps it in single quotes, casts it to the to the given data type, and finally wraps the whole thing in parentheses.

For example, "123" and "int4" becomes "('123'::int)"

The additional parentheses is added to ensure that the surrounding text of where the parameter value is entered does modify the interpretation of the value.

For example if our input SQL is: SELECT ?b

Using a parameter value of '{}' and type of json we'd get:

test=# SELECT ('{}'::json)b;
 b
----
 {}

But without the parentheses the result changes:

test=# SELECT '{}'::jsonb;
jsonb
-------
{}
registerOutParameterback to summary
public void registerOutParameter(int index, int sqlType) throws SQLException
Annotations
@Override
setBinaryParameterback to summary
public void setBinaryParameter(@Positive int index, byte[] value, int oid) throws SQLException
Annotations
@Override
setByteaback to summary
public void setBytea(@Positive int index, byte[] data, int offset, @NonNegative int length) throws SQLException
Annotations
@Override
setByteaback to summary
public void setBytea(@Positive int index, InputStream stream, @NonNegative int length) throws SQLException
Annotations
@Override
setByteaback to summary
public void setBytea(@Positive int index, InputStream stream) throws SQLException
Annotations
@Override
setByteaback to summary
public void setBytea(@Positive int index, ByteStreamWriter writer) throws SQLException
Annotations
@Override
setIntParameterback to summary
public void setIntParameter(@Positive int index, int value) throws SQLException
Annotations
@Override
setLiteralParameterback to summary
public void setLiteralParameter(@Positive int index, String value, int oid) throws SQLException
Annotations
@Override
setNullback to summary
public void setNull(@Positive int index, int oid) throws SQLException
Annotations
@Override
setResolvedTypeback to summary
pack-priv void setResolvedType(@Positive int index, int oid)
setStringParameterback to summary
public void setStringParameter(@Positive int index, String value, int oid) throws SQLException
Annotations
@Override
setTextback to summary
public void setText(@Positive int index, InputStream stream) throws SQLException
Annotations
@Override
streamByteaback to summary
private static void streamBytea(PGStream pgStream, StreamWrapper wrapper) throws IOException
streamByteaback to summary
private static void streamBytea(PGStream pgStream, ByteStreamWriter writer) throws IOException
toStringback to summary
public String toString(@Positive int index, boolean standardConformingStrings)
Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Useful implementation of toString.

Returns:String

String representation of the list values

Annotations
@Override
writeV3Valueback to summary
pack-priv void writeV3Value(@Positive int index, PGStream pgStream) throws IOException