NewConnectionHandler returns a new ConnectionHandler for the connection provided
(conn net.Conn, handler mysql.Handler, engine *gms.Engine, sm *server.SessionManager, connID uint32, server *Server)
| 74 | // pendingCommandCompletes are response tags whose statement has finished, |
| 75 | // but whose message-group transaction still needs to commit. COPY uses this |
| 76 | // queue in the extended protocol because the client may send Sync only after |
| 77 | // receiving all data frames. Keep a queue rather than a single slot so a |
| 78 | // pipelined group cannot silently lose an earlier COPY completion. |
| 79 | pendingCommandCompletes []*pgproto3.CommandComplete |
| 80 | // pendingProtocolMessages is the ordered form of the deferred response |
| 81 | // queue. Most statements only need a CommandComplete, but in-place handlers |
| 82 | // such as SET also emit ParameterStatus; keeping both messages in one queue |
| 83 | // preserves their wire order until an implicit simple-query commit succeeds. |
| 84 | pendingProtocolMessages []pgproto3.BackendMessage |
| 85 | // txStatus is the transaction state advertised by ReadyForQuery. It is |
| 86 | // deliberately kept at the protocol layer because PostgreSQL transaction |
| 87 | // control is handled outside GMS's transaction iterator. |
| 88 | txStatus ReadyForQueryTransactionIndicator |
| 89 | // copyFromStdinState is set when this connection is in the COPY FROM STDIN mode, meaning it is waiting on |
| 90 | // COPY DATA messages from the client to import data into tables. |
| 91 | copyFromStdinState *copyFromStdinState |
| 92 | // pendingCopyRelease keeps a successful extended-protocol COPY-IN lease |
| 93 | // alive from CopyDone through the following Sync, where the implicit |
| 94 | // transaction is committed. It is idempotent and nil outside that window. |
| 95 | pendingCopyRelease func() |
| 96 | |
| 97 | server *Server |
| 98 | readOnly bool |
| 99 | logger *logrus.Entry |
| 100 | } |
| 101 | |
| 102 | // frontendContext explicitly marks ordinary PostgreSQL protocol work. The |
| 103 | // origin marker is propagated into sql.Context and eventually into the |
| 104 | // provider's per-connection initializer; unmarked and replication contexts |
| 105 | // remain fail-closed. |
| 106 | func frontendContext(ctx context.Context) context.Context { |
| 107 | return mycontext.WithFrontendQuery(ctx) |
| 108 | } |
| 109 | |
| 110 | // statementLogText keeps diagnostic logging useful without formatting the |
| 111 | // full ConvertedStatement. The latter may carry a BackupConfig/RestoreConfig |
| 112 | // whose ObjectStorageConfig contains client credentials, and prepared portals |
| 113 | // may also carry bound values that must never be serialized into logs. |
| 114 | func statementLogText(statement ConvertedStatement) string { |
| 115 | if statement.BackupConfig != nil || statement.RestoreConfig != nil { |
| 116 | // The parsed config contains ObjectStorage credentials even when the |
| 117 | // original text was embedded in a larger statement. Never serialize that |
| 118 | // text or config into diagnostics. |
no test coverage detected