123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615 |
- //go:build !windows
- // +build !windows
- package postgresql
- import (
- "fmt"
- pg "github.com/pganalyze/pg_query_go/v2"
- "github.com/kyleconroy/sqlc/internal/sql/ast"
- )
- func convertFuncParamMode(m pg.FunctionParameterMode) (ast.FuncParamMode, error) {
- switch m {
- case pg.FunctionParameterMode_FUNC_PARAM_IN:
- return ast.FuncParamIn, nil
- case pg.FunctionParameterMode_FUNC_PARAM_OUT:
- return ast.FuncParamOut, nil
- case pg.FunctionParameterMode_FUNC_PARAM_INOUT:
- return ast.FuncParamInOut, nil
- case pg.FunctionParameterMode_FUNC_PARAM_VARIADIC:
- return ast.FuncParamVariadic, nil
- case pg.FunctionParameterMode_FUNC_PARAM_TABLE:
- return ast.FuncParamTable, nil
- default:
- return -1, fmt.Errorf("parse func param: invalid mode %v", m)
- }
- }
- func convertSubLinkType(t pg.SubLinkType) (ast.SubLinkType, error) {
- switch t {
- case pg.SubLinkType_EXISTS_SUBLINK:
- return ast.EXISTS_SUBLINK, nil
- case pg.SubLinkType_ALL_SUBLINK:
- return ast.ALL_SUBLINK, nil
- case pg.SubLinkType_ANY_SUBLINK:
- return ast.ANY_SUBLINK, nil
- case pg.SubLinkType_ROWCOMPARE_SUBLINK:
- return ast.ROWCOMPARE_SUBLINK, nil
- case pg.SubLinkType_EXPR_SUBLINK:
- return ast.EXPR_SUBLINK, nil
- case pg.SubLinkType_MULTIEXPR_SUBLINK:
- return ast.MULTIEXPR_SUBLINK, nil
- case pg.SubLinkType_ARRAY_SUBLINK:
- return ast.ARRAY_SUBLINK, nil
- case pg.SubLinkType_CTE_SUBLINK:
- return ast.CTE_SUBLINK, nil
- default:
- return 0, fmt.Errorf("parse sublink type: unknown type %s", t)
- }
- }
- func convertSetOperation(t pg.SetOperation) (ast.SetOperation, error) {
- switch t {
- case pg.SetOperation_SETOP_NONE:
- return ast.None, nil
- case pg.SetOperation_SETOP_UNION:
- return ast.Union, nil
- case pg.SetOperation_SETOP_INTERSECT:
- return ast.Intersect, nil
- case pg.SetOperation_SETOP_EXCEPT:
- return ast.Except, nil
- default:
- return 0, fmt.Errorf("parse set operation: unknown type %s", t)
- }
- }
- func convertList(l *pg.List) *ast.List {
- out := &ast.List{}
- for _, item := range l.Items {
- out.Items = append(out.Items, convertNode(item))
- }
- return out
- }
- func convertSlice(nodes []*pg.Node) *ast.List {
- out := &ast.List{}
- for _, n := range nodes {
- out.Items = append(out.Items, convertNode(n))
- }
- return out
- }
- func convertValuesList(l [][]*pg.Node) *ast.List {
- out := &ast.List{}
- for _, outer := range l {
- o := &ast.List{}
- for _, inner := range outer {
- o.Items = append(o.Items, convertNode(inner))
- }
- out.Items = append(out.Items, o)
- }
- return out
- }
- func convert(node *pg.Node) (ast.Node, error) {
- return convertNode(node), nil
- }
- func convertA_ArrayExpr(n *pg.A_ArrayExpr) *ast.A_ArrayExpr {
- if n == nil {
- return nil
- }
- return &ast.A_ArrayExpr{
- Elements: convertSlice(n.Elements),
- Location: int(n.Location),
- }
- }
- func convertA_Const(n *pg.A_Const) *ast.A_Const {
- if n == nil {
- return nil
- }
- return &ast.A_Const{
- Val: convertNode(n.Val),
- Location: int(n.Location),
- }
- }
- func convertA_Expr(n *pg.A_Expr) *ast.A_Expr {
- if n == nil {
- return nil
- }
- return &ast.A_Expr{
- Kind: ast.A_Expr_Kind(n.Kind),
- Name: convertSlice(n.Name),
- Lexpr: convertNode(n.Lexpr),
- Rexpr: convertNode(n.Rexpr),
- Location: int(n.Location),
- }
- }
- func convertA_Indices(n *pg.A_Indices) *ast.A_Indices {
- if n == nil {
- return nil
- }
- return &ast.A_Indices{
- IsSlice: n.IsSlice,
- Lidx: convertNode(n.Lidx),
- Uidx: convertNode(n.Uidx),
- }
- }
- func convertA_Indirection(n *pg.A_Indirection) *ast.A_Indirection {
- if n == nil {
- return nil
- }
- return &ast.A_Indirection{
- Arg: convertNode(n.Arg),
- Indirection: convertSlice(n.Indirection),
- }
- }
- func convertA_Star(n *pg.A_Star) *ast.A_Star {
- if n == nil {
- return nil
- }
- return &ast.A_Star{}
- }
- func convertAccessPriv(n *pg.AccessPriv) *ast.AccessPriv {
- if n == nil {
- return nil
- }
- return &ast.AccessPriv{
- PrivName: makeString(n.PrivName),
- Cols: convertSlice(n.Cols),
- }
- }
- func convertAggref(n *pg.Aggref) *ast.Aggref {
- if n == nil {
- return nil
- }
- return &ast.Aggref{
- Xpr: convertNode(n.Xpr),
- Aggfnoid: ast.Oid(n.Aggfnoid),
- Aggtype: ast.Oid(n.Aggtype),
- Aggcollid: ast.Oid(n.Aggcollid),
- Inputcollid: ast.Oid(n.Inputcollid),
- Aggtranstype: ast.Oid(n.Aggtranstype),
- Aggargtypes: convertSlice(n.Aggargtypes),
- Aggdirectargs: convertSlice(n.Aggdirectargs),
- Args: convertSlice(n.Args),
- Aggorder: convertSlice(n.Aggorder),
- Aggdistinct: convertSlice(n.Aggdistinct),
- Aggfilter: convertNode(n.Aggfilter),
- Aggstar: n.Aggstar,
- Aggvariadic: n.Aggvariadic,
- Aggkind: makeByte(n.Aggkind),
- Agglevelsup: ast.Index(n.Agglevelsup),
- Aggsplit: ast.AggSplit(n.Aggsplit),
- Location: int(n.Location),
- }
- }
- func convertAlias(n *pg.Alias) *ast.Alias {
- if n == nil {
- return nil
- }
- return &ast.Alias{
- Aliasname: makeString(n.Aliasname),
- Colnames: convertSlice(n.Colnames),
- }
- }
- func convertAlterCollationStmt(n *pg.AlterCollationStmt) *ast.AlterCollationStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterCollationStmt{
- Collname: convertSlice(n.Collname),
- }
- }
- func convertAlterDatabaseSetStmt(n *pg.AlterDatabaseSetStmt) *ast.AlterDatabaseSetStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterDatabaseSetStmt{
- Dbname: makeString(n.Dbname),
- Setstmt: convertVariableSetStmt(n.Setstmt),
- }
- }
- func convertAlterDatabaseStmt(n *pg.AlterDatabaseStmt) *ast.AlterDatabaseStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterDatabaseStmt{
- Dbname: makeString(n.Dbname),
- Options: convertSlice(n.Options),
- }
- }
- func convertAlterDefaultPrivilegesStmt(n *pg.AlterDefaultPrivilegesStmt) *ast.AlterDefaultPrivilegesStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterDefaultPrivilegesStmt{
- Options: convertSlice(n.Options),
- Action: convertGrantStmt(n.Action),
- }
- }
- func convertAlterDomainStmt(n *pg.AlterDomainStmt) *ast.AlterDomainStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterDomainStmt{
- Subtype: makeByte(n.Subtype),
- TypeName: convertSlice(n.TypeName),
- Name: makeString(n.Name),
- Def: convertNode(n.Def),
- Behavior: ast.DropBehavior(n.Behavior),
- MissingOk: n.MissingOk,
- }
- }
- func convertAlterEnumStmt(n *pg.AlterEnumStmt) *ast.AlterEnumStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterEnumStmt{
- TypeName: convertSlice(n.TypeName),
- OldVal: makeString(n.OldVal),
- NewVal: makeString(n.NewVal),
- NewValNeighbor: makeString(n.NewValNeighbor),
- NewValIsAfter: n.NewValIsAfter,
- SkipIfNewValExists: n.SkipIfNewValExists,
- }
- }
- func convertAlterEventTrigStmt(n *pg.AlterEventTrigStmt) *ast.AlterEventTrigStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterEventTrigStmt{
- Trigname: makeString(n.Trigname),
- Tgenabled: makeByte(n.Tgenabled),
- }
- }
- func convertAlterExtensionContentsStmt(n *pg.AlterExtensionContentsStmt) *ast.AlterExtensionContentsStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterExtensionContentsStmt{
- Extname: makeString(n.Extname),
- Action: int(n.Action),
- Objtype: ast.ObjectType(n.Objtype),
- Object: convertNode(n.Object),
- }
- }
- func convertAlterExtensionStmt(n *pg.AlterExtensionStmt) *ast.AlterExtensionStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterExtensionStmt{
- Extname: makeString(n.Extname),
- Options: convertSlice(n.Options),
- }
- }
- func convertAlterFdwStmt(n *pg.AlterFdwStmt) *ast.AlterFdwStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterFdwStmt{
- Fdwname: makeString(n.Fdwname),
- FuncOptions: convertSlice(n.FuncOptions),
- Options: convertSlice(n.Options),
- }
- }
- func convertAlterForeignServerStmt(n *pg.AlterForeignServerStmt) *ast.AlterForeignServerStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterForeignServerStmt{
- Servername: makeString(n.Servername),
- Version: makeString(n.Version),
- Options: convertSlice(n.Options),
- HasVersion: n.HasVersion,
- }
- }
- func convertAlterFunctionStmt(n *pg.AlterFunctionStmt) *ast.AlterFunctionStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterFunctionStmt{
- Func: convertObjectWithArgs(n.Func),
- Actions: convertSlice(n.Actions),
- }
- }
- func convertAlterObjectDependsStmt(n *pg.AlterObjectDependsStmt) *ast.AlterObjectDependsStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterObjectDependsStmt{
- ObjectType: ast.ObjectType(n.ObjectType),
- Relation: convertRangeVar(n.Relation),
- Object: convertNode(n.Object),
- Extname: convertNode(n.Extname),
- }
- }
- func convertAlterObjectSchemaStmt(n *pg.AlterObjectSchemaStmt) *ast.AlterObjectSchemaStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterObjectSchemaStmt{
- ObjectType: ast.ObjectType(n.ObjectType),
- Relation: convertRangeVar(n.Relation),
- Object: convertNode(n.Object),
- Newschema: makeString(n.Newschema),
- MissingOk: n.MissingOk,
- }
- }
- func convertAlterOpFamilyStmt(n *pg.AlterOpFamilyStmt) *ast.AlterOpFamilyStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterOpFamilyStmt{
- Opfamilyname: convertSlice(n.Opfamilyname),
- Amname: makeString(n.Amname),
- IsDrop: n.IsDrop,
- Items: convertSlice(n.Items),
- }
- }
- func convertAlterOperatorStmt(n *pg.AlterOperatorStmt) *ast.AlterOperatorStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterOperatorStmt{
- Opername: convertObjectWithArgs(n.Opername),
- Options: convertSlice(n.Options),
- }
- }
- func convertAlterOwnerStmt(n *pg.AlterOwnerStmt) *ast.AlterOwnerStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterOwnerStmt{
- ObjectType: ast.ObjectType(n.ObjectType),
- Relation: convertRangeVar(n.Relation),
- Object: convertNode(n.Object),
- Newowner: convertRoleSpec(n.Newowner),
- }
- }
- func convertAlterPolicyStmt(n *pg.AlterPolicyStmt) *ast.AlterPolicyStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterPolicyStmt{
- PolicyName: makeString(n.PolicyName),
- Table: convertRangeVar(n.Table),
- Roles: convertSlice(n.Roles),
- Qual: convertNode(n.Qual),
- WithCheck: convertNode(n.WithCheck),
- }
- }
- func convertAlterPublicationStmt(n *pg.AlterPublicationStmt) *ast.AlterPublicationStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterPublicationStmt{
- Pubname: makeString(n.Pubname),
- Options: convertSlice(n.Options),
- Tables: convertSlice(n.Tables),
- ForAllTables: n.ForAllTables,
- TableAction: ast.DefElemAction(n.TableAction),
- }
- }
- func convertAlterRoleSetStmt(n *pg.AlterRoleSetStmt) *ast.AlterRoleSetStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterRoleSetStmt{
- Role: convertRoleSpec(n.Role),
- Database: makeString(n.Database),
- Setstmt: convertVariableSetStmt(n.Setstmt),
- }
- }
- func convertAlterRoleStmt(n *pg.AlterRoleStmt) *ast.AlterRoleStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterRoleStmt{
- Role: convertRoleSpec(n.Role),
- Options: convertSlice(n.Options),
- Action: int(n.Action),
- }
- }
- func convertAlterSeqStmt(n *pg.AlterSeqStmt) *ast.AlterSeqStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterSeqStmt{
- Sequence: convertRangeVar(n.Sequence),
- Options: convertSlice(n.Options),
- ForIdentity: n.ForIdentity,
- MissingOk: n.MissingOk,
- }
- }
- func convertAlterSubscriptionStmt(n *pg.AlterSubscriptionStmt) *ast.AlterSubscriptionStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterSubscriptionStmt{
- Kind: ast.AlterSubscriptionType(n.Kind),
- Subname: makeString(n.Subname),
- Conninfo: makeString(n.Conninfo),
- Publication: convertSlice(n.Publication),
- Options: convertSlice(n.Options),
- }
- }
- func convertAlterSystemStmt(n *pg.AlterSystemStmt) *ast.AlterSystemStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterSystemStmt{
- Setstmt: convertVariableSetStmt(n.Setstmt),
- }
- }
- func convertAlterTSConfigurationStmt(n *pg.AlterTSConfigurationStmt) *ast.AlterTSConfigurationStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterTSConfigurationStmt{
- Kind: ast.AlterTSConfigType(n.Kind),
- Cfgname: convertSlice(n.Cfgname),
- Tokentype: convertSlice(n.Tokentype),
- Dicts: convertSlice(n.Dicts),
- Override: n.Override,
- Replace: n.Replace,
- MissingOk: n.MissingOk,
- }
- }
- func convertAlterTSDictionaryStmt(n *pg.AlterTSDictionaryStmt) *ast.AlterTSDictionaryStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterTSDictionaryStmt{
- Dictname: convertSlice(n.Dictname),
- Options: convertSlice(n.Options),
- }
- }
- func convertAlterTableCmd(n *pg.AlterTableCmd) *ast.AlterTableCmd {
- if n == nil {
- return nil
- }
- def := convertNode(n.Def)
- columnDef := def.(*ast.ColumnDef)
- return &ast.AlterTableCmd{
- Subtype: ast.AlterTableType(n.Subtype),
- Name: makeString(n.Name),
- Newowner: convertRoleSpec(n.Newowner),
- Def: columnDef,
- Behavior: ast.DropBehavior(n.Behavior),
- MissingOk: n.MissingOk,
- }
- }
- func convertAlterTableMoveAllStmt(n *pg.AlterTableMoveAllStmt) *ast.AlterTableMoveAllStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterTableMoveAllStmt{
- OrigTablespacename: makeString(n.OrigTablespacename),
- Objtype: ast.ObjectType(n.Objtype),
- Roles: convertSlice(n.Roles),
- NewTablespacename: makeString(n.NewTablespacename),
- Nowait: n.Nowait,
- }
- }
- func convertAlterTableSpaceOptionsStmt(n *pg.AlterTableSpaceOptionsStmt) *ast.AlterTableSpaceOptionsStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterTableSpaceOptionsStmt{
- Tablespacename: makeString(n.Tablespacename),
- Options: convertSlice(n.Options),
- IsReset: n.IsReset,
- }
- }
- func convertAlterTableStmt(n *pg.AlterTableStmt) *ast.AlterTableStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterTableStmt{
- Relation: convertRangeVar(n.Relation),
- Cmds: convertSlice(n.Cmds),
- Relkind: ast.ObjectType(n.Relkind),
- MissingOk: n.MissingOk,
- }
- }
- func convertAlterUserMappingStmt(n *pg.AlterUserMappingStmt) *ast.AlterUserMappingStmt {
- if n == nil {
- return nil
- }
- return &ast.AlterUserMappingStmt{
- User: convertRoleSpec(n.User),
- Servername: makeString(n.Servername),
- Options: convertSlice(n.Options),
- }
- }
- func convertAlternativeSubPlan(n *pg.AlternativeSubPlan) *ast.AlternativeSubPlan {
- if n == nil {
- return nil
- }
- return &ast.AlternativeSubPlan{
- Xpr: convertNode(n.Xpr),
- Subplans: convertSlice(n.Subplans),
- }
- }
- func convertArrayCoerceExpr(n *pg.ArrayCoerceExpr) *ast.ArrayCoerceExpr {
- if n == nil {
- return nil
- }
- return &ast.ArrayCoerceExpr{
- Xpr: convertNode(n.Xpr),
- Arg: convertNode(n.Arg),
- Resulttype: ast.Oid(n.Resulttype),
- Resulttypmod: n.Resulttypmod,
- Resultcollid: ast.Oid(n.Resultcollid),
- Coerceformat: ast.CoercionForm(n.Coerceformat),
- Location: int(n.Location),
- }
- }
- func convertArrayExpr(n *pg.ArrayExpr) *ast.ArrayExpr {
- if n == nil {
- return nil
- }
- return &ast.ArrayExpr{
- Xpr: convertNode(n.Xpr),
- ArrayTypeid: ast.Oid(n.ArrayTypeid),
- ArrayCollid: ast.Oid(n.ArrayCollid),
- ElementTypeid: ast.Oid(n.ElementTypeid),
- Elements: convertSlice(n.Elements),
- Multidims: n.Multidims,
- Location: int(n.Location),
- }
- }
- func convertBitString(n *pg.BitString) *ast.BitString {
- if n == nil {
- return nil
- }
- return &ast.BitString{
- Str: n.Str,
- }
- }
- func convertBoolExpr(n *pg.BoolExpr) *ast.BoolExpr {
- if n == nil {
- return nil
- }
- return &ast.BoolExpr{
- Xpr: convertNode(n.Xpr),
- Boolop: ast.BoolExprType(n.Boolop),
- Args: convertSlice(n.Args),
- Location: int(n.Location),
- }
- }
- func convertBooleanTest(n *pg.BooleanTest) *ast.BooleanTest {
- if n == nil {
- return nil
- }
- return &ast.BooleanTest{
- Xpr: convertNode(n.Xpr),
- Arg: convertNode(n.Arg),
- Booltesttype: ast.BoolTestType(n.Booltesttype),
- Location: int(n.Location),
- }
- }
- func convertCaseExpr(n *pg.CaseExpr) *ast.CaseExpr {
- if n == nil {
- return nil
- }
- return &ast.CaseExpr{
- Xpr: convertNode(n.Xpr),
- Casetype: ast.Oid(n.Casetype),
- Casecollid: ast.Oid(n.Casecollid),
- Arg: convertNode(n.Arg),
- Args: convertSlice(n.Args),
- Defresult: convertNode(n.Defresult),
- Location: int(n.Location),
- }
- }
- func convertCaseTestExpr(n *pg.CaseTestExpr) *ast.CaseTestExpr {
- if n == nil {
- return nil
- }
- return &ast.CaseTestExpr{
- Xpr: convertNode(n.Xpr),
- TypeId: ast.Oid(n.TypeId),
- TypeMod: n.TypeMod,
- Collation: ast.Oid(n.Collation),
- }
- }
- func convertCaseWhen(n *pg.CaseWhen) *ast.CaseWhen {
- if n == nil {
- return nil
- }
- return &ast.CaseWhen{
- Xpr: convertNode(n.Xpr),
- Expr: convertNode(n.Expr),
- Result: convertNode(n.Result),
- Location: int(n.Location),
- }
- }
- func convertCheckPointStmt(n *pg.CheckPointStmt) *ast.CheckPointStmt {
- if n == nil {
- return nil
- }
- return &ast.CheckPointStmt{}
- }
- func convertClosePortalStmt(n *pg.ClosePortalStmt) *ast.ClosePortalStmt {
- if n == nil {
- return nil
- }
- return &ast.ClosePortalStmt{
- Portalname: makeString(n.Portalname),
- }
- }
- func convertClusterStmt(n *pg.ClusterStmt) *ast.ClusterStmt {
- if n == nil {
- return nil
- }
- return &ast.ClusterStmt{
- Relation: convertRangeVar(n.Relation),
- Indexname: makeString(n.Indexname),
- }
- }
- func convertCoalesceExpr(n *pg.CoalesceExpr) *ast.CoalesceExpr {
- if n == nil {
- return nil
- }
- return &ast.CoalesceExpr{
- Xpr: convertNode(n.Xpr),
- Coalescetype: ast.Oid(n.Coalescetype),
- Coalescecollid: ast.Oid(n.Coalescecollid),
- Args: convertSlice(n.Args),
- Location: int(n.Location),
- }
- }
- func convertCoerceToDomain(n *pg.CoerceToDomain) *ast.CoerceToDomain {
- if n == nil {
- return nil
- }
- return &ast.CoerceToDomain{
- Xpr: convertNode(n.Xpr),
- Arg: convertNode(n.Arg),
- Resulttype: ast.Oid(n.Resulttype),
- Resulttypmod: n.Resulttypmod,
- Resultcollid: ast.Oid(n.Resultcollid),
- Coercionformat: ast.CoercionForm(n.Coercionformat),
- Location: int(n.Location),
- }
- }
- func convertCoerceToDomainValue(n *pg.CoerceToDomainValue) *ast.CoerceToDomainValue {
- if n == nil {
- return nil
- }
- return &ast.CoerceToDomainValue{
- Xpr: convertNode(n.Xpr),
- TypeId: ast.Oid(n.TypeId),
- TypeMod: n.TypeMod,
- Collation: ast.Oid(n.Collation),
- Location: int(n.Location),
- }
- }
- func convertCoerceViaIO(n *pg.CoerceViaIO) *ast.CoerceViaIO {
- if n == nil {
- return nil
- }
- return &ast.CoerceViaIO{
- Xpr: convertNode(n.Xpr),
- Arg: convertNode(n.Arg),
- Resulttype: ast.Oid(n.Resulttype),
- Resultcollid: ast.Oid(n.Resultcollid),
- Coerceformat: ast.CoercionForm(n.Coerceformat),
- Location: int(n.Location),
- }
- }
- func convertCollateClause(n *pg.CollateClause) *ast.CollateClause {
- if n == nil {
- return nil
- }
- return &ast.CollateClause{
- Arg: convertNode(n.Arg),
- Collname: convertSlice(n.Collname),
- Location: int(n.Location),
- }
- }
- func convertCollateExpr(n *pg.CollateExpr) *ast.CollateExpr {
- if n == nil {
- return nil
- }
- return &ast.CollateExpr{
- Xpr: convertNode(n.Xpr),
- Arg: convertNode(n.Arg),
- CollOid: ast.Oid(n.CollOid),
- Location: int(n.Location),
- }
- }
- func convertColumnDef(n *pg.ColumnDef) *ast.ColumnDef {
- if n == nil {
- return nil
- }
- return &ast.ColumnDef{
- Colname: n.Colname,
- TypeName: convertTypeName(n.TypeName),
- Inhcount: int(n.Inhcount),
- IsLocal: n.IsLocal,
- IsNotNull: n.IsNotNull,
- IsFromType: n.IsFromType,
- Storage: makeByte(n.Storage),
- RawDefault: convertNode(n.RawDefault),
- CookedDefault: convertNode(n.CookedDefault),
- Identity: makeByte(n.Identity),
- CollClause: convertCollateClause(n.CollClause),
- CollOid: ast.Oid(n.CollOid),
- Constraints: convertSlice(n.Constraints),
- Fdwoptions: convertSlice(n.Fdwoptions),
- Location: int(n.Location),
- }
- }
- func convertColumnRef(n *pg.ColumnRef) *ast.ColumnRef {
- if n == nil {
- return nil
- }
- return &ast.ColumnRef{
- Fields: convertSlice(n.Fields),
- Location: int(n.Location),
- }
- }
- func convertCommentStmt(n *pg.CommentStmt) *ast.CommentStmt {
- if n == nil {
- return nil
- }
- return &ast.CommentStmt{
- Objtype: ast.ObjectType(n.Objtype),
- Object: convertNode(n.Object),
- Comment: makeString(n.Comment),
- }
- }
- func convertCommonTableExpr(n *pg.CommonTableExpr) *ast.CommonTableExpr {
- if n == nil {
- return nil
- }
- return &ast.CommonTableExpr{
- Ctename: makeString(n.Ctename),
- Aliascolnames: convertSlice(n.Aliascolnames),
- Ctequery: convertNode(n.Ctequery),
- Location: int(n.Location),
- Cterecursive: n.Cterecursive,
- Cterefcount: int(n.Cterefcount),
- Ctecolnames: convertSlice(n.Ctecolnames),
- Ctecoltypes: convertSlice(n.Ctecoltypes),
- Ctecoltypmods: convertSlice(n.Ctecoltypmods),
- Ctecolcollations: convertSlice(n.Ctecolcollations),
- }
- }
- func convertCompositeTypeStmt(n *pg.CompositeTypeStmt) *ast.CompositeTypeStmt {
- if n == nil {
- return nil
- }
- rel := parseRelationFromRangeVar(n.Typevar)
- return &ast.CompositeTypeStmt{
- TypeName: rel.TypeName(),
- }
- }
- func convertConstraint(n *pg.Constraint) *ast.Constraint {
- if n == nil {
- return nil
- }
- return &ast.Constraint{
- Contype: ast.ConstrType(n.Contype),
- Conname: makeString(n.Conname),
- Deferrable: n.Deferrable,
- Initdeferred: n.Initdeferred,
- Location: int(n.Location),
- IsNoInherit: n.IsNoInherit,
- RawExpr: convertNode(n.RawExpr),
- CookedExpr: makeString(n.CookedExpr),
- GeneratedWhen: makeByte(n.GeneratedWhen),
- Keys: convertSlice(n.Keys),
- Exclusions: convertSlice(n.Exclusions),
- Options: convertSlice(n.Options),
- Indexname: makeString(n.Indexname),
- Indexspace: makeString(n.Indexspace),
- AccessMethod: makeString(n.AccessMethod),
- WhereClause: convertNode(n.WhereClause),
- Pktable: convertRangeVar(n.Pktable),
- FkAttrs: convertSlice(n.FkAttrs),
- PkAttrs: convertSlice(n.PkAttrs),
- FkMatchtype: makeByte(n.FkMatchtype),
- FkUpdAction: makeByte(n.FkUpdAction),
- FkDelAction: makeByte(n.FkDelAction),
- OldConpfeqop: convertSlice(n.OldConpfeqop),
- OldPktableOid: ast.Oid(n.OldPktableOid),
- SkipValidation: n.SkipValidation,
- InitiallyValid: n.InitiallyValid,
- }
- }
- func convertConstraintsSetStmt(n *pg.ConstraintsSetStmt) *ast.ConstraintsSetStmt {
- if n == nil {
- return nil
- }
- return &ast.ConstraintsSetStmt{
- Constraints: convertSlice(n.Constraints),
- Deferred: n.Deferred,
- }
- }
- func convertConvertRowtypeExpr(n *pg.ConvertRowtypeExpr) *ast.ConvertRowtypeExpr {
- if n == nil {
- return nil
- }
- return &ast.ConvertRowtypeExpr{
- Xpr: convertNode(n.Xpr),
- Arg: convertNode(n.Arg),
- Resulttype: ast.Oid(n.Resulttype),
- Convertformat: ast.CoercionForm(n.Convertformat),
- Location: int(n.Location),
- }
- }
- func convertCopyStmt(n *pg.CopyStmt) *ast.CopyStmt {
- if n == nil {
- return nil
- }
- return &ast.CopyStmt{
- Relation: convertRangeVar(n.Relation),
- Query: convertNode(n.Query),
- Attlist: convertSlice(n.Attlist),
- IsFrom: n.IsFrom,
- IsProgram: n.IsProgram,
- Filename: makeString(n.Filename),
- Options: convertSlice(n.Options),
- }
- }
- func convertCreateAmStmt(n *pg.CreateAmStmt) *ast.CreateAmStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateAmStmt{
- Amname: makeString(n.Amname),
- HandlerName: convertSlice(n.HandlerName),
- Amtype: makeByte(n.Amtype),
- }
- }
- func convertCreateCastStmt(n *pg.CreateCastStmt) *ast.CreateCastStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateCastStmt{
- Sourcetype: convertTypeName(n.Sourcetype),
- Targettype: convertTypeName(n.Targettype),
- Func: convertObjectWithArgs(n.Func),
- Context: ast.CoercionContext(n.Context),
- Inout: n.Inout,
- }
- }
- func convertCreateConversionStmt(n *pg.CreateConversionStmt) *ast.CreateConversionStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateConversionStmt{
- ConversionName: convertSlice(n.ConversionName),
- ForEncodingName: makeString(n.ForEncodingName),
- ToEncodingName: makeString(n.ToEncodingName),
- FuncName: convertSlice(n.FuncName),
- Def: n.Def,
- }
- }
- func convertCreateDomainStmt(n *pg.CreateDomainStmt) *ast.CreateDomainStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateDomainStmt{
- Domainname: convertSlice(n.Domainname),
- TypeName: convertTypeName(n.TypeName),
- CollClause: convertCollateClause(n.CollClause),
- Constraints: convertSlice(n.Constraints),
- }
- }
- func convertCreateEnumStmt(n *pg.CreateEnumStmt) *ast.CreateEnumStmt {
- if n == nil {
- return nil
- }
- rel, err := parseRelationFromNodes(n.TypeName)
- if err != nil {
- panic(err)
- }
- return &ast.CreateEnumStmt{
- TypeName: rel.TypeName(),
- Vals: convertSlice(n.Vals),
- }
- }
- func convertCreateEventTrigStmt(n *pg.CreateEventTrigStmt) *ast.CreateEventTrigStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateEventTrigStmt{
- Trigname: makeString(n.Trigname),
- Eventname: makeString(n.Eventname),
- Whenclause: convertSlice(n.Whenclause),
- Funcname: convertSlice(n.Funcname),
- }
- }
- func convertCreateExtensionStmt(n *pg.CreateExtensionStmt) *ast.CreateExtensionStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateExtensionStmt{
- Extname: makeString(n.Extname),
- IfNotExists: n.IfNotExists,
- Options: convertSlice(n.Options),
- }
- }
- func convertCreateFdwStmt(n *pg.CreateFdwStmt) *ast.CreateFdwStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateFdwStmt{
- Fdwname: makeString(n.Fdwname),
- FuncOptions: convertSlice(n.FuncOptions),
- Options: convertSlice(n.Options),
- }
- }
- func convertCreateForeignServerStmt(n *pg.CreateForeignServerStmt) *ast.CreateForeignServerStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateForeignServerStmt{
- Servername: makeString(n.Servername),
- Servertype: makeString(n.Servertype),
- Version: makeString(n.Version),
- Fdwname: makeString(n.Fdwname),
- IfNotExists: n.IfNotExists,
- Options: convertSlice(n.Options),
- }
- }
- func convertCreateForeignTableStmt(n *pg.CreateForeignTableStmt) *ast.CreateForeignTableStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateForeignTableStmt{
- Servername: makeString(n.Servername),
- Options: convertSlice(n.Options),
- }
- }
- func convertCreateFunctionStmt(n *pg.CreateFunctionStmt) *ast.CreateFunctionStmt {
- if n == nil {
- return nil
- }
- rel, err := parseRelationFromNodes(n.Funcname)
- if err != nil {
- panic(err)
- }
- return &ast.CreateFunctionStmt{
- Replace: n.Replace,
- Func: rel.FuncName(),
- Params: convertSlice(n.Parameters),
- ReturnType: convertTypeName(n.ReturnType),
- Options: convertSlice(n.Options),
- }
- }
- func convertCreateOpClassItem(n *pg.CreateOpClassItem) *ast.CreateOpClassItem {
- if n == nil {
- return nil
- }
- return &ast.CreateOpClassItem{
- Itemtype: int(n.Itemtype),
- Name: convertObjectWithArgs(n.Name),
- Number: int(n.Number),
- OrderFamily: convertSlice(n.OrderFamily),
- ClassArgs: convertSlice(n.ClassArgs),
- Storedtype: convertTypeName(n.Storedtype),
- }
- }
- func convertCreateOpClassStmt(n *pg.CreateOpClassStmt) *ast.CreateOpClassStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateOpClassStmt{
- Opclassname: convertSlice(n.Opclassname),
- Opfamilyname: convertSlice(n.Opfamilyname),
- Amname: makeString(n.Amname),
- Datatype: convertTypeName(n.Datatype),
- Items: convertSlice(n.Items),
- IsDefault: n.IsDefault,
- }
- }
- func convertCreateOpFamilyStmt(n *pg.CreateOpFamilyStmt) *ast.CreateOpFamilyStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateOpFamilyStmt{
- Opfamilyname: convertSlice(n.Opfamilyname),
- Amname: makeString(n.Amname),
- }
- }
- func convertCreatePLangStmt(n *pg.CreatePLangStmt) *ast.CreatePLangStmt {
- if n == nil {
- return nil
- }
- return &ast.CreatePLangStmt{
- Replace: n.Replace,
- Plname: makeString(n.Plname),
- Plhandler: convertSlice(n.Plhandler),
- Plinline: convertSlice(n.Plinline),
- Plvalidator: convertSlice(n.Plvalidator),
- Pltrusted: n.Pltrusted,
- }
- }
- func convertCreatePolicyStmt(n *pg.CreatePolicyStmt) *ast.CreatePolicyStmt {
- if n == nil {
- return nil
- }
- return &ast.CreatePolicyStmt{
- PolicyName: makeString(n.PolicyName),
- Table: convertRangeVar(n.Table),
- CmdName: makeString(n.CmdName),
- Permissive: n.Permissive,
- Roles: convertSlice(n.Roles),
- Qual: convertNode(n.Qual),
- WithCheck: convertNode(n.WithCheck),
- }
- }
- func convertCreatePublicationStmt(n *pg.CreatePublicationStmt) *ast.CreatePublicationStmt {
- if n == nil {
- return nil
- }
- return &ast.CreatePublicationStmt{
- Pubname: makeString(n.Pubname),
- Options: convertSlice(n.Options),
- Tables: convertSlice(n.Tables),
- ForAllTables: n.ForAllTables,
- }
- }
- func convertCreateRangeStmt(n *pg.CreateRangeStmt) *ast.CreateRangeStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateRangeStmt{
- TypeName: convertSlice(n.TypeName),
- Params: convertSlice(n.Params),
- }
- }
- func convertCreateRoleStmt(n *pg.CreateRoleStmt) *ast.CreateRoleStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateRoleStmt{
- StmtType: ast.RoleStmtType(n.StmtType),
- Role: makeString(n.Role),
- Options: convertSlice(n.Options),
- }
- }
- func convertCreateSchemaStmt(n *pg.CreateSchemaStmt) *ast.CreateSchemaStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateSchemaStmt{
- Name: makeString(n.Schemaname),
- Authrole: convertRoleSpec(n.Authrole),
- SchemaElts: convertSlice(n.SchemaElts),
- IfNotExists: n.IfNotExists,
- }
- }
- func convertCreateSeqStmt(n *pg.CreateSeqStmt) *ast.CreateSeqStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateSeqStmt{
- Sequence: convertRangeVar(n.Sequence),
- Options: convertSlice(n.Options),
- OwnerId: ast.Oid(n.OwnerId),
- ForIdentity: n.ForIdentity,
- IfNotExists: n.IfNotExists,
- }
- }
- func convertCreateStatsStmt(n *pg.CreateStatsStmt) *ast.CreateStatsStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateStatsStmt{
- Defnames: convertSlice(n.Defnames),
- StatTypes: convertSlice(n.StatTypes),
- Exprs: convertSlice(n.Exprs),
- Relations: convertSlice(n.Relations),
- IfNotExists: n.IfNotExists,
- }
- }
- func convertCreateStmt(n *pg.CreateStmt) *ast.CreateStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateStmt{
- Relation: convertRangeVar(n.Relation),
- TableElts: convertSlice(n.TableElts),
- InhRelations: convertSlice(n.InhRelations),
- Partbound: convertPartitionBoundSpec(n.Partbound),
- Partspec: convertPartitionSpec(n.Partspec),
- OfTypename: convertTypeName(n.OfTypename),
- Constraints: convertSlice(n.Constraints),
- Options: convertSlice(n.Options),
- Oncommit: ast.OnCommitAction(n.Oncommit),
- Tablespacename: makeString(n.Tablespacename),
- IfNotExists: n.IfNotExists,
- }
- }
- func convertCreateSubscriptionStmt(n *pg.CreateSubscriptionStmt) *ast.CreateSubscriptionStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateSubscriptionStmt{
- Subname: makeString(n.Subname),
- Conninfo: makeString(n.Conninfo),
- Publication: convertSlice(n.Publication),
- Options: convertSlice(n.Options),
- }
- }
- func convertCreateTableAsStmt(n *pg.CreateTableAsStmt) *ast.CreateTableAsStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateTableAsStmt{
- Query: convertNode(n.Query),
- Into: convertIntoClause(n.Into),
- Relkind: ast.ObjectType(n.Relkind),
- IsSelectInto: n.IsSelectInto,
- IfNotExists: n.IfNotExists,
- }
- }
- func convertCreateTableSpaceStmt(n *pg.CreateTableSpaceStmt) *ast.CreateTableSpaceStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateTableSpaceStmt{
- Tablespacename: makeString(n.Tablespacename),
- Owner: convertRoleSpec(n.Owner),
- Location: makeString(n.Location),
- Options: convertSlice(n.Options),
- }
- }
- func convertCreateTransformStmt(n *pg.CreateTransformStmt) *ast.CreateTransformStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateTransformStmt{
- Replace: n.Replace,
- TypeName: convertTypeName(n.TypeName),
- Lang: makeString(n.Lang),
- Fromsql: convertObjectWithArgs(n.Fromsql),
- Tosql: convertObjectWithArgs(n.Tosql),
- }
- }
- func convertCreateTrigStmt(n *pg.CreateTrigStmt) *ast.CreateTrigStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateTrigStmt{
- Trigname: makeString(n.Trigname),
- Relation: convertRangeVar(n.Relation),
- Funcname: convertSlice(n.Funcname),
- Args: convertSlice(n.Args),
- Row: n.Row,
- Timing: int16(n.Timing),
- Events: int16(n.Events),
- Columns: convertSlice(n.Columns),
- WhenClause: convertNode(n.WhenClause),
- Isconstraint: n.Isconstraint,
- TransitionRels: convertSlice(n.TransitionRels),
- Deferrable: n.Deferrable,
- Initdeferred: n.Initdeferred,
- Constrrel: convertRangeVar(n.Constrrel),
- }
- }
- func convertCreateUserMappingStmt(n *pg.CreateUserMappingStmt) *ast.CreateUserMappingStmt {
- if n == nil {
- return nil
- }
- return &ast.CreateUserMappingStmt{
- User: convertRoleSpec(n.User),
- Servername: makeString(n.Servername),
- IfNotExists: n.IfNotExists,
- Options: convertSlice(n.Options),
- }
- }
- func convertCreatedbStmt(n *pg.CreatedbStmt) *ast.CreatedbStmt {
- if n == nil {
- return nil
- }
- return &ast.CreatedbStmt{
- Dbname: makeString(n.Dbname),
- Options: convertSlice(n.Options),
- }
- }
- func convertCurrentOfExpr(n *pg.CurrentOfExpr) *ast.CurrentOfExpr {
- if n == nil {
- return nil
- }
- return &ast.CurrentOfExpr{
- Xpr: convertNode(n.Xpr),
- Cvarno: ast.Index(n.Cvarno),
- CursorName: makeString(n.CursorName),
- CursorParam: int(n.CursorParam),
- }
- }
- func convertDeallocateStmt(n *pg.DeallocateStmt) *ast.DeallocateStmt {
- if n == nil {
- return nil
- }
- return &ast.DeallocateStmt{
- Name: makeString(n.Name),
- }
- }
- func convertDeclareCursorStmt(n *pg.DeclareCursorStmt) *ast.DeclareCursorStmt {
- if n == nil {
- return nil
- }
- return &ast.DeclareCursorStmt{
- Portalname: makeString(n.Portalname),
- Options: int(n.Options),
- Query: convertNode(n.Query),
- }
- }
- func convertDefElem(n *pg.DefElem) *ast.DefElem {
- if n == nil {
- return nil
- }
- return &ast.DefElem{
- Defnamespace: makeString(n.Defnamespace),
- Defname: makeString(n.Defname),
- Arg: convertNode(n.Arg),
- Defaction: ast.DefElemAction(n.Defaction),
- Location: int(n.Location),
- }
- }
- func convertDefineStmt(n *pg.DefineStmt) *ast.DefineStmt {
- if n == nil {
- return nil
- }
- return &ast.DefineStmt{
- Kind: ast.ObjectType(n.Kind),
- Oldstyle: n.Oldstyle,
- Defnames: convertSlice(n.Defnames),
- Args: convertSlice(n.Args),
- Definition: convertSlice(n.Definition),
- IfNotExists: n.IfNotExists,
- }
- }
- func convertDeleteStmt(n *pg.DeleteStmt) *ast.DeleteStmt {
- if n == nil {
- return nil
- }
- return &ast.DeleteStmt{
- Relation: convertRangeVar(n.Relation),
- UsingClause: convertSlice(n.UsingClause),
- WhereClause: convertNode(n.WhereClause),
- ReturningList: convertSlice(n.ReturningList),
- WithClause: convertWithClause(n.WithClause),
- }
- }
- func convertDiscardStmt(n *pg.DiscardStmt) *ast.DiscardStmt {
- if n == nil {
- return nil
- }
- return &ast.DiscardStmt{
- Target: ast.DiscardMode(n.Target),
- }
- }
- func convertDoStmt(n *pg.DoStmt) *ast.DoStmt {
- if n == nil {
- return nil
- }
- return &ast.DoStmt{
- Args: convertSlice(n.Args),
- }
- }
- func convertDropOwnedStmt(n *pg.DropOwnedStmt) *ast.DropOwnedStmt {
- if n == nil {
- return nil
- }
- return &ast.DropOwnedStmt{
- Roles: convertSlice(n.Roles),
- Behavior: ast.DropBehavior(n.Behavior),
- }
- }
- func convertDropRoleStmt(n *pg.DropRoleStmt) *ast.DropRoleStmt {
- if n == nil {
- return nil
- }
- return &ast.DropRoleStmt{
- Roles: convertSlice(n.Roles),
- MissingOk: n.MissingOk,
- }
- }
- func convertDropStmt(n *pg.DropStmt) *ast.DropStmt {
- if n == nil {
- return nil
- }
- return &ast.DropStmt{
- Objects: convertSlice(n.Objects),
- RemoveType: ast.ObjectType(n.RemoveType),
- Behavior: ast.DropBehavior(n.Behavior),
- MissingOk: n.MissingOk,
- Concurrent: n.Concurrent,
- }
- }
- func convertDropSubscriptionStmt(n *pg.DropSubscriptionStmt) *ast.DropSubscriptionStmt {
- if n == nil {
- return nil
- }
- return &ast.DropSubscriptionStmt{
- Subname: makeString(n.Subname),
- MissingOk: n.MissingOk,
- Behavior: ast.DropBehavior(n.Behavior),
- }
- }
- func convertDropTableSpaceStmt(n *pg.DropTableSpaceStmt) *ast.DropTableSpaceStmt {
- if n == nil {
- return nil
- }
- return &ast.DropTableSpaceStmt{
- Tablespacename: makeString(n.Tablespacename),
- MissingOk: n.MissingOk,
- }
- }
- func convertDropUserMappingStmt(n *pg.DropUserMappingStmt) *ast.DropUserMappingStmt {
- if n == nil {
- return nil
- }
- return &ast.DropUserMappingStmt{
- User: convertRoleSpec(n.User),
- Servername: makeString(n.Servername),
- MissingOk: n.MissingOk,
- }
- }
- func convertDropdbStmt(n *pg.DropdbStmt) *ast.DropdbStmt {
- if n == nil {
- return nil
- }
- return &ast.DropdbStmt{
- Dbname: makeString(n.Dbname),
- MissingOk: n.MissingOk,
- }
- }
- func convertExecuteStmt(n *pg.ExecuteStmt) *ast.ExecuteStmt {
- if n == nil {
- return nil
- }
- return &ast.ExecuteStmt{
- Name: makeString(n.Name),
- Params: convertSlice(n.Params),
- }
- }
- func convertExplainStmt(n *pg.ExplainStmt) *ast.ExplainStmt {
- if n == nil {
- return nil
- }
- return &ast.ExplainStmt{
- Query: convertNode(n.Query),
- Options: convertSlice(n.Options),
- }
- }
- func convertExpr(n *pg.Expr) *ast.Expr {
- if n == nil {
- return nil
- }
- return &ast.Expr{}
- }
- func convertFetchStmt(n *pg.FetchStmt) *ast.FetchStmt {
- if n == nil {
- return nil
- }
- return &ast.FetchStmt{
- Direction: ast.FetchDirection(n.Direction),
- HowMany: n.HowMany,
- Portalname: makeString(n.Portalname),
- Ismove: n.Ismove,
- }
- }
- func convertFieldSelect(n *pg.FieldSelect) *ast.FieldSelect {
- if n == nil {
- return nil
- }
- return &ast.FieldSelect{
- Xpr: convertNode(n.Xpr),
- Arg: convertNode(n.Arg),
- Fieldnum: ast.AttrNumber(n.Fieldnum),
- Resulttype: ast.Oid(n.Resulttype),
- Resulttypmod: n.Resulttypmod,
- Resultcollid: ast.Oid(n.Resultcollid),
- }
- }
- func convertFieldStore(n *pg.FieldStore) *ast.FieldStore {
- if n == nil {
- return nil
- }
- return &ast.FieldStore{
- Xpr: convertNode(n.Xpr),
- Arg: convertNode(n.Arg),
- Newvals: convertSlice(n.Newvals),
- Fieldnums: convertSlice(n.Fieldnums),
- Resulttype: ast.Oid(n.Resulttype),
- }
- }
- func convertFloat(n *pg.Float) *ast.Float {
- if n == nil {
- return nil
- }
- return &ast.Float{
- Str: n.Str,
- }
- }
- func convertFromExpr(n *pg.FromExpr) *ast.FromExpr {
- if n == nil {
- return nil
- }
- return &ast.FromExpr{
- Fromlist: convertSlice(n.Fromlist),
- Quals: convertNode(n.Quals),
- }
- }
- func convertFuncCall(n *pg.FuncCall) *ast.FuncCall {
- if n == nil {
- return nil
- }
- rel, err := parseRelationFromNodes(n.Funcname)
- if err != nil {
- // TODO: How should we handle errors?
- panic(err)
- }
- return &ast.FuncCall{
- Func: rel.FuncName(),
- Funcname: convertSlice(n.Funcname),
- Args: convertSlice(n.Args),
- AggOrder: convertSlice(n.AggOrder),
- AggFilter: convertNode(n.AggFilter),
- AggWithinGroup: n.AggWithinGroup,
- AggStar: n.AggStar,
- AggDistinct: n.AggDistinct,
- FuncVariadic: n.FuncVariadic,
- Over: convertWindowDef(n.Over),
- Location: int(n.Location),
- }
- }
- func convertFuncExpr(n *pg.FuncExpr) *ast.FuncExpr {
- if n == nil {
- return nil
- }
- return &ast.FuncExpr{
- Xpr: convertNode(n.Xpr),
- Funcid: ast.Oid(n.Funcid),
- Funcresulttype: ast.Oid(n.Funcresulttype),
- Funcretset: n.Funcretset,
- Funcvariadic: n.Funcvariadic,
- Funcformat: ast.CoercionForm(n.Funcformat),
- Funccollid: ast.Oid(n.Funccollid),
- Inputcollid: ast.Oid(n.Inputcollid),
- Args: convertSlice(n.Args),
- Location: int(n.Location),
- }
- }
- func convertFunctionParameter(n *pg.FunctionParameter) *ast.FunctionParameter {
- if n == nil {
- return nil
- }
- return &ast.FunctionParameter{
- Name: makeString(n.Name),
- ArgType: convertTypeName(n.ArgType),
- Mode: ast.FunctionParameterMode(n.Mode),
- Defexpr: convertNode(n.Defexpr),
- }
- }
- func convertGrantRoleStmt(n *pg.GrantRoleStmt) *ast.GrantRoleStmt {
- if n == nil {
- return nil
- }
- return &ast.GrantRoleStmt{
- GrantedRoles: convertSlice(n.GrantedRoles),
- GranteeRoles: convertSlice(n.GranteeRoles),
- IsGrant: n.IsGrant,
- AdminOpt: n.AdminOpt,
- Grantor: convertRoleSpec(n.Grantor),
- Behavior: ast.DropBehavior(n.Behavior),
- }
- }
- func convertGrantStmt(n *pg.GrantStmt) *ast.GrantStmt {
- if n == nil {
- return nil
- }
- return &ast.GrantStmt{
- IsGrant: n.IsGrant,
- Targtype: ast.GrantTargetType(n.Targtype),
- Objtype: ast.GrantObjectType(n.Objtype),
- Objects: convertSlice(n.Objects),
- Privileges: convertSlice(n.Privileges),
- Grantees: convertSlice(n.Grantees),
- GrantOption: n.GrantOption,
- Behavior: ast.DropBehavior(n.Behavior),
- }
- }
- func convertGroupingFunc(n *pg.GroupingFunc) *ast.GroupingFunc {
- if n == nil {
- return nil
- }
- return &ast.GroupingFunc{
- Xpr: convertNode(n.Xpr),
- Args: convertSlice(n.Args),
- Refs: convertSlice(n.Refs),
- Cols: convertSlice(n.Cols),
- Agglevelsup: ast.Index(n.Agglevelsup),
- Location: int(n.Location),
- }
- }
- func convertGroupingSet(n *pg.GroupingSet) *ast.GroupingSet {
- if n == nil {
- return nil
- }
- return &ast.GroupingSet{
- Kind: ast.GroupingSetKind(n.Kind),
- Content: convertSlice(n.Content),
- Location: int(n.Location),
- }
- }
- func convertImportForeignSchemaStmt(n *pg.ImportForeignSchemaStmt) *ast.ImportForeignSchemaStmt {
- if n == nil {
- return nil
- }
- return &ast.ImportForeignSchemaStmt{
- ServerName: makeString(n.ServerName),
- RemoteSchema: makeString(n.RemoteSchema),
- LocalSchema: makeString(n.LocalSchema),
- ListType: ast.ImportForeignSchemaType(n.ListType),
- TableList: convertSlice(n.TableList),
- Options: convertSlice(n.Options),
- }
- }
- func convertIndexElem(n *pg.IndexElem) *ast.IndexElem {
- if n == nil {
- return nil
- }
- return &ast.IndexElem{
- Name: makeString(n.Name),
- Expr: convertNode(n.Expr),
- Indexcolname: makeString(n.Indexcolname),
- Collation: convertSlice(n.Collation),
- Opclass: convertSlice(n.Opclass),
- Ordering: ast.SortByDir(n.Ordering),
- NullsOrdering: ast.SortByNulls(n.NullsOrdering),
- }
- }
- func convertIndexStmt(n *pg.IndexStmt) *ast.IndexStmt {
- if n == nil {
- return nil
- }
- return &ast.IndexStmt{
- Idxname: makeString(n.Idxname),
- Relation: convertRangeVar(n.Relation),
- AccessMethod: makeString(n.AccessMethod),
- TableSpace: makeString(n.TableSpace),
- IndexParams: convertSlice(n.IndexParams),
- Options: convertSlice(n.Options),
- WhereClause: convertNode(n.WhereClause),
- ExcludeOpNames: convertSlice(n.ExcludeOpNames),
- Idxcomment: makeString(n.Idxcomment),
- IndexOid: ast.Oid(n.IndexOid),
- OldNode: ast.Oid(n.OldNode),
- Unique: n.Unique,
- Primary: n.Primary,
- Isconstraint: n.Isconstraint,
- Deferrable: n.Deferrable,
- Initdeferred: n.Initdeferred,
- Transformed: n.Transformed,
- Concurrent: n.Concurrent,
- IfNotExists: n.IfNotExists,
- }
- }
- func convertInferClause(n *pg.InferClause) *ast.InferClause {
- if n == nil {
- return nil
- }
- return &ast.InferClause{
- IndexElems: convertSlice(n.IndexElems),
- WhereClause: convertNode(n.WhereClause),
- Conname: makeString(n.Conname),
- Location: int(n.Location),
- }
- }
- func convertInferenceElem(n *pg.InferenceElem) *ast.InferenceElem {
- if n == nil {
- return nil
- }
- return &ast.InferenceElem{
- Xpr: convertNode(n.Xpr),
- Expr: convertNode(n.Expr),
- Infercollid: ast.Oid(n.Infercollid),
- Inferopclass: ast.Oid(n.Inferopclass),
- }
- }
- func convertInlineCodeBlock(n *pg.InlineCodeBlock) *ast.InlineCodeBlock {
- if n == nil {
- return nil
- }
- return &ast.InlineCodeBlock{
- SourceText: makeString(n.SourceText),
- LangOid: ast.Oid(n.LangOid),
- LangIsTrusted: n.LangIsTrusted,
- }
- }
- func convertInsertStmt(n *pg.InsertStmt) *ast.InsertStmt {
- if n == nil {
- return nil
- }
- return &ast.InsertStmt{
- Relation: convertRangeVar(n.Relation),
- Cols: convertSlice(n.Cols),
- SelectStmt: convertNode(n.SelectStmt),
- OnConflictClause: convertOnConflictClause(n.OnConflictClause),
- ReturningList: convertSlice(n.ReturningList),
- WithClause: convertWithClause(n.WithClause),
- Override: ast.OverridingKind(n.Override),
- }
- }
- func convertInteger(n *pg.Integer) *ast.Integer {
- if n == nil {
- return nil
- }
- return &ast.Integer{
- Ival: int64(n.Ival),
- }
- }
- func convertIntoClause(n *pg.IntoClause) *ast.IntoClause {
- if n == nil {
- return nil
- }
- return &ast.IntoClause{
- Rel: convertRangeVar(n.Rel),
- ColNames: convertSlice(n.ColNames),
- Options: convertSlice(n.Options),
- OnCommit: ast.OnCommitAction(n.OnCommit),
- TableSpaceName: makeString(n.TableSpaceName),
- ViewQuery: convertNode(n.ViewQuery),
- SkipData: n.SkipData,
- }
- }
- func convertJoinExpr(n *pg.JoinExpr) *ast.JoinExpr {
- if n == nil {
- return nil
- }
- return &ast.JoinExpr{
- Jointype: ast.JoinType(n.Jointype),
- IsNatural: n.IsNatural,
- Larg: convertNode(n.Larg),
- Rarg: convertNode(n.Rarg),
- UsingClause: convertSlice(n.UsingClause),
- Quals: convertNode(n.Quals),
- Alias: convertAlias(n.Alias),
- Rtindex: int(n.Rtindex),
- }
- }
- func convertListenStmt(n *pg.ListenStmt) *ast.ListenStmt {
- if n == nil {
- return nil
- }
- return &ast.ListenStmt{
- Conditionname: makeString(n.Conditionname),
- }
- }
- func convertLoadStmt(n *pg.LoadStmt) *ast.LoadStmt {
- if n == nil {
- return nil
- }
- return &ast.LoadStmt{
- Filename: makeString(n.Filename),
- }
- }
- func convertLockStmt(n *pg.LockStmt) *ast.LockStmt {
- if n == nil {
- return nil
- }
- return &ast.LockStmt{
- Relations: convertSlice(n.Relations),
- Mode: int(n.Mode),
- Nowait: n.Nowait,
- }
- }
- func convertLockingClause(n *pg.LockingClause) *ast.LockingClause {
- if n == nil {
- return nil
- }
- return &ast.LockingClause{
- LockedRels: convertSlice(n.LockedRels),
- Strength: ast.LockClauseStrength(n.Strength),
- WaitPolicy: ast.LockWaitPolicy(n.WaitPolicy),
- }
- }
- func convertMinMaxExpr(n *pg.MinMaxExpr) *ast.MinMaxExpr {
- if n == nil {
- return nil
- }
- return &ast.MinMaxExpr{
- Xpr: convertNode(n.Xpr),
- Minmaxtype: ast.Oid(n.Minmaxtype),
- Minmaxcollid: ast.Oid(n.Minmaxcollid),
- Inputcollid: ast.Oid(n.Inputcollid),
- Op: ast.MinMaxOp(n.Op),
- Args: convertSlice(n.Args),
- Location: int(n.Location),
- }
- }
- func convertMultiAssignRef(n *pg.MultiAssignRef) *ast.MultiAssignRef {
- if n == nil {
- return nil
- }
- return &ast.MultiAssignRef{
- Source: convertNode(n.Source),
- Colno: int(n.Colno),
- Ncolumns: int(n.Ncolumns),
- }
- }
- func convertNamedArgExpr(n *pg.NamedArgExpr) *ast.NamedArgExpr {
- if n == nil {
- return nil
- }
- return &ast.NamedArgExpr{
- Xpr: convertNode(n.Xpr),
- Arg: convertNode(n.Arg),
- Name: makeString(n.Name),
- Argnumber: int(n.Argnumber),
- Location: int(n.Location),
- }
- }
- func convertNextValueExpr(n *pg.NextValueExpr) *ast.NextValueExpr {
- if n == nil {
- return nil
- }
- return &ast.NextValueExpr{
- Xpr: convertNode(n.Xpr),
- Seqid: ast.Oid(n.Seqid),
- TypeId: ast.Oid(n.TypeId),
- }
- }
- func convertNotifyStmt(n *pg.NotifyStmt) *ast.NotifyStmt {
- if n == nil {
- return nil
- }
- return &ast.NotifyStmt{
- Conditionname: makeString(n.Conditionname),
- Payload: makeString(n.Payload),
- }
- }
- func convertNull(n *pg.Null) *ast.Null {
- if n == nil {
- return nil
- }
- return &ast.Null{}
- }
- func convertNullTest(n *pg.NullTest) *ast.NullTest {
- if n == nil {
- return nil
- }
- return &ast.NullTest{
- Xpr: convertNode(n.Xpr),
- Arg: convertNode(n.Arg),
- Nulltesttype: ast.NullTestType(n.Nulltesttype),
- Argisrow: n.Argisrow,
- Location: int(n.Location),
- }
- }
- func convertObjectWithArgs(n *pg.ObjectWithArgs) *ast.ObjectWithArgs {
- if n == nil {
- return nil
- }
- return &ast.ObjectWithArgs{
- Objname: convertSlice(n.Objname),
- Objargs: convertSlice(n.Objargs),
- ArgsUnspecified: n.ArgsUnspecified,
- }
- }
- func convertOnConflictClause(n *pg.OnConflictClause) *ast.OnConflictClause {
- if n == nil {
- return nil
- }
- return &ast.OnConflictClause{
- Action: ast.OnConflictAction(n.Action),
- Infer: convertInferClause(n.Infer),
- TargetList: convertSlice(n.TargetList),
- WhereClause: convertNode(n.WhereClause),
- Location: int(n.Location),
- }
- }
- func convertOnConflictExpr(n *pg.OnConflictExpr) *ast.OnConflictExpr {
- if n == nil {
- return nil
- }
- return &ast.OnConflictExpr{
- Action: ast.OnConflictAction(n.Action),
- ArbiterElems: convertSlice(n.ArbiterElems),
- ArbiterWhere: convertNode(n.ArbiterWhere),
- Constraint: ast.Oid(n.Constraint),
- OnConflictSet: convertSlice(n.OnConflictSet),
- OnConflictWhere: convertNode(n.OnConflictWhere),
- ExclRelIndex: int(n.ExclRelIndex),
- ExclRelTlist: convertSlice(n.ExclRelTlist),
- }
- }
- func convertOpExpr(n *pg.OpExpr) *ast.OpExpr {
- if n == nil {
- return nil
- }
- return &ast.OpExpr{
- Xpr: convertNode(n.Xpr),
- Opno: ast.Oid(n.Opno),
- Opfuncid: ast.Oid(n.Opfuncid),
- Opresulttype: ast.Oid(n.Opresulttype),
- Opretset: n.Opretset,
- Opcollid: ast.Oid(n.Opcollid),
- Inputcollid: ast.Oid(n.Inputcollid),
- Args: convertSlice(n.Args),
- Location: int(n.Location),
- }
- }
- func convertParam(n *pg.Param) *ast.Param {
- if n == nil {
- return nil
- }
- return &ast.Param{
- Xpr: convertNode(n.Xpr),
- Paramkind: ast.ParamKind(n.Paramkind),
- Paramid: int(n.Paramid),
- Paramtype: ast.Oid(n.Paramtype),
- Paramtypmod: n.Paramtypmod,
- Paramcollid: ast.Oid(n.Paramcollid),
- Location: int(n.Location),
- }
- }
- func convertParamRef(n *pg.ParamRef) *ast.ParamRef {
- if n == nil {
- return nil
- }
- var dollar bool
- if n.Number != 0 {
- dollar = true
- }
- return &ast.ParamRef{
- Dollar: dollar,
- Number: int(n.Number),
- Location: int(n.Location),
- }
- }
- func convertPartitionBoundSpec(n *pg.PartitionBoundSpec) *ast.PartitionBoundSpec {
- if n == nil {
- return nil
- }
- return &ast.PartitionBoundSpec{
- Strategy: makeByte(n.Strategy),
- Listdatums: convertSlice(n.Listdatums),
- Lowerdatums: convertSlice(n.Lowerdatums),
- Upperdatums: convertSlice(n.Upperdatums),
- Location: int(n.Location),
- }
- }
- func convertPartitionCmd(n *pg.PartitionCmd) *ast.PartitionCmd {
- if n == nil {
- return nil
- }
- return &ast.PartitionCmd{
- Name: convertRangeVar(n.Name),
- Bound: convertPartitionBoundSpec(n.Bound),
- }
- }
- func convertPartitionElem(n *pg.PartitionElem) *ast.PartitionElem {
- if n == nil {
- return nil
- }
- return &ast.PartitionElem{
- Name: makeString(n.Name),
- Expr: convertNode(n.Expr),
- Collation: convertSlice(n.Collation),
- Opclass: convertSlice(n.Opclass),
- Location: int(n.Location),
- }
- }
- func convertPartitionRangeDatum(n *pg.PartitionRangeDatum) *ast.PartitionRangeDatum {
- if n == nil {
- return nil
- }
- return &ast.PartitionRangeDatum{
- Kind: ast.PartitionRangeDatumKind(n.Kind),
- Value: convertNode(n.Value),
- Location: int(n.Location),
- }
- }
- func convertPartitionSpec(n *pg.PartitionSpec) *ast.PartitionSpec {
- if n == nil {
- return nil
- }
- return &ast.PartitionSpec{
- Strategy: makeString(n.Strategy),
- PartParams: convertSlice(n.PartParams),
- Location: int(n.Location),
- }
- }
- func convertPrepareStmt(n *pg.PrepareStmt) *ast.PrepareStmt {
- if n == nil {
- return nil
- }
- return &ast.PrepareStmt{
- Name: makeString(n.Name),
- Argtypes: convertSlice(n.Argtypes),
- Query: convertNode(n.Query),
- }
- }
- func convertQuery(n *pg.Query) *ast.Query {
- if n == nil {
- return nil
- }
- return &ast.Query{
- CommandType: ast.CmdType(n.CommandType),
- QuerySource: ast.QuerySource(n.QuerySource),
- CanSetTag: n.CanSetTag,
- UtilityStmt: convertNode(n.UtilityStmt),
- ResultRelation: int(n.ResultRelation),
- HasAggs: n.HasAggs,
- HasWindowFuncs: n.HasWindowFuncs,
- HasTargetSrfs: n.HasTargetSrfs,
- HasSubLinks: n.HasSubLinks,
- HasDistinctOn: n.HasDistinctOn,
- HasRecursive: n.HasRecursive,
- HasModifyingCte: n.HasModifyingCte,
- HasForUpdate: n.HasForUpdate,
- HasRowSecurity: n.HasRowSecurity,
- CteList: convertSlice(n.CteList),
- Rtable: convertSlice(n.Rtable),
- Jointree: convertFromExpr(n.Jointree),
- TargetList: convertSlice(n.TargetList),
- Override: ast.OverridingKind(n.Override),
- OnConflict: convertOnConflictExpr(n.OnConflict),
- ReturningList: convertSlice(n.ReturningList),
- GroupClause: convertSlice(n.GroupClause),
- GroupingSets: convertSlice(n.GroupingSets),
- HavingQual: convertNode(n.HavingQual),
- WindowClause: convertSlice(n.WindowClause),
- DistinctClause: convertSlice(n.DistinctClause),
- SortClause: convertSlice(n.SortClause),
- LimitOffset: convertNode(n.LimitOffset),
- LimitCount: convertNode(n.LimitCount),
- RowMarks: convertSlice(n.RowMarks),
- SetOperations: convertNode(n.SetOperations),
- ConstraintDeps: convertSlice(n.ConstraintDeps),
- WithCheckOptions: convertSlice(n.WithCheckOptions),
- StmtLocation: int(n.StmtLocation),
- StmtLen: int(n.StmtLen),
- }
- }
- func convertRangeFunction(n *pg.RangeFunction) *ast.RangeFunction {
- if n == nil {
- return nil
- }
- return &ast.RangeFunction{
- Lateral: n.Lateral,
- Ordinality: n.Ordinality,
- IsRowsfrom: n.IsRowsfrom,
- Functions: convertSlice(n.Functions),
- Alias: convertAlias(n.Alias),
- Coldeflist: convertSlice(n.Coldeflist),
- }
- }
- func convertRangeSubselect(n *pg.RangeSubselect) *ast.RangeSubselect {
- if n == nil {
- return nil
- }
- return &ast.RangeSubselect{
- Lateral: n.Lateral,
- Subquery: convertNode(n.Subquery),
- Alias: convertAlias(n.Alias),
- }
- }
- func convertRangeTableFunc(n *pg.RangeTableFunc) *ast.RangeTableFunc {
- if n == nil {
- return nil
- }
- return &ast.RangeTableFunc{
- Lateral: n.Lateral,
- Docexpr: convertNode(n.Docexpr),
- Rowexpr: convertNode(n.Rowexpr),
- Namespaces: convertSlice(n.Namespaces),
- Columns: convertSlice(n.Columns),
- Alias: convertAlias(n.Alias),
- Location: int(n.Location),
- }
- }
- func convertRangeTableFuncCol(n *pg.RangeTableFuncCol) *ast.RangeTableFuncCol {
- if n == nil {
- return nil
- }
- return &ast.RangeTableFuncCol{
- Colname: makeString(n.Colname),
- TypeName: convertTypeName(n.TypeName),
- ForOrdinality: n.ForOrdinality,
- IsNotNull: n.IsNotNull,
- Colexpr: convertNode(n.Colexpr),
- Coldefexpr: convertNode(n.Coldefexpr),
- Location: int(n.Location),
- }
- }
- func convertRangeTableSample(n *pg.RangeTableSample) *ast.RangeTableSample {
- if n == nil {
- return nil
- }
- return &ast.RangeTableSample{
- Relation: convertNode(n.Relation),
- Method: convertSlice(n.Method),
- Args: convertSlice(n.Args),
- Repeatable: convertNode(n.Repeatable),
- Location: int(n.Location),
- }
- }
- func convertRangeTblEntry(n *pg.RangeTblEntry) *ast.RangeTblEntry {
- if n == nil {
- return nil
- }
- return &ast.RangeTblEntry{
- Rtekind: ast.RTEKind(n.Rtekind),
- Relid: ast.Oid(n.Relid),
- Relkind: makeByte(n.Relkind),
- Tablesample: convertTableSampleClause(n.Tablesample),
- Subquery: convertQuery(n.Subquery),
- SecurityBarrier: n.SecurityBarrier,
- Jointype: ast.JoinType(n.Jointype),
- Joinaliasvars: convertSlice(n.Joinaliasvars),
- Functions: convertSlice(n.Functions),
- Funcordinality: n.Funcordinality,
- Tablefunc: convertTableFunc(n.Tablefunc),
- ValuesLists: convertSlice(n.ValuesLists),
- Ctename: makeString(n.Ctename),
- Ctelevelsup: ast.Index(n.Ctelevelsup),
- SelfReference: n.SelfReference,
- Coltypes: convertSlice(n.Coltypes),
- Coltypmods: convertSlice(n.Coltypmods),
- Colcollations: convertSlice(n.Colcollations),
- Enrname: makeString(n.Enrname),
- Enrtuples: n.Enrtuples,
- Alias: convertAlias(n.Alias),
- Eref: convertAlias(n.Eref),
- Lateral: n.Lateral,
- Inh: n.Inh,
- InFromCl: n.InFromCl,
- RequiredPerms: ast.AclMode(n.RequiredPerms),
- CheckAsUser: ast.Oid(n.CheckAsUser),
- SelectedCols: makeUint32Slice(n.SelectedCols),
- InsertedCols: makeUint32Slice(n.InsertedCols),
- UpdatedCols: makeUint32Slice(n.UpdatedCols),
- SecurityQuals: convertSlice(n.SecurityQuals),
- }
- }
- func convertRangeTblFunction(n *pg.RangeTblFunction) *ast.RangeTblFunction {
- if n == nil {
- return nil
- }
- return &ast.RangeTblFunction{
- Funcexpr: convertNode(n.Funcexpr),
- Funccolcount: int(n.Funccolcount),
- Funccolnames: convertSlice(n.Funccolnames),
- Funccoltypes: convertSlice(n.Funccoltypes),
- Funccoltypmods: convertSlice(n.Funccoltypmods),
- Funccolcollations: convertSlice(n.Funccolcollations),
- Funcparams: makeUint32Slice(n.Funcparams),
- }
- }
- func convertRangeTblRef(n *pg.RangeTblRef) *ast.RangeTblRef {
- if n == nil {
- return nil
- }
- return &ast.RangeTblRef{
- Rtindex: int(n.Rtindex),
- }
- }
- func convertRangeVar(n *pg.RangeVar) *ast.RangeVar {
- if n == nil {
- return nil
- }
- return &ast.RangeVar{
- Catalogname: makeString(n.Catalogname),
- Schemaname: makeString(n.Schemaname),
- Relname: makeString(n.Relname),
- Inh: n.Inh,
- Relpersistence: makeByte(n.Relpersistence),
- Alias: convertAlias(n.Alias),
- Location: int(n.Location),
- }
- }
- func convertRawStmt(n *pg.RawStmt) *ast.RawStmt {
- if n == nil {
- return nil
- }
- return &ast.RawStmt{
- Stmt: convertNode(n.Stmt),
- StmtLocation: int(n.StmtLocation),
- StmtLen: int(n.StmtLen),
- }
- }
- func convertReassignOwnedStmt(n *pg.ReassignOwnedStmt) *ast.ReassignOwnedStmt {
- if n == nil {
- return nil
- }
- return &ast.ReassignOwnedStmt{
- Roles: convertSlice(n.Roles),
- Newrole: convertRoleSpec(n.Newrole),
- }
- }
- func convertRefreshMatViewStmt(n *pg.RefreshMatViewStmt) *ast.RefreshMatViewStmt {
- if n == nil {
- return nil
- }
- return &ast.RefreshMatViewStmt{
- Concurrent: n.Concurrent,
- SkipData: n.SkipData,
- Relation: convertRangeVar(n.Relation),
- }
- }
- func convertReindexStmt(n *pg.ReindexStmt) *ast.ReindexStmt {
- if n == nil {
- return nil
- }
- return &ast.ReindexStmt{
- Kind: ast.ReindexObjectType(n.Kind),
- Relation: convertRangeVar(n.Relation),
- Name: makeString(n.Name),
- Options: int(n.Options),
- }
- }
- func convertRelabelType(n *pg.RelabelType) *ast.RelabelType {
- if n == nil {
- return nil
- }
- return &ast.RelabelType{
- Xpr: convertNode(n.Xpr),
- Arg: convertNode(n.Arg),
- Resulttype: ast.Oid(n.Resulttype),
- Resulttypmod: n.Resulttypmod,
- Resultcollid: ast.Oid(n.Resultcollid),
- Relabelformat: ast.CoercionForm(n.Relabelformat),
- Location: int(n.Location),
- }
- }
- func convertRenameStmt(n *pg.RenameStmt) *ast.RenameStmt {
- if n == nil {
- return nil
- }
- return &ast.RenameStmt{
- RenameType: ast.ObjectType(n.RenameType),
- RelationType: ast.ObjectType(n.RelationType),
- Relation: convertRangeVar(n.Relation),
- Object: convertNode(n.Object),
- Subname: makeString(n.Subname),
- Newname: makeString(n.Newname),
- Behavior: ast.DropBehavior(n.Behavior),
- MissingOk: n.MissingOk,
- }
- }
- func convertReplicaIdentityStmt(n *pg.ReplicaIdentityStmt) *ast.ReplicaIdentityStmt {
- if n == nil {
- return nil
- }
- return &ast.ReplicaIdentityStmt{
- IdentityType: makeByte(n.IdentityType),
- Name: makeString(n.Name),
- }
- }
- func convertResTarget(n *pg.ResTarget) *ast.ResTarget {
- if n == nil {
- return nil
- }
- return &ast.ResTarget{
- Name: makeString(n.Name),
- Indirection: convertSlice(n.Indirection),
- Val: convertNode(n.Val),
- Location: int(n.Location),
- }
- }
- func convertRoleSpec(n *pg.RoleSpec) *ast.RoleSpec {
- if n == nil {
- return nil
- }
- return &ast.RoleSpec{
- Roletype: ast.RoleSpecType(n.Roletype),
- Rolename: makeString(n.Rolename),
- Location: int(n.Location),
- }
- }
- func convertRowCompareExpr(n *pg.RowCompareExpr) *ast.RowCompareExpr {
- if n == nil {
- return nil
- }
- return &ast.RowCompareExpr{
- Xpr: convertNode(n.Xpr),
- Rctype: ast.RowCompareType(n.Rctype),
- Opnos: convertSlice(n.Opnos),
- Opfamilies: convertSlice(n.Opfamilies),
- Inputcollids: convertSlice(n.Inputcollids),
- Largs: convertSlice(n.Largs),
- Rargs: convertSlice(n.Rargs),
- }
- }
- func convertRowExpr(n *pg.RowExpr) *ast.RowExpr {
- if n == nil {
- return nil
- }
- return &ast.RowExpr{
- Xpr: convertNode(n.Xpr),
- Args: convertSlice(n.Args),
- RowTypeid: ast.Oid(n.RowTypeid),
- RowFormat: ast.CoercionForm(n.RowFormat),
- Colnames: convertSlice(n.Colnames),
- Location: int(n.Location),
- }
- }
- func convertRowMarkClause(n *pg.RowMarkClause) *ast.RowMarkClause {
- if n == nil {
- return nil
- }
- return &ast.RowMarkClause{
- Rti: ast.Index(n.Rti),
- Strength: ast.LockClauseStrength(n.Strength),
- WaitPolicy: ast.LockWaitPolicy(n.WaitPolicy),
- PushedDown: n.PushedDown,
- }
- }
- func convertRuleStmt(n *pg.RuleStmt) *ast.RuleStmt {
- if n == nil {
- return nil
- }
- return &ast.RuleStmt{
- Relation: convertRangeVar(n.Relation),
- Rulename: makeString(n.Rulename),
- WhereClause: convertNode(n.WhereClause),
- Event: ast.CmdType(n.Event),
- Instead: n.Instead,
- Actions: convertSlice(n.Actions),
- Replace: n.Replace,
- }
- }
- func convertSQLValueFunction(n *pg.SQLValueFunction) *ast.SQLValueFunction {
- if n == nil {
- return nil
- }
- return &ast.SQLValueFunction{
- Xpr: convertNode(n.Xpr),
- Op: ast.SQLValueFunctionOp(n.Op),
- Type: ast.Oid(n.Type),
- Typmod: n.Typmod,
- Location: int(n.Location),
- }
- }
- func convertScalarArrayOpExpr(n *pg.ScalarArrayOpExpr) *ast.ScalarArrayOpExpr {
- if n == nil {
- return nil
- }
- return &ast.ScalarArrayOpExpr{
- Xpr: convertNode(n.Xpr),
- Opno: ast.Oid(n.Opno),
- Opfuncid: ast.Oid(n.Opfuncid),
- UseOr: n.UseOr,
- Inputcollid: ast.Oid(n.Inputcollid),
- Args: convertSlice(n.Args),
- Location: int(n.Location),
- }
- }
- func convertSecLabelStmt(n *pg.SecLabelStmt) *ast.SecLabelStmt {
- if n == nil {
- return nil
- }
- return &ast.SecLabelStmt{
- Objtype: ast.ObjectType(n.Objtype),
- Object: convertNode(n.Object),
- Provider: makeString(n.Provider),
- Label: makeString(n.Label),
- }
- }
- func convertSelectStmt(n *pg.SelectStmt) *ast.SelectStmt {
- if n == nil {
- return nil
- }
- op, err := convertSetOperation(n.Op)
- if err != nil {
- panic(err)
- }
- return &ast.SelectStmt{
- DistinctClause: convertSlice(n.DistinctClause),
- IntoClause: convertIntoClause(n.IntoClause),
- TargetList: convertSlice(n.TargetList),
- FromClause: convertSlice(n.FromClause),
- WhereClause: convertNode(n.WhereClause),
- GroupClause: convertSlice(n.GroupClause),
- HavingClause: convertNode(n.HavingClause),
- WindowClause: convertSlice(n.WindowClause),
- ValuesLists: convertSlice(n.ValuesLists),
- SortClause: convertSlice(n.SortClause),
- LimitOffset: convertNode(n.LimitOffset),
- LimitCount: convertNode(n.LimitCount),
- LockingClause: convertSlice(n.LockingClause),
- WithClause: convertWithClause(n.WithClause),
- Op: op,
- All: n.All,
- Larg: convertSelectStmt(n.Larg),
- Rarg: convertSelectStmt(n.Rarg),
- }
- }
- func convertSetOperationStmt(n *pg.SetOperationStmt) *ast.SetOperationStmt {
- if n == nil {
- return nil
- }
- op, err := convertSetOperation(n.Op)
- if err != nil {
- panic(err)
- }
- return &ast.SetOperationStmt{
- Op: op,
- All: n.All,
- Larg: convertNode(n.Larg),
- Rarg: convertNode(n.Rarg),
- ColTypes: convertSlice(n.ColTypes),
- ColTypmods: convertSlice(n.ColTypmods),
- ColCollations: convertSlice(n.ColCollations),
- GroupClauses: convertSlice(n.GroupClauses),
- }
- }
- func convertSetToDefault(n *pg.SetToDefault) *ast.SetToDefault {
- if n == nil {
- return nil
- }
- return &ast.SetToDefault{
- Xpr: convertNode(n.Xpr),
- TypeId: ast.Oid(n.TypeId),
- TypeMod: n.TypeMod,
- Collation: ast.Oid(n.Collation),
- Location: int(n.Location),
- }
- }
- func convertSortBy(n *pg.SortBy) *ast.SortBy {
- if n == nil {
- return nil
- }
- return &ast.SortBy{
- Node: convertNode(n.Node),
- SortbyDir: ast.SortByDir(n.SortbyDir),
- SortbyNulls: ast.SortByNulls(n.SortbyNulls),
- UseOp: convertSlice(n.UseOp),
- Location: int(n.Location),
- }
- }
- func convertSortGroupClause(n *pg.SortGroupClause) *ast.SortGroupClause {
- if n == nil {
- return nil
- }
- return &ast.SortGroupClause{
- TleSortGroupRef: ast.Index(n.TleSortGroupRef),
- Eqop: ast.Oid(n.Eqop),
- Sortop: ast.Oid(n.Sortop),
- NullsFirst: n.NullsFirst,
- Hashable: n.Hashable,
- }
- }
- func convertString(n *pg.String) *ast.String {
- if n == nil {
- return nil
- }
- return &ast.String{
- Str: n.Str,
- }
- }
- func convertSubLink(n *pg.SubLink) *ast.SubLink {
- if n == nil {
- return nil
- }
- slt, err := convertSubLinkType(n.SubLinkType)
- if err != nil {
- panic(err)
- }
- return &ast.SubLink{
- Xpr: convertNode(n.Xpr),
- SubLinkType: slt,
- SubLinkId: int(n.SubLinkId),
- Testexpr: convertNode(n.Testexpr),
- OperName: convertSlice(n.OperName),
- Subselect: convertNode(n.Subselect),
- Location: int(n.Location),
- }
- }
- func convertSubPlan(n *pg.SubPlan) *ast.SubPlan {
- if n == nil {
- return nil
- }
- slt, err := convertSubLinkType(n.SubLinkType)
- if err != nil {
- panic(err)
- }
- return &ast.SubPlan{
- Xpr: convertNode(n.Xpr),
- SubLinkType: slt,
- Testexpr: convertNode(n.Testexpr),
- ParamIds: convertSlice(n.ParamIds),
- PlanId: int(n.PlanId),
- PlanName: makeString(n.PlanName),
- FirstColType: ast.Oid(n.FirstColType),
- FirstColTypmod: n.FirstColTypmod,
- FirstColCollation: ast.Oid(n.FirstColCollation),
- UseHashTable: n.UseHashTable,
- UnknownEqFalse: n.UnknownEqFalse,
- ParallelSafe: n.ParallelSafe,
- SetParam: convertSlice(n.SetParam),
- ParParam: convertSlice(n.ParParam),
- Args: convertSlice(n.Args),
- StartupCost: ast.Cost(n.StartupCost),
- PerCallCost: ast.Cost(n.PerCallCost),
- }
- }
- func convertTableFunc(n *pg.TableFunc) *ast.TableFunc {
- if n == nil {
- return nil
- }
- return &ast.TableFunc{
- NsUris: convertSlice(n.NsUris),
- NsNames: convertSlice(n.NsNames),
- Docexpr: convertNode(n.Docexpr),
- Rowexpr: convertNode(n.Rowexpr),
- Colnames: convertSlice(n.Colnames),
- Coltypes: convertSlice(n.Coltypes),
- Coltypmods: convertSlice(n.Coltypmods),
- Colcollations: convertSlice(n.Colcollations),
- Colexprs: convertSlice(n.Colexprs),
- Coldefexprs: convertSlice(n.Coldefexprs),
- Notnulls: makeUint32Slice(n.Notnulls),
- Ordinalitycol: int(n.Ordinalitycol),
- Location: int(n.Location),
- }
- }
- func convertTableLikeClause(n *pg.TableLikeClause) *ast.TableLikeClause {
- if n == nil {
- return nil
- }
- return &ast.TableLikeClause{
- Relation: convertRangeVar(n.Relation),
- Options: n.Options,
- }
- }
- func convertTableSampleClause(n *pg.TableSampleClause) *ast.TableSampleClause {
- if n == nil {
- return nil
- }
- return &ast.TableSampleClause{
- Tsmhandler: ast.Oid(n.Tsmhandler),
- Args: convertSlice(n.Args),
- Repeatable: convertNode(n.Repeatable),
- }
- }
- func convertTargetEntry(n *pg.TargetEntry) *ast.TargetEntry {
- if n == nil {
- return nil
- }
- return &ast.TargetEntry{
- Xpr: convertNode(n.Xpr),
- Expr: convertNode(n.Expr),
- Resno: ast.AttrNumber(n.Resno),
- Resname: makeString(n.Resname),
- Ressortgroupref: ast.Index(n.Ressortgroupref),
- Resorigtbl: ast.Oid(n.Resorigtbl),
- Resorigcol: ast.AttrNumber(n.Resorigcol),
- Resjunk: n.Resjunk,
- }
- }
- func convertTransactionStmt(n *pg.TransactionStmt) *ast.TransactionStmt {
- if n == nil {
- return nil
- }
- return &ast.TransactionStmt{
- Kind: ast.TransactionStmtKind(n.Kind),
- Options: convertSlice(n.Options),
- Gid: makeString(n.Gid),
- }
- }
- func convertTriggerTransition(n *pg.TriggerTransition) *ast.TriggerTransition {
- if n == nil {
- return nil
- }
- return &ast.TriggerTransition{
- Name: makeString(n.Name),
- IsNew: n.IsNew,
- IsTable: n.IsTable,
- }
- }
- func convertTruncateStmt(n *pg.TruncateStmt) *ast.TruncateStmt {
- if n == nil {
- return nil
- }
- return &ast.TruncateStmt{
- Relations: convertSlice(n.Relations),
- RestartSeqs: n.RestartSeqs,
- Behavior: ast.DropBehavior(n.Behavior),
- }
- }
- func convertTypeCast(n *pg.TypeCast) *ast.TypeCast {
- if n == nil {
- return nil
- }
- return &ast.TypeCast{
- Arg: convertNode(n.Arg),
- TypeName: convertTypeName(n.TypeName),
- Location: int(n.Location),
- }
- }
- func convertTypeName(n *pg.TypeName) *ast.TypeName {
- if n == nil {
- return nil
- }
- return &ast.TypeName{
- Names: convertSlice(n.Names),
- TypeOid: ast.Oid(n.TypeOid),
- Setof: n.Setof,
- PctType: n.PctType,
- Typmods: convertSlice(n.Typmods),
- Typemod: n.Typemod,
- ArrayBounds: convertSlice(n.ArrayBounds),
- Location: int(n.Location),
- }
- }
- func convertUnlistenStmt(n *pg.UnlistenStmt) *ast.UnlistenStmt {
- if n == nil {
- return nil
- }
- return &ast.UnlistenStmt{
- Conditionname: makeString(n.Conditionname),
- }
- }
- func convertUpdateStmt(n *pg.UpdateStmt) *ast.UpdateStmt {
- if n == nil {
- return nil
- }
- return &ast.UpdateStmt{
- Relations: &ast.List{
- Items: []ast.Node{convertRangeVar(n.Relation)},
- },
- TargetList: convertSlice(n.TargetList),
- WhereClause: convertNode(n.WhereClause),
- FromClause: convertSlice(n.FromClause),
- ReturningList: convertSlice(n.ReturningList),
- WithClause: convertWithClause(n.WithClause),
- }
- }
- func convertVacuumStmt(n *pg.VacuumStmt) *ast.VacuumStmt {
- if n == nil {
- return nil
- }
- return &ast.VacuumStmt{
- // FIXME: The VacuumStmt node has changed quite a bit
- // Options: n.Options
- // Relation: convertRangeVar(n.Relation),
- // VaCols: convertSlice(n.VaCols),
- }
- }
- func convertVar(n *pg.Var) *ast.Var {
- if n == nil {
- return nil
- }
- return &ast.Var{
- Xpr: convertNode(n.Xpr),
- Varno: ast.Index(n.Varno),
- Varattno: ast.AttrNumber(n.Varattno),
- Vartype: ast.Oid(n.Vartype),
- Vartypmod: n.Vartypmod,
- Varcollid: ast.Oid(n.Varcollid),
- Varlevelsup: ast.Index(n.Varlevelsup),
- Location: int(n.Location),
- }
- }
- func convertVariableSetStmt(n *pg.VariableSetStmt) *ast.VariableSetStmt {
- if n == nil {
- return nil
- }
- return &ast.VariableSetStmt{
- Kind: ast.VariableSetKind(n.Kind),
- Name: makeString(n.Name),
- Args: convertSlice(n.Args),
- IsLocal: n.IsLocal,
- }
- }
- func convertVariableShowStmt(n *pg.VariableShowStmt) *ast.VariableShowStmt {
- if n == nil {
- return nil
- }
- return &ast.VariableShowStmt{
- Name: makeString(n.Name),
- }
- }
- func convertViewStmt(n *pg.ViewStmt) *ast.ViewStmt {
- if n == nil {
- return nil
- }
- return &ast.ViewStmt{
- View: convertRangeVar(n.View),
- Aliases: convertSlice(n.Aliases),
- Query: convertNode(n.Query),
- Replace: n.Replace,
- Options: convertSlice(n.Options),
- WithCheckOption: ast.ViewCheckOption(n.WithCheckOption),
- }
- }
- func convertWindowClause(n *pg.WindowClause) *ast.WindowClause {
- if n == nil {
- return nil
- }
- return &ast.WindowClause{
- Name: makeString(n.Name),
- Refname: makeString(n.Refname),
- PartitionClause: convertSlice(n.PartitionClause),
- OrderClause: convertSlice(n.OrderClause),
- FrameOptions: int(n.FrameOptions),
- StartOffset: convertNode(n.StartOffset),
- EndOffset: convertNode(n.EndOffset),
- Winref: ast.Index(n.Winref),
- CopiedOrder: n.CopiedOrder,
- }
- }
- func convertWindowDef(n *pg.WindowDef) *ast.WindowDef {
- if n == nil {
- return nil
- }
- return &ast.WindowDef{
- Name: makeString(n.Name),
- Refname: makeString(n.Refname),
- PartitionClause: convertSlice(n.PartitionClause),
- OrderClause: convertSlice(n.OrderClause),
- FrameOptions: int(n.FrameOptions),
- StartOffset: convertNode(n.StartOffset),
- EndOffset: convertNode(n.EndOffset),
- Location: int(n.Location),
- }
- }
- func convertWindowFunc(n *pg.WindowFunc) *ast.WindowFunc {
- if n == nil {
- return nil
- }
- return &ast.WindowFunc{
- Xpr: convertNode(n.Xpr),
- Winfnoid: ast.Oid(n.Winfnoid),
- Wintype: ast.Oid(n.Wintype),
- Wincollid: ast.Oid(n.Wincollid),
- Inputcollid: ast.Oid(n.Inputcollid),
- Args: convertSlice(n.Args),
- Aggfilter: convertNode(n.Aggfilter),
- Winref: ast.Index(n.Winref),
- Winstar: n.Winstar,
- Winagg: n.Winagg,
- Location: int(n.Location),
- }
- }
- func convertWithCheckOption(n *pg.WithCheckOption) *ast.WithCheckOption {
- if n == nil {
- return nil
- }
- return &ast.WithCheckOption{
- Kind: ast.WCOKind(n.Kind),
- Relname: makeString(n.Relname),
- Polname: makeString(n.Polname),
- Qual: convertNode(n.Qual),
- Cascaded: n.Cascaded,
- }
- }
- func convertWithClause(n *pg.WithClause) *ast.WithClause {
- if n == nil {
- return nil
- }
- return &ast.WithClause{
- Ctes: convertSlice(n.Ctes),
- Recursive: n.Recursive,
- Location: int(n.Location),
- }
- }
- func convertXmlExpr(n *pg.XmlExpr) *ast.XmlExpr {
- if n == nil {
- return nil
- }
- return &ast.XmlExpr{
- Xpr: convertNode(n.Xpr),
- Op: ast.XmlExprOp(n.Op),
- Name: makeString(n.Name),
- NamedArgs: convertSlice(n.NamedArgs),
- ArgNames: convertSlice(n.ArgNames),
- Args: convertSlice(n.Args),
- Xmloption: ast.XmlOptionType(n.Xmloption),
- Type: ast.Oid(n.Type),
- Typmod: n.Typmod,
- Location: int(n.Location),
- }
- }
- func convertXmlSerialize(n *pg.XmlSerialize) *ast.XmlSerialize {
- if n == nil {
- return nil
- }
- return &ast.XmlSerialize{
- Xmloption: ast.XmlOptionType(n.Xmloption),
- Expr: convertNode(n.Expr),
- TypeName: convertTypeName(n.TypeName),
- Location: int(n.Location),
- }
- }
- func convertNode(node *pg.Node) ast.Node {
- if node == nil || node.Node == nil {
- return &ast.TODO{}
- }
- switch n := node.Node.(type) {
- case *pg.Node_AArrayExpr:
- return convertA_ArrayExpr(n.AArrayExpr)
- case *pg.Node_AConst:
- return convertA_Const(n.AConst)
- case *pg.Node_AExpr:
- return convertA_Expr(n.AExpr)
- case *pg.Node_AIndices:
- return convertA_Indices(n.AIndices)
- case *pg.Node_AIndirection:
- return convertA_Indirection(n.AIndirection)
- case *pg.Node_AStar:
- return convertA_Star(n.AStar)
- case *pg.Node_AccessPriv:
- return convertAccessPriv(n.AccessPriv)
- case *pg.Node_Aggref:
- return convertAggref(n.Aggref)
- case *pg.Node_Alias:
- return convertAlias(n.Alias)
- case *pg.Node_AlterCollationStmt:
- return convertAlterCollationStmt(n.AlterCollationStmt)
- case *pg.Node_AlterDatabaseSetStmt:
- return convertAlterDatabaseSetStmt(n.AlterDatabaseSetStmt)
- case *pg.Node_AlterDatabaseStmt:
- return convertAlterDatabaseStmt(n.AlterDatabaseStmt)
- case *pg.Node_AlterDefaultPrivilegesStmt:
- return convertAlterDefaultPrivilegesStmt(n.AlterDefaultPrivilegesStmt)
- case *pg.Node_AlterDomainStmt:
- return convertAlterDomainStmt(n.AlterDomainStmt)
- case *pg.Node_AlterEnumStmt:
- return convertAlterEnumStmt(n.AlterEnumStmt)
- case *pg.Node_AlterEventTrigStmt:
- return convertAlterEventTrigStmt(n.AlterEventTrigStmt)
- case *pg.Node_AlterExtensionContentsStmt:
- return convertAlterExtensionContentsStmt(n.AlterExtensionContentsStmt)
- case *pg.Node_AlterExtensionStmt:
- return convertAlterExtensionStmt(n.AlterExtensionStmt)
- case *pg.Node_AlterFdwStmt:
- return convertAlterFdwStmt(n.AlterFdwStmt)
- case *pg.Node_AlterForeignServerStmt:
- return convertAlterForeignServerStmt(n.AlterForeignServerStmt)
- case *pg.Node_AlterFunctionStmt:
- return convertAlterFunctionStmt(n.AlterFunctionStmt)
- case *pg.Node_AlterObjectDependsStmt:
- return convertAlterObjectDependsStmt(n.AlterObjectDependsStmt)
- case *pg.Node_AlterObjectSchemaStmt:
- return convertAlterObjectSchemaStmt(n.AlterObjectSchemaStmt)
- case *pg.Node_AlterOpFamilyStmt:
- return convertAlterOpFamilyStmt(n.AlterOpFamilyStmt)
- case *pg.Node_AlterOperatorStmt:
- return convertAlterOperatorStmt(n.AlterOperatorStmt)
- case *pg.Node_AlterOwnerStmt:
- return convertAlterOwnerStmt(n.AlterOwnerStmt)
- case *pg.Node_AlterPolicyStmt:
- return convertAlterPolicyStmt(n.AlterPolicyStmt)
- case *pg.Node_AlterPublicationStmt:
- return convertAlterPublicationStmt(n.AlterPublicationStmt)
- case *pg.Node_AlterRoleSetStmt:
- return convertAlterRoleSetStmt(n.AlterRoleSetStmt)
- case *pg.Node_AlterRoleStmt:
- return convertAlterRoleStmt(n.AlterRoleStmt)
- case *pg.Node_AlterSeqStmt:
- return convertAlterSeqStmt(n.AlterSeqStmt)
- case *pg.Node_AlterSubscriptionStmt:
- return convertAlterSubscriptionStmt(n.AlterSubscriptionStmt)
- case *pg.Node_AlterSystemStmt:
- return convertAlterSystemStmt(n.AlterSystemStmt)
- case *pg.Node_AlterTsconfigurationStmt:
- return convertAlterTSConfigurationStmt(n.AlterTsconfigurationStmt)
- case *pg.Node_AlterTsdictionaryStmt:
- return convertAlterTSDictionaryStmt(n.AlterTsdictionaryStmt)
- case *pg.Node_AlterTableCmd:
- return convertAlterTableCmd(n.AlterTableCmd)
- case *pg.Node_AlterTableMoveAllStmt:
- return convertAlterTableMoveAllStmt(n.AlterTableMoveAllStmt)
- case *pg.Node_AlterTableSpaceOptionsStmt:
- return convertAlterTableSpaceOptionsStmt(n.AlterTableSpaceOptionsStmt)
- case *pg.Node_AlterTableStmt:
- return convertAlterTableStmt(n.AlterTableStmt)
- case *pg.Node_AlterUserMappingStmt:
- return convertAlterUserMappingStmt(n.AlterUserMappingStmt)
- case *pg.Node_AlternativeSubPlan:
- return convertAlternativeSubPlan(n.AlternativeSubPlan)
- case *pg.Node_ArrayCoerceExpr:
- return convertArrayCoerceExpr(n.ArrayCoerceExpr)
- case *pg.Node_ArrayExpr:
- return convertArrayExpr(n.ArrayExpr)
- case *pg.Node_BitString:
- return convertBitString(n.BitString)
- case *pg.Node_BoolExpr:
- return convertBoolExpr(n.BoolExpr)
- case *pg.Node_BooleanTest:
- return convertBooleanTest(n.BooleanTest)
- case *pg.Node_CaseExpr:
- return convertCaseExpr(n.CaseExpr)
- case *pg.Node_CaseTestExpr:
- return convertCaseTestExpr(n.CaseTestExpr)
- case *pg.Node_CaseWhen:
- return convertCaseWhen(n.CaseWhen)
- case *pg.Node_CheckPointStmt:
- return convertCheckPointStmt(n.CheckPointStmt)
- case *pg.Node_ClosePortalStmt:
- return convertClosePortalStmt(n.ClosePortalStmt)
- case *pg.Node_ClusterStmt:
- return convertClusterStmt(n.ClusterStmt)
- case *pg.Node_CoalesceExpr:
- return convertCoalesceExpr(n.CoalesceExpr)
- case *pg.Node_CoerceToDomain:
- return convertCoerceToDomain(n.CoerceToDomain)
- case *pg.Node_CoerceToDomainValue:
- return convertCoerceToDomainValue(n.CoerceToDomainValue)
- case *pg.Node_CoerceViaIo:
- return convertCoerceViaIO(n.CoerceViaIo)
- case *pg.Node_CollateClause:
- return convertCollateClause(n.CollateClause)
- case *pg.Node_CollateExpr:
- return convertCollateExpr(n.CollateExpr)
- case *pg.Node_ColumnDef:
- return convertColumnDef(n.ColumnDef)
- case *pg.Node_ColumnRef:
- return convertColumnRef(n.ColumnRef)
- case *pg.Node_CommentStmt:
- return convertCommentStmt(n.CommentStmt)
- case *pg.Node_CommonTableExpr:
- return convertCommonTableExpr(n.CommonTableExpr)
- case *pg.Node_CompositeTypeStmt:
- return convertCompositeTypeStmt(n.CompositeTypeStmt)
- case *pg.Node_Constraint:
- return convertConstraint(n.Constraint)
- case *pg.Node_ConstraintsSetStmt:
- return convertConstraintsSetStmt(n.ConstraintsSetStmt)
- case *pg.Node_ConvertRowtypeExpr:
- return convertConvertRowtypeExpr(n.ConvertRowtypeExpr)
- case *pg.Node_CopyStmt:
- return convertCopyStmt(n.CopyStmt)
- case *pg.Node_CreateAmStmt:
- return convertCreateAmStmt(n.CreateAmStmt)
- case *pg.Node_CreateCastStmt:
- return convertCreateCastStmt(n.CreateCastStmt)
- case *pg.Node_CreateConversionStmt:
- return convertCreateConversionStmt(n.CreateConversionStmt)
- case *pg.Node_CreateDomainStmt:
- return convertCreateDomainStmt(n.CreateDomainStmt)
- case *pg.Node_CreateEnumStmt:
- return convertCreateEnumStmt(n.CreateEnumStmt)
- case *pg.Node_CreateEventTrigStmt:
- return convertCreateEventTrigStmt(n.CreateEventTrigStmt)
- case *pg.Node_CreateExtensionStmt:
- return convertCreateExtensionStmt(n.CreateExtensionStmt)
- case *pg.Node_CreateFdwStmt:
- return convertCreateFdwStmt(n.CreateFdwStmt)
- case *pg.Node_CreateForeignServerStmt:
- return convertCreateForeignServerStmt(n.CreateForeignServerStmt)
- case *pg.Node_CreateForeignTableStmt:
- return convertCreateForeignTableStmt(n.CreateForeignTableStmt)
- case *pg.Node_CreateFunctionStmt:
- return convertCreateFunctionStmt(n.CreateFunctionStmt)
- case *pg.Node_CreateOpClassItem:
- return convertCreateOpClassItem(n.CreateOpClassItem)
- case *pg.Node_CreateOpClassStmt:
- return convertCreateOpClassStmt(n.CreateOpClassStmt)
- case *pg.Node_CreateOpFamilyStmt:
- return convertCreateOpFamilyStmt(n.CreateOpFamilyStmt)
- case *pg.Node_CreatePlangStmt:
- return convertCreatePLangStmt(n.CreatePlangStmt)
- case *pg.Node_CreatePolicyStmt:
- return convertCreatePolicyStmt(n.CreatePolicyStmt)
- case *pg.Node_CreatePublicationStmt:
- return convertCreatePublicationStmt(n.CreatePublicationStmt)
- case *pg.Node_CreateRangeStmt:
- return convertCreateRangeStmt(n.CreateRangeStmt)
- case *pg.Node_CreateRoleStmt:
- return convertCreateRoleStmt(n.CreateRoleStmt)
- case *pg.Node_CreateSchemaStmt:
- return convertCreateSchemaStmt(n.CreateSchemaStmt)
- case *pg.Node_CreateSeqStmt:
- return convertCreateSeqStmt(n.CreateSeqStmt)
- case *pg.Node_CreateStatsStmt:
- return convertCreateStatsStmt(n.CreateStatsStmt)
- case *pg.Node_CreateStmt:
- return convertCreateStmt(n.CreateStmt)
- case *pg.Node_CreateSubscriptionStmt:
- return convertCreateSubscriptionStmt(n.CreateSubscriptionStmt)
- case *pg.Node_CreateTableAsStmt:
- return convertCreateTableAsStmt(n.CreateTableAsStmt)
- case *pg.Node_CreateTableSpaceStmt:
- return convertCreateTableSpaceStmt(n.CreateTableSpaceStmt)
- case *pg.Node_CreateTransformStmt:
- return convertCreateTransformStmt(n.CreateTransformStmt)
- case *pg.Node_CreateTrigStmt:
- return convertCreateTrigStmt(n.CreateTrigStmt)
- case *pg.Node_CreateUserMappingStmt:
- return convertCreateUserMappingStmt(n.CreateUserMappingStmt)
- case *pg.Node_CreatedbStmt:
- return convertCreatedbStmt(n.CreatedbStmt)
- case *pg.Node_CurrentOfExpr:
- return convertCurrentOfExpr(n.CurrentOfExpr)
- case *pg.Node_DeallocateStmt:
- return convertDeallocateStmt(n.DeallocateStmt)
- case *pg.Node_DeclareCursorStmt:
- return convertDeclareCursorStmt(n.DeclareCursorStmt)
- case *pg.Node_DefElem:
- return convertDefElem(n.DefElem)
- case *pg.Node_DefineStmt:
- return convertDefineStmt(n.DefineStmt)
- case *pg.Node_DeleteStmt:
- return convertDeleteStmt(n.DeleteStmt)
- case *pg.Node_DiscardStmt:
- return convertDiscardStmt(n.DiscardStmt)
- case *pg.Node_DoStmt:
- return convertDoStmt(n.DoStmt)
- case *pg.Node_DropOwnedStmt:
- return convertDropOwnedStmt(n.DropOwnedStmt)
- case *pg.Node_DropRoleStmt:
- return convertDropRoleStmt(n.DropRoleStmt)
- case *pg.Node_DropStmt:
- return convertDropStmt(n.DropStmt)
- case *pg.Node_DropSubscriptionStmt:
- return convertDropSubscriptionStmt(n.DropSubscriptionStmt)
- case *pg.Node_DropTableSpaceStmt:
- return convertDropTableSpaceStmt(n.DropTableSpaceStmt)
- case *pg.Node_DropUserMappingStmt:
- return convertDropUserMappingStmt(n.DropUserMappingStmt)
- case *pg.Node_DropdbStmt:
- return convertDropdbStmt(n.DropdbStmt)
- case *pg.Node_ExecuteStmt:
- return convertExecuteStmt(n.ExecuteStmt)
- case *pg.Node_ExplainStmt:
- return convertExplainStmt(n.ExplainStmt)
- case *pg.Node_Expr:
- return convertExpr(n.Expr)
- case *pg.Node_FetchStmt:
- return convertFetchStmt(n.FetchStmt)
- case *pg.Node_FieldSelect:
- return convertFieldSelect(n.FieldSelect)
- case *pg.Node_FieldStore:
- return convertFieldStore(n.FieldStore)
- case *pg.Node_Float:
- return convertFloat(n.Float)
- case *pg.Node_FromExpr:
- return convertFromExpr(n.FromExpr)
- case *pg.Node_FuncCall:
- return convertFuncCall(n.FuncCall)
- case *pg.Node_FuncExpr:
- return convertFuncExpr(n.FuncExpr)
- case *pg.Node_FunctionParameter:
- return convertFunctionParameter(n.FunctionParameter)
- case *pg.Node_GrantRoleStmt:
- return convertGrantRoleStmt(n.GrantRoleStmt)
- case *pg.Node_GrantStmt:
- return convertGrantStmt(n.GrantStmt)
- case *pg.Node_GroupingFunc:
- return convertGroupingFunc(n.GroupingFunc)
- case *pg.Node_GroupingSet:
- return convertGroupingSet(n.GroupingSet)
- case *pg.Node_ImportForeignSchemaStmt:
- return convertImportForeignSchemaStmt(n.ImportForeignSchemaStmt)
- case *pg.Node_IndexElem:
- return convertIndexElem(n.IndexElem)
- case *pg.Node_IndexStmt:
- return convertIndexStmt(n.IndexStmt)
- case *pg.Node_InferClause:
- return convertInferClause(n.InferClause)
- case *pg.Node_InferenceElem:
- return convertInferenceElem(n.InferenceElem)
- case *pg.Node_InlineCodeBlock:
- return convertInlineCodeBlock(n.InlineCodeBlock)
- case *pg.Node_InsertStmt:
- return convertInsertStmt(n.InsertStmt)
- case *pg.Node_Integer:
- return convertInteger(n.Integer)
- case *pg.Node_IntoClause:
- return convertIntoClause(n.IntoClause)
- case *pg.Node_JoinExpr:
- return convertJoinExpr(n.JoinExpr)
- case *pg.Node_List:
- return convertList(n.List)
- case *pg.Node_ListenStmt:
- return convertListenStmt(n.ListenStmt)
- case *pg.Node_LoadStmt:
- return convertLoadStmt(n.LoadStmt)
- case *pg.Node_LockStmt:
- return convertLockStmt(n.LockStmt)
- case *pg.Node_LockingClause:
- return convertLockingClause(n.LockingClause)
- case *pg.Node_MinMaxExpr:
- return convertMinMaxExpr(n.MinMaxExpr)
- case *pg.Node_MultiAssignRef:
- return convertMultiAssignRef(n.MultiAssignRef)
- case *pg.Node_NamedArgExpr:
- return convertNamedArgExpr(n.NamedArgExpr)
- case *pg.Node_NextValueExpr:
- return convertNextValueExpr(n.NextValueExpr)
- case *pg.Node_NotifyStmt:
- return convertNotifyStmt(n.NotifyStmt)
- case *pg.Node_Null:
- return convertNull(n.Null)
- case *pg.Node_NullTest:
- return convertNullTest(n.NullTest)
- case *pg.Node_ObjectWithArgs:
- return convertObjectWithArgs(n.ObjectWithArgs)
- case *pg.Node_OnConflictClause:
- return convertOnConflictClause(n.OnConflictClause)
- case *pg.Node_OnConflictExpr:
- return convertOnConflictExpr(n.OnConflictExpr)
- case *pg.Node_OpExpr:
- return convertOpExpr(n.OpExpr)
- case *pg.Node_Param:
- return convertParam(n.Param)
- case *pg.Node_ParamRef:
- return convertParamRef(n.ParamRef)
- case *pg.Node_PartitionBoundSpec:
- return convertPartitionBoundSpec(n.PartitionBoundSpec)
- case *pg.Node_PartitionCmd:
- return convertPartitionCmd(n.PartitionCmd)
- case *pg.Node_PartitionElem:
- return convertPartitionElem(n.PartitionElem)
- case *pg.Node_PartitionRangeDatum:
- return convertPartitionRangeDatum(n.PartitionRangeDatum)
- case *pg.Node_PartitionSpec:
- return convertPartitionSpec(n.PartitionSpec)
- case *pg.Node_PrepareStmt:
- return convertPrepareStmt(n.PrepareStmt)
- case *pg.Node_Query:
- return convertQuery(n.Query)
- case *pg.Node_RangeFunction:
- return convertRangeFunction(n.RangeFunction)
- case *pg.Node_RangeSubselect:
- return convertRangeSubselect(n.RangeSubselect)
- case *pg.Node_RangeTableFunc:
- return convertRangeTableFunc(n.RangeTableFunc)
- case *pg.Node_RangeTableFuncCol:
- return convertRangeTableFuncCol(n.RangeTableFuncCol)
- case *pg.Node_RangeTableSample:
- return convertRangeTableSample(n.RangeTableSample)
- case *pg.Node_RangeTblEntry:
- return convertRangeTblEntry(n.RangeTblEntry)
- case *pg.Node_RangeTblFunction:
- return convertRangeTblFunction(n.RangeTblFunction)
- case *pg.Node_RangeTblRef:
- return convertRangeTblRef(n.RangeTblRef)
- case *pg.Node_RangeVar:
- return convertRangeVar(n.RangeVar)
- case *pg.Node_RawStmt:
- return convertRawStmt(n.RawStmt)
- case *pg.Node_ReassignOwnedStmt:
- return convertReassignOwnedStmt(n.ReassignOwnedStmt)
- case *pg.Node_RefreshMatViewStmt:
- return convertRefreshMatViewStmt(n.RefreshMatViewStmt)
- case *pg.Node_ReindexStmt:
- return convertReindexStmt(n.ReindexStmt)
- case *pg.Node_RelabelType:
- return convertRelabelType(n.RelabelType)
- case *pg.Node_RenameStmt:
- return convertRenameStmt(n.RenameStmt)
- case *pg.Node_ReplicaIdentityStmt:
- return convertReplicaIdentityStmt(n.ReplicaIdentityStmt)
- case *pg.Node_ResTarget:
- return convertResTarget(n.ResTarget)
- case *pg.Node_RoleSpec:
- return convertRoleSpec(n.RoleSpec)
- case *pg.Node_RowCompareExpr:
- return convertRowCompareExpr(n.RowCompareExpr)
- case *pg.Node_RowExpr:
- return convertRowExpr(n.RowExpr)
- case *pg.Node_RowMarkClause:
- return convertRowMarkClause(n.RowMarkClause)
- case *pg.Node_RuleStmt:
- return convertRuleStmt(n.RuleStmt)
- case *pg.Node_SqlvalueFunction:
- return convertSQLValueFunction(n.SqlvalueFunction)
- case *pg.Node_ScalarArrayOpExpr:
- return convertScalarArrayOpExpr(n.ScalarArrayOpExpr)
- case *pg.Node_SecLabelStmt:
- return convertSecLabelStmt(n.SecLabelStmt)
- case *pg.Node_SelectStmt:
- return convertSelectStmt(n.SelectStmt)
- case *pg.Node_SetOperationStmt:
- return convertSetOperationStmt(n.SetOperationStmt)
- case *pg.Node_SetToDefault:
- return convertSetToDefault(n.SetToDefault)
- case *pg.Node_SortBy:
- return convertSortBy(n.SortBy)
- case *pg.Node_SortGroupClause:
- return convertSortGroupClause(n.SortGroupClause)
- case *pg.Node_String_:
- return convertString(n.String_)
- case *pg.Node_SubLink:
- return convertSubLink(n.SubLink)
- case *pg.Node_SubPlan:
- return convertSubPlan(n.SubPlan)
- case *pg.Node_TableFunc:
- return convertTableFunc(n.TableFunc)
- case *pg.Node_TableLikeClause:
- return convertTableLikeClause(n.TableLikeClause)
- case *pg.Node_TableSampleClause:
- return convertTableSampleClause(n.TableSampleClause)
- case *pg.Node_TargetEntry:
- return convertTargetEntry(n.TargetEntry)
- case *pg.Node_TransactionStmt:
- return convertTransactionStmt(n.TransactionStmt)
- case *pg.Node_TriggerTransition:
- return convertTriggerTransition(n.TriggerTransition)
- case *pg.Node_TruncateStmt:
- return convertTruncateStmt(n.TruncateStmt)
- case *pg.Node_TypeCast:
- return convertTypeCast(n.TypeCast)
- case *pg.Node_TypeName:
- return convertTypeName(n.TypeName)
- case *pg.Node_UnlistenStmt:
- return convertUnlistenStmt(n.UnlistenStmt)
- case *pg.Node_UpdateStmt:
- return convertUpdateStmt(n.UpdateStmt)
- case *pg.Node_VacuumStmt:
- return convertVacuumStmt(n.VacuumStmt)
- case *pg.Node_Var:
- return convertVar(n.Var)
- case *pg.Node_VariableSetStmt:
- return convertVariableSetStmt(n.VariableSetStmt)
- case *pg.Node_VariableShowStmt:
- return convertVariableShowStmt(n.VariableShowStmt)
- case *pg.Node_ViewStmt:
- return convertViewStmt(n.ViewStmt)
- case *pg.Node_WindowClause:
- return convertWindowClause(n.WindowClause)
- case *pg.Node_WindowDef:
- return convertWindowDef(n.WindowDef)
- case *pg.Node_WindowFunc:
- return convertWindowFunc(n.WindowFunc)
- case *pg.Node_WithCheckOption:
- return convertWithCheckOption(n.WithCheckOption)
- case *pg.Node_WithClause:
- return convertWithClause(n.WithClause)
- case *pg.Node_XmlExpr:
- return convertXmlExpr(n.XmlExpr)
- case *pg.Node_XmlSerialize:
- return convertXmlSerialize(n.XmlSerialize)
- default:
- return &ast.TODO{}
- }
- }
|