Top Description Inners Fields Constructors Methods
org.h2.server.pg

public final Class PgServerThread

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .DataInputStream, .DataOutputStream, .EOFException, .IOException, .InputStream, .OutputStream, .StringReader, java.math.BigDecimal, .BigInteger, java.net.Socket, java.nio.charset.Charset, .StandardCharsets, java.sql.SQLException, java.util.ArrayList, .HashMap, .HashSet, .List, .Properties, java.util.regex.Pattern, org.h2.api.ErrorCode, org.h2.command.CommandInterface, org.h2.engine.ConnectionInfo, .Constants, .Database, .Engine, .SessionLocal, .SysProperties, org.h2.expression.ParameterInterface, org.h2.message.DbException, org.h2.result.ResultInterface, org.h2.schema.Schema, org.h2.table.Column, .Table, org.h2.util.DateTimeUtils, .MathUtils, .NetUtils, .NetworkConnectionInfo, .ScriptReader, .StringUtils, .TimeZoneProvider, .Utils, org.h2.value.CaseInsensitiveMap, .TypeInfo, .Value, .ValueArray, .ValueBigint, .ValueDate, .ValueDecfloat, .ValueDouble, .ValueInteger, .ValueNull, .ValueNumeric, .ValueReal, .ValueSmallint, .ValueTime, .ValueTimeTimeZone, .ValueTimestamp, .ValueTimestampTimeZone, .ValueVarbinary, .ValueVarchar

One server thread is opened for each client.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
PgServerThread.Portal

Represents a PostgreSQL Portal object.

pack-priv static class
PgServerThread.Prepared

Represents a PostgreSQL Prepared object.

Field Summary

Modifier and TypeField and Description
private CommandInterface
private String
private String
private DataInputStream
private DataInputStream
private DataOutputStream
private String
private boolean
private static final boolean
private static final int
private static final int
private int
private static final BigInteger
private static final short
private static final short
private static final short
private OutputStream
private ByteArrayOutputStream
private final HashMap<String, PgServerThread.Portal>
private static final int[]
private final HashMap<String, PgServerThread.Prepared>
private int
private final int
private final PgServer
private SessionLocal
private static final Pattern
private Socket
private boolean
private Thread
private TimeZoneProvider
private String

Constructor Summary

AccessConstructor and Description
pack-priv
PgServerThread(Socket socket, PgServer server)

Method Summary

Modifier and TypeMethod and Description
private synchronized void
cancelRequest()

Kill a currently running query on this thread.

private static void
checkParamLength(int expected, int got)

pack-priv void
close()

Close this connection.

private static String
convertTimeZone(String value, String prefix)

private static int
divide(BigInteger[] unscaled, int divisor)

private void
executeQuery(PgServerThread.Prepared prepared, CommandInterface prep, int[] resultColumnFormat, int maxRows)

private static boolean

Returns:

true for text
formatAsText
(int
data type
pgType
,
int[]
format codes, or null
formatCodes
,
int
0-based column number
column
)

Check whether the given type should be formatted as text.

private Charset
pack-priv int
private String
pack-priv Thread
private static int
getTypeSize(int pgType, int precision)

private void
private static String
private void
private byte
private void
readFully(byte[] buff)

private int
private Value
readNumericBinary(int paramLen)

private short
private String
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

private void
private void
private void
private void
private void
private void
private void
sendCommandComplete(CommandInterface command, long updateCount)

private void
private void
sendDataRow(ResultInterface result, int[] formatCodes)

private void
private void
private void
private void
private void
private void
sendParameterDescription(ArrayList<? extends ParameterInterface> parameters, int[] paramTypes)

private void
private void
private void
private void
sendRowDescription(ResultInterface result, int[] formatCodes)

private synchronized void
private void
setParameter(ArrayList<? extends ParameterInterface> parameters, int pgType, int i, int[] formatCodes)

pack-priv void
setProcessId(int id)

pack-priv void
setThread(Thread thread)

private void
startMessage(int newMessageType)

private static long
toPostgreDays(long dateValue)

private void
write(byte[] data)

private void
private void
write(int b)

private void
writeDataColumn(Value v, int pgType, boolean text)

private void
writeInt(int i)

private void
private void
writeShort(int i)

private void
private void
private void
writeTimeBinary(long m, int numBytes)

private void
writeTimestampBinary(long m, long nanos)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

activeRequestback to summary
private CommandInterface activeRequest
clientEncodingback to summary
private String clientEncoding
databaseNameback to summary
private String databaseName
dataInback to summary
private DataInputStream dataIn
dataInRawback to summary
private DataInputStream dataInRaw
dataOutback to summary
private DataOutputStream dataOut
dateStyleback to summary
private String dateStyle
initDoneback to summary
private boolean initDone
INTEGER_DATE_TYPESback to summary
private static final boolean INTEGER_DATE_TYPES
MAX_GROUP_SCALEback to summary
private static final int MAX_GROUP_SCALE
MAX_GROUP_SIZEback to summary
private static final int MAX_GROUP_SIZE
messageTypeback to summary
private int messageType
NUMERIC_CHUNK_MULTIPLIERback to summary
private static final BigInteger NUMERIC_CHUNK_MULTIPLIER
NUMERIC_NANback to summary
private static final short NUMERIC_NAN
NUMERIC_NEGATIVEback to summary
private static final short NUMERIC_NEGATIVE
NUMERIC_POSITIVEback to summary
private static final short NUMERIC_POSITIVE
outback to summary
private OutputStream out
outBufferback to summary
private ByteArrayOutputStream outBuffer
portalsback to summary
private final HashMap<String, PgServerThread.Portal> portals
POWERS10back to summary
private static final int[] POWERS10
preparedback to summary
private final HashMap<String, PgServerThread.Prepared> prepared
processIdback to summary
private int processId
secretback to summary
private final int secret
serverback to summary
private final PgServer server
sessionback to summary
private SessionLocal session
SHOULD_QUOTEback to summary
private static final Pattern SHOULD_QUOTE
socketback to summary
private Socket socket
stopback to summary
private boolean stop
threadback to summary
private Thread thread
timeZoneback to summary
private TimeZoneProvider timeZone
userNameback to summary
private String userName

Constructor Detail

PgServerThreadback to summary
pack-priv PgServerThread(Socket socket, PgServer server)

Method Detail

cancelRequestback to summary
private synchronized void cancelRequest()

Kill a currently running query on this thread.

checkParamLengthback to summary
private static void checkParamLength(int expected, int got)
closeback to summary
pack-priv void close()

Close this connection.

convertTimeZoneback to summary
private static String convertTimeZone(String value, String prefix)
divideback to summary
private static int divide(BigInteger[] unscaled, int divisor)
executeQueryback to summary
private void executeQuery(PgServerThread.Prepared prepared, CommandInterface prep, int[] resultColumnFormat, int maxRows) throws Exception
formatAsTextback to summary
private static boolean formatAsText(int pgType, int[] formatCodes, int column)

Check whether the given type should be formatted as text.

Parameters
pgType:int

data type

formatCodes:int[]

format codes, or null

column:int

0-based column number

Returns:boolean

true for text

getEncodingback to summary
private Charset getEncoding()
getProcessIdback to summary
pack-priv int getProcessId()
getSQLback to summary
private String getSQL(String s)
getThreadback to summary
pack-priv Thread getThread()
getTypeSizeback to summary
private static int getTypeSize(int pgType, int precision)
initDbback to summary
private void initDb()
pgTimeZoneback to summary
private static String pgTimeZone(String value)
processback to summary
private void process() throws IOException
readByteback to summary
private byte readByte() throws IOException
readFullyback to summary
private void readFully(byte[] buff) throws IOException
readIntback to summary
private int readInt() throws IOException
readNumericBinaryback to summary
private Value readNumericBinary(int paramLen) throws IOException
readShortback to summary
private short readShort() throws IOException
readStringback to summary
private String readString() throws IOException
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
sendAuthenticationCleartextPasswordback to summary
private void sendAuthenticationCleartextPassword() throws IOException
sendAuthenticationOkback to summary
private void sendAuthenticationOk() throws IOException
sendBackendKeyDataback to summary
private void sendBackendKeyData() throws IOException
sendBindCompleteback to summary
private void sendBindComplete() throws IOException
sendCancelQueryResponseback to summary
private void sendCancelQueryResponse() throws IOException
sendCloseCompleteback to summary
private void sendCloseComplete() throws IOException
sendCommandCompleteback to summary
private void sendCommandComplete(CommandInterface command, long updateCount) throws IOException
sendCommandSuspendedback to summary
private void sendCommandSuspended() throws IOException
sendDataRowback to summary
private void sendDataRow(ResultInterface result, int[] formatCodes) throws IOException
sendErrorOrCancelResponseback to summary
private void sendErrorOrCancelResponse(Exception e) throws IOException
sendErrorResponseback to summary
private void sendErrorResponse(Exception re) throws IOException
sendErrorResponseback to summary
private void sendErrorResponse(String message) throws IOException
sendMessageback to summary
private void sendMessage() throws IOException
sendNoDataback to summary
private void sendNoData() throws IOException
sendParameterDescriptionback to summary
private void sendParameterDescription(ArrayList<? extends ParameterInterface> parameters, int[] paramTypes) throws Exception
sendParameterStatusback to summary
private void sendParameterStatus(String param, String value) throws IOException
sendParseCompleteback to summary
private void sendParseComplete() throws IOException
sendReadyForQueryback to summary
private void sendReadyForQuery() throws IOException
sendRowDescriptionback to summary
private void sendRowDescription(ResultInterface result, int[] formatCodes) throws IOException
setActiveRequestback to summary
private synchronized void setActiveRequest(CommandInterface statement)
setParameterback to summary
private void setParameter(ArrayList<? extends ParameterInterface> parameters, int pgType, int i, int[] formatCodes) throws IOException
setProcessIdback to summary
pack-priv void setProcessId(int id)
setThreadback to summary
pack-priv void setThread(Thread thread)
startMessageback to summary
private void startMessage(int newMessageType)
toPostgreDaysback to summary
private static long toPostgreDays(long dateValue)
writeback to summary
private void write(byte[] data) throws IOException
writeback to summary
private void write(ByteArrayOutputStream baos) throws IOException
writeback to summary
private void write(int b) throws IOException
writeDataColumnback to summary
private void writeDataColumn(Value v, int pgType, boolean text) throws IOException
writeIntback to summary
private void writeInt(int i) throws IOException
writeNumericBinaryback to summary
private void writeNumericBinary(BigDecimal value) throws IOException
writeShortback to summary
private void writeShort(int i) throws IOException
writeStringback to summary
private void writeString(String s) throws IOException
writeStringPartback to summary
private void writeStringPart(String s) throws IOException
writeTimeBinaryback to summary
private void writeTimeBinary(long m, int numBytes) throws IOException
writeTimestampBinaryback to summary
private void writeTimestampBinary(long m, long nanos) throws IOException
org.h2.server.pg back to summary

pack-priv Class PgServerThread.Portal

extends Object
Class Inheritance

Represents a PostgreSQL Portal object.

Field Summary

Modifier and TypeField and Description
pack-priv String
name

The portal name.

pack-priv PgServerThread.Prepared
prep

The prepared object.

pack-priv int[]
resultColumnFormat

The format used in the result set columns (if set).

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nameback to summary
pack-priv String name

The portal name.

prepback to summary
pack-priv PgServerThread.Prepared prep

The prepared object.

resultColumnFormatback to summary
pack-priv int[] resultColumnFormat

The format used in the result set columns (if set).

Constructor Detail

Portalback to summary
pack-priv Portal()
org.h2.server.pg back to summary

pack-priv Class PgServerThread.Prepared

extends Object
Class Inheritance

Represents a PostgreSQL Prepared object.

Field Summary

Modifier and TypeField and Description
pack-priv String
name

The object name.

pack-priv int[]
paramType

The list of parameter types (if set).

pack-priv CommandInterface
prep

The prepared statement.

pack-priv ResultInterface
result

The current result (for suspended portal).

pack-priv String
sql

The SQL statement.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
close()

Closes prepared statement and result, if any.

pack-priv void
closeResult()

Closes the result, if any.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

nameback to summary
pack-priv String name

The object name.

paramTypeback to summary
pack-priv int[] paramType

The list of parameter types (if set).

prepback to summary
pack-priv CommandInterface prep

The prepared statement.

resultback to summary
pack-priv ResultInterface result

The current result (for suspended portal).

sqlback to summary
pack-priv String sql

The SQL statement.

Constructor Detail

Preparedback to summary
pack-priv Prepared()

Method Detail

closeback to summary
pack-priv void close()

Closes prepared statement and result, if any.

closeResultback to summary
pack-priv void closeResult()

Closes the result, if any.