handleQueryOutsideEngine handles any queries that should be handled by the handler directly, rather than being passed to the engine. The response parameter |handled| is true if the query was handled, |endOfMessages| is true if no more messages are expected for this query and server should send the c
(query ConvertedQuery)
| 487 | // if no more messages are expected for this query and server should send the client a READY FOR QUERY message, |
| 488 | // and any error that occurred while handling the query. |
| 489 | func (h *ConnectionHandler) handleQueryOutsideEngine(query ConvertedQuery) (handled bool, endOfMessages bool, err error) { |
| 490 | switch stmt := query.AST.(type) { |
| 491 | case *sqlparser.Begin: |
| 492 | h.inTransaction = true |
| 493 | case *sqlparser.Commit: |
| 494 | h.inTransaction = false |
| 495 | case *sqlparser.Deallocate: |
| 496 | return true, true, h.deallocatePreparedStatement(stmt.Name, h.preparedStatements, query, h.Conn()) |
| 497 | case sqlparser.InjectedStatement: |
| 498 | switch injectedStmt := stmt.Statement.(type) { |
| 499 | case node.DiscardStatement: |
| 500 | return true, true, h.discardAll(query) |
| 501 | case *node.CopyFrom: |
| 502 | // When copying data from STDIN, the data is sent to the server as CopyData messages |
| 503 | // We send endOfMessages=false since the server will be in COPY DATA mode and won't |
| 504 | // be ready for more queries util COPY DATA mode is completed. |
| 505 | if injectedStmt.Stdin { |
| 506 | return true, false, h.handleCopyFromStdinQuery(injectedStmt, h.Conn()) |
| 507 | } else { |
| 508 | // copying from a file is handled in a single message |
| 509 | return true, true, h.copyFromFileQuery(injectedStmt) |
| 510 | } |
| 511 | } |
| 512 | } |
| 513 | return false, true, nil |
| 514 | } |
| 515 | |
| 516 | // handleParse handles a parse message, returning any error that occurs |
| 517 | func (h *ConnectionHandler) handleParse(message *pgproto3.Parse) error { |
no test coverage detected