パッケージ org.postgresql.core.v3

クラス QueryExecutorImpl

java.lang.Object
org.postgresql.core.QueryExecutorBase
org.postgresql.core.v3.QueryExecutorImpl
すべての実装されたインタフェース:
QueryExecutor, TypeTransferModeRegistry

public class QueryExecutorImpl extends QueryExecutorBase
QueryExecutor implementation for the V3 protocol.
  • コンストラクタの詳細

  • メソッドの詳細

    • getProtocolVersion

      public int getProtocolVersion()
      戻り値:
      the version of the implementation
    • createSimpleQuery

      public Query createSimpleQuery(String sql) throws SQLException
      インタフェースからコピーされた説明: QueryExecutor
      Create an unparameterized Query object suitable for execution by this QueryExecutor. The provided query string is not parsed for parameter placeholders ('?' characters), and the Query.createParameterList() of the returned object will always return an empty ParameterList.
      パラメータ:
      sql - the SQL for the query to create
      戻り値:
      a new Query object
      例外:
      SQLException - if something goes wrong
    • wrap

      public Query wrap(List<NativeQuery> queries)
      インタフェースからコピーされた説明: QueryExecutor
      Wrap given native query into a ready for execution format.
      パラメータ:
      queries - list of queries in native to database syntax
      戻り値:
      query object ready for execution by this query executor
    • execute

      public void execute(Query query, @Nullable ParameterList parameters, ResultHandler handler, int maxRows, int fetchSize, int flags) throws SQLException
      インタフェースからコピーされた説明: QueryExecutor
      Execute a Query, passing results to a provided ResultHandler.
      パラメータ:
      query - the query to execute; must be a query returned from calling QueryExecutor.wrap(List) on this QueryExecutor object.
      parameters - the parameters for the query. Must be non-null if the query takes parameters. Must be a parameter object returned by Query.createParameterList().
      handler - a ResultHandler responsible for handling results generated by this query
      maxRows - the maximum number of rows to retrieve
      fetchSize - if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspending
      flags - a combination of QUERY_* flags indicating how to handle the query.
      例外:
      SQLException - if query execution fails
    • execute

      public void execute(Query query, @Nullable ParameterList parameters, ResultHandler handler, int maxRows, int fetchSize, int flags, boolean adaptiveFetch) throws SQLException
      インタフェースからコピーされた説明: QueryExecutor
      Execute a Query with adaptive fetch, passing results to a provided ResultHandler.
      パラメータ:
      query - the query to execute; must be a query returned from calling QueryExecutor.wrap(List) on this QueryExecutor object.
      parameters - the parameters for the query. Must be non-null if the query takes parameters. Must be a parameter object returned by Query.createParameterList().
      handler - a ResultHandler responsible for handling results generated by this query
      maxRows - the maximum number of rows to retrieve
      fetchSize - if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspending
      flags - a combination of QUERY_* flags indicating how to handle the query.
      adaptiveFetch - state of adaptiveFetch to use during execution
      例外:
      SQLException - if query execution fails
    • execute

      public void execute(Query[] queries, @Nullable ParameterList[] parameterLists, BatchResultHandler batchHandler, int maxRows, int fetchSize, int flags) throws SQLException
      インタフェースからコピーされた説明: QueryExecutor
      Execute several Query, passing results to a provided ResultHandler.
      パラメータ:
      queries - the queries to execute; each must be a query returned from calling QueryExecutor.wrap(List) on this QueryExecutor object.
      parameterLists - the parameter lists for the queries. The parameter lists correspond 1:1 to the queries passed in the queries array. Each must be non- null if the corresponding query takes parameters, and must be a parameter object returned by Query.createParameterList() created by the corresponding query.
      batchHandler - a ResultHandler responsible for handling results generated by this query
      maxRows - the maximum number of rows to retrieve
      fetchSize - if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspending
      flags - a combination of QUERY_* flags indicating how to handle the query.
      例外:
      SQLException - if query execution fails
    • execute

      public void execute(Query[] queries, @Nullable ParameterList[] parameterLists, BatchResultHandler batchHandler, int maxRows, int fetchSize, int flags, boolean adaptiveFetch) throws SQLException
      インタフェースからコピーされた説明: QueryExecutor
      Execute several Query with adaptive fetch, passing results to a provided ResultHandler.
      パラメータ:
      queries - the queries to execute; each must be a query returned from calling QueryExecutor.wrap(List) on this QueryExecutor object.
      parameterLists - the parameter lists for the queries. The parameter lists correspond 1:1 to the queries passed in the queries array. Each must be non- null if the corresponding query takes parameters, and must be a parameter object returned by Query.createParameterList() created by the corresponding query.
      batchHandler - a ResultHandler responsible for handling results generated by this query
      maxRows - the maximum number of rows to retrieve
      fetchSize - if QUERY_FORWARD_CURSOR is set, the preferred number of rows to retrieve before suspending
      flags - a combination of QUERY_* flags indicating how to handle the query.
      adaptiveFetch - state of adaptiveFetch to use during execution
      例外:
      SQLException - if query execution fails
    • fastpathCall

      public byte @Nullable [] fastpathCall(int fnid, ParameterList parameters, boolean suppressBegin) throws SQLException
      インタフェースからコピーされた説明: QueryExecutor
      Invoke a backend function via the fastpath interface.
      パラメータ:
      fnid - the OID of the backend function to invoke
      parameters - a ParameterList returned from QueryExecutor.createFastpathParameters(int) containing the parameters to pass to the backend function
      suppressBegin - if begin should be suppressed
      戻り値:
      the binary-format result of the fastpath call, or null if a void result was returned
      例外:
      SQLException - if an error occurs while executing the fastpath call
    • doSubprotocolBegin

      public void doSubprotocolBegin() throws SQLException
      例外:
      SQLException
    • createFastpathParameters

      public ParameterList createFastpathParameters(int count)
      インタフェースからコピーされた説明: QueryExecutor
      Create a new ParameterList implementation suitable for invoking a fastpath function via QueryExecutor.fastpathCall(int, org.postgresql.core.ParameterList, boolean).
      パラメータ:
      count - the number of parameters the fastpath call will take
      戻り値:
      a ParameterList suitable for passing to QueryExecutor.fastpathCall(int, org.postgresql.core.ParameterList, boolean).
    • processNotifies

      public void processNotifies() throws SQLException
      インタフェースからコピーされた説明: QueryExecutor
      Prior to attempting to retrieve notifications, we need to pull any recently received notifications off of the network buffers. The notification retrieval in ProtocolConnection cannot do this as it is prone to deadlock, so the higher level caller must be responsible which requires exposing this method.
      例外:
      SQLException - if and error occurs while fetching notifications
    • processNotifies

      public void processNotifies(int timeoutMillis) throws SQLException
      インタフェースからコピーされた説明: QueryExecutor
      Prior to attempting to retrieve notifications, we need to pull any recently received notifications off of the network buffers. The notification retrieval in ProtocolConnection cannot do this as it is prone to deadlock, so the higher level caller must be responsible which requires exposing this method. This variant supports blocking for the given time in millis.
      パラメータ:
      timeoutMillis - when > 0, block for this time when =0, block forever when < 0, don't block
      例外:
      SQLException - if and error occurs while fetching notifications
    • startCopy

      public CopyOperation startCopy(String sql, boolean suppressBegin) throws SQLException
      Sends given query to BE to start, initialize and lock connection for a CopyOperation.
      パラメータ:
      sql - COPY FROM STDIN / COPY TO STDOUT statement
      suppressBegin - if begin should be suppressed
      戻り値:
      CopyIn or CopyOut operation object
      例外:
      SQLException - on failure
    • cancelCopy

      public void cancelCopy(CopyOperationImpl op) throws SQLException
      Finishes a copy operation and unlocks connection discarding any exchanged data.
      パラメータ:
      op - the copy operation presumably currently holding lock on this connection
      例外:
      SQLException - on any additional failure
    • endCopy

      public long endCopy(CopyOperationImpl op) throws SQLException
      Finishes writing to copy and unlocks connection.
      パラメータ:
      op - the copy operation presumably currently holding lock on this connection
      戻り値:
      number of rows updated for server versions 8.2 or newer
      例外:
      SQLException - on failure
    • writeToCopy

      public void writeToCopy(CopyOperationImpl op, byte[] data, int off, int siz) throws SQLException
      Sends data during a live COPY IN operation. Only unlocks the connection if server suddenly returns CommandComplete, which should not happen
      パラメータ:
      op - the CopyIn operation presumably currently holding lock on this connection
      data - bytes to send
      off - index of first byte to send (usually 0)
      siz - number of bytes to send (usually data.length)
      例外:
      SQLException - on failure
    • writeToCopy

      public void writeToCopy(CopyOperationImpl op, ByteStreamWriter from) throws SQLException
      Sends data during a live COPY IN operation. Only unlocks the connection if server suddenly returns CommandComplete, which should not happen
      パラメータ:
      op - the CopyIn operation presumably currently holding lock on this connection
      from - the source of bytes, e.g. a ByteBufferByteStreamWriter
      例外:
      SQLException - on failure
    • flushCopy

      public void flushCopy(CopyOperationImpl op) throws SQLException
      例外:
      SQLException
    • processResults

      protected void processResults(ResultHandler handler, int flags) throws IOException
      例外:
      IOException
    • processResults

      protected void processResults(ResultHandler handler, int flags, boolean adaptiveFetch) throws IOException
      例外:
      IOException
    • fetch

      public void fetch(ResultCursor cursor, ResultHandler handler, int fetchSize, boolean adaptiveFetch) throws SQLException
      インタフェースからコピーされた説明: QueryExecutor
      Fetch additional rows from a cursor.
      パラメータ:
      cursor - the cursor to fetch from
      handler - the handler to feed results to
      fetchSize - the preferred number of rows to retrieve before suspending
      adaptiveFetch - state of adaptiveFetch to use during fetching
      例外:
      SQLException - if query execution fails
    • getAdaptiveFetchSize

      public int getAdaptiveFetchSize(boolean adaptiveFetch, ResultCursor cursor)
      インタフェースからコピーされた説明: QueryExecutor
      Get fetch size computed by adaptive fetch size for given query.
      パラメータ:
      adaptiveFetch - state of adaptive fetch, which should be used during retrieving
      cursor - Cursor used by resultSet, containing query, have to be able to cast to Portal class.
      戻り値:
      fetch size computed by adaptive fetch size for given query passed inside cursor
    • setAdaptiveFetch

      public void setAdaptiveFetch(boolean adaptiveFetch)
      インタフェースからコピーされた説明: QueryExecutor
      Set state of adaptive fetch inside QueryExecutor.
      パラメータ:
      adaptiveFetch - desired state of adaptive fetch
    • getAdaptiveFetch

      public boolean getAdaptiveFetch()
      インタフェースからコピーされた説明: QueryExecutor
      Get state of adaptive fetch inside QueryExecutor.
      戻り値:
      state of adaptive fetch inside QueryExecutor
    • addQueryToAdaptiveFetchCache

      public void addQueryToAdaptiveFetchCache(boolean adaptiveFetch, ResultCursor cursor)
      インタフェースからコピーされた説明: QueryExecutor
      Add query to adaptive fetch cache inside QueryExecutor.
      パラメータ:
      adaptiveFetch - state of adaptive fetch used during adding query
      cursor - Cursor used by resultSet, containing query, have to be able to cast to Portal class.
    • removeQueryFromAdaptiveFetchCache

      public void removeQueryFromAdaptiveFetchCache(boolean adaptiveFetch, ResultCursor cursor)
      インタフェースからコピーされた説明: QueryExecutor
      Remove query from adaptive fetch cache inside QueryExecutor
      パラメータ:
      adaptiveFetch - state of adaptive fetch used during removing query
      cursor - Cursor used by resultSet, containing query, have to be able to cast to Portal class.
    • sendCloseMessage

      protected void sendCloseMessage() throws IOException
      クラスからコピーされた説明: QueryExecutorBase
      Sends "terminate connection" message to the backend.
      定義:
      sendCloseMessage クラス内 QueryExecutorBase
      例外:
      IOException - in case connection termination fails
    • readStartupMessages

      public void readStartupMessages() throws IOException, SQLException
      例外:
      IOException
      SQLException
    • receiveParameterStatus

      public void receiveParameterStatus() throws IOException, SQLException
      例外:
      IOException
      SQLException
    • setTimeZone

      public void setTimeZone(TimeZone timeZone)
    • getTimeZone

      public @Nullable TimeZone getTimeZone()
      インタフェースからコピーされた説明: QueryExecutor
      Returns backend timezone in java format.
      戻り値:
      backend timezone in java format.
    • setApplicationName

      public void setApplicationName(String applicationName)
    • getApplicationName

      public String getApplicationName()
      インタフェースからコピーされた説明: QueryExecutor
      Returns application_name connection property.
      戻り値:
      application_name connection property
    • getReplicationProtocol

      public ReplicationProtocol getReplicationProtocol()
      戻り値:
      the ReplicationProtocol instance for this connection.
    • addBinaryReceiveOid

      public void addBinaryReceiveOid(int oid)
      インタフェースからコピーされた説明: QueryExecutor
      Adds a single oid that should be received using binary encoding.
      パラメータ:
      oid - The oid to request with binary encoding.
    • removeBinaryReceiveOid

      public void removeBinaryReceiveOid(int oid)
      インタフェースからコピーされた説明: QueryExecutor
      Remove given oid from the list of oids for binary receive encoding.

      Note: the binary receive for the oid can be re-activated later.

      パラメータ:
      oid - The oid to request with binary encoding.
    • getBinaryReceiveOids

      public Set<? extends Integer> getBinaryReceiveOids()
      インタフェースからコピーされた説明: QueryExecutor
      Gets the oids that should be received using binary encoding.

      Note: this returns an unmodifiable set, and its contents might not reflect the current state.

      戻り値:
      The oids to request with binary encoding.
    • useBinaryForReceive

      public boolean useBinaryForReceive(int oid)
      インタフェースからコピーされた説明: TypeTransferModeRegistry
      Returns if given oid should be received in binary format.
      パラメータ:
      oid - type oid
      戻り値:
      true if given oid should be received in binary format
    • setBinaryReceiveOids

      public void setBinaryReceiveOids(Set<Integer> oids)
      インタフェースからコピーされた説明: QueryExecutor
      Sets the oids that should be received using binary encoding.
      パラメータ:
      oids - The oids to request with binary encoding.
    • addBinarySendOid

      public void addBinarySendOid(int oid)
      インタフェースからコピーされた説明: QueryExecutor
      Adds a single oid that should be sent using binary encoding.
      パラメータ:
      oid - The oid to send with binary encoding.
    • removeBinarySendOid

      public void removeBinarySendOid(int oid)
      インタフェースからコピーされた説明: QueryExecutor
      Remove given oid from the list of oids for binary send encoding.

      Note: the binary send for the oid can be re-activated later.

      パラメータ:
      oid - The oid to send with binary encoding.
    • getBinarySendOids

      public Set<? extends Integer> getBinarySendOids()
      インタフェースからコピーされた説明: QueryExecutor
      Gets the oids that should be sent using binary encoding.

      Note: this returns an unmodifiable set, and its contents might not reflect the current state.

      戻り値:
      useBinaryForOids The oids to send with binary encoding.
    • useBinaryForSend

      public boolean useBinaryForSend(int oid)
      インタフェースからコピーされた説明: TypeTransferModeRegistry
      Returns if given oid should be sent in binary format.
      パラメータ:
      oid - type oid
      戻り値:
      true if given oid should be sent in binary format
    • setBinarySendOids

      public void setBinarySendOids(Set<Integer> oids)
      インタフェースからコピーされた説明: QueryExecutor
      Sets the oids that should be sent using binary encoding.
      パラメータ:
      oids - The oids to send with binary encoding.
    • getIntegerDateTimes

      public boolean getIntegerDateTimes()
      インタフェースからコピーされた説明: QueryExecutor
      Returns true if server uses integer instead of double for binary date and time encodings.
      戻り値:
      the server integer_datetime setting.