From 1ec95b084ee7764e03eafbfc9499305330d085e1 Mon Sep 17 00:00:00 2001 From: douxin Date: Fri, 19 Apr 2024 15:34:42 +0800 Subject: [PATCH] [feature] adding trace_id --- build.properties | 8 ++++---- .../org/postgresql/core/v3/QueryExecutorImpl.java | 12 ++++++++++++ 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/build.properties b/build.properties index b900f9b..d908dcb 100644 --- a/build.properties +++ b/build.properties @@ -20,15 +20,15 @@ maven.staging.repository.id=sonatype-nexus-staging maven.staging.repository.url=https://oss.sonatype.org/service/local/staging/deploy/maven2 gs_version=openGauss 1.0.0 # the open postgresql jdbc properties -server=localhost -port=5432 +server=192.168.0.219 +port=55432 secondaryServer=localhost secondaryPort=5433 secondaryServer2=localhost secondaryServerPort2=5434 -database=postgres +database=testb username=test -password=test123@ +password=Sample@123 privilegedUser=postgres privilegedPassword= sspiusername=testsspi 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 985e447..47f96c9 100644 --- a/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java +++ b/pgjdbc/src/main/java/org/postgresql/core/v3/QueryExecutorImpl.java @@ -1579,6 +1579,16 @@ public class QueryExecutorImpl extends QueryExecutorBase { pendingDescribePortalQueue.add(sync); } + private void sendTraceId() throws IOException { + String traceId = "6f5d1e74-de53-11ed-b97a-fa163e3d2519"; + byte[] encodedTraceId = Utils.encodeUTF8(traceId); + int encodedSize = 4 + encodedTraceId.length + 1; + pgStream.sendChar('J'); + pgStream.sendInteger4(encodedSize); + pgStream.send(encodedTraceId); + pgStream.sendChar(0); + } + private void checkAndUpdateRewriteQueries(SimpleQuery query) { if (!(query instanceof BatchedQuery)) { return; @@ -2187,6 +2197,7 @@ public class QueryExecutorImpl extends QueryExecutorBase { rows = fetchSize; // maxRows > fetchSize } + sendTraceId(); sendParse(query, params, oneShot); // Must do this after sendParse to pick up any changes to the @@ -2288,6 +2299,7 @@ public class QueryExecutorImpl extends QueryExecutorBase { V3ParameterList parameters = (V3ParameterList) parameterLists[0]; SimpleParameterList params = (SimpleParameterList) parameters; + sendTraceId(); sendParse(query, params, oneShot); // Must do this after sendParse to pick up any changes to the -- Gitee