MCPcopy Create free account
hub / github.com/cockroachdb/cockroachdb-parser / GetTypeFromValidSQLSyntax

Function GetTypeFromValidSQLSyntax

pkg/sql/parser/parse.go:425–431  ·  view source on GitHub ↗

GetTypeFromValidSQLSyntax retrieves a type from its SQL syntax. The caller is responsible for guaranteeing that the type expression is valid SQL (or handling the resulting error). This includes verifying that complex identifiers are enclosed in double quotes, etc.

(sql string)

Source from the content-addressed store, hash-verified

423// SQL (or handling the resulting error). This includes verifying that complex
424// identifiers are enclosed in double quotes, etc.
425func GetTypeFromValidSQLSyntax(sql string) (tree.ResolvableTypeReference, error) {
426 expr, err := ParseExpr(fmt.Sprintf("1::%s", sql))
427 if err != nil {
428 return nil, err
429 }
430 return GetTypeFromCastOrCollate(expr)
431}
432
433// GetTypeFromCastOrCollate returns the type of the given tree.Expr. The method
434// assumes that the expression is either tree.CastExpr or tree.CollateExpr

Callers

nothing calls this directly

Calls 2

ParseExprFunction · 0.85
GetTypeFromCastOrCollateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…