pgjdbc/pgjdbc GitHub issues and pull requests (mirror)
help / color / mirror / Atom feedFrom: davecramer (@davecramer) <[email protected]>
To: pgjdbc/pgjdbc <[email protected]>
Subject: [pgjdbc/pgjdbc] PR #4119: refactor: replace literal chars with PgMessageType constants
Date: Sat, 30 May 2026 15:56:58 +0000
Message-ID: <[email protected]> (raw)
Replace raw character literals in QueryExecutorImpl with named constants from PgMessageType for readability and consistency:
- 'A', 'E', 'N' in notification polling and processResults
- 'I', 'T', 'E' transaction status in receiveRFQ
Add TRANSACTION_IDLE, TRANSACTION_OPEN, TRANSACTION_FAILED constants.
diff --git a/pgjdbc/src/main/java/org/postgresql/core/PgMessageType.java b/pgjdbc/src/main/java/org/postgresql/core/PgMessageType.java
index 3c2bfb76fb..2a6a37934c 100644
--- a/pgjdbc/src/main/java/org/postgresql/core/PgMessageType.java
+++ b/pgjdbc/src/main/java/org/postgresql/core/PgMessageType.java
@@ -58,4 +58,9 @@ public class PgMessageType {
public static final byte COPY_DONE = 'c';
public static final byte COPY_DATA = 'd';
+ // ReadyForQuery transaction status indicators
+ public static final byte TRANSACTION_IDLE = 'I';
+ public static final byte TRANSACTION_OPEN = 'T';
+ public static final byte TRANSACTION_FAILED = 'E';
+
}
diff --git a/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java b/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java
index 304a55f9cc..9afb9a3788 100644
--- a/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java
+++ b/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java
@@ -935,14 +935,14 @@ public void processNotifies(int timeoutMillis) throws SQLException {
setSocketTimeout(0); // Don't timeout after first char
}
switch (c) {
- case 'A': // Asynchronous Notify
+ case PgMessageType.ASYNCHRONOUS_NOTICE:
receiveAsyncNotify();
timeoutMillis = -1;
continue;
- case 'E':
+ case PgMessageType.ERROR_RESPONSE:
// Error Response (response to pretty much everything; backend then skips until Sync)
throw receiveErrorResponse();
- case 'N': // Notice Response (warnings / info)
+ case PgMessageType.NOTICE_RESPONSE: // warnings / info
SQLWarning warning = receiveNoticeResponse();
addWarning(warning);
if (useTimeout) {
@@ -2372,7 +2372,7 @@ protected void processResults(ResultHandler handler, int flags, boolean adaptive
while (!endQuery) {
c = pgStream.receiveChar();
switch (c) {
- case 'A': // Asynchronous Notify
+ case PgMessageType.ASYNCHRONOUS_NOTICE:
receiveAsyncNotify();
break;
@@ -3002,15 +3002,15 @@ private void receiveRFQ() throws IOException {
// Update connection state.
switch (tStatus) {
- case 'I':
+ case PgMessageType.TRANSACTION_IDLE:
transactionFailCause = null;
setTransactionState(TransactionState.IDLE);
break;
- case 'T':
+ case PgMessageType.TRANSACTION_OPEN:
transactionFailCause = null;
setTransactionState(TransactionState.OPEN);
break;
- case 'E':
+ case PgMessageType.TRANSACTION_FAILED:
setTransactionState(TransactionState.FAILED);
break;
default:
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: github://pgjdbc/pgjdbc
Cc: [email protected], [email protected]
Subject: Re: [pgjdbc/pgjdbc] PR #4119: refactor: replace literal chars with PgMessageType constants
In-Reply-To: <<[email protected]>>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox