Skip to content

Commit

Permalink
basic rename
Browse files Browse the repository at this point in the history
  • Loading branch information
makalaaneesh committed Dec 6, 2024
1 parent e242809 commit 1063357
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 7 deletions.
Empty file.
5 changes: 5 additions & 0 deletions yb-voyager/src/queryparser/helpers_protomsg.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package queryparser
import (
"strings"

pg_query "github.com/pganalyze/pg_query_go/v5"
log "github.com/sirupsen/logrus"
"google.golang.org/protobuf/reflect/protoreflect"
)
Expand All @@ -30,6 +31,10 @@ const (
XML_FUNCTIONS_DOC_LINK = DOCS_LINK_PREFIX + POSTGRESQL_PREFIX + "#xml-functions-is-not-yet-supported"
)

func GetProtoMessageFromParseTree(parseTree *pg_query.ParseResult) protoreflect.Message {
return parseTree.Stmts[0].Stmt.ProtoReflect()
}

func GetMsgFullName(msg protoreflect.Message) string {
return string(msg.Descriptor().FullName())
}
Expand Down
8 changes: 1 addition & 7 deletions yb-voyager/src/queryparser/helpers_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (

pg_query "github.com/pganalyze/pg_query_go/v5"
"github.com/samber/lo"
"google.golang.org/protobuf/reflect/protoreflect"
)

func DeparseSelectStmt(selectStmt *pg_query.SelectStmt) (string, error) {
Expand All @@ -43,10 +42,6 @@ func DeparseSelectStmt(selectStmt *pg_query.SelectStmt) (string, error) {
return "", nil
}

func GetProtoMessageFromParseTree(parseTree *pg_query.ParseResult) protoreflect.Message {
return parseTree.Stmts[0].Stmt.ProtoReflect()
}

func IsPLPGSQLObject(parseTree *pg_query.ParseResult) bool {
// CREATE FUNCTION is same parser NODE for FUNCTION/PROCEDURE
_, isPlPgSQLObject := getCreateFuncStmtNode(parseTree)
Expand Down Expand Up @@ -289,7 +284,6 @@ func GetFuncParametersTypeNames(parseTree *pg_query.ParseResult) []string {
return paramTypeNames
}


func IsDDL(parseTree *pg_query.ParseResult) (bool, error) {
ddlParser, err := GetDDLProcessor(parseTree)
if err != nil {
Expand All @@ -299,4 +293,4 @@ func IsDDL(parseTree *pg_query.ParseResult) (bool, error) {
//Considering all the DDLs we have a Processor for as of now.
//Not Full-proof as we don't have all DDL types but atleast we will skip all the types we know currently
return !ok, nil
}
}
11 changes: 11 additions & 0 deletions yb-voyager/src/queryparser/query_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

/*
This package contains all the logic related to parsing a query string, and extracting details out of it.
We mainly use the pg_query_go library to help with this.
The main functions in this package are:
1. Use pg_query_go to parse the query string into a ParseResult (i.e. a parseTree)
2. Traverse and process each protobufMessage node of the ParseTree.
3. For PLPGSQL, convert the PLPGSQL to JSON; get all the statements out of the PLPGSQL block.
we can put all the parser related logic (the parsing, the parsing of plpgsql to json, the traversal through the proto messages, the traversal through the nested plpgsql json, adding clauses to statements, etc
*/
package queryparser

import (
Expand Down
File renamed without changes.

0 comments on commit 1063357

Please sign in to comment.