Package org.h2.server.pg
Class PgServerThread
java.lang.Object
org.h2.server.pg.PgServerThread
- All Implemented Interfaces:
Runnable
One server thread is opened for each client.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static class
Represents a PostgreSQL Portal object.(package private) static class
Represents a PostgreSQL Prepared object. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate 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 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
Kill a currently running query on this thread.private static void
checkParamLength
(int expected, int got) (package private) 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
formatAsText
(int pgType, int[] formatCodes, int column) Check whether the given type should be formatted as text.private Charset
(package private) int
private String
(package private) Thread
private static int
getTypeSize
(int pgType, int precision) private void
initDb()
private static String
pgTimeZone
(String value) private void
process()
private byte
readByte()
private void
readFully
(byte[] buff) private int
readInt()
private short
private String
void
run()
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
sendErrorResponse
(String message) private void
private void
private void
sendParameterDescription
(ArrayList<? extends ParameterInterface> parameters, int[] paramTypes) private void
sendParameterStatus
(String param, String value) private void
private void
private void
sendRowDescription
(ResultInterface result, int[] formatCodes) private void
setActiveRequest
(CommandInterface statement) private void
setParameter
(ArrayList<? extends ParameterInterface> parameters, int pgType, int i, int[] formatCodes) (package private) void
setProcessId
(int id) (package private) void
private void
startMessage
(int newMessageType) private static long
toPostgreDays
(long dateValue) private void
write
(byte[] data) private void
write
(int b) private void
write
(ByteArrayOutputStream baos) private void
writeDataColumn
(Value v, int pgType, boolean text) private void
writeInt
(int i) private void
writeNumericBinary
(BigDecimal value) private void
writeShort
(int i) private void
private void
private void
writeTimeBinary
(long m, int numBytes) private void
writeTimestampBinary
(long m, long nanos)
-
Field Details
-
INTEGER_DATE_TYPES
private static final boolean INTEGER_DATE_TYPES- See Also:
-
SHOULD_QUOTE
-
server
-
socket
-
session
-
stop
private boolean stop -
dataInRaw
-
dataIn
-
out
-
messageType
private int messageType -
outBuffer
-
dataOut
-
thread
-
initDone
private boolean initDone -
userName
-
databaseName
-
processId
private int processId -
secret
private final int secret -
activeRequest
-
clientEncoding
-
dateStyle
-
timeZone
-
prepared
-
portals
-
POWERS10
private static final int[] POWERS10 -
MAX_GROUP_SCALE
private static final int MAX_GROUP_SCALE- See Also:
-
MAX_GROUP_SIZE
private static final int MAX_GROUP_SIZE
-
-
Constructor Details
-
PgServerThread
-
-
Method Details
-
pgTimeZone
-
convertTimeZone
-
run
public void run() -
readString
- Throws:
IOException
-
readInt
- Throws:
IOException
-
readShort
- Throws:
IOException
-
readByte
- Throws:
IOException
-
readFully
- Throws:
IOException
-
process
- Throws:
IOException
-
executeQuery
private void executeQuery(PgServerThread.Prepared prepared, CommandInterface prep, int[] resultColumnFormat, int maxRows) throws Exception - Throws:
Exception
-
getSQL
-
sendCommandComplete
- Throws:
IOException
-
sendCommandSuspended
- Throws:
IOException
-
sendDataRow
- Throws:
IOException
-
toPostgreDays
private static long toPostgreDays(long dateValue) -
writeDataColumn
- Throws:
IOException
-
divide
-
writeNumericBinary
- Throws:
IOException
-
writeTimeBinary
- Throws:
IOException
-
writeTimestampBinary
- Throws:
IOException
-
getEncoding
-
setParameter
private void setParameter(ArrayList<? extends ParameterInterface> parameters, int pgType, int i, int[] formatCodes) throws IOException - Throws:
IOException
-
checkParamLength
private static void checkParamLength(int expected, int got) -
sendErrorOrCancelResponse
- Throws:
IOException
-
sendErrorResponse
- Throws:
IOException
-
sendCancelQueryResponse
- Throws:
IOException
-
sendParameterDescription
private void sendParameterDescription(ArrayList<? extends ParameterInterface> parameters, int[] paramTypes) throws Exception - Throws:
Exception
-
sendNoData
- Throws:
IOException
-
sendRowDescription
- Throws:
IOException
-
formatAsText
private static boolean formatAsText(int pgType, int[] formatCodes, int column) Check whether the given type should be formatted as text.- Parameters:
pgType
- data typeformatCodes
- format codes, ornull
column
- 0-based column number- Returns:
- true for text
-
getTypeSize
private static int getTypeSize(int pgType, int precision) -
sendErrorResponse
- Throws:
IOException
-
sendParseComplete
- Throws:
IOException
-
sendBindComplete
- Throws:
IOException
-
sendCloseComplete
- Throws:
IOException
-
initDb
private void initDb() -
close
void close()Close this connection. -
sendAuthenticationCleartextPassword
- Throws:
IOException
-
sendAuthenticationOk
- Throws:
IOException
-
sendReadyForQuery
- Throws:
IOException
-
sendBackendKeyData
- Throws:
IOException
-
writeString
- Throws:
IOException
-
writeStringPart
- Throws:
IOException
-
writeInt
- Throws:
IOException
-
writeShort
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
write
- Throws:
IOException
-
startMessage
private void startMessage(int newMessageType) -
sendMessage
- Throws:
IOException
-
sendParameterStatus
- Throws:
IOException
-
setThread
-
getThread
Thread getThread() -
setProcessId
void setProcessId(int id) -
getProcessId
int getProcessId() -
setActiveRequest
-
cancelRequest
private void cancelRequest()Kill a currently running query on this thread.
-