MCPcopy Create free account
hub / github.com/dolthub/doltgresql / convertQuery

Method convertQuery

server/connection_handler.go:1151–1180  ·  view source on GitHub ↗

convertQuery takes the given Postgres query, and converts it as an ast.ConvertedQuery that will work with the handler. If the query string contains multiple queries, then multiple ConvertedQuery will be returned.

(query string)

Source from the content-addressed store, hash-verified

1149// convertQuery takes the given Postgres query, and converts it as an ast.ConvertedQuery that will work with the handler.
1150// If the query string contains multiple queries, then multiple ConvertedQuery will be returned.
1151func (h *ConnectionHandler) convertQuery(query string) ([]ConvertedQuery, error) {
1152 s, err := parser.Parse(query)
1153 if err != nil {
1154 return nil, err
1155 }
1156 if len(s) == 0 {
1157 return []ConvertedQuery{{String: query}}, nil
1158 }
1159 converted := make([]ConvertedQuery, len(s))
1160 for i := range s {
1161 vitessAST, err := ast.Convert(s[i])
1162 stmtTag := s[i].AST.StatementTag()
1163 if err != nil {
1164 return nil, err
1165 }
1166 if vitessAST == nil {
1167 converted[i] = ConvertedQuery{
1168 String: s[i].AST.String(),
1169 StatementTag: stmtTag,
1170 }
1171 } else {
1172 converted[i] = ConvertedQuery{
1173 String: query,
1174 AST: vitessAST,
1175 StatementTag: stmtTag,
1176 }
1177 }
1178 }
1179 return converted, nil
1180}
1181
1182// discardAll handles the DISCARD ALL command
1183func (h *ConnectionHandler) discardAll(query ConvertedQuery) error {

Callers 2

handleQueryMethod · 0.95
handleParseMethod · 0.95

Calls 4

ParseFunction · 0.92
ConvertFunction · 0.92
StatementTagMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected