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

pack-priv Class SimpleQuery

extends Object
implements Query
Class Inheritance
All Implemented Interfaces
org.postgresql.core.Query
Known Direct Subclasses
org.postgresql.core.v3.BatchedQuery
Imports
org.postgresql.core.Field, .NativeQuery, .Oid, .ParameterList, .Query, .SqlCommand, org.postgresql.jdbc.PgResultSet, org.checkerframework.checker.nullness.qual.Nullable, java.lang.ref.PhantomReference, java.nio.charset.StandardCharsets, java.util.BitSet, .Map, java.util.logging.Level, .Logger

V3 Query implementation for a single-statement query. This also holds the state of any associated server-side named statement. We use a PhantomReference managed by the QueryExecutor to handle statement cleanup.
Author
Oliver Jowett ([email protected])

Field Summary

Modifier and TypeField and Description
private @Nullable Integer
private @Nullable PhantomReference<?>
private short
private @Nullable byte[]
private @Nullable Field[]
fields

The stored fields from previous execution or describe of a prepared statement.

private boolean
private static final Logger
private final NativeQuery
private boolean
pack-priv static final SimpleParameterList
private boolean
private @Nullable int[]
private @Nullable Map<String, Integer>
private final boolean
private boolean
private @Nullable String
private final @Nullable TypeTransferModeRegistry
private @Nullable BitSet

Constructor Summary

AccessConstructor and Description
pack-priv
pack-priv
SimpleQuery(NativeQuery query, @Nullable TypeTransferModeRegistry transferModeRegistry, boolean sanitiserDisabled)

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements org.postgresql.core.Query.close.

Close this query and free any server-side resources associated with it.

public ParameterList
createParameterList()

Implements org.postgresql.core.Query.createParameterList.

Create a ParameterList suitable for storing parameters associated with this Query.

public int
getBatchSize()

Implements org.postgresql.core.Query.getBatchSize.

Get the number of times this Query has been batched.

public final int
pack-priv @Nullable byte[]
pack-priv @Nullable Field[]

Returns:

the fields that this query will return.
getFields
()

Returns the fields that this query will return.

public int

Returns:

Max size of result data in bytes according to returned fields, 0 if no results, -1 if result is unbounded.
getMaxResultRowSize
()

Return maximum size in bytes that each result row from this query may return.

pack-priv NativeQuery
public String
getNativeSql()

Implements org.postgresql.core.Query.getNativeSql.

Returns SQL in native for database format.

pack-priv @Nullable int[]
public @Nullable Map<String, Integer>
getResultSetColumnNameIndexMap()

Implements org.postgresql.core.Query.getResultSetColumnNameIndexMap.

Get a map that a result set can use to find the index associated to a name.

public SqlCommand
getSqlCommand()

Implements org.postgresql.core.Query.getSqlCommand.

Returns properties of the query (sql keyword, and some other parsing info).

pack-priv @Nullable String
public @Nullable SimpleQuery[]
getSubqueries()

Implements org.postgresql.core.Query.getSubqueries.

Return a list of the Query objects that make up this query.

public boolean
pack-priv boolean
public boolean
pack-priv boolean
pack-priv boolean
isPreparedFor(int[] paramTypes, short deallocateEpoch)

public boolean
pack-priv boolean

Returns:

true if current query needs field formats be adjusted as per connection configuration
needUpdateFieldFormats
()

Returns true if current query needs field formats be adjusted as per connection configuration.

public void
pack-priv void
pack-priv void
setFields(@Nullable Field[]
The fields that this query will return.
fields
)

Sets the fields that this query will return.

public void
setHasBinaryFields(boolean hasBinaryFields)

pack-priv void
setPortalDescribed(boolean portalDescribed)

pack-priv void
setPrepareTypes(int[] paramTypes)

pack-priv void
setStatementDescribed(boolean statementDescribed)

pack-priv void
setStatementName(String statementName, short deallocateEpoch)

public String
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

cachedMaxResultRowSizeback to summary
private @Nullable Integer cachedMaxResultRowSize
cleanupRefback to summary
private @Nullable PhantomReference<?> cleanupRef
deallocateEpochback to summary
private short deallocateEpoch
encodedStatementNameback to summary
private @Nullable byte[] encodedStatementName
fieldsback to summary
private @Nullable Field[] fields

The stored fields from previous execution or describe of a prepared statement. Always null for non-prepared statements.

hasBinaryFieldsback to summary
private boolean hasBinaryFields
LOGGERback to summary
private static final Logger LOGGER
nativeQueryback to summary
private final NativeQuery nativeQuery
needUpdateFieldFormatsback to summary
private boolean needUpdateFieldFormats
NO_PARAMETERSback to summary
pack-priv static final SimpleParameterList NO_PARAMETERS
portalDescribedback to summary
private boolean portalDescribed
preparedTypesback to summary
private @Nullable int[] preparedTypes
resultSetColumnNameIndexMapback to summary
private @Nullable Map<String, Integer> resultSetColumnNameIndexMap
sanitiserDisabledback to summary
private final boolean sanitiserDisabled
statementDescribedback to summary
private boolean statementDescribed
statementNameback to summary
private @Nullable String statementName
transferModeRegistryback to summary
private final @Nullable TypeTransferModeRegistry transferModeRegistry
unspecifiedParamsback to summary
private @Nullable BitSet unspecifiedParams

Constructor Detail

SimpleQueryback to summary
pack-priv SimpleQuery(SimpleQuery src)
SimpleQueryback to summary
pack-priv SimpleQuery(NativeQuery query, @Nullable TypeTransferModeRegistry transferModeRegistry, boolean sanitiserDisabled)

Method Detail

closeback to summary
public void close()

Implements org.postgresql.core.Query.close.

Doc from org.postgresql.core.Query.close.

Close this query and free any server-side resources associated with it. The resources may not be immediately deallocated, but closing a Query may make the deallocation more prompt.

A closed Query should not be executed.

Annotations
@Override
createParameterListback to summary
public ParameterList createParameterList()

Implements org.postgresql.core.Query.createParameterList.

Doc from org.postgresql.core.Query.createParameterList.

Create a ParameterList suitable for storing parameters associated with this Query.

If this query has no parameters, a ParameterList will be returned, but it may be a shared immutable object. If this query does have parameters, the returned ParameterList is a new list, unshared by other callers.

Returns:ParameterList

a suitable ParameterList instance for this query

Annotations
@Override
getBatchSizeback to summary
public int getBatchSize()

Implements org.postgresql.core.Query.getBatchSize.

Doc from org.postgresql.core.Query.getBatchSize.

Get the number of times this Query has been batched.

Returns:int

number of times addBatch() has been called.

Annotations
@Override
getBindCountback to summary
public final int getBindCount()
getEncodedStatementNameback to summary
pack-priv @Nullable byte[] getEncodedStatementName()
getFieldsback to summary
pack-priv @Nullable Field[] getFields()

Returns the fields that this query will return. If the result set fields are not known returns null.

Returns:@Nullable Field[]

the fields that this query will return.

getMaxResultRowSizeback to summary
public int getMaxResultRowSize()

Return maximum size in bytes that each result row from this query may return. Mainly used for batches that return results.

Results are cached until/unless the query is re-described.

Returns:int

Max size of result data in bytes according to returned fields, 0 if no results, -1 if result is unbounded.

Exceptions
IllegalStateException:
if the query is not described
getNativeQueryback to summary
pack-priv NativeQuery getNativeQuery()
getNativeSqlback to summary
public String getNativeSql()

Implements org.postgresql.core.Query.getNativeSql.

Doc from org.postgresql.core.Query.getNativeSql.

Returns SQL in native for database format.

Returns:String

SQL in native for database format

Annotations
@Override
getPrepareTypesback to summary
pack-priv @Nullable int[] getPrepareTypes()
getResultSetColumnNameIndexMapback to summary
public @Nullable Map<String, Integer> getResultSetColumnNameIndexMap()

Implements org.postgresql.core.Query.getResultSetColumnNameIndexMap.

Doc from org.postgresql.core.Query.getResultSetColumnNameIndexMap.

Get a map that a result set can use to find the index associated to a name.

Returns:@Nullable Map<String, Integer>

null if the query implementation does not support this method.

Annotations
@Override
getSqlCommandback to summary
public SqlCommand getSqlCommand()

Implements org.postgresql.core.Query.getSqlCommand.

Doc from org.postgresql.core.Query.getSqlCommand.

Returns properties of the query (sql keyword, and some other parsing info).

Returns:SqlCommand

returns properties of the query (sql keyword, and some other parsing info) or null if not applicable

Annotations
@Override
getStatementNameback to summary
pack-priv @Nullable String getStatementName()
getSubqueriesback to summary
public @Nullable SimpleQuery[] getSubqueries()

Implements org.postgresql.core.Query.getSubqueries.

Doc from org.postgresql.core.Query.getSubqueries.

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

Returns:@Nullable SimpleQuery[]

an array of single-statement queries, or null if this object is already a single-statement query.

Annotations
@Override
hasBinaryFieldsback to summary
public boolean hasBinaryFields()
hasUnresolvedTypesback to summary
pack-priv boolean hasUnresolvedTypes()
isEmptyback to summary
public boolean isEmpty()

Implements org.postgresql.core.Query.isEmpty.

Annotations
@Override
isPortalDescribedback to summary
pack-priv boolean isPortalDescribed()
isPreparedForback to summary
pack-priv boolean isPreparedFor(int[] paramTypes, short deallocateEpoch)
isStatementDescribedback to summary
public boolean isStatementDescribed()

Implements org.postgresql.core.Query.isStatementDescribed.

Annotations
@Override
needUpdateFieldFormatsback to summary
pack-priv boolean needUpdateFieldFormats()

Returns true if current query needs field formats be adjusted as per connection configuration. Subsequent invocations would return false. The idea is to perform adjustments only once, not for each QueryExecutorImpl#sendBind(SimpleQuery, SimpleParameterList, Portal, boolean).

Returns:boolean

true if current query needs field formats be adjusted as per connection configuration

resetNeedUpdateFieldFormatsback to summary
public void resetNeedUpdateFieldFormats()
setCleanupRefback to summary
pack-priv void setCleanupRef(PhantomReference<?> cleanupRef)
setFieldsback to summary
pack-priv void setFields(@Nullable Field[] fields)

Sets the fields that this query will return.

Parameters
fields:@Nullable Field[]

The fields that this query will return.

setHasBinaryFieldsback to summary
public void setHasBinaryFields(boolean hasBinaryFields)
setPortalDescribedback to summary
pack-priv void setPortalDescribed(boolean portalDescribed)
setPrepareTypesback to summary
pack-priv void setPrepareTypes(int[] paramTypes)
setStatementDescribedback to summary
pack-priv void setStatementDescribed(boolean statementDescribed)
setStatementNameback to summary
pack-priv void setStatementName(String statementName, short deallocateEpoch)
toStringback to summary
public String toString(@Nullable ParameterList parameters)
Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
unprepareback to summary
pack-priv void unprepare()