1
0

convert.go 89 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615
  1. //go:build !windows
  2. // +build !windows
  3. package postgresql
  4. import (
  5. "fmt"
  6. pg "github.com/pganalyze/pg_query_go/v2"
  7. "github.com/kyleconroy/sqlc/internal/sql/ast"
  8. )
  9. func convertFuncParamMode(m pg.FunctionParameterMode) (ast.FuncParamMode, error) {
  10. switch m {
  11. case pg.FunctionParameterMode_FUNC_PARAM_IN:
  12. return ast.FuncParamIn, nil
  13. case pg.FunctionParameterMode_FUNC_PARAM_OUT:
  14. return ast.FuncParamOut, nil
  15. case pg.FunctionParameterMode_FUNC_PARAM_INOUT:
  16. return ast.FuncParamInOut, nil
  17. case pg.FunctionParameterMode_FUNC_PARAM_VARIADIC:
  18. return ast.FuncParamVariadic, nil
  19. case pg.FunctionParameterMode_FUNC_PARAM_TABLE:
  20. return ast.FuncParamTable, nil
  21. default:
  22. return -1, fmt.Errorf("parse func param: invalid mode %v", m)
  23. }
  24. }
  25. func convertSubLinkType(t pg.SubLinkType) (ast.SubLinkType, error) {
  26. switch t {
  27. case pg.SubLinkType_EXISTS_SUBLINK:
  28. return ast.EXISTS_SUBLINK, nil
  29. case pg.SubLinkType_ALL_SUBLINK:
  30. return ast.ALL_SUBLINK, nil
  31. case pg.SubLinkType_ANY_SUBLINK:
  32. return ast.ANY_SUBLINK, nil
  33. case pg.SubLinkType_ROWCOMPARE_SUBLINK:
  34. return ast.ROWCOMPARE_SUBLINK, nil
  35. case pg.SubLinkType_EXPR_SUBLINK:
  36. return ast.EXPR_SUBLINK, nil
  37. case pg.SubLinkType_MULTIEXPR_SUBLINK:
  38. return ast.MULTIEXPR_SUBLINK, nil
  39. case pg.SubLinkType_ARRAY_SUBLINK:
  40. return ast.ARRAY_SUBLINK, nil
  41. case pg.SubLinkType_CTE_SUBLINK:
  42. return ast.CTE_SUBLINK, nil
  43. default:
  44. return 0, fmt.Errorf("parse sublink type: unknown type %s", t)
  45. }
  46. }
  47. func convertSetOperation(t pg.SetOperation) (ast.SetOperation, error) {
  48. switch t {
  49. case pg.SetOperation_SETOP_NONE:
  50. return ast.None, nil
  51. case pg.SetOperation_SETOP_UNION:
  52. return ast.Union, nil
  53. case pg.SetOperation_SETOP_INTERSECT:
  54. return ast.Intersect, nil
  55. case pg.SetOperation_SETOP_EXCEPT:
  56. return ast.Except, nil
  57. default:
  58. return 0, fmt.Errorf("parse set operation: unknown type %s", t)
  59. }
  60. }
  61. func convertList(l *pg.List) *ast.List {
  62. out := &ast.List{}
  63. for _, item := range l.Items {
  64. out.Items = append(out.Items, convertNode(item))
  65. }
  66. return out
  67. }
  68. func convertSlice(nodes []*pg.Node) *ast.List {
  69. out := &ast.List{}
  70. for _, n := range nodes {
  71. out.Items = append(out.Items, convertNode(n))
  72. }
  73. return out
  74. }
  75. func convertValuesList(l [][]*pg.Node) *ast.List {
  76. out := &ast.List{}
  77. for _, outer := range l {
  78. o := &ast.List{}
  79. for _, inner := range outer {
  80. o.Items = append(o.Items, convertNode(inner))
  81. }
  82. out.Items = append(out.Items, o)
  83. }
  84. return out
  85. }
  86. func convert(node *pg.Node) (ast.Node, error) {
  87. return convertNode(node), nil
  88. }
  89. func convertA_ArrayExpr(n *pg.A_ArrayExpr) *ast.A_ArrayExpr {
  90. if n == nil {
  91. return nil
  92. }
  93. return &ast.A_ArrayExpr{
  94. Elements: convertSlice(n.Elements),
  95. Location: int(n.Location),
  96. }
  97. }
  98. func convertA_Const(n *pg.A_Const) *ast.A_Const {
  99. if n == nil {
  100. return nil
  101. }
  102. return &ast.A_Const{
  103. Val: convertNode(n.Val),
  104. Location: int(n.Location),
  105. }
  106. }
  107. func convertA_Expr(n *pg.A_Expr) *ast.A_Expr {
  108. if n == nil {
  109. return nil
  110. }
  111. return &ast.A_Expr{
  112. Kind: ast.A_Expr_Kind(n.Kind),
  113. Name: convertSlice(n.Name),
  114. Lexpr: convertNode(n.Lexpr),
  115. Rexpr: convertNode(n.Rexpr),
  116. Location: int(n.Location),
  117. }
  118. }
  119. func convertA_Indices(n *pg.A_Indices) *ast.A_Indices {
  120. if n == nil {
  121. return nil
  122. }
  123. return &ast.A_Indices{
  124. IsSlice: n.IsSlice,
  125. Lidx: convertNode(n.Lidx),
  126. Uidx: convertNode(n.Uidx),
  127. }
  128. }
  129. func convertA_Indirection(n *pg.A_Indirection) *ast.A_Indirection {
  130. if n == nil {
  131. return nil
  132. }
  133. return &ast.A_Indirection{
  134. Arg: convertNode(n.Arg),
  135. Indirection: convertSlice(n.Indirection),
  136. }
  137. }
  138. func convertA_Star(n *pg.A_Star) *ast.A_Star {
  139. if n == nil {
  140. return nil
  141. }
  142. return &ast.A_Star{}
  143. }
  144. func convertAccessPriv(n *pg.AccessPriv) *ast.AccessPriv {
  145. if n == nil {
  146. return nil
  147. }
  148. return &ast.AccessPriv{
  149. PrivName: makeString(n.PrivName),
  150. Cols: convertSlice(n.Cols),
  151. }
  152. }
  153. func convertAggref(n *pg.Aggref) *ast.Aggref {
  154. if n == nil {
  155. return nil
  156. }
  157. return &ast.Aggref{
  158. Xpr: convertNode(n.Xpr),
  159. Aggfnoid: ast.Oid(n.Aggfnoid),
  160. Aggtype: ast.Oid(n.Aggtype),
  161. Aggcollid: ast.Oid(n.Aggcollid),
  162. Inputcollid: ast.Oid(n.Inputcollid),
  163. Aggtranstype: ast.Oid(n.Aggtranstype),
  164. Aggargtypes: convertSlice(n.Aggargtypes),
  165. Aggdirectargs: convertSlice(n.Aggdirectargs),
  166. Args: convertSlice(n.Args),
  167. Aggorder: convertSlice(n.Aggorder),
  168. Aggdistinct: convertSlice(n.Aggdistinct),
  169. Aggfilter: convertNode(n.Aggfilter),
  170. Aggstar: n.Aggstar,
  171. Aggvariadic: n.Aggvariadic,
  172. Aggkind: makeByte(n.Aggkind),
  173. Agglevelsup: ast.Index(n.Agglevelsup),
  174. Aggsplit: ast.AggSplit(n.Aggsplit),
  175. Location: int(n.Location),
  176. }
  177. }
  178. func convertAlias(n *pg.Alias) *ast.Alias {
  179. if n == nil {
  180. return nil
  181. }
  182. return &ast.Alias{
  183. Aliasname: makeString(n.Aliasname),
  184. Colnames: convertSlice(n.Colnames),
  185. }
  186. }
  187. func convertAlterCollationStmt(n *pg.AlterCollationStmt) *ast.AlterCollationStmt {
  188. if n == nil {
  189. return nil
  190. }
  191. return &ast.AlterCollationStmt{
  192. Collname: convertSlice(n.Collname),
  193. }
  194. }
  195. func convertAlterDatabaseSetStmt(n *pg.AlterDatabaseSetStmt) *ast.AlterDatabaseSetStmt {
  196. if n == nil {
  197. return nil
  198. }
  199. return &ast.AlterDatabaseSetStmt{
  200. Dbname: makeString(n.Dbname),
  201. Setstmt: convertVariableSetStmt(n.Setstmt),
  202. }
  203. }
  204. func convertAlterDatabaseStmt(n *pg.AlterDatabaseStmt) *ast.AlterDatabaseStmt {
  205. if n == nil {
  206. return nil
  207. }
  208. return &ast.AlterDatabaseStmt{
  209. Dbname: makeString(n.Dbname),
  210. Options: convertSlice(n.Options),
  211. }
  212. }
  213. func convertAlterDefaultPrivilegesStmt(n *pg.AlterDefaultPrivilegesStmt) *ast.AlterDefaultPrivilegesStmt {
  214. if n == nil {
  215. return nil
  216. }
  217. return &ast.AlterDefaultPrivilegesStmt{
  218. Options: convertSlice(n.Options),
  219. Action: convertGrantStmt(n.Action),
  220. }
  221. }
  222. func convertAlterDomainStmt(n *pg.AlterDomainStmt) *ast.AlterDomainStmt {
  223. if n == nil {
  224. return nil
  225. }
  226. return &ast.AlterDomainStmt{
  227. Subtype: makeByte(n.Subtype),
  228. TypeName: convertSlice(n.TypeName),
  229. Name: makeString(n.Name),
  230. Def: convertNode(n.Def),
  231. Behavior: ast.DropBehavior(n.Behavior),
  232. MissingOk: n.MissingOk,
  233. }
  234. }
  235. func convertAlterEnumStmt(n *pg.AlterEnumStmt) *ast.AlterEnumStmt {
  236. if n == nil {
  237. return nil
  238. }
  239. return &ast.AlterEnumStmt{
  240. TypeName: convertSlice(n.TypeName),
  241. OldVal: makeString(n.OldVal),
  242. NewVal: makeString(n.NewVal),
  243. NewValNeighbor: makeString(n.NewValNeighbor),
  244. NewValIsAfter: n.NewValIsAfter,
  245. SkipIfNewValExists: n.SkipIfNewValExists,
  246. }
  247. }
  248. func convertAlterEventTrigStmt(n *pg.AlterEventTrigStmt) *ast.AlterEventTrigStmt {
  249. if n == nil {
  250. return nil
  251. }
  252. return &ast.AlterEventTrigStmt{
  253. Trigname: makeString(n.Trigname),
  254. Tgenabled: makeByte(n.Tgenabled),
  255. }
  256. }
  257. func convertAlterExtensionContentsStmt(n *pg.AlterExtensionContentsStmt) *ast.AlterExtensionContentsStmt {
  258. if n == nil {
  259. return nil
  260. }
  261. return &ast.AlterExtensionContentsStmt{
  262. Extname: makeString(n.Extname),
  263. Action: int(n.Action),
  264. Objtype: ast.ObjectType(n.Objtype),
  265. Object: convertNode(n.Object),
  266. }
  267. }
  268. func convertAlterExtensionStmt(n *pg.AlterExtensionStmt) *ast.AlterExtensionStmt {
  269. if n == nil {
  270. return nil
  271. }
  272. return &ast.AlterExtensionStmt{
  273. Extname: makeString(n.Extname),
  274. Options: convertSlice(n.Options),
  275. }
  276. }
  277. func convertAlterFdwStmt(n *pg.AlterFdwStmt) *ast.AlterFdwStmt {
  278. if n == nil {
  279. return nil
  280. }
  281. return &ast.AlterFdwStmt{
  282. Fdwname: makeString(n.Fdwname),
  283. FuncOptions: convertSlice(n.FuncOptions),
  284. Options: convertSlice(n.Options),
  285. }
  286. }
  287. func convertAlterForeignServerStmt(n *pg.AlterForeignServerStmt) *ast.AlterForeignServerStmt {
  288. if n == nil {
  289. return nil
  290. }
  291. return &ast.AlterForeignServerStmt{
  292. Servername: makeString(n.Servername),
  293. Version: makeString(n.Version),
  294. Options: convertSlice(n.Options),
  295. HasVersion: n.HasVersion,
  296. }
  297. }
  298. func convertAlterFunctionStmt(n *pg.AlterFunctionStmt) *ast.AlterFunctionStmt {
  299. if n == nil {
  300. return nil
  301. }
  302. return &ast.AlterFunctionStmt{
  303. Func: convertObjectWithArgs(n.Func),
  304. Actions: convertSlice(n.Actions),
  305. }
  306. }
  307. func convertAlterObjectDependsStmt(n *pg.AlterObjectDependsStmt) *ast.AlterObjectDependsStmt {
  308. if n == nil {
  309. return nil
  310. }
  311. return &ast.AlterObjectDependsStmt{
  312. ObjectType: ast.ObjectType(n.ObjectType),
  313. Relation: convertRangeVar(n.Relation),
  314. Object: convertNode(n.Object),
  315. Extname: convertNode(n.Extname),
  316. }
  317. }
  318. func convertAlterObjectSchemaStmt(n *pg.AlterObjectSchemaStmt) *ast.AlterObjectSchemaStmt {
  319. if n == nil {
  320. return nil
  321. }
  322. return &ast.AlterObjectSchemaStmt{
  323. ObjectType: ast.ObjectType(n.ObjectType),
  324. Relation: convertRangeVar(n.Relation),
  325. Object: convertNode(n.Object),
  326. Newschema: makeString(n.Newschema),
  327. MissingOk: n.MissingOk,
  328. }
  329. }
  330. func convertAlterOpFamilyStmt(n *pg.AlterOpFamilyStmt) *ast.AlterOpFamilyStmt {
  331. if n == nil {
  332. return nil
  333. }
  334. return &ast.AlterOpFamilyStmt{
  335. Opfamilyname: convertSlice(n.Opfamilyname),
  336. Amname: makeString(n.Amname),
  337. IsDrop: n.IsDrop,
  338. Items: convertSlice(n.Items),
  339. }
  340. }
  341. func convertAlterOperatorStmt(n *pg.AlterOperatorStmt) *ast.AlterOperatorStmt {
  342. if n == nil {
  343. return nil
  344. }
  345. return &ast.AlterOperatorStmt{
  346. Opername: convertObjectWithArgs(n.Opername),
  347. Options: convertSlice(n.Options),
  348. }
  349. }
  350. func convertAlterOwnerStmt(n *pg.AlterOwnerStmt) *ast.AlterOwnerStmt {
  351. if n == nil {
  352. return nil
  353. }
  354. return &ast.AlterOwnerStmt{
  355. ObjectType: ast.ObjectType(n.ObjectType),
  356. Relation: convertRangeVar(n.Relation),
  357. Object: convertNode(n.Object),
  358. Newowner: convertRoleSpec(n.Newowner),
  359. }
  360. }
  361. func convertAlterPolicyStmt(n *pg.AlterPolicyStmt) *ast.AlterPolicyStmt {
  362. if n == nil {
  363. return nil
  364. }
  365. return &ast.AlterPolicyStmt{
  366. PolicyName: makeString(n.PolicyName),
  367. Table: convertRangeVar(n.Table),
  368. Roles: convertSlice(n.Roles),
  369. Qual: convertNode(n.Qual),
  370. WithCheck: convertNode(n.WithCheck),
  371. }
  372. }
  373. func convertAlterPublicationStmt(n *pg.AlterPublicationStmt) *ast.AlterPublicationStmt {
  374. if n == nil {
  375. return nil
  376. }
  377. return &ast.AlterPublicationStmt{
  378. Pubname: makeString(n.Pubname),
  379. Options: convertSlice(n.Options),
  380. Tables: convertSlice(n.Tables),
  381. ForAllTables: n.ForAllTables,
  382. TableAction: ast.DefElemAction(n.TableAction),
  383. }
  384. }
  385. func convertAlterRoleSetStmt(n *pg.AlterRoleSetStmt) *ast.AlterRoleSetStmt {
  386. if n == nil {
  387. return nil
  388. }
  389. return &ast.AlterRoleSetStmt{
  390. Role: convertRoleSpec(n.Role),
  391. Database: makeString(n.Database),
  392. Setstmt: convertVariableSetStmt(n.Setstmt),
  393. }
  394. }
  395. func convertAlterRoleStmt(n *pg.AlterRoleStmt) *ast.AlterRoleStmt {
  396. if n == nil {
  397. return nil
  398. }
  399. return &ast.AlterRoleStmt{
  400. Role: convertRoleSpec(n.Role),
  401. Options: convertSlice(n.Options),
  402. Action: int(n.Action),
  403. }
  404. }
  405. func convertAlterSeqStmt(n *pg.AlterSeqStmt) *ast.AlterSeqStmt {
  406. if n == nil {
  407. return nil
  408. }
  409. return &ast.AlterSeqStmt{
  410. Sequence: convertRangeVar(n.Sequence),
  411. Options: convertSlice(n.Options),
  412. ForIdentity: n.ForIdentity,
  413. MissingOk: n.MissingOk,
  414. }
  415. }
  416. func convertAlterSubscriptionStmt(n *pg.AlterSubscriptionStmt) *ast.AlterSubscriptionStmt {
  417. if n == nil {
  418. return nil
  419. }
  420. return &ast.AlterSubscriptionStmt{
  421. Kind: ast.AlterSubscriptionType(n.Kind),
  422. Subname: makeString(n.Subname),
  423. Conninfo: makeString(n.Conninfo),
  424. Publication: convertSlice(n.Publication),
  425. Options: convertSlice(n.Options),
  426. }
  427. }
  428. func convertAlterSystemStmt(n *pg.AlterSystemStmt) *ast.AlterSystemStmt {
  429. if n == nil {
  430. return nil
  431. }
  432. return &ast.AlterSystemStmt{
  433. Setstmt: convertVariableSetStmt(n.Setstmt),
  434. }
  435. }
  436. func convertAlterTSConfigurationStmt(n *pg.AlterTSConfigurationStmt) *ast.AlterTSConfigurationStmt {
  437. if n == nil {
  438. return nil
  439. }
  440. return &ast.AlterTSConfigurationStmt{
  441. Kind: ast.AlterTSConfigType(n.Kind),
  442. Cfgname: convertSlice(n.Cfgname),
  443. Tokentype: convertSlice(n.Tokentype),
  444. Dicts: convertSlice(n.Dicts),
  445. Override: n.Override,
  446. Replace: n.Replace,
  447. MissingOk: n.MissingOk,
  448. }
  449. }
  450. func convertAlterTSDictionaryStmt(n *pg.AlterTSDictionaryStmt) *ast.AlterTSDictionaryStmt {
  451. if n == nil {
  452. return nil
  453. }
  454. return &ast.AlterTSDictionaryStmt{
  455. Dictname: convertSlice(n.Dictname),
  456. Options: convertSlice(n.Options),
  457. }
  458. }
  459. func convertAlterTableCmd(n *pg.AlterTableCmd) *ast.AlterTableCmd {
  460. if n == nil {
  461. return nil
  462. }
  463. def := convertNode(n.Def)
  464. columnDef := def.(*ast.ColumnDef)
  465. return &ast.AlterTableCmd{
  466. Subtype: ast.AlterTableType(n.Subtype),
  467. Name: makeString(n.Name),
  468. Newowner: convertRoleSpec(n.Newowner),
  469. Def: columnDef,
  470. Behavior: ast.DropBehavior(n.Behavior),
  471. MissingOk: n.MissingOk,
  472. }
  473. }
  474. func convertAlterTableMoveAllStmt(n *pg.AlterTableMoveAllStmt) *ast.AlterTableMoveAllStmt {
  475. if n == nil {
  476. return nil
  477. }
  478. return &ast.AlterTableMoveAllStmt{
  479. OrigTablespacename: makeString(n.OrigTablespacename),
  480. Objtype: ast.ObjectType(n.Objtype),
  481. Roles: convertSlice(n.Roles),
  482. NewTablespacename: makeString(n.NewTablespacename),
  483. Nowait: n.Nowait,
  484. }
  485. }
  486. func convertAlterTableSpaceOptionsStmt(n *pg.AlterTableSpaceOptionsStmt) *ast.AlterTableSpaceOptionsStmt {
  487. if n == nil {
  488. return nil
  489. }
  490. return &ast.AlterTableSpaceOptionsStmt{
  491. Tablespacename: makeString(n.Tablespacename),
  492. Options: convertSlice(n.Options),
  493. IsReset: n.IsReset,
  494. }
  495. }
  496. func convertAlterTableStmt(n *pg.AlterTableStmt) *ast.AlterTableStmt {
  497. if n == nil {
  498. return nil
  499. }
  500. return &ast.AlterTableStmt{
  501. Relation: convertRangeVar(n.Relation),
  502. Cmds: convertSlice(n.Cmds),
  503. Relkind: ast.ObjectType(n.Relkind),
  504. MissingOk: n.MissingOk,
  505. }
  506. }
  507. func convertAlterUserMappingStmt(n *pg.AlterUserMappingStmt) *ast.AlterUserMappingStmt {
  508. if n == nil {
  509. return nil
  510. }
  511. return &ast.AlterUserMappingStmt{
  512. User: convertRoleSpec(n.User),
  513. Servername: makeString(n.Servername),
  514. Options: convertSlice(n.Options),
  515. }
  516. }
  517. func convertAlternativeSubPlan(n *pg.AlternativeSubPlan) *ast.AlternativeSubPlan {
  518. if n == nil {
  519. return nil
  520. }
  521. return &ast.AlternativeSubPlan{
  522. Xpr: convertNode(n.Xpr),
  523. Subplans: convertSlice(n.Subplans),
  524. }
  525. }
  526. func convertArrayCoerceExpr(n *pg.ArrayCoerceExpr) *ast.ArrayCoerceExpr {
  527. if n == nil {
  528. return nil
  529. }
  530. return &ast.ArrayCoerceExpr{
  531. Xpr: convertNode(n.Xpr),
  532. Arg: convertNode(n.Arg),
  533. Resulttype: ast.Oid(n.Resulttype),
  534. Resulttypmod: n.Resulttypmod,
  535. Resultcollid: ast.Oid(n.Resultcollid),
  536. Coerceformat: ast.CoercionForm(n.Coerceformat),
  537. Location: int(n.Location),
  538. }
  539. }
  540. func convertArrayExpr(n *pg.ArrayExpr) *ast.ArrayExpr {
  541. if n == nil {
  542. return nil
  543. }
  544. return &ast.ArrayExpr{
  545. Xpr: convertNode(n.Xpr),
  546. ArrayTypeid: ast.Oid(n.ArrayTypeid),
  547. ArrayCollid: ast.Oid(n.ArrayCollid),
  548. ElementTypeid: ast.Oid(n.ElementTypeid),
  549. Elements: convertSlice(n.Elements),
  550. Multidims: n.Multidims,
  551. Location: int(n.Location),
  552. }
  553. }
  554. func convertBitString(n *pg.BitString) *ast.BitString {
  555. if n == nil {
  556. return nil
  557. }
  558. return &ast.BitString{
  559. Str: n.Str,
  560. }
  561. }
  562. func convertBoolExpr(n *pg.BoolExpr) *ast.BoolExpr {
  563. if n == nil {
  564. return nil
  565. }
  566. return &ast.BoolExpr{
  567. Xpr: convertNode(n.Xpr),
  568. Boolop: ast.BoolExprType(n.Boolop),
  569. Args: convertSlice(n.Args),
  570. Location: int(n.Location),
  571. }
  572. }
  573. func convertBooleanTest(n *pg.BooleanTest) *ast.BooleanTest {
  574. if n == nil {
  575. return nil
  576. }
  577. return &ast.BooleanTest{
  578. Xpr: convertNode(n.Xpr),
  579. Arg: convertNode(n.Arg),
  580. Booltesttype: ast.BoolTestType(n.Booltesttype),
  581. Location: int(n.Location),
  582. }
  583. }
  584. func convertCaseExpr(n *pg.CaseExpr) *ast.CaseExpr {
  585. if n == nil {
  586. return nil
  587. }
  588. return &ast.CaseExpr{
  589. Xpr: convertNode(n.Xpr),
  590. Casetype: ast.Oid(n.Casetype),
  591. Casecollid: ast.Oid(n.Casecollid),
  592. Arg: convertNode(n.Arg),
  593. Args: convertSlice(n.Args),
  594. Defresult: convertNode(n.Defresult),
  595. Location: int(n.Location),
  596. }
  597. }
  598. func convertCaseTestExpr(n *pg.CaseTestExpr) *ast.CaseTestExpr {
  599. if n == nil {
  600. return nil
  601. }
  602. return &ast.CaseTestExpr{
  603. Xpr: convertNode(n.Xpr),
  604. TypeId: ast.Oid(n.TypeId),
  605. TypeMod: n.TypeMod,
  606. Collation: ast.Oid(n.Collation),
  607. }
  608. }
  609. func convertCaseWhen(n *pg.CaseWhen) *ast.CaseWhen {
  610. if n == nil {
  611. return nil
  612. }
  613. return &ast.CaseWhen{
  614. Xpr: convertNode(n.Xpr),
  615. Expr: convertNode(n.Expr),
  616. Result: convertNode(n.Result),
  617. Location: int(n.Location),
  618. }
  619. }
  620. func convertCheckPointStmt(n *pg.CheckPointStmt) *ast.CheckPointStmt {
  621. if n == nil {
  622. return nil
  623. }
  624. return &ast.CheckPointStmt{}
  625. }
  626. func convertClosePortalStmt(n *pg.ClosePortalStmt) *ast.ClosePortalStmt {
  627. if n == nil {
  628. return nil
  629. }
  630. return &ast.ClosePortalStmt{
  631. Portalname: makeString(n.Portalname),
  632. }
  633. }
  634. func convertClusterStmt(n *pg.ClusterStmt) *ast.ClusterStmt {
  635. if n == nil {
  636. return nil
  637. }
  638. return &ast.ClusterStmt{
  639. Relation: convertRangeVar(n.Relation),
  640. Indexname: makeString(n.Indexname),
  641. }
  642. }
  643. func convertCoalesceExpr(n *pg.CoalesceExpr) *ast.CoalesceExpr {
  644. if n == nil {
  645. return nil
  646. }
  647. return &ast.CoalesceExpr{
  648. Xpr: convertNode(n.Xpr),
  649. Coalescetype: ast.Oid(n.Coalescetype),
  650. Coalescecollid: ast.Oid(n.Coalescecollid),
  651. Args: convertSlice(n.Args),
  652. Location: int(n.Location),
  653. }
  654. }
  655. func convertCoerceToDomain(n *pg.CoerceToDomain) *ast.CoerceToDomain {
  656. if n == nil {
  657. return nil
  658. }
  659. return &ast.CoerceToDomain{
  660. Xpr: convertNode(n.Xpr),
  661. Arg: convertNode(n.Arg),
  662. Resulttype: ast.Oid(n.Resulttype),
  663. Resulttypmod: n.Resulttypmod,
  664. Resultcollid: ast.Oid(n.Resultcollid),
  665. Coercionformat: ast.CoercionForm(n.Coercionformat),
  666. Location: int(n.Location),
  667. }
  668. }
  669. func convertCoerceToDomainValue(n *pg.CoerceToDomainValue) *ast.CoerceToDomainValue {
  670. if n == nil {
  671. return nil
  672. }
  673. return &ast.CoerceToDomainValue{
  674. Xpr: convertNode(n.Xpr),
  675. TypeId: ast.Oid(n.TypeId),
  676. TypeMod: n.TypeMod,
  677. Collation: ast.Oid(n.Collation),
  678. Location: int(n.Location),
  679. }
  680. }
  681. func convertCoerceViaIO(n *pg.CoerceViaIO) *ast.CoerceViaIO {
  682. if n == nil {
  683. return nil
  684. }
  685. return &ast.CoerceViaIO{
  686. Xpr: convertNode(n.Xpr),
  687. Arg: convertNode(n.Arg),
  688. Resulttype: ast.Oid(n.Resulttype),
  689. Resultcollid: ast.Oid(n.Resultcollid),
  690. Coerceformat: ast.CoercionForm(n.Coerceformat),
  691. Location: int(n.Location),
  692. }
  693. }
  694. func convertCollateClause(n *pg.CollateClause) *ast.CollateClause {
  695. if n == nil {
  696. return nil
  697. }
  698. return &ast.CollateClause{
  699. Arg: convertNode(n.Arg),
  700. Collname: convertSlice(n.Collname),
  701. Location: int(n.Location),
  702. }
  703. }
  704. func convertCollateExpr(n *pg.CollateExpr) *ast.CollateExpr {
  705. if n == nil {
  706. return nil
  707. }
  708. return &ast.CollateExpr{
  709. Xpr: convertNode(n.Xpr),
  710. Arg: convertNode(n.Arg),
  711. CollOid: ast.Oid(n.CollOid),
  712. Location: int(n.Location),
  713. }
  714. }
  715. func convertColumnDef(n *pg.ColumnDef) *ast.ColumnDef {
  716. if n == nil {
  717. return nil
  718. }
  719. return &ast.ColumnDef{
  720. Colname: n.Colname,
  721. TypeName: convertTypeName(n.TypeName),
  722. Inhcount: int(n.Inhcount),
  723. IsLocal: n.IsLocal,
  724. IsNotNull: n.IsNotNull,
  725. IsFromType: n.IsFromType,
  726. Storage: makeByte(n.Storage),
  727. RawDefault: convertNode(n.RawDefault),
  728. CookedDefault: convertNode(n.CookedDefault),
  729. Identity: makeByte(n.Identity),
  730. CollClause: convertCollateClause(n.CollClause),
  731. CollOid: ast.Oid(n.CollOid),
  732. Constraints: convertSlice(n.Constraints),
  733. Fdwoptions: convertSlice(n.Fdwoptions),
  734. Location: int(n.Location),
  735. }
  736. }
  737. func convertColumnRef(n *pg.ColumnRef) *ast.ColumnRef {
  738. if n == nil {
  739. return nil
  740. }
  741. return &ast.ColumnRef{
  742. Fields: convertSlice(n.Fields),
  743. Location: int(n.Location),
  744. }
  745. }
  746. func convertCommentStmt(n *pg.CommentStmt) *ast.CommentStmt {
  747. if n == nil {
  748. return nil
  749. }
  750. return &ast.CommentStmt{
  751. Objtype: ast.ObjectType(n.Objtype),
  752. Object: convertNode(n.Object),
  753. Comment: makeString(n.Comment),
  754. }
  755. }
  756. func convertCommonTableExpr(n *pg.CommonTableExpr) *ast.CommonTableExpr {
  757. if n == nil {
  758. return nil
  759. }
  760. return &ast.CommonTableExpr{
  761. Ctename: makeString(n.Ctename),
  762. Aliascolnames: convertSlice(n.Aliascolnames),
  763. Ctequery: convertNode(n.Ctequery),
  764. Location: int(n.Location),
  765. Cterecursive: n.Cterecursive,
  766. Cterefcount: int(n.Cterefcount),
  767. Ctecolnames: convertSlice(n.Ctecolnames),
  768. Ctecoltypes: convertSlice(n.Ctecoltypes),
  769. Ctecoltypmods: convertSlice(n.Ctecoltypmods),
  770. Ctecolcollations: convertSlice(n.Ctecolcollations),
  771. }
  772. }
  773. func convertCompositeTypeStmt(n *pg.CompositeTypeStmt) *ast.CompositeTypeStmt {
  774. if n == nil {
  775. return nil
  776. }
  777. rel := parseRelationFromRangeVar(n.Typevar)
  778. return &ast.CompositeTypeStmt{
  779. TypeName: rel.TypeName(),
  780. }
  781. }
  782. func convertConstraint(n *pg.Constraint) *ast.Constraint {
  783. if n == nil {
  784. return nil
  785. }
  786. return &ast.Constraint{
  787. Contype: ast.ConstrType(n.Contype),
  788. Conname: makeString(n.Conname),
  789. Deferrable: n.Deferrable,
  790. Initdeferred: n.Initdeferred,
  791. Location: int(n.Location),
  792. IsNoInherit: n.IsNoInherit,
  793. RawExpr: convertNode(n.RawExpr),
  794. CookedExpr: makeString(n.CookedExpr),
  795. GeneratedWhen: makeByte(n.GeneratedWhen),
  796. Keys: convertSlice(n.Keys),
  797. Exclusions: convertSlice(n.Exclusions),
  798. Options: convertSlice(n.Options),
  799. Indexname: makeString(n.Indexname),
  800. Indexspace: makeString(n.Indexspace),
  801. AccessMethod: makeString(n.AccessMethod),
  802. WhereClause: convertNode(n.WhereClause),
  803. Pktable: convertRangeVar(n.Pktable),
  804. FkAttrs: convertSlice(n.FkAttrs),
  805. PkAttrs: convertSlice(n.PkAttrs),
  806. FkMatchtype: makeByte(n.FkMatchtype),
  807. FkUpdAction: makeByte(n.FkUpdAction),
  808. FkDelAction: makeByte(n.FkDelAction),
  809. OldConpfeqop: convertSlice(n.OldConpfeqop),
  810. OldPktableOid: ast.Oid(n.OldPktableOid),
  811. SkipValidation: n.SkipValidation,
  812. InitiallyValid: n.InitiallyValid,
  813. }
  814. }
  815. func convertConstraintsSetStmt(n *pg.ConstraintsSetStmt) *ast.ConstraintsSetStmt {
  816. if n == nil {
  817. return nil
  818. }
  819. return &ast.ConstraintsSetStmt{
  820. Constraints: convertSlice(n.Constraints),
  821. Deferred: n.Deferred,
  822. }
  823. }
  824. func convertConvertRowtypeExpr(n *pg.ConvertRowtypeExpr) *ast.ConvertRowtypeExpr {
  825. if n == nil {
  826. return nil
  827. }
  828. return &ast.ConvertRowtypeExpr{
  829. Xpr: convertNode(n.Xpr),
  830. Arg: convertNode(n.Arg),
  831. Resulttype: ast.Oid(n.Resulttype),
  832. Convertformat: ast.CoercionForm(n.Convertformat),
  833. Location: int(n.Location),
  834. }
  835. }
  836. func convertCopyStmt(n *pg.CopyStmt) *ast.CopyStmt {
  837. if n == nil {
  838. return nil
  839. }
  840. return &ast.CopyStmt{
  841. Relation: convertRangeVar(n.Relation),
  842. Query: convertNode(n.Query),
  843. Attlist: convertSlice(n.Attlist),
  844. IsFrom: n.IsFrom,
  845. IsProgram: n.IsProgram,
  846. Filename: makeString(n.Filename),
  847. Options: convertSlice(n.Options),
  848. }
  849. }
  850. func convertCreateAmStmt(n *pg.CreateAmStmt) *ast.CreateAmStmt {
  851. if n == nil {
  852. return nil
  853. }
  854. return &ast.CreateAmStmt{
  855. Amname: makeString(n.Amname),
  856. HandlerName: convertSlice(n.HandlerName),
  857. Amtype: makeByte(n.Amtype),
  858. }
  859. }
  860. func convertCreateCastStmt(n *pg.CreateCastStmt) *ast.CreateCastStmt {
  861. if n == nil {
  862. return nil
  863. }
  864. return &ast.CreateCastStmt{
  865. Sourcetype: convertTypeName(n.Sourcetype),
  866. Targettype: convertTypeName(n.Targettype),
  867. Func: convertObjectWithArgs(n.Func),
  868. Context: ast.CoercionContext(n.Context),
  869. Inout: n.Inout,
  870. }
  871. }
  872. func convertCreateConversionStmt(n *pg.CreateConversionStmt) *ast.CreateConversionStmt {
  873. if n == nil {
  874. return nil
  875. }
  876. return &ast.CreateConversionStmt{
  877. ConversionName: convertSlice(n.ConversionName),
  878. ForEncodingName: makeString(n.ForEncodingName),
  879. ToEncodingName: makeString(n.ToEncodingName),
  880. FuncName: convertSlice(n.FuncName),
  881. Def: n.Def,
  882. }
  883. }
  884. func convertCreateDomainStmt(n *pg.CreateDomainStmt) *ast.CreateDomainStmt {
  885. if n == nil {
  886. return nil
  887. }
  888. return &ast.CreateDomainStmt{
  889. Domainname: convertSlice(n.Domainname),
  890. TypeName: convertTypeName(n.TypeName),
  891. CollClause: convertCollateClause(n.CollClause),
  892. Constraints: convertSlice(n.Constraints),
  893. }
  894. }
  895. func convertCreateEnumStmt(n *pg.CreateEnumStmt) *ast.CreateEnumStmt {
  896. if n == nil {
  897. return nil
  898. }
  899. rel, err := parseRelationFromNodes(n.TypeName)
  900. if err != nil {
  901. panic(err)
  902. }
  903. return &ast.CreateEnumStmt{
  904. TypeName: rel.TypeName(),
  905. Vals: convertSlice(n.Vals),
  906. }
  907. }
  908. func convertCreateEventTrigStmt(n *pg.CreateEventTrigStmt) *ast.CreateEventTrigStmt {
  909. if n == nil {
  910. return nil
  911. }
  912. return &ast.CreateEventTrigStmt{
  913. Trigname: makeString(n.Trigname),
  914. Eventname: makeString(n.Eventname),
  915. Whenclause: convertSlice(n.Whenclause),
  916. Funcname: convertSlice(n.Funcname),
  917. }
  918. }
  919. func convertCreateExtensionStmt(n *pg.CreateExtensionStmt) *ast.CreateExtensionStmt {
  920. if n == nil {
  921. return nil
  922. }
  923. return &ast.CreateExtensionStmt{
  924. Extname: makeString(n.Extname),
  925. IfNotExists: n.IfNotExists,
  926. Options: convertSlice(n.Options),
  927. }
  928. }
  929. func convertCreateFdwStmt(n *pg.CreateFdwStmt) *ast.CreateFdwStmt {
  930. if n == nil {
  931. return nil
  932. }
  933. return &ast.CreateFdwStmt{
  934. Fdwname: makeString(n.Fdwname),
  935. FuncOptions: convertSlice(n.FuncOptions),
  936. Options: convertSlice(n.Options),
  937. }
  938. }
  939. func convertCreateForeignServerStmt(n *pg.CreateForeignServerStmt) *ast.CreateForeignServerStmt {
  940. if n == nil {
  941. return nil
  942. }
  943. return &ast.CreateForeignServerStmt{
  944. Servername: makeString(n.Servername),
  945. Servertype: makeString(n.Servertype),
  946. Version: makeString(n.Version),
  947. Fdwname: makeString(n.Fdwname),
  948. IfNotExists: n.IfNotExists,
  949. Options: convertSlice(n.Options),
  950. }
  951. }
  952. func convertCreateForeignTableStmt(n *pg.CreateForeignTableStmt) *ast.CreateForeignTableStmt {
  953. if n == nil {
  954. return nil
  955. }
  956. return &ast.CreateForeignTableStmt{
  957. Servername: makeString(n.Servername),
  958. Options: convertSlice(n.Options),
  959. }
  960. }
  961. func convertCreateFunctionStmt(n *pg.CreateFunctionStmt) *ast.CreateFunctionStmt {
  962. if n == nil {
  963. return nil
  964. }
  965. rel, err := parseRelationFromNodes(n.Funcname)
  966. if err != nil {
  967. panic(err)
  968. }
  969. return &ast.CreateFunctionStmt{
  970. Replace: n.Replace,
  971. Func: rel.FuncName(),
  972. Params: convertSlice(n.Parameters),
  973. ReturnType: convertTypeName(n.ReturnType),
  974. Options: convertSlice(n.Options),
  975. }
  976. }
  977. func convertCreateOpClassItem(n *pg.CreateOpClassItem) *ast.CreateOpClassItem {
  978. if n == nil {
  979. return nil
  980. }
  981. return &ast.CreateOpClassItem{
  982. Itemtype: int(n.Itemtype),
  983. Name: convertObjectWithArgs(n.Name),
  984. Number: int(n.Number),
  985. OrderFamily: convertSlice(n.OrderFamily),
  986. ClassArgs: convertSlice(n.ClassArgs),
  987. Storedtype: convertTypeName(n.Storedtype),
  988. }
  989. }
  990. func convertCreateOpClassStmt(n *pg.CreateOpClassStmt) *ast.CreateOpClassStmt {
  991. if n == nil {
  992. return nil
  993. }
  994. return &ast.CreateOpClassStmt{
  995. Opclassname: convertSlice(n.Opclassname),
  996. Opfamilyname: convertSlice(n.Opfamilyname),
  997. Amname: makeString(n.Amname),
  998. Datatype: convertTypeName(n.Datatype),
  999. Items: convertSlice(n.Items),
  1000. IsDefault: n.IsDefault,
  1001. }
  1002. }
  1003. func convertCreateOpFamilyStmt(n *pg.CreateOpFamilyStmt) *ast.CreateOpFamilyStmt {
  1004. if n == nil {
  1005. return nil
  1006. }
  1007. return &ast.CreateOpFamilyStmt{
  1008. Opfamilyname: convertSlice(n.Opfamilyname),
  1009. Amname: makeString(n.Amname),
  1010. }
  1011. }
  1012. func convertCreatePLangStmt(n *pg.CreatePLangStmt) *ast.CreatePLangStmt {
  1013. if n == nil {
  1014. return nil
  1015. }
  1016. return &ast.CreatePLangStmt{
  1017. Replace: n.Replace,
  1018. Plname: makeString(n.Plname),
  1019. Plhandler: convertSlice(n.Plhandler),
  1020. Plinline: convertSlice(n.Plinline),
  1021. Plvalidator: convertSlice(n.Plvalidator),
  1022. Pltrusted: n.Pltrusted,
  1023. }
  1024. }
  1025. func convertCreatePolicyStmt(n *pg.CreatePolicyStmt) *ast.CreatePolicyStmt {
  1026. if n == nil {
  1027. return nil
  1028. }
  1029. return &ast.CreatePolicyStmt{
  1030. PolicyName: makeString(n.PolicyName),
  1031. Table: convertRangeVar(n.Table),
  1032. CmdName: makeString(n.CmdName),
  1033. Permissive: n.Permissive,
  1034. Roles: convertSlice(n.Roles),
  1035. Qual: convertNode(n.Qual),
  1036. WithCheck: convertNode(n.WithCheck),
  1037. }
  1038. }
  1039. func convertCreatePublicationStmt(n *pg.CreatePublicationStmt) *ast.CreatePublicationStmt {
  1040. if n == nil {
  1041. return nil
  1042. }
  1043. return &ast.CreatePublicationStmt{
  1044. Pubname: makeString(n.Pubname),
  1045. Options: convertSlice(n.Options),
  1046. Tables: convertSlice(n.Tables),
  1047. ForAllTables: n.ForAllTables,
  1048. }
  1049. }
  1050. func convertCreateRangeStmt(n *pg.CreateRangeStmt) *ast.CreateRangeStmt {
  1051. if n == nil {
  1052. return nil
  1053. }
  1054. return &ast.CreateRangeStmt{
  1055. TypeName: convertSlice(n.TypeName),
  1056. Params: convertSlice(n.Params),
  1057. }
  1058. }
  1059. func convertCreateRoleStmt(n *pg.CreateRoleStmt) *ast.CreateRoleStmt {
  1060. if n == nil {
  1061. return nil
  1062. }
  1063. return &ast.CreateRoleStmt{
  1064. StmtType: ast.RoleStmtType(n.StmtType),
  1065. Role: makeString(n.Role),
  1066. Options: convertSlice(n.Options),
  1067. }
  1068. }
  1069. func convertCreateSchemaStmt(n *pg.CreateSchemaStmt) *ast.CreateSchemaStmt {
  1070. if n == nil {
  1071. return nil
  1072. }
  1073. return &ast.CreateSchemaStmt{
  1074. Name: makeString(n.Schemaname),
  1075. Authrole: convertRoleSpec(n.Authrole),
  1076. SchemaElts: convertSlice(n.SchemaElts),
  1077. IfNotExists: n.IfNotExists,
  1078. }
  1079. }
  1080. func convertCreateSeqStmt(n *pg.CreateSeqStmt) *ast.CreateSeqStmt {
  1081. if n == nil {
  1082. return nil
  1083. }
  1084. return &ast.CreateSeqStmt{
  1085. Sequence: convertRangeVar(n.Sequence),
  1086. Options: convertSlice(n.Options),
  1087. OwnerId: ast.Oid(n.OwnerId),
  1088. ForIdentity: n.ForIdentity,
  1089. IfNotExists: n.IfNotExists,
  1090. }
  1091. }
  1092. func convertCreateStatsStmt(n *pg.CreateStatsStmt) *ast.CreateStatsStmt {
  1093. if n == nil {
  1094. return nil
  1095. }
  1096. return &ast.CreateStatsStmt{
  1097. Defnames: convertSlice(n.Defnames),
  1098. StatTypes: convertSlice(n.StatTypes),
  1099. Exprs: convertSlice(n.Exprs),
  1100. Relations: convertSlice(n.Relations),
  1101. IfNotExists: n.IfNotExists,
  1102. }
  1103. }
  1104. func convertCreateStmt(n *pg.CreateStmt) *ast.CreateStmt {
  1105. if n == nil {
  1106. return nil
  1107. }
  1108. return &ast.CreateStmt{
  1109. Relation: convertRangeVar(n.Relation),
  1110. TableElts: convertSlice(n.TableElts),
  1111. InhRelations: convertSlice(n.InhRelations),
  1112. Partbound: convertPartitionBoundSpec(n.Partbound),
  1113. Partspec: convertPartitionSpec(n.Partspec),
  1114. OfTypename: convertTypeName(n.OfTypename),
  1115. Constraints: convertSlice(n.Constraints),
  1116. Options: convertSlice(n.Options),
  1117. Oncommit: ast.OnCommitAction(n.Oncommit),
  1118. Tablespacename: makeString(n.Tablespacename),
  1119. IfNotExists: n.IfNotExists,
  1120. }
  1121. }
  1122. func convertCreateSubscriptionStmt(n *pg.CreateSubscriptionStmt) *ast.CreateSubscriptionStmt {
  1123. if n == nil {
  1124. return nil
  1125. }
  1126. return &ast.CreateSubscriptionStmt{
  1127. Subname: makeString(n.Subname),
  1128. Conninfo: makeString(n.Conninfo),
  1129. Publication: convertSlice(n.Publication),
  1130. Options: convertSlice(n.Options),
  1131. }
  1132. }
  1133. func convertCreateTableAsStmt(n *pg.CreateTableAsStmt) *ast.CreateTableAsStmt {
  1134. if n == nil {
  1135. return nil
  1136. }
  1137. return &ast.CreateTableAsStmt{
  1138. Query: convertNode(n.Query),
  1139. Into: convertIntoClause(n.Into),
  1140. Relkind: ast.ObjectType(n.Relkind),
  1141. IsSelectInto: n.IsSelectInto,
  1142. IfNotExists: n.IfNotExists,
  1143. }
  1144. }
  1145. func convertCreateTableSpaceStmt(n *pg.CreateTableSpaceStmt) *ast.CreateTableSpaceStmt {
  1146. if n == nil {
  1147. return nil
  1148. }
  1149. return &ast.CreateTableSpaceStmt{
  1150. Tablespacename: makeString(n.Tablespacename),
  1151. Owner: convertRoleSpec(n.Owner),
  1152. Location: makeString(n.Location),
  1153. Options: convertSlice(n.Options),
  1154. }
  1155. }
  1156. func convertCreateTransformStmt(n *pg.CreateTransformStmt) *ast.CreateTransformStmt {
  1157. if n == nil {
  1158. return nil
  1159. }
  1160. return &ast.CreateTransformStmt{
  1161. Replace: n.Replace,
  1162. TypeName: convertTypeName(n.TypeName),
  1163. Lang: makeString(n.Lang),
  1164. Fromsql: convertObjectWithArgs(n.Fromsql),
  1165. Tosql: convertObjectWithArgs(n.Tosql),
  1166. }
  1167. }
  1168. func convertCreateTrigStmt(n *pg.CreateTrigStmt) *ast.CreateTrigStmt {
  1169. if n == nil {
  1170. return nil
  1171. }
  1172. return &ast.CreateTrigStmt{
  1173. Trigname: makeString(n.Trigname),
  1174. Relation: convertRangeVar(n.Relation),
  1175. Funcname: convertSlice(n.Funcname),
  1176. Args: convertSlice(n.Args),
  1177. Row: n.Row,
  1178. Timing: int16(n.Timing),
  1179. Events: int16(n.Events),
  1180. Columns: convertSlice(n.Columns),
  1181. WhenClause: convertNode(n.WhenClause),
  1182. Isconstraint: n.Isconstraint,
  1183. TransitionRels: convertSlice(n.TransitionRels),
  1184. Deferrable: n.Deferrable,
  1185. Initdeferred: n.Initdeferred,
  1186. Constrrel: convertRangeVar(n.Constrrel),
  1187. }
  1188. }
  1189. func convertCreateUserMappingStmt(n *pg.CreateUserMappingStmt) *ast.CreateUserMappingStmt {
  1190. if n == nil {
  1191. return nil
  1192. }
  1193. return &ast.CreateUserMappingStmt{
  1194. User: convertRoleSpec(n.User),
  1195. Servername: makeString(n.Servername),
  1196. IfNotExists: n.IfNotExists,
  1197. Options: convertSlice(n.Options),
  1198. }
  1199. }
  1200. func convertCreatedbStmt(n *pg.CreatedbStmt) *ast.CreatedbStmt {
  1201. if n == nil {
  1202. return nil
  1203. }
  1204. return &ast.CreatedbStmt{
  1205. Dbname: makeString(n.Dbname),
  1206. Options: convertSlice(n.Options),
  1207. }
  1208. }
  1209. func convertCurrentOfExpr(n *pg.CurrentOfExpr) *ast.CurrentOfExpr {
  1210. if n == nil {
  1211. return nil
  1212. }
  1213. return &ast.CurrentOfExpr{
  1214. Xpr: convertNode(n.Xpr),
  1215. Cvarno: ast.Index(n.Cvarno),
  1216. CursorName: makeString(n.CursorName),
  1217. CursorParam: int(n.CursorParam),
  1218. }
  1219. }
  1220. func convertDeallocateStmt(n *pg.DeallocateStmt) *ast.DeallocateStmt {
  1221. if n == nil {
  1222. return nil
  1223. }
  1224. return &ast.DeallocateStmt{
  1225. Name: makeString(n.Name),
  1226. }
  1227. }
  1228. func convertDeclareCursorStmt(n *pg.DeclareCursorStmt) *ast.DeclareCursorStmt {
  1229. if n == nil {
  1230. return nil
  1231. }
  1232. return &ast.DeclareCursorStmt{
  1233. Portalname: makeString(n.Portalname),
  1234. Options: int(n.Options),
  1235. Query: convertNode(n.Query),
  1236. }
  1237. }
  1238. func convertDefElem(n *pg.DefElem) *ast.DefElem {
  1239. if n == nil {
  1240. return nil
  1241. }
  1242. return &ast.DefElem{
  1243. Defnamespace: makeString(n.Defnamespace),
  1244. Defname: makeString(n.Defname),
  1245. Arg: convertNode(n.Arg),
  1246. Defaction: ast.DefElemAction(n.Defaction),
  1247. Location: int(n.Location),
  1248. }
  1249. }
  1250. func convertDefineStmt(n *pg.DefineStmt) *ast.DefineStmt {
  1251. if n == nil {
  1252. return nil
  1253. }
  1254. return &ast.DefineStmt{
  1255. Kind: ast.ObjectType(n.Kind),
  1256. Oldstyle: n.Oldstyle,
  1257. Defnames: convertSlice(n.Defnames),
  1258. Args: convertSlice(n.Args),
  1259. Definition: convertSlice(n.Definition),
  1260. IfNotExists: n.IfNotExists,
  1261. }
  1262. }
  1263. func convertDeleteStmt(n *pg.DeleteStmt) *ast.DeleteStmt {
  1264. if n == nil {
  1265. return nil
  1266. }
  1267. return &ast.DeleteStmt{
  1268. Relation: convertRangeVar(n.Relation),
  1269. UsingClause: convertSlice(n.UsingClause),
  1270. WhereClause: convertNode(n.WhereClause),
  1271. ReturningList: convertSlice(n.ReturningList),
  1272. WithClause: convertWithClause(n.WithClause),
  1273. }
  1274. }
  1275. func convertDiscardStmt(n *pg.DiscardStmt) *ast.DiscardStmt {
  1276. if n == nil {
  1277. return nil
  1278. }
  1279. return &ast.DiscardStmt{
  1280. Target: ast.DiscardMode(n.Target),
  1281. }
  1282. }
  1283. func convertDoStmt(n *pg.DoStmt) *ast.DoStmt {
  1284. if n == nil {
  1285. return nil
  1286. }
  1287. return &ast.DoStmt{
  1288. Args: convertSlice(n.Args),
  1289. }
  1290. }
  1291. func convertDropOwnedStmt(n *pg.DropOwnedStmt) *ast.DropOwnedStmt {
  1292. if n == nil {
  1293. return nil
  1294. }
  1295. return &ast.DropOwnedStmt{
  1296. Roles: convertSlice(n.Roles),
  1297. Behavior: ast.DropBehavior(n.Behavior),
  1298. }
  1299. }
  1300. func convertDropRoleStmt(n *pg.DropRoleStmt) *ast.DropRoleStmt {
  1301. if n == nil {
  1302. return nil
  1303. }
  1304. return &ast.DropRoleStmt{
  1305. Roles: convertSlice(n.Roles),
  1306. MissingOk: n.MissingOk,
  1307. }
  1308. }
  1309. func convertDropStmt(n *pg.DropStmt) *ast.DropStmt {
  1310. if n == nil {
  1311. return nil
  1312. }
  1313. return &ast.DropStmt{
  1314. Objects: convertSlice(n.Objects),
  1315. RemoveType: ast.ObjectType(n.RemoveType),
  1316. Behavior: ast.DropBehavior(n.Behavior),
  1317. MissingOk: n.MissingOk,
  1318. Concurrent: n.Concurrent,
  1319. }
  1320. }
  1321. func convertDropSubscriptionStmt(n *pg.DropSubscriptionStmt) *ast.DropSubscriptionStmt {
  1322. if n == nil {
  1323. return nil
  1324. }
  1325. return &ast.DropSubscriptionStmt{
  1326. Subname: makeString(n.Subname),
  1327. MissingOk: n.MissingOk,
  1328. Behavior: ast.DropBehavior(n.Behavior),
  1329. }
  1330. }
  1331. func convertDropTableSpaceStmt(n *pg.DropTableSpaceStmt) *ast.DropTableSpaceStmt {
  1332. if n == nil {
  1333. return nil
  1334. }
  1335. return &ast.DropTableSpaceStmt{
  1336. Tablespacename: makeString(n.Tablespacename),
  1337. MissingOk: n.MissingOk,
  1338. }
  1339. }
  1340. func convertDropUserMappingStmt(n *pg.DropUserMappingStmt) *ast.DropUserMappingStmt {
  1341. if n == nil {
  1342. return nil
  1343. }
  1344. return &ast.DropUserMappingStmt{
  1345. User: convertRoleSpec(n.User),
  1346. Servername: makeString(n.Servername),
  1347. MissingOk: n.MissingOk,
  1348. }
  1349. }
  1350. func convertDropdbStmt(n *pg.DropdbStmt) *ast.DropdbStmt {
  1351. if n == nil {
  1352. return nil
  1353. }
  1354. return &ast.DropdbStmt{
  1355. Dbname: makeString(n.Dbname),
  1356. MissingOk: n.MissingOk,
  1357. }
  1358. }
  1359. func convertExecuteStmt(n *pg.ExecuteStmt) *ast.ExecuteStmt {
  1360. if n == nil {
  1361. return nil
  1362. }
  1363. return &ast.ExecuteStmt{
  1364. Name: makeString(n.Name),
  1365. Params: convertSlice(n.Params),
  1366. }
  1367. }
  1368. func convertExplainStmt(n *pg.ExplainStmt) *ast.ExplainStmt {
  1369. if n == nil {
  1370. return nil
  1371. }
  1372. return &ast.ExplainStmt{
  1373. Query: convertNode(n.Query),
  1374. Options: convertSlice(n.Options),
  1375. }
  1376. }
  1377. func convertExpr(n *pg.Expr) *ast.Expr {
  1378. if n == nil {
  1379. return nil
  1380. }
  1381. return &ast.Expr{}
  1382. }
  1383. func convertFetchStmt(n *pg.FetchStmt) *ast.FetchStmt {
  1384. if n == nil {
  1385. return nil
  1386. }
  1387. return &ast.FetchStmt{
  1388. Direction: ast.FetchDirection(n.Direction),
  1389. HowMany: n.HowMany,
  1390. Portalname: makeString(n.Portalname),
  1391. Ismove: n.Ismove,
  1392. }
  1393. }
  1394. func convertFieldSelect(n *pg.FieldSelect) *ast.FieldSelect {
  1395. if n == nil {
  1396. return nil
  1397. }
  1398. return &ast.FieldSelect{
  1399. Xpr: convertNode(n.Xpr),
  1400. Arg: convertNode(n.Arg),
  1401. Fieldnum: ast.AttrNumber(n.Fieldnum),
  1402. Resulttype: ast.Oid(n.Resulttype),
  1403. Resulttypmod: n.Resulttypmod,
  1404. Resultcollid: ast.Oid(n.Resultcollid),
  1405. }
  1406. }
  1407. func convertFieldStore(n *pg.FieldStore) *ast.FieldStore {
  1408. if n == nil {
  1409. return nil
  1410. }
  1411. return &ast.FieldStore{
  1412. Xpr: convertNode(n.Xpr),
  1413. Arg: convertNode(n.Arg),
  1414. Newvals: convertSlice(n.Newvals),
  1415. Fieldnums: convertSlice(n.Fieldnums),
  1416. Resulttype: ast.Oid(n.Resulttype),
  1417. }
  1418. }
  1419. func convertFloat(n *pg.Float) *ast.Float {
  1420. if n == nil {
  1421. return nil
  1422. }
  1423. return &ast.Float{
  1424. Str: n.Str,
  1425. }
  1426. }
  1427. func convertFromExpr(n *pg.FromExpr) *ast.FromExpr {
  1428. if n == nil {
  1429. return nil
  1430. }
  1431. return &ast.FromExpr{
  1432. Fromlist: convertSlice(n.Fromlist),
  1433. Quals: convertNode(n.Quals),
  1434. }
  1435. }
  1436. func convertFuncCall(n *pg.FuncCall) *ast.FuncCall {
  1437. if n == nil {
  1438. return nil
  1439. }
  1440. rel, err := parseRelationFromNodes(n.Funcname)
  1441. if err != nil {
  1442. // TODO: How should we handle errors?
  1443. panic(err)
  1444. }
  1445. return &ast.FuncCall{
  1446. Func: rel.FuncName(),
  1447. Funcname: convertSlice(n.Funcname),
  1448. Args: convertSlice(n.Args),
  1449. AggOrder: convertSlice(n.AggOrder),
  1450. AggFilter: convertNode(n.AggFilter),
  1451. AggWithinGroup: n.AggWithinGroup,
  1452. AggStar: n.AggStar,
  1453. AggDistinct: n.AggDistinct,
  1454. FuncVariadic: n.FuncVariadic,
  1455. Over: convertWindowDef(n.Over),
  1456. Location: int(n.Location),
  1457. }
  1458. }
  1459. func convertFuncExpr(n *pg.FuncExpr) *ast.FuncExpr {
  1460. if n == nil {
  1461. return nil
  1462. }
  1463. return &ast.FuncExpr{
  1464. Xpr: convertNode(n.Xpr),
  1465. Funcid: ast.Oid(n.Funcid),
  1466. Funcresulttype: ast.Oid(n.Funcresulttype),
  1467. Funcretset: n.Funcretset,
  1468. Funcvariadic: n.Funcvariadic,
  1469. Funcformat: ast.CoercionForm(n.Funcformat),
  1470. Funccollid: ast.Oid(n.Funccollid),
  1471. Inputcollid: ast.Oid(n.Inputcollid),
  1472. Args: convertSlice(n.Args),
  1473. Location: int(n.Location),
  1474. }
  1475. }
  1476. func convertFunctionParameter(n *pg.FunctionParameter) *ast.FunctionParameter {
  1477. if n == nil {
  1478. return nil
  1479. }
  1480. return &ast.FunctionParameter{
  1481. Name: makeString(n.Name),
  1482. ArgType: convertTypeName(n.ArgType),
  1483. Mode: ast.FunctionParameterMode(n.Mode),
  1484. Defexpr: convertNode(n.Defexpr),
  1485. }
  1486. }
  1487. func convertGrantRoleStmt(n *pg.GrantRoleStmt) *ast.GrantRoleStmt {
  1488. if n == nil {
  1489. return nil
  1490. }
  1491. return &ast.GrantRoleStmt{
  1492. GrantedRoles: convertSlice(n.GrantedRoles),
  1493. GranteeRoles: convertSlice(n.GranteeRoles),
  1494. IsGrant: n.IsGrant,
  1495. AdminOpt: n.AdminOpt,
  1496. Grantor: convertRoleSpec(n.Grantor),
  1497. Behavior: ast.DropBehavior(n.Behavior),
  1498. }
  1499. }
  1500. func convertGrantStmt(n *pg.GrantStmt) *ast.GrantStmt {
  1501. if n == nil {
  1502. return nil
  1503. }
  1504. return &ast.GrantStmt{
  1505. IsGrant: n.IsGrant,
  1506. Targtype: ast.GrantTargetType(n.Targtype),
  1507. Objtype: ast.GrantObjectType(n.Objtype),
  1508. Objects: convertSlice(n.Objects),
  1509. Privileges: convertSlice(n.Privileges),
  1510. Grantees: convertSlice(n.Grantees),
  1511. GrantOption: n.GrantOption,
  1512. Behavior: ast.DropBehavior(n.Behavior),
  1513. }
  1514. }
  1515. func convertGroupingFunc(n *pg.GroupingFunc) *ast.GroupingFunc {
  1516. if n == nil {
  1517. return nil
  1518. }
  1519. return &ast.GroupingFunc{
  1520. Xpr: convertNode(n.Xpr),
  1521. Args: convertSlice(n.Args),
  1522. Refs: convertSlice(n.Refs),
  1523. Cols: convertSlice(n.Cols),
  1524. Agglevelsup: ast.Index(n.Agglevelsup),
  1525. Location: int(n.Location),
  1526. }
  1527. }
  1528. func convertGroupingSet(n *pg.GroupingSet) *ast.GroupingSet {
  1529. if n == nil {
  1530. return nil
  1531. }
  1532. return &ast.GroupingSet{
  1533. Kind: ast.GroupingSetKind(n.Kind),
  1534. Content: convertSlice(n.Content),
  1535. Location: int(n.Location),
  1536. }
  1537. }
  1538. func convertImportForeignSchemaStmt(n *pg.ImportForeignSchemaStmt) *ast.ImportForeignSchemaStmt {
  1539. if n == nil {
  1540. return nil
  1541. }
  1542. return &ast.ImportForeignSchemaStmt{
  1543. ServerName: makeString(n.ServerName),
  1544. RemoteSchema: makeString(n.RemoteSchema),
  1545. LocalSchema: makeString(n.LocalSchema),
  1546. ListType: ast.ImportForeignSchemaType(n.ListType),
  1547. TableList: convertSlice(n.TableList),
  1548. Options: convertSlice(n.Options),
  1549. }
  1550. }
  1551. func convertIndexElem(n *pg.IndexElem) *ast.IndexElem {
  1552. if n == nil {
  1553. return nil
  1554. }
  1555. return &ast.IndexElem{
  1556. Name: makeString(n.Name),
  1557. Expr: convertNode(n.Expr),
  1558. Indexcolname: makeString(n.Indexcolname),
  1559. Collation: convertSlice(n.Collation),
  1560. Opclass: convertSlice(n.Opclass),
  1561. Ordering: ast.SortByDir(n.Ordering),
  1562. NullsOrdering: ast.SortByNulls(n.NullsOrdering),
  1563. }
  1564. }
  1565. func convertIndexStmt(n *pg.IndexStmt) *ast.IndexStmt {
  1566. if n == nil {
  1567. return nil
  1568. }
  1569. return &ast.IndexStmt{
  1570. Idxname: makeString(n.Idxname),
  1571. Relation: convertRangeVar(n.Relation),
  1572. AccessMethod: makeString(n.AccessMethod),
  1573. TableSpace: makeString(n.TableSpace),
  1574. IndexParams: convertSlice(n.IndexParams),
  1575. Options: convertSlice(n.Options),
  1576. WhereClause: convertNode(n.WhereClause),
  1577. ExcludeOpNames: convertSlice(n.ExcludeOpNames),
  1578. Idxcomment: makeString(n.Idxcomment),
  1579. IndexOid: ast.Oid(n.IndexOid),
  1580. OldNode: ast.Oid(n.OldNode),
  1581. Unique: n.Unique,
  1582. Primary: n.Primary,
  1583. Isconstraint: n.Isconstraint,
  1584. Deferrable: n.Deferrable,
  1585. Initdeferred: n.Initdeferred,
  1586. Transformed: n.Transformed,
  1587. Concurrent: n.Concurrent,
  1588. IfNotExists: n.IfNotExists,
  1589. }
  1590. }
  1591. func convertInferClause(n *pg.InferClause) *ast.InferClause {
  1592. if n == nil {
  1593. return nil
  1594. }
  1595. return &ast.InferClause{
  1596. IndexElems: convertSlice(n.IndexElems),
  1597. WhereClause: convertNode(n.WhereClause),
  1598. Conname: makeString(n.Conname),
  1599. Location: int(n.Location),
  1600. }
  1601. }
  1602. func convertInferenceElem(n *pg.InferenceElem) *ast.InferenceElem {
  1603. if n == nil {
  1604. return nil
  1605. }
  1606. return &ast.InferenceElem{
  1607. Xpr: convertNode(n.Xpr),
  1608. Expr: convertNode(n.Expr),
  1609. Infercollid: ast.Oid(n.Infercollid),
  1610. Inferopclass: ast.Oid(n.Inferopclass),
  1611. }
  1612. }
  1613. func convertInlineCodeBlock(n *pg.InlineCodeBlock) *ast.InlineCodeBlock {
  1614. if n == nil {
  1615. return nil
  1616. }
  1617. return &ast.InlineCodeBlock{
  1618. SourceText: makeString(n.SourceText),
  1619. LangOid: ast.Oid(n.LangOid),
  1620. LangIsTrusted: n.LangIsTrusted,
  1621. }
  1622. }
  1623. func convertInsertStmt(n *pg.InsertStmt) *ast.InsertStmt {
  1624. if n == nil {
  1625. return nil
  1626. }
  1627. return &ast.InsertStmt{
  1628. Relation: convertRangeVar(n.Relation),
  1629. Cols: convertSlice(n.Cols),
  1630. SelectStmt: convertNode(n.SelectStmt),
  1631. OnConflictClause: convertOnConflictClause(n.OnConflictClause),
  1632. ReturningList: convertSlice(n.ReturningList),
  1633. WithClause: convertWithClause(n.WithClause),
  1634. Override: ast.OverridingKind(n.Override),
  1635. }
  1636. }
  1637. func convertInteger(n *pg.Integer) *ast.Integer {
  1638. if n == nil {
  1639. return nil
  1640. }
  1641. return &ast.Integer{
  1642. Ival: int64(n.Ival),
  1643. }
  1644. }
  1645. func convertIntoClause(n *pg.IntoClause) *ast.IntoClause {
  1646. if n == nil {
  1647. return nil
  1648. }
  1649. return &ast.IntoClause{
  1650. Rel: convertRangeVar(n.Rel),
  1651. ColNames: convertSlice(n.ColNames),
  1652. Options: convertSlice(n.Options),
  1653. OnCommit: ast.OnCommitAction(n.OnCommit),
  1654. TableSpaceName: makeString(n.TableSpaceName),
  1655. ViewQuery: convertNode(n.ViewQuery),
  1656. SkipData: n.SkipData,
  1657. }
  1658. }
  1659. func convertJoinExpr(n *pg.JoinExpr) *ast.JoinExpr {
  1660. if n == nil {
  1661. return nil
  1662. }
  1663. return &ast.JoinExpr{
  1664. Jointype: ast.JoinType(n.Jointype),
  1665. IsNatural: n.IsNatural,
  1666. Larg: convertNode(n.Larg),
  1667. Rarg: convertNode(n.Rarg),
  1668. UsingClause: convertSlice(n.UsingClause),
  1669. Quals: convertNode(n.Quals),
  1670. Alias: convertAlias(n.Alias),
  1671. Rtindex: int(n.Rtindex),
  1672. }
  1673. }
  1674. func convertListenStmt(n *pg.ListenStmt) *ast.ListenStmt {
  1675. if n == nil {
  1676. return nil
  1677. }
  1678. return &ast.ListenStmt{
  1679. Conditionname: makeString(n.Conditionname),
  1680. }
  1681. }
  1682. func convertLoadStmt(n *pg.LoadStmt) *ast.LoadStmt {
  1683. if n == nil {
  1684. return nil
  1685. }
  1686. return &ast.LoadStmt{
  1687. Filename: makeString(n.Filename),
  1688. }
  1689. }
  1690. func convertLockStmt(n *pg.LockStmt) *ast.LockStmt {
  1691. if n == nil {
  1692. return nil
  1693. }
  1694. return &ast.LockStmt{
  1695. Relations: convertSlice(n.Relations),
  1696. Mode: int(n.Mode),
  1697. Nowait: n.Nowait,
  1698. }
  1699. }
  1700. func convertLockingClause(n *pg.LockingClause) *ast.LockingClause {
  1701. if n == nil {
  1702. return nil
  1703. }
  1704. return &ast.LockingClause{
  1705. LockedRels: convertSlice(n.LockedRels),
  1706. Strength: ast.LockClauseStrength(n.Strength),
  1707. WaitPolicy: ast.LockWaitPolicy(n.WaitPolicy),
  1708. }
  1709. }
  1710. func convertMinMaxExpr(n *pg.MinMaxExpr) *ast.MinMaxExpr {
  1711. if n == nil {
  1712. return nil
  1713. }
  1714. return &ast.MinMaxExpr{
  1715. Xpr: convertNode(n.Xpr),
  1716. Minmaxtype: ast.Oid(n.Minmaxtype),
  1717. Minmaxcollid: ast.Oid(n.Minmaxcollid),
  1718. Inputcollid: ast.Oid(n.Inputcollid),
  1719. Op: ast.MinMaxOp(n.Op),
  1720. Args: convertSlice(n.Args),
  1721. Location: int(n.Location),
  1722. }
  1723. }
  1724. func convertMultiAssignRef(n *pg.MultiAssignRef) *ast.MultiAssignRef {
  1725. if n == nil {
  1726. return nil
  1727. }
  1728. return &ast.MultiAssignRef{
  1729. Source: convertNode(n.Source),
  1730. Colno: int(n.Colno),
  1731. Ncolumns: int(n.Ncolumns),
  1732. }
  1733. }
  1734. func convertNamedArgExpr(n *pg.NamedArgExpr) *ast.NamedArgExpr {
  1735. if n == nil {
  1736. return nil
  1737. }
  1738. return &ast.NamedArgExpr{
  1739. Xpr: convertNode(n.Xpr),
  1740. Arg: convertNode(n.Arg),
  1741. Name: makeString(n.Name),
  1742. Argnumber: int(n.Argnumber),
  1743. Location: int(n.Location),
  1744. }
  1745. }
  1746. func convertNextValueExpr(n *pg.NextValueExpr) *ast.NextValueExpr {
  1747. if n == nil {
  1748. return nil
  1749. }
  1750. return &ast.NextValueExpr{
  1751. Xpr: convertNode(n.Xpr),
  1752. Seqid: ast.Oid(n.Seqid),
  1753. TypeId: ast.Oid(n.TypeId),
  1754. }
  1755. }
  1756. func convertNotifyStmt(n *pg.NotifyStmt) *ast.NotifyStmt {
  1757. if n == nil {
  1758. return nil
  1759. }
  1760. return &ast.NotifyStmt{
  1761. Conditionname: makeString(n.Conditionname),
  1762. Payload: makeString(n.Payload),
  1763. }
  1764. }
  1765. func convertNull(n *pg.Null) *ast.Null {
  1766. if n == nil {
  1767. return nil
  1768. }
  1769. return &ast.Null{}
  1770. }
  1771. func convertNullTest(n *pg.NullTest) *ast.NullTest {
  1772. if n == nil {
  1773. return nil
  1774. }
  1775. return &ast.NullTest{
  1776. Xpr: convertNode(n.Xpr),
  1777. Arg: convertNode(n.Arg),
  1778. Nulltesttype: ast.NullTestType(n.Nulltesttype),
  1779. Argisrow: n.Argisrow,
  1780. Location: int(n.Location),
  1781. }
  1782. }
  1783. func convertObjectWithArgs(n *pg.ObjectWithArgs) *ast.ObjectWithArgs {
  1784. if n == nil {
  1785. return nil
  1786. }
  1787. return &ast.ObjectWithArgs{
  1788. Objname: convertSlice(n.Objname),
  1789. Objargs: convertSlice(n.Objargs),
  1790. ArgsUnspecified: n.ArgsUnspecified,
  1791. }
  1792. }
  1793. func convertOnConflictClause(n *pg.OnConflictClause) *ast.OnConflictClause {
  1794. if n == nil {
  1795. return nil
  1796. }
  1797. return &ast.OnConflictClause{
  1798. Action: ast.OnConflictAction(n.Action),
  1799. Infer: convertInferClause(n.Infer),
  1800. TargetList: convertSlice(n.TargetList),
  1801. WhereClause: convertNode(n.WhereClause),
  1802. Location: int(n.Location),
  1803. }
  1804. }
  1805. func convertOnConflictExpr(n *pg.OnConflictExpr) *ast.OnConflictExpr {
  1806. if n == nil {
  1807. return nil
  1808. }
  1809. return &ast.OnConflictExpr{
  1810. Action: ast.OnConflictAction(n.Action),
  1811. ArbiterElems: convertSlice(n.ArbiterElems),
  1812. ArbiterWhere: convertNode(n.ArbiterWhere),
  1813. Constraint: ast.Oid(n.Constraint),
  1814. OnConflictSet: convertSlice(n.OnConflictSet),
  1815. OnConflictWhere: convertNode(n.OnConflictWhere),
  1816. ExclRelIndex: int(n.ExclRelIndex),
  1817. ExclRelTlist: convertSlice(n.ExclRelTlist),
  1818. }
  1819. }
  1820. func convertOpExpr(n *pg.OpExpr) *ast.OpExpr {
  1821. if n == nil {
  1822. return nil
  1823. }
  1824. return &ast.OpExpr{
  1825. Xpr: convertNode(n.Xpr),
  1826. Opno: ast.Oid(n.Opno),
  1827. Opfuncid: ast.Oid(n.Opfuncid),
  1828. Opresulttype: ast.Oid(n.Opresulttype),
  1829. Opretset: n.Opretset,
  1830. Opcollid: ast.Oid(n.Opcollid),
  1831. Inputcollid: ast.Oid(n.Inputcollid),
  1832. Args: convertSlice(n.Args),
  1833. Location: int(n.Location),
  1834. }
  1835. }
  1836. func convertParam(n *pg.Param) *ast.Param {
  1837. if n == nil {
  1838. return nil
  1839. }
  1840. return &ast.Param{
  1841. Xpr: convertNode(n.Xpr),
  1842. Paramkind: ast.ParamKind(n.Paramkind),
  1843. Paramid: int(n.Paramid),
  1844. Paramtype: ast.Oid(n.Paramtype),
  1845. Paramtypmod: n.Paramtypmod,
  1846. Paramcollid: ast.Oid(n.Paramcollid),
  1847. Location: int(n.Location),
  1848. }
  1849. }
  1850. func convertParamRef(n *pg.ParamRef) *ast.ParamRef {
  1851. if n == nil {
  1852. return nil
  1853. }
  1854. var dollar bool
  1855. if n.Number != 0 {
  1856. dollar = true
  1857. }
  1858. return &ast.ParamRef{
  1859. Dollar: dollar,
  1860. Number: int(n.Number),
  1861. Location: int(n.Location),
  1862. }
  1863. }
  1864. func convertPartitionBoundSpec(n *pg.PartitionBoundSpec) *ast.PartitionBoundSpec {
  1865. if n == nil {
  1866. return nil
  1867. }
  1868. return &ast.PartitionBoundSpec{
  1869. Strategy: makeByte(n.Strategy),
  1870. Listdatums: convertSlice(n.Listdatums),
  1871. Lowerdatums: convertSlice(n.Lowerdatums),
  1872. Upperdatums: convertSlice(n.Upperdatums),
  1873. Location: int(n.Location),
  1874. }
  1875. }
  1876. func convertPartitionCmd(n *pg.PartitionCmd) *ast.PartitionCmd {
  1877. if n == nil {
  1878. return nil
  1879. }
  1880. return &ast.PartitionCmd{
  1881. Name: convertRangeVar(n.Name),
  1882. Bound: convertPartitionBoundSpec(n.Bound),
  1883. }
  1884. }
  1885. func convertPartitionElem(n *pg.PartitionElem) *ast.PartitionElem {
  1886. if n == nil {
  1887. return nil
  1888. }
  1889. return &ast.PartitionElem{
  1890. Name: makeString(n.Name),
  1891. Expr: convertNode(n.Expr),
  1892. Collation: convertSlice(n.Collation),
  1893. Opclass: convertSlice(n.Opclass),
  1894. Location: int(n.Location),
  1895. }
  1896. }
  1897. func convertPartitionRangeDatum(n *pg.PartitionRangeDatum) *ast.PartitionRangeDatum {
  1898. if n == nil {
  1899. return nil
  1900. }
  1901. return &ast.PartitionRangeDatum{
  1902. Kind: ast.PartitionRangeDatumKind(n.Kind),
  1903. Value: convertNode(n.Value),
  1904. Location: int(n.Location),
  1905. }
  1906. }
  1907. func convertPartitionSpec(n *pg.PartitionSpec) *ast.PartitionSpec {
  1908. if n == nil {
  1909. return nil
  1910. }
  1911. return &ast.PartitionSpec{
  1912. Strategy: makeString(n.Strategy),
  1913. PartParams: convertSlice(n.PartParams),
  1914. Location: int(n.Location),
  1915. }
  1916. }
  1917. func convertPrepareStmt(n *pg.PrepareStmt) *ast.PrepareStmt {
  1918. if n == nil {
  1919. return nil
  1920. }
  1921. return &ast.PrepareStmt{
  1922. Name: makeString(n.Name),
  1923. Argtypes: convertSlice(n.Argtypes),
  1924. Query: convertNode(n.Query),
  1925. }
  1926. }
  1927. func convertQuery(n *pg.Query) *ast.Query {
  1928. if n == nil {
  1929. return nil
  1930. }
  1931. return &ast.Query{
  1932. CommandType: ast.CmdType(n.CommandType),
  1933. QuerySource: ast.QuerySource(n.QuerySource),
  1934. CanSetTag: n.CanSetTag,
  1935. UtilityStmt: convertNode(n.UtilityStmt),
  1936. ResultRelation: int(n.ResultRelation),
  1937. HasAggs: n.HasAggs,
  1938. HasWindowFuncs: n.HasWindowFuncs,
  1939. HasTargetSrfs: n.HasTargetSrfs,
  1940. HasSubLinks: n.HasSubLinks,
  1941. HasDistinctOn: n.HasDistinctOn,
  1942. HasRecursive: n.HasRecursive,
  1943. HasModifyingCte: n.HasModifyingCte,
  1944. HasForUpdate: n.HasForUpdate,
  1945. HasRowSecurity: n.HasRowSecurity,
  1946. CteList: convertSlice(n.CteList),
  1947. Rtable: convertSlice(n.Rtable),
  1948. Jointree: convertFromExpr(n.Jointree),
  1949. TargetList: convertSlice(n.TargetList),
  1950. Override: ast.OverridingKind(n.Override),
  1951. OnConflict: convertOnConflictExpr(n.OnConflict),
  1952. ReturningList: convertSlice(n.ReturningList),
  1953. GroupClause: convertSlice(n.GroupClause),
  1954. GroupingSets: convertSlice(n.GroupingSets),
  1955. HavingQual: convertNode(n.HavingQual),
  1956. WindowClause: convertSlice(n.WindowClause),
  1957. DistinctClause: convertSlice(n.DistinctClause),
  1958. SortClause: convertSlice(n.SortClause),
  1959. LimitOffset: convertNode(n.LimitOffset),
  1960. LimitCount: convertNode(n.LimitCount),
  1961. RowMarks: convertSlice(n.RowMarks),
  1962. SetOperations: convertNode(n.SetOperations),
  1963. ConstraintDeps: convertSlice(n.ConstraintDeps),
  1964. WithCheckOptions: convertSlice(n.WithCheckOptions),
  1965. StmtLocation: int(n.StmtLocation),
  1966. StmtLen: int(n.StmtLen),
  1967. }
  1968. }
  1969. func convertRangeFunction(n *pg.RangeFunction) *ast.RangeFunction {
  1970. if n == nil {
  1971. return nil
  1972. }
  1973. return &ast.RangeFunction{
  1974. Lateral: n.Lateral,
  1975. Ordinality: n.Ordinality,
  1976. IsRowsfrom: n.IsRowsfrom,
  1977. Functions: convertSlice(n.Functions),
  1978. Alias: convertAlias(n.Alias),
  1979. Coldeflist: convertSlice(n.Coldeflist),
  1980. }
  1981. }
  1982. func convertRangeSubselect(n *pg.RangeSubselect) *ast.RangeSubselect {
  1983. if n == nil {
  1984. return nil
  1985. }
  1986. return &ast.RangeSubselect{
  1987. Lateral: n.Lateral,
  1988. Subquery: convertNode(n.Subquery),
  1989. Alias: convertAlias(n.Alias),
  1990. }
  1991. }
  1992. func convertRangeTableFunc(n *pg.RangeTableFunc) *ast.RangeTableFunc {
  1993. if n == nil {
  1994. return nil
  1995. }
  1996. return &ast.RangeTableFunc{
  1997. Lateral: n.Lateral,
  1998. Docexpr: convertNode(n.Docexpr),
  1999. Rowexpr: convertNode(n.Rowexpr),
  2000. Namespaces: convertSlice(n.Namespaces),
  2001. Columns: convertSlice(n.Columns),
  2002. Alias: convertAlias(n.Alias),
  2003. Location: int(n.Location),
  2004. }
  2005. }
  2006. func convertRangeTableFuncCol(n *pg.RangeTableFuncCol) *ast.RangeTableFuncCol {
  2007. if n == nil {
  2008. return nil
  2009. }
  2010. return &ast.RangeTableFuncCol{
  2011. Colname: makeString(n.Colname),
  2012. TypeName: convertTypeName(n.TypeName),
  2013. ForOrdinality: n.ForOrdinality,
  2014. IsNotNull: n.IsNotNull,
  2015. Colexpr: convertNode(n.Colexpr),
  2016. Coldefexpr: convertNode(n.Coldefexpr),
  2017. Location: int(n.Location),
  2018. }
  2019. }
  2020. func convertRangeTableSample(n *pg.RangeTableSample) *ast.RangeTableSample {
  2021. if n == nil {
  2022. return nil
  2023. }
  2024. return &ast.RangeTableSample{
  2025. Relation: convertNode(n.Relation),
  2026. Method: convertSlice(n.Method),
  2027. Args: convertSlice(n.Args),
  2028. Repeatable: convertNode(n.Repeatable),
  2029. Location: int(n.Location),
  2030. }
  2031. }
  2032. func convertRangeTblEntry(n *pg.RangeTblEntry) *ast.RangeTblEntry {
  2033. if n == nil {
  2034. return nil
  2035. }
  2036. return &ast.RangeTblEntry{
  2037. Rtekind: ast.RTEKind(n.Rtekind),
  2038. Relid: ast.Oid(n.Relid),
  2039. Relkind: makeByte(n.Relkind),
  2040. Tablesample: convertTableSampleClause(n.Tablesample),
  2041. Subquery: convertQuery(n.Subquery),
  2042. SecurityBarrier: n.SecurityBarrier,
  2043. Jointype: ast.JoinType(n.Jointype),
  2044. Joinaliasvars: convertSlice(n.Joinaliasvars),
  2045. Functions: convertSlice(n.Functions),
  2046. Funcordinality: n.Funcordinality,
  2047. Tablefunc: convertTableFunc(n.Tablefunc),
  2048. ValuesLists: convertSlice(n.ValuesLists),
  2049. Ctename: makeString(n.Ctename),
  2050. Ctelevelsup: ast.Index(n.Ctelevelsup),
  2051. SelfReference: n.SelfReference,
  2052. Coltypes: convertSlice(n.Coltypes),
  2053. Coltypmods: convertSlice(n.Coltypmods),
  2054. Colcollations: convertSlice(n.Colcollations),
  2055. Enrname: makeString(n.Enrname),
  2056. Enrtuples: n.Enrtuples,
  2057. Alias: convertAlias(n.Alias),
  2058. Eref: convertAlias(n.Eref),
  2059. Lateral: n.Lateral,
  2060. Inh: n.Inh,
  2061. InFromCl: n.InFromCl,
  2062. RequiredPerms: ast.AclMode(n.RequiredPerms),
  2063. CheckAsUser: ast.Oid(n.CheckAsUser),
  2064. SelectedCols: makeUint32Slice(n.SelectedCols),
  2065. InsertedCols: makeUint32Slice(n.InsertedCols),
  2066. UpdatedCols: makeUint32Slice(n.UpdatedCols),
  2067. SecurityQuals: convertSlice(n.SecurityQuals),
  2068. }
  2069. }
  2070. func convertRangeTblFunction(n *pg.RangeTblFunction) *ast.RangeTblFunction {
  2071. if n == nil {
  2072. return nil
  2073. }
  2074. return &ast.RangeTblFunction{
  2075. Funcexpr: convertNode(n.Funcexpr),
  2076. Funccolcount: int(n.Funccolcount),
  2077. Funccolnames: convertSlice(n.Funccolnames),
  2078. Funccoltypes: convertSlice(n.Funccoltypes),
  2079. Funccoltypmods: convertSlice(n.Funccoltypmods),
  2080. Funccolcollations: convertSlice(n.Funccolcollations),
  2081. Funcparams: makeUint32Slice(n.Funcparams),
  2082. }
  2083. }
  2084. func convertRangeTblRef(n *pg.RangeTblRef) *ast.RangeTblRef {
  2085. if n == nil {
  2086. return nil
  2087. }
  2088. return &ast.RangeTblRef{
  2089. Rtindex: int(n.Rtindex),
  2090. }
  2091. }
  2092. func convertRangeVar(n *pg.RangeVar) *ast.RangeVar {
  2093. if n == nil {
  2094. return nil
  2095. }
  2096. return &ast.RangeVar{
  2097. Catalogname: makeString(n.Catalogname),
  2098. Schemaname: makeString(n.Schemaname),
  2099. Relname: makeString(n.Relname),
  2100. Inh: n.Inh,
  2101. Relpersistence: makeByte(n.Relpersistence),
  2102. Alias: convertAlias(n.Alias),
  2103. Location: int(n.Location),
  2104. }
  2105. }
  2106. func convertRawStmt(n *pg.RawStmt) *ast.RawStmt {
  2107. if n == nil {
  2108. return nil
  2109. }
  2110. return &ast.RawStmt{
  2111. Stmt: convertNode(n.Stmt),
  2112. StmtLocation: int(n.StmtLocation),
  2113. StmtLen: int(n.StmtLen),
  2114. }
  2115. }
  2116. func convertReassignOwnedStmt(n *pg.ReassignOwnedStmt) *ast.ReassignOwnedStmt {
  2117. if n == nil {
  2118. return nil
  2119. }
  2120. return &ast.ReassignOwnedStmt{
  2121. Roles: convertSlice(n.Roles),
  2122. Newrole: convertRoleSpec(n.Newrole),
  2123. }
  2124. }
  2125. func convertRefreshMatViewStmt(n *pg.RefreshMatViewStmt) *ast.RefreshMatViewStmt {
  2126. if n == nil {
  2127. return nil
  2128. }
  2129. return &ast.RefreshMatViewStmt{
  2130. Concurrent: n.Concurrent,
  2131. SkipData: n.SkipData,
  2132. Relation: convertRangeVar(n.Relation),
  2133. }
  2134. }
  2135. func convertReindexStmt(n *pg.ReindexStmt) *ast.ReindexStmt {
  2136. if n == nil {
  2137. return nil
  2138. }
  2139. return &ast.ReindexStmt{
  2140. Kind: ast.ReindexObjectType(n.Kind),
  2141. Relation: convertRangeVar(n.Relation),
  2142. Name: makeString(n.Name),
  2143. Options: int(n.Options),
  2144. }
  2145. }
  2146. func convertRelabelType(n *pg.RelabelType) *ast.RelabelType {
  2147. if n == nil {
  2148. return nil
  2149. }
  2150. return &ast.RelabelType{
  2151. Xpr: convertNode(n.Xpr),
  2152. Arg: convertNode(n.Arg),
  2153. Resulttype: ast.Oid(n.Resulttype),
  2154. Resulttypmod: n.Resulttypmod,
  2155. Resultcollid: ast.Oid(n.Resultcollid),
  2156. Relabelformat: ast.CoercionForm(n.Relabelformat),
  2157. Location: int(n.Location),
  2158. }
  2159. }
  2160. func convertRenameStmt(n *pg.RenameStmt) *ast.RenameStmt {
  2161. if n == nil {
  2162. return nil
  2163. }
  2164. return &ast.RenameStmt{
  2165. RenameType: ast.ObjectType(n.RenameType),
  2166. RelationType: ast.ObjectType(n.RelationType),
  2167. Relation: convertRangeVar(n.Relation),
  2168. Object: convertNode(n.Object),
  2169. Subname: makeString(n.Subname),
  2170. Newname: makeString(n.Newname),
  2171. Behavior: ast.DropBehavior(n.Behavior),
  2172. MissingOk: n.MissingOk,
  2173. }
  2174. }
  2175. func convertReplicaIdentityStmt(n *pg.ReplicaIdentityStmt) *ast.ReplicaIdentityStmt {
  2176. if n == nil {
  2177. return nil
  2178. }
  2179. return &ast.ReplicaIdentityStmt{
  2180. IdentityType: makeByte(n.IdentityType),
  2181. Name: makeString(n.Name),
  2182. }
  2183. }
  2184. func convertResTarget(n *pg.ResTarget) *ast.ResTarget {
  2185. if n == nil {
  2186. return nil
  2187. }
  2188. return &ast.ResTarget{
  2189. Name: makeString(n.Name),
  2190. Indirection: convertSlice(n.Indirection),
  2191. Val: convertNode(n.Val),
  2192. Location: int(n.Location),
  2193. }
  2194. }
  2195. func convertRoleSpec(n *pg.RoleSpec) *ast.RoleSpec {
  2196. if n == nil {
  2197. return nil
  2198. }
  2199. return &ast.RoleSpec{
  2200. Roletype: ast.RoleSpecType(n.Roletype),
  2201. Rolename: makeString(n.Rolename),
  2202. Location: int(n.Location),
  2203. }
  2204. }
  2205. func convertRowCompareExpr(n *pg.RowCompareExpr) *ast.RowCompareExpr {
  2206. if n == nil {
  2207. return nil
  2208. }
  2209. return &ast.RowCompareExpr{
  2210. Xpr: convertNode(n.Xpr),
  2211. Rctype: ast.RowCompareType(n.Rctype),
  2212. Opnos: convertSlice(n.Opnos),
  2213. Opfamilies: convertSlice(n.Opfamilies),
  2214. Inputcollids: convertSlice(n.Inputcollids),
  2215. Largs: convertSlice(n.Largs),
  2216. Rargs: convertSlice(n.Rargs),
  2217. }
  2218. }
  2219. func convertRowExpr(n *pg.RowExpr) *ast.RowExpr {
  2220. if n == nil {
  2221. return nil
  2222. }
  2223. return &ast.RowExpr{
  2224. Xpr: convertNode(n.Xpr),
  2225. Args: convertSlice(n.Args),
  2226. RowTypeid: ast.Oid(n.RowTypeid),
  2227. RowFormat: ast.CoercionForm(n.RowFormat),
  2228. Colnames: convertSlice(n.Colnames),
  2229. Location: int(n.Location),
  2230. }
  2231. }
  2232. func convertRowMarkClause(n *pg.RowMarkClause) *ast.RowMarkClause {
  2233. if n == nil {
  2234. return nil
  2235. }
  2236. return &ast.RowMarkClause{
  2237. Rti: ast.Index(n.Rti),
  2238. Strength: ast.LockClauseStrength(n.Strength),
  2239. WaitPolicy: ast.LockWaitPolicy(n.WaitPolicy),
  2240. PushedDown: n.PushedDown,
  2241. }
  2242. }
  2243. func convertRuleStmt(n *pg.RuleStmt) *ast.RuleStmt {
  2244. if n == nil {
  2245. return nil
  2246. }
  2247. return &ast.RuleStmt{
  2248. Relation: convertRangeVar(n.Relation),
  2249. Rulename: makeString(n.Rulename),
  2250. WhereClause: convertNode(n.WhereClause),
  2251. Event: ast.CmdType(n.Event),
  2252. Instead: n.Instead,
  2253. Actions: convertSlice(n.Actions),
  2254. Replace: n.Replace,
  2255. }
  2256. }
  2257. func convertSQLValueFunction(n *pg.SQLValueFunction) *ast.SQLValueFunction {
  2258. if n == nil {
  2259. return nil
  2260. }
  2261. return &ast.SQLValueFunction{
  2262. Xpr: convertNode(n.Xpr),
  2263. Op: ast.SQLValueFunctionOp(n.Op),
  2264. Type: ast.Oid(n.Type),
  2265. Typmod: n.Typmod,
  2266. Location: int(n.Location),
  2267. }
  2268. }
  2269. func convertScalarArrayOpExpr(n *pg.ScalarArrayOpExpr) *ast.ScalarArrayOpExpr {
  2270. if n == nil {
  2271. return nil
  2272. }
  2273. return &ast.ScalarArrayOpExpr{
  2274. Xpr: convertNode(n.Xpr),
  2275. Opno: ast.Oid(n.Opno),
  2276. Opfuncid: ast.Oid(n.Opfuncid),
  2277. UseOr: n.UseOr,
  2278. Inputcollid: ast.Oid(n.Inputcollid),
  2279. Args: convertSlice(n.Args),
  2280. Location: int(n.Location),
  2281. }
  2282. }
  2283. func convertSecLabelStmt(n *pg.SecLabelStmt) *ast.SecLabelStmt {
  2284. if n == nil {
  2285. return nil
  2286. }
  2287. return &ast.SecLabelStmt{
  2288. Objtype: ast.ObjectType(n.Objtype),
  2289. Object: convertNode(n.Object),
  2290. Provider: makeString(n.Provider),
  2291. Label: makeString(n.Label),
  2292. }
  2293. }
  2294. func convertSelectStmt(n *pg.SelectStmt) *ast.SelectStmt {
  2295. if n == nil {
  2296. return nil
  2297. }
  2298. op, err := convertSetOperation(n.Op)
  2299. if err != nil {
  2300. panic(err)
  2301. }
  2302. return &ast.SelectStmt{
  2303. DistinctClause: convertSlice(n.DistinctClause),
  2304. IntoClause: convertIntoClause(n.IntoClause),
  2305. TargetList: convertSlice(n.TargetList),
  2306. FromClause: convertSlice(n.FromClause),
  2307. WhereClause: convertNode(n.WhereClause),
  2308. GroupClause: convertSlice(n.GroupClause),
  2309. HavingClause: convertNode(n.HavingClause),
  2310. WindowClause: convertSlice(n.WindowClause),
  2311. ValuesLists: convertSlice(n.ValuesLists),
  2312. SortClause: convertSlice(n.SortClause),
  2313. LimitOffset: convertNode(n.LimitOffset),
  2314. LimitCount: convertNode(n.LimitCount),
  2315. LockingClause: convertSlice(n.LockingClause),
  2316. WithClause: convertWithClause(n.WithClause),
  2317. Op: op,
  2318. All: n.All,
  2319. Larg: convertSelectStmt(n.Larg),
  2320. Rarg: convertSelectStmt(n.Rarg),
  2321. }
  2322. }
  2323. func convertSetOperationStmt(n *pg.SetOperationStmt) *ast.SetOperationStmt {
  2324. if n == nil {
  2325. return nil
  2326. }
  2327. op, err := convertSetOperation(n.Op)
  2328. if err != nil {
  2329. panic(err)
  2330. }
  2331. return &ast.SetOperationStmt{
  2332. Op: op,
  2333. All: n.All,
  2334. Larg: convertNode(n.Larg),
  2335. Rarg: convertNode(n.Rarg),
  2336. ColTypes: convertSlice(n.ColTypes),
  2337. ColTypmods: convertSlice(n.ColTypmods),
  2338. ColCollations: convertSlice(n.ColCollations),
  2339. GroupClauses: convertSlice(n.GroupClauses),
  2340. }
  2341. }
  2342. func convertSetToDefault(n *pg.SetToDefault) *ast.SetToDefault {
  2343. if n == nil {
  2344. return nil
  2345. }
  2346. return &ast.SetToDefault{
  2347. Xpr: convertNode(n.Xpr),
  2348. TypeId: ast.Oid(n.TypeId),
  2349. TypeMod: n.TypeMod,
  2350. Collation: ast.Oid(n.Collation),
  2351. Location: int(n.Location),
  2352. }
  2353. }
  2354. func convertSortBy(n *pg.SortBy) *ast.SortBy {
  2355. if n == nil {
  2356. return nil
  2357. }
  2358. return &ast.SortBy{
  2359. Node: convertNode(n.Node),
  2360. SortbyDir: ast.SortByDir(n.SortbyDir),
  2361. SortbyNulls: ast.SortByNulls(n.SortbyNulls),
  2362. UseOp: convertSlice(n.UseOp),
  2363. Location: int(n.Location),
  2364. }
  2365. }
  2366. func convertSortGroupClause(n *pg.SortGroupClause) *ast.SortGroupClause {
  2367. if n == nil {
  2368. return nil
  2369. }
  2370. return &ast.SortGroupClause{
  2371. TleSortGroupRef: ast.Index(n.TleSortGroupRef),
  2372. Eqop: ast.Oid(n.Eqop),
  2373. Sortop: ast.Oid(n.Sortop),
  2374. NullsFirst: n.NullsFirst,
  2375. Hashable: n.Hashable,
  2376. }
  2377. }
  2378. func convertString(n *pg.String) *ast.String {
  2379. if n == nil {
  2380. return nil
  2381. }
  2382. return &ast.String{
  2383. Str: n.Str,
  2384. }
  2385. }
  2386. func convertSubLink(n *pg.SubLink) *ast.SubLink {
  2387. if n == nil {
  2388. return nil
  2389. }
  2390. slt, err := convertSubLinkType(n.SubLinkType)
  2391. if err != nil {
  2392. panic(err)
  2393. }
  2394. return &ast.SubLink{
  2395. Xpr: convertNode(n.Xpr),
  2396. SubLinkType: slt,
  2397. SubLinkId: int(n.SubLinkId),
  2398. Testexpr: convertNode(n.Testexpr),
  2399. OperName: convertSlice(n.OperName),
  2400. Subselect: convertNode(n.Subselect),
  2401. Location: int(n.Location),
  2402. }
  2403. }
  2404. func convertSubPlan(n *pg.SubPlan) *ast.SubPlan {
  2405. if n == nil {
  2406. return nil
  2407. }
  2408. slt, err := convertSubLinkType(n.SubLinkType)
  2409. if err != nil {
  2410. panic(err)
  2411. }
  2412. return &ast.SubPlan{
  2413. Xpr: convertNode(n.Xpr),
  2414. SubLinkType: slt,
  2415. Testexpr: convertNode(n.Testexpr),
  2416. ParamIds: convertSlice(n.ParamIds),
  2417. PlanId: int(n.PlanId),
  2418. PlanName: makeString(n.PlanName),
  2419. FirstColType: ast.Oid(n.FirstColType),
  2420. FirstColTypmod: n.FirstColTypmod,
  2421. FirstColCollation: ast.Oid(n.FirstColCollation),
  2422. UseHashTable: n.UseHashTable,
  2423. UnknownEqFalse: n.UnknownEqFalse,
  2424. ParallelSafe: n.ParallelSafe,
  2425. SetParam: convertSlice(n.SetParam),
  2426. ParParam: convertSlice(n.ParParam),
  2427. Args: convertSlice(n.Args),
  2428. StartupCost: ast.Cost(n.StartupCost),
  2429. PerCallCost: ast.Cost(n.PerCallCost),
  2430. }
  2431. }
  2432. func convertTableFunc(n *pg.TableFunc) *ast.TableFunc {
  2433. if n == nil {
  2434. return nil
  2435. }
  2436. return &ast.TableFunc{
  2437. NsUris: convertSlice(n.NsUris),
  2438. NsNames: convertSlice(n.NsNames),
  2439. Docexpr: convertNode(n.Docexpr),
  2440. Rowexpr: convertNode(n.Rowexpr),
  2441. Colnames: convertSlice(n.Colnames),
  2442. Coltypes: convertSlice(n.Coltypes),
  2443. Coltypmods: convertSlice(n.Coltypmods),
  2444. Colcollations: convertSlice(n.Colcollations),
  2445. Colexprs: convertSlice(n.Colexprs),
  2446. Coldefexprs: convertSlice(n.Coldefexprs),
  2447. Notnulls: makeUint32Slice(n.Notnulls),
  2448. Ordinalitycol: int(n.Ordinalitycol),
  2449. Location: int(n.Location),
  2450. }
  2451. }
  2452. func convertTableLikeClause(n *pg.TableLikeClause) *ast.TableLikeClause {
  2453. if n == nil {
  2454. return nil
  2455. }
  2456. return &ast.TableLikeClause{
  2457. Relation: convertRangeVar(n.Relation),
  2458. Options: n.Options,
  2459. }
  2460. }
  2461. func convertTableSampleClause(n *pg.TableSampleClause) *ast.TableSampleClause {
  2462. if n == nil {
  2463. return nil
  2464. }
  2465. return &ast.TableSampleClause{
  2466. Tsmhandler: ast.Oid(n.Tsmhandler),
  2467. Args: convertSlice(n.Args),
  2468. Repeatable: convertNode(n.Repeatable),
  2469. }
  2470. }
  2471. func convertTargetEntry(n *pg.TargetEntry) *ast.TargetEntry {
  2472. if n == nil {
  2473. return nil
  2474. }
  2475. return &ast.TargetEntry{
  2476. Xpr: convertNode(n.Xpr),
  2477. Expr: convertNode(n.Expr),
  2478. Resno: ast.AttrNumber(n.Resno),
  2479. Resname: makeString(n.Resname),
  2480. Ressortgroupref: ast.Index(n.Ressortgroupref),
  2481. Resorigtbl: ast.Oid(n.Resorigtbl),
  2482. Resorigcol: ast.AttrNumber(n.Resorigcol),
  2483. Resjunk: n.Resjunk,
  2484. }
  2485. }
  2486. func convertTransactionStmt(n *pg.TransactionStmt) *ast.TransactionStmt {
  2487. if n == nil {
  2488. return nil
  2489. }
  2490. return &ast.TransactionStmt{
  2491. Kind: ast.TransactionStmtKind(n.Kind),
  2492. Options: convertSlice(n.Options),
  2493. Gid: makeString(n.Gid),
  2494. }
  2495. }
  2496. func convertTriggerTransition(n *pg.TriggerTransition) *ast.TriggerTransition {
  2497. if n == nil {
  2498. return nil
  2499. }
  2500. return &ast.TriggerTransition{
  2501. Name: makeString(n.Name),
  2502. IsNew: n.IsNew,
  2503. IsTable: n.IsTable,
  2504. }
  2505. }
  2506. func convertTruncateStmt(n *pg.TruncateStmt) *ast.TruncateStmt {
  2507. if n == nil {
  2508. return nil
  2509. }
  2510. return &ast.TruncateStmt{
  2511. Relations: convertSlice(n.Relations),
  2512. RestartSeqs: n.RestartSeqs,
  2513. Behavior: ast.DropBehavior(n.Behavior),
  2514. }
  2515. }
  2516. func convertTypeCast(n *pg.TypeCast) *ast.TypeCast {
  2517. if n == nil {
  2518. return nil
  2519. }
  2520. return &ast.TypeCast{
  2521. Arg: convertNode(n.Arg),
  2522. TypeName: convertTypeName(n.TypeName),
  2523. Location: int(n.Location),
  2524. }
  2525. }
  2526. func convertTypeName(n *pg.TypeName) *ast.TypeName {
  2527. if n == nil {
  2528. return nil
  2529. }
  2530. return &ast.TypeName{
  2531. Names: convertSlice(n.Names),
  2532. TypeOid: ast.Oid(n.TypeOid),
  2533. Setof: n.Setof,
  2534. PctType: n.PctType,
  2535. Typmods: convertSlice(n.Typmods),
  2536. Typemod: n.Typemod,
  2537. ArrayBounds: convertSlice(n.ArrayBounds),
  2538. Location: int(n.Location),
  2539. }
  2540. }
  2541. func convertUnlistenStmt(n *pg.UnlistenStmt) *ast.UnlistenStmt {
  2542. if n == nil {
  2543. return nil
  2544. }
  2545. return &ast.UnlistenStmt{
  2546. Conditionname: makeString(n.Conditionname),
  2547. }
  2548. }
  2549. func convertUpdateStmt(n *pg.UpdateStmt) *ast.UpdateStmt {
  2550. if n == nil {
  2551. return nil
  2552. }
  2553. return &ast.UpdateStmt{
  2554. Relations: &ast.List{
  2555. Items: []ast.Node{convertRangeVar(n.Relation)},
  2556. },
  2557. TargetList: convertSlice(n.TargetList),
  2558. WhereClause: convertNode(n.WhereClause),
  2559. FromClause: convertSlice(n.FromClause),
  2560. ReturningList: convertSlice(n.ReturningList),
  2561. WithClause: convertWithClause(n.WithClause),
  2562. }
  2563. }
  2564. func convertVacuumStmt(n *pg.VacuumStmt) *ast.VacuumStmt {
  2565. if n == nil {
  2566. return nil
  2567. }
  2568. return &ast.VacuumStmt{
  2569. // FIXME: The VacuumStmt node has changed quite a bit
  2570. // Options: n.Options
  2571. // Relation: convertRangeVar(n.Relation),
  2572. // VaCols: convertSlice(n.VaCols),
  2573. }
  2574. }
  2575. func convertVar(n *pg.Var) *ast.Var {
  2576. if n == nil {
  2577. return nil
  2578. }
  2579. return &ast.Var{
  2580. Xpr: convertNode(n.Xpr),
  2581. Varno: ast.Index(n.Varno),
  2582. Varattno: ast.AttrNumber(n.Varattno),
  2583. Vartype: ast.Oid(n.Vartype),
  2584. Vartypmod: n.Vartypmod,
  2585. Varcollid: ast.Oid(n.Varcollid),
  2586. Varlevelsup: ast.Index(n.Varlevelsup),
  2587. Location: int(n.Location),
  2588. }
  2589. }
  2590. func convertVariableSetStmt(n *pg.VariableSetStmt) *ast.VariableSetStmt {
  2591. if n == nil {
  2592. return nil
  2593. }
  2594. return &ast.VariableSetStmt{
  2595. Kind: ast.VariableSetKind(n.Kind),
  2596. Name: makeString(n.Name),
  2597. Args: convertSlice(n.Args),
  2598. IsLocal: n.IsLocal,
  2599. }
  2600. }
  2601. func convertVariableShowStmt(n *pg.VariableShowStmt) *ast.VariableShowStmt {
  2602. if n == nil {
  2603. return nil
  2604. }
  2605. return &ast.VariableShowStmt{
  2606. Name: makeString(n.Name),
  2607. }
  2608. }
  2609. func convertViewStmt(n *pg.ViewStmt) *ast.ViewStmt {
  2610. if n == nil {
  2611. return nil
  2612. }
  2613. return &ast.ViewStmt{
  2614. View: convertRangeVar(n.View),
  2615. Aliases: convertSlice(n.Aliases),
  2616. Query: convertNode(n.Query),
  2617. Replace: n.Replace,
  2618. Options: convertSlice(n.Options),
  2619. WithCheckOption: ast.ViewCheckOption(n.WithCheckOption),
  2620. }
  2621. }
  2622. func convertWindowClause(n *pg.WindowClause) *ast.WindowClause {
  2623. if n == nil {
  2624. return nil
  2625. }
  2626. return &ast.WindowClause{
  2627. Name: makeString(n.Name),
  2628. Refname: makeString(n.Refname),
  2629. PartitionClause: convertSlice(n.PartitionClause),
  2630. OrderClause: convertSlice(n.OrderClause),
  2631. FrameOptions: int(n.FrameOptions),
  2632. StartOffset: convertNode(n.StartOffset),
  2633. EndOffset: convertNode(n.EndOffset),
  2634. Winref: ast.Index(n.Winref),
  2635. CopiedOrder: n.CopiedOrder,
  2636. }
  2637. }
  2638. func convertWindowDef(n *pg.WindowDef) *ast.WindowDef {
  2639. if n == nil {
  2640. return nil
  2641. }
  2642. return &ast.WindowDef{
  2643. Name: makeString(n.Name),
  2644. Refname: makeString(n.Refname),
  2645. PartitionClause: convertSlice(n.PartitionClause),
  2646. OrderClause: convertSlice(n.OrderClause),
  2647. FrameOptions: int(n.FrameOptions),
  2648. StartOffset: convertNode(n.StartOffset),
  2649. EndOffset: convertNode(n.EndOffset),
  2650. Location: int(n.Location),
  2651. }
  2652. }
  2653. func convertWindowFunc(n *pg.WindowFunc) *ast.WindowFunc {
  2654. if n == nil {
  2655. return nil
  2656. }
  2657. return &ast.WindowFunc{
  2658. Xpr: convertNode(n.Xpr),
  2659. Winfnoid: ast.Oid(n.Winfnoid),
  2660. Wintype: ast.Oid(n.Wintype),
  2661. Wincollid: ast.Oid(n.Wincollid),
  2662. Inputcollid: ast.Oid(n.Inputcollid),
  2663. Args: convertSlice(n.Args),
  2664. Aggfilter: convertNode(n.Aggfilter),
  2665. Winref: ast.Index(n.Winref),
  2666. Winstar: n.Winstar,
  2667. Winagg: n.Winagg,
  2668. Location: int(n.Location),
  2669. }
  2670. }
  2671. func convertWithCheckOption(n *pg.WithCheckOption) *ast.WithCheckOption {
  2672. if n == nil {
  2673. return nil
  2674. }
  2675. return &ast.WithCheckOption{
  2676. Kind: ast.WCOKind(n.Kind),
  2677. Relname: makeString(n.Relname),
  2678. Polname: makeString(n.Polname),
  2679. Qual: convertNode(n.Qual),
  2680. Cascaded: n.Cascaded,
  2681. }
  2682. }
  2683. func convertWithClause(n *pg.WithClause) *ast.WithClause {
  2684. if n == nil {
  2685. return nil
  2686. }
  2687. return &ast.WithClause{
  2688. Ctes: convertSlice(n.Ctes),
  2689. Recursive: n.Recursive,
  2690. Location: int(n.Location),
  2691. }
  2692. }
  2693. func convertXmlExpr(n *pg.XmlExpr) *ast.XmlExpr {
  2694. if n == nil {
  2695. return nil
  2696. }
  2697. return &ast.XmlExpr{
  2698. Xpr: convertNode(n.Xpr),
  2699. Op: ast.XmlExprOp(n.Op),
  2700. Name: makeString(n.Name),
  2701. NamedArgs: convertSlice(n.NamedArgs),
  2702. ArgNames: convertSlice(n.ArgNames),
  2703. Args: convertSlice(n.Args),
  2704. Xmloption: ast.XmlOptionType(n.Xmloption),
  2705. Type: ast.Oid(n.Type),
  2706. Typmod: n.Typmod,
  2707. Location: int(n.Location),
  2708. }
  2709. }
  2710. func convertXmlSerialize(n *pg.XmlSerialize) *ast.XmlSerialize {
  2711. if n == nil {
  2712. return nil
  2713. }
  2714. return &ast.XmlSerialize{
  2715. Xmloption: ast.XmlOptionType(n.Xmloption),
  2716. Expr: convertNode(n.Expr),
  2717. TypeName: convertTypeName(n.TypeName),
  2718. Location: int(n.Location),
  2719. }
  2720. }
  2721. func convertNode(node *pg.Node) ast.Node {
  2722. if node == nil || node.Node == nil {
  2723. return &ast.TODO{}
  2724. }
  2725. switch n := node.Node.(type) {
  2726. case *pg.Node_AArrayExpr:
  2727. return convertA_ArrayExpr(n.AArrayExpr)
  2728. case *pg.Node_AConst:
  2729. return convertA_Const(n.AConst)
  2730. case *pg.Node_AExpr:
  2731. return convertA_Expr(n.AExpr)
  2732. case *pg.Node_AIndices:
  2733. return convertA_Indices(n.AIndices)
  2734. case *pg.Node_AIndirection:
  2735. return convertA_Indirection(n.AIndirection)
  2736. case *pg.Node_AStar:
  2737. return convertA_Star(n.AStar)
  2738. case *pg.Node_AccessPriv:
  2739. return convertAccessPriv(n.AccessPriv)
  2740. case *pg.Node_Aggref:
  2741. return convertAggref(n.Aggref)
  2742. case *pg.Node_Alias:
  2743. return convertAlias(n.Alias)
  2744. case *pg.Node_AlterCollationStmt:
  2745. return convertAlterCollationStmt(n.AlterCollationStmt)
  2746. case *pg.Node_AlterDatabaseSetStmt:
  2747. return convertAlterDatabaseSetStmt(n.AlterDatabaseSetStmt)
  2748. case *pg.Node_AlterDatabaseStmt:
  2749. return convertAlterDatabaseStmt(n.AlterDatabaseStmt)
  2750. case *pg.Node_AlterDefaultPrivilegesStmt:
  2751. return convertAlterDefaultPrivilegesStmt(n.AlterDefaultPrivilegesStmt)
  2752. case *pg.Node_AlterDomainStmt:
  2753. return convertAlterDomainStmt(n.AlterDomainStmt)
  2754. case *pg.Node_AlterEnumStmt:
  2755. return convertAlterEnumStmt(n.AlterEnumStmt)
  2756. case *pg.Node_AlterEventTrigStmt:
  2757. return convertAlterEventTrigStmt(n.AlterEventTrigStmt)
  2758. case *pg.Node_AlterExtensionContentsStmt:
  2759. return convertAlterExtensionContentsStmt(n.AlterExtensionContentsStmt)
  2760. case *pg.Node_AlterExtensionStmt:
  2761. return convertAlterExtensionStmt(n.AlterExtensionStmt)
  2762. case *pg.Node_AlterFdwStmt:
  2763. return convertAlterFdwStmt(n.AlterFdwStmt)
  2764. case *pg.Node_AlterForeignServerStmt:
  2765. return convertAlterForeignServerStmt(n.AlterForeignServerStmt)
  2766. case *pg.Node_AlterFunctionStmt:
  2767. return convertAlterFunctionStmt(n.AlterFunctionStmt)
  2768. case *pg.Node_AlterObjectDependsStmt:
  2769. return convertAlterObjectDependsStmt(n.AlterObjectDependsStmt)
  2770. case *pg.Node_AlterObjectSchemaStmt:
  2771. return convertAlterObjectSchemaStmt(n.AlterObjectSchemaStmt)
  2772. case *pg.Node_AlterOpFamilyStmt:
  2773. return convertAlterOpFamilyStmt(n.AlterOpFamilyStmt)
  2774. case *pg.Node_AlterOperatorStmt:
  2775. return convertAlterOperatorStmt(n.AlterOperatorStmt)
  2776. case *pg.Node_AlterOwnerStmt:
  2777. return convertAlterOwnerStmt(n.AlterOwnerStmt)
  2778. case *pg.Node_AlterPolicyStmt:
  2779. return convertAlterPolicyStmt(n.AlterPolicyStmt)
  2780. case *pg.Node_AlterPublicationStmt:
  2781. return convertAlterPublicationStmt(n.AlterPublicationStmt)
  2782. case *pg.Node_AlterRoleSetStmt:
  2783. return convertAlterRoleSetStmt(n.AlterRoleSetStmt)
  2784. case *pg.Node_AlterRoleStmt:
  2785. return convertAlterRoleStmt(n.AlterRoleStmt)
  2786. case *pg.Node_AlterSeqStmt:
  2787. return convertAlterSeqStmt(n.AlterSeqStmt)
  2788. case *pg.Node_AlterSubscriptionStmt:
  2789. return convertAlterSubscriptionStmt(n.AlterSubscriptionStmt)
  2790. case *pg.Node_AlterSystemStmt:
  2791. return convertAlterSystemStmt(n.AlterSystemStmt)
  2792. case *pg.Node_AlterTsconfigurationStmt:
  2793. return convertAlterTSConfigurationStmt(n.AlterTsconfigurationStmt)
  2794. case *pg.Node_AlterTsdictionaryStmt:
  2795. return convertAlterTSDictionaryStmt(n.AlterTsdictionaryStmt)
  2796. case *pg.Node_AlterTableCmd:
  2797. return convertAlterTableCmd(n.AlterTableCmd)
  2798. case *pg.Node_AlterTableMoveAllStmt:
  2799. return convertAlterTableMoveAllStmt(n.AlterTableMoveAllStmt)
  2800. case *pg.Node_AlterTableSpaceOptionsStmt:
  2801. return convertAlterTableSpaceOptionsStmt(n.AlterTableSpaceOptionsStmt)
  2802. case *pg.Node_AlterTableStmt:
  2803. return convertAlterTableStmt(n.AlterTableStmt)
  2804. case *pg.Node_AlterUserMappingStmt:
  2805. return convertAlterUserMappingStmt(n.AlterUserMappingStmt)
  2806. case *pg.Node_AlternativeSubPlan:
  2807. return convertAlternativeSubPlan(n.AlternativeSubPlan)
  2808. case *pg.Node_ArrayCoerceExpr:
  2809. return convertArrayCoerceExpr(n.ArrayCoerceExpr)
  2810. case *pg.Node_ArrayExpr:
  2811. return convertArrayExpr(n.ArrayExpr)
  2812. case *pg.Node_BitString:
  2813. return convertBitString(n.BitString)
  2814. case *pg.Node_BoolExpr:
  2815. return convertBoolExpr(n.BoolExpr)
  2816. case *pg.Node_BooleanTest:
  2817. return convertBooleanTest(n.BooleanTest)
  2818. case *pg.Node_CaseExpr:
  2819. return convertCaseExpr(n.CaseExpr)
  2820. case *pg.Node_CaseTestExpr:
  2821. return convertCaseTestExpr(n.CaseTestExpr)
  2822. case *pg.Node_CaseWhen:
  2823. return convertCaseWhen(n.CaseWhen)
  2824. case *pg.Node_CheckPointStmt:
  2825. return convertCheckPointStmt(n.CheckPointStmt)
  2826. case *pg.Node_ClosePortalStmt:
  2827. return convertClosePortalStmt(n.ClosePortalStmt)
  2828. case *pg.Node_ClusterStmt:
  2829. return convertClusterStmt(n.ClusterStmt)
  2830. case *pg.Node_CoalesceExpr:
  2831. return convertCoalesceExpr(n.CoalesceExpr)
  2832. case *pg.Node_CoerceToDomain:
  2833. return convertCoerceToDomain(n.CoerceToDomain)
  2834. case *pg.Node_CoerceToDomainValue:
  2835. return convertCoerceToDomainValue(n.CoerceToDomainValue)
  2836. case *pg.Node_CoerceViaIo:
  2837. return convertCoerceViaIO(n.CoerceViaIo)
  2838. case *pg.Node_CollateClause:
  2839. return convertCollateClause(n.CollateClause)
  2840. case *pg.Node_CollateExpr:
  2841. return convertCollateExpr(n.CollateExpr)
  2842. case *pg.Node_ColumnDef:
  2843. return convertColumnDef(n.ColumnDef)
  2844. case *pg.Node_ColumnRef:
  2845. return convertColumnRef(n.ColumnRef)
  2846. case *pg.Node_CommentStmt:
  2847. return convertCommentStmt(n.CommentStmt)
  2848. case *pg.Node_CommonTableExpr:
  2849. return convertCommonTableExpr(n.CommonTableExpr)
  2850. case *pg.Node_CompositeTypeStmt:
  2851. return convertCompositeTypeStmt(n.CompositeTypeStmt)
  2852. case *pg.Node_Constraint:
  2853. return convertConstraint(n.Constraint)
  2854. case *pg.Node_ConstraintsSetStmt:
  2855. return convertConstraintsSetStmt(n.ConstraintsSetStmt)
  2856. case *pg.Node_ConvertRowtypeExpr:
  2857. return convertConvertRowtypeExpr(n.ConvertRowtypeExpr)
  2858. case *pg.Node_CopyStmt:
  2859. return convertCopyStmt(n.CopyStmt)
  2860. case *pg.Node_CreateAmStmt:
  2861. return convertCreateAmStmt(n.CreateAmStmt)
  2862. case *pg.Node_CreateCastStmt:
  2863. return convertCreateCastStmt(n.CreateCastStmt)
  2864. case *pg.Node_CreateConversionStmt:
  2865. return convertCreateConversionStmt(n.CreateConversionStmt)
  2866. case *pg.Node_CreateDomainStmt:
  2867. return convertCreateDomainStmt(n.CreateDomainStmt)
  2868. case *pg.Node_CreateEnumStmt:
  2869. return convertCreateEnumStmt(n.CreateEnumStmt)
  2870. case *pg.Node_CreateEventTrigStmt:
  2871. return convertCreateEventTrigStmt(n.CreateEventTrigStmt)
  2872. case *pg.Node_CreateExtensionStmt:
  2873. return convertCreateExtensionStmt(n.CreateExtensionStmt)
  2874. case *pg.Node_CreateFdwStmt:
  2875. return convertCreateFdwStmt(n.CreateFdwStmt)
  2876. case *pg.Node_CreateForeignServerStmt:
  2877. return convertCreateForeignServerStmt(n.CreateForeignServerStmt)
  2878. case *pg.Node_CreateForeignTableStmt:
  2879. return convertCreateForeignTableStmt(n.CreateForeignTableStmt)
  2880. case *pg.Node_CreateFunctionStmt:
  2881. return convertCreateFunctionStmt(n.CreateFunctionStmt)
  2882. case *pg.Node_CreateOpClassItem:
  2883. return convertCreateOpClassItem(n.CreateOpClassItem)
  2884. case *pg.Node_CreateOpClassStmt:
  2885. return convertCreateOpClassStmt(n.CreateOpClassStmt)
  2886. case *pg.Node_CreateOpFamilyStmt:
  2887. return convertCreateOpFamilyStmt(n.CreateOpFamilyStmt)
  2888. case *pg.Node_CreatePlangStmt:
  2889. return convertCreatePLangStmt(n.CreatePlangStmt)
  2890. case *pg.Node_CreatePolicyStmt:
  2891. return convertCreatePolicyStmt(n.CreatePolicyStmt)
  2892. case *pg.Node_CreatePublicationStmt:
  2893. return convertCreatePublicationStmt(n.CreatePublicationStmt)
  2894. case *pg.Node_CreateRangeStmt:
  2895. return convertCreateRangeStmt(n.CreateRangeStmt)
  2896. case *pg.Node_CreateRoleStmt:
  2897. return convertCreateRoleStmt(n.CreateRoleStmt)
  2898. case *pg.Node_CreateSchemaStmt:
  2899. return convertCreateSchemaStmt(n.CreateSchemaStmt)
  2900. case *pg.Node_CreateSeqStmt:
  2901. return convertCreateSeqStmt(n.CreateSeqStmt)
  2902. case *pg.Node_CreateStatsStmt:
  2903. return convertCreateStatsStmt(n.CreateStatsStmt)
  2904. case *pg.Node_CreateStmt:
  2905. return convertCreateStmt(n.CreateStmt)
  2906. case *pg.Node_CreateSubscriptionStmt:
  2907. return convertCreateSubscriptionStmt(n.CreateSubscriptionStmt)
  2908. case *pg.Node_CreateTableAsStmt:
  2909. return convertCreateTableAsStmt(n.CreateTableAsStmt)
  2910. case *pg.Node_CreateTableSpaceStmt:
  2911. return convertCreateTableSpaceStmt(n.CreateTableSpaceStmt)
  2912. case *pg.Node_CreateTransformStmt:
  2913. return convertCreateTransformStmt(n.CreateTransformStmt)
  2914. case *pg.Node_CreateTrigStmt:
  2915. return convertCreateTrigStmt(n.CreateTrigStmt)
  2916. case *pg.Node_CreateUserMappingStmt:
  2917. return convertCreateUserMappingStmt(n.CreateUserMappingStmt)
  2918. case *pg.Node_CreatedbStmt:
  2919. return convertCreatedbStmt(n.CreatedbStmt)
  2920. case *pg.Node_CurrentOfExpr:
  2921. return convertCurrentOfExpr(n.CurrentOfExpr)
  2922. case *pg.Node_DeallocateStmt:
  2923. return convertDeallocateStmt(n.DeallocateStmt)
  2924. case *pg.Node_DeclareCursorStmt:
  2925. return convertDeclareCursorStmt(n.DeclareCursorStmt)
  2926. case *pg.Node_DefElem:
  2927. return convertDefElem(n.DefElem)
  2928. case *pg.Node_DefineStmt:
  2929. return convertDefineStmt(n.DefineStmt)
  2930. case *pg.Node_DeleteStmt:
  2931. return convertDeleteStmt(n.DeleteStmt)
  2932. case *pg.Node_DiscardStmt:
  2933. return convertDiscardStmt(n.DiscardStmt)
  2934. case *pg.Node_DoStmt:
  2935. return convertDoStmt(n.DoStmt)
  2936. case *pg.Node_DropOwnedStmt:
  2937. return convertDropOwnedStmt(n.DropOwnedStmt)
  2938. case *pg.Node_DropRoleStmt:
  2939. return convertDropRoleStmt(n.DropRoleStmt)
  2940. case *pg.Node_DropStmt:
  2941. return convertDropStmt(n.DropStmt)
  2942. case *pg.Node_DropSubscriptionStmt:
  2943. return convertDropSubscriptionStmt(n.DropSubscriptionStmt)
  2944. case *pg.Node_DropTableSpaceStmt:
  2945. return convertDropTableSpaceStmt(n.DropTableSpaceStmt)
  2946. case *pg.Node_DropUserMappingStmt:
  2947. return convertDropUserMappingStmt(n.DropUserMappingStmt)
  2948. case *pg.Node_DropdbStmt:
  2949. return convertDropdbStmt(n.DropdbStmt)
  2950. case *pg.Node_ExecuteStmt:
  2951. return convertExecuteStmt(n.ExecuteStmt)
  2952. case *pg.Node_ExplainStmt:
  2953. return convertExplainStmt(n.ExplainStmt)
  2954. case *pg.Node_Expr:
  2955. return convertExpr(n.Expr)
  2956. case *pg.Node_FetchStmt:
  2957. return convertFetchStmt(n.FetchStmt)
  2958. case *pg.Node_FieldSelect:
  2959. return convertFieldSelect(n.FieldSelect)
  2960. case *pg.Node_FieldStore:
  2961. return convertFieldStore(n.FieldStore)
  2962. case *pg.Node_Float:
  2963. return convertFloat(n.Float)
  2964. case *pg.Node_FromExpr:
  2965. return convertFromExpr(n.FromExpr)
  2966. case *pg.Node_FuncCall:
  2967. return convertFuncCall(n.FuncCall)
  2968. case *pg.Node_FuncExpr:
  2969. return convertFuncExpr(n.FuncExpr)
  2970. case *pg.Node_FunctionParameter:
  2971. return convertFunctionParameter(n.FunctionParameter)
  2972. case *pg.Node_GrantRoleStmt:
  2973. return convertGrantRoleStmt(n.GrantRoleStmt)
  2974. case *pg.Node_GrantStmt:
  2975. return convertGrantStmt(n.GrantStmt)
  2976. case *pg.Node_GroupingFunc:
  2977. return convertGroupingFunc(n.GroupingFunc)
  2978. case *pg.Node_GroupingSet:
  2979. return convertGroupingSet(n.GroupingSet)
  2980. case *pg.Node_ImportForeignSchemaStmt:
  2981. return convertImportForeignSchemaStmt(n.ImportForeignSchemaStmt)
  2982. case *pg.Node_IndexElem:
  2983. return convertIndexElem(n.IndexElem)
  2984. case *pg.Node_IndexStmt:
  2985. return convertIndexStmt(n.IndexStmt)
  2986. case *pg.Node_InferClause:
  2987. return convertInferClause(n.InferClause)
  2988. case *pg.Node_InferenceElem:
  2989. return convertInferenceElem(n.InferenceElem)
  2990. case *pg.Node_InlineCodeBlock:
  2991. return convertInlineCodeBlock(n.InlineCodeBlock)
  2992. case *pg.Node_InsertStmt:
  2993. return convertInsertStmt(n.InsertStmt)
  2994. case *pg.Node_Integer:
  2995. return convertInteger(n.Integer)
  2996. case *pg.Node_IntoClause:
  2997. return convertIntoClause(n.IntoClause)
  2998. case *pg.Node_JoinExpr:
  2999. return convertJoinExpr(n.JoinExpr)
  3000. case *pg.Node_List:
  3001. return convertList(n.List)
  3002. case *pg.Node_ListenStmt:
  3003. return convertListenStmt(n.ListenStmt)
  3004. case *pg.Node_LoadStmt:
  3005. return convertLoadStmt(n.LoadStmt)
  3006. case *pg.Node_LockStmt:
  3007. return convertLockStmt(n.LockStmt)
  3008. case *pg.Node_LockingClause:
  3009. return convertLockingClause(n.LockingClause)
  3010. case *pg.Node_MinMaxExpr:
  3011. return convertMinMaxExpr(n.MinMaxExpr)
  3012. case *pg.Node_MultiAssignRef:
  3013. return convertMultiAssignRef(n.MultiAssignRef)
  3014. case *pg.Node_NamedArgExpr:
  3015. return convertNamedArgExpr(n.NamedArgExpr)
  3016. case *pg.Node_NextValueExpr:
  3017. return convertNextValueExpr(n.NextValueExpr)
  3018. case *pg.Node_NotifyStmt:
  3019. return convertNotifyStmt(n.NotifyStmt)
  3020. case *pg.Node_Null:
  3021. return convertNull(n.Null)
  3022. case *pg.Node_NullTest:
  3023. return convertNullTest(n.NullTest)
  3024. case *pg.Node_ObjectWithArgs:
  3025. return convertObjectWithArgs(n.ObjectWithArgs)
  3026. case *pg.Node_OnConflictClause:
  3027. return convertOnConflictClause(n.OnConflictClause)
  3028. case *pg.Node_OnConflictExpr:
  3029. return convertOnConflictExpr(n.OnConflictExpr)
  3030. case *pg.Node_OpExpr:
  3031. return convertOpExpr(n.OpExpr)
  3032. case *pg.Node_Param:
  3033. return convertParam(n.Param)
  3034. case *pg.Node_ParamRef:
  3035. return convertParamRef(n.ParamRef)
  3036. case *pg.Node_PartitionBoundSpec:
  3037. return convertPartitionBoundSpec(n.PartitionBoundSpec)
  3038. case *pg.Node_PartitionCmd:
  3039. return convertPartitionCmd(n.PartitionCmd)
  3040. case *pg.Node_PartitionElem:
  3041. return convertPartitionElem(n.PartitionElem)
  3042. case *pg.Node_PartitionRangeDatum:
  3043. return convertPartitionRangeDatum(n.PartitionRangeDatum)
  3044. case *pg.Node_PartitionSpec:
  3045. return convertPartitionSpec(n.PartitionSpec)
  3046. case *pg.Node_PrepareStmt:
  3047. return convertPrepareStmt(n.PrepareStmt)
  3048. case *pg.Node_Query:
  3049. return convertQuery(n.Query)
  3050. case *pg.Node_RangeFunction:
  3051. return convertRangeFunction(n.RangeFunction)
  3052. case *pg.Node_RangeSubselect:
  3053. return convertRangeSubselect(n.RangeSubselect)
  3054. case *pg.Node_RangeTableFunc:
  3055. return convertRangeTableFunc(n.RangeTableFunc)
  3056. case *pg.Node_RangeTableFuncCol:
  3057. return convertRangeTableFuncCol(n.RangeTableFuncCol)
  3058. case *pg.Node_RangeTableSample:
  3059. return convertRangeTableSample(n.RangeTableSample)
  3060. case *pg.Node_RangeTblEntry:
  3061. return convertRangeTblEntry(n.RangeTblEntry)
  3062. case *pg.Node_RangeTblFunction:
  3063. return convertRangeTblFunction(n.RangeTblFunction)
  3064. case *pg.Node_RangeTblRef:
  3065. return convertRangeTblRef(n.RangeTblRef)
  3066. case *pg.Node_RangeVar:
  3067. return convertRangeVar(n.RangeVar)
  3068. case *pg.Node_RawStmt:
  3069. return convertRawStmt(n.RawStmt)
  3070. case *pg.Node_ReassignOwnedStmt:
  3071. return convertReassignOwnedStmt(n.ReassignOwnedStmt)
  3072. case *pg.Node_RefreshMatViewStmt:
  3073. return convertRefreshMatViewStmt(n.RefreshMatViewStmt)
  3074. case *pg.Node_ReindexStmt:
  3075. return convertReindexStmt(n.ReindexStmt)
  3076. case *pg.Node_RelabelType:
  3077. return convertRelabelType(n.RelabelType)
  3078. case *pg.Node_RenameStmt:
  3079. return convertRenameStmt(n.RenameStmt)
  3080. case *pg.Node_ReplicaIdentityStmt:
  3081. return convertReplicaIdentityStmt(n.ReplicaIdentityStmt)
  3082. case *pg.Node_ResTarget:
  3083. return convertResTarget(n.ResTarget)
  3084. case *pg.Node_RoleSpec:
  3085. return convertRoleSpec(n.RoleSpec)
  3086. case *pg.Node_RowCompareExpr:
  3087. return convertRowCompareExpr(n.RowCompareExpr)
  3088. case *pg.Node_RowExpr:
  3089. return convertRowExpr(n.RowExpr)
  3090. case *pg.Node_RowMarkClause:
  3091. return convertRowMarkClause(n.RowMarkClause)
  3092. case *pg.Node_RuleStmt:
  3093. return convertRuleStmt(n.RuleStmt)
  3094. case *pg.Node_SqlvalueFunction:
  3095. return convertSQLValueFunction(n.SqlvalueFunction)
  3096. case *pg.Node_ScalarArrayOpExpr:
  3097. return convertScalarArrayOpExpr(n.ScalarArrayOpExpr)
  3098. case *pg.Node_SecLabelStmt:
  3099. return convertSecLabelStmt(n.SecLabelStmt)
  3100. case *pg.Node_SelectStmt:
  3101. return convertSelectStmt(n.SelectStmt)
  3102. case *pg.Node_SetOperationStmt:
  3103. return convertSetOperationStmt(n.SetOperationStmt)
  3104. case *pg.Node_SetToDefault:
  3105. return convertSetToDefault(n.SetToDefault)
  3106. case *pg.Node_SortBy:
  3107. return convertSortBy(n.SortBy)
  3108. case *pg.Node_SortGroupClause:
  3109. return convertSortGroupClause(n.SortGroupClause)
  3110. case *pg.Node_String_:
  3111. return convertString(n.String_)
  3112. case *pg.Node_SubLink:
  3113. return convertSubLink(n.SubLink)
  3114. case *pg.Node_SubPlan:
  3115. return convertSubPlan(n.SubPlan)
  3116. case *pg.Node_TableFunc:
  3117. return convertTableFunc(n.TableFunc)
  3118. case *pg.Node_TableLikeClause:
  3119. return convertTableLikeClause(n.TableLikeClause)
  3120. case *pg.Node_TableSampleClause:
  3121. return convertTableSampleClause(n.TableSampleClause)
  3122. case *pg.Node_TargetEntry:
  3123. return convertTargetEntry(n.TargetEntry)
  3124. case *pg.Node_TransactionStmt:
  3125. return convertTransactionStmt(n.TransactionStmt)
  3126. case *pg.Node_TriggerTransition:
  3127. return convertTriggerTransition(n.TriggerTransition)
  3128. case *pg.Node_TruncateStmt:
  3129. return convertTruncateStmt(n.TruncateStmt)
  3130. case *pg.Node_TypeCast:
  3131. return convertTypeCast(n.TypeCast)
  3132. case *pg.Node_TypeName:
  3133. return convertTypeName(n.TypeName)
  3134. case *pg.Node_UnlistenStmt:
  3135. return convertUnlistenStmt(n.UnlistenStmt)
  3136. case *pg.Node_UpdateStmt:
  3137. return convertUpdateStmt(n.UpdateStmt)
  3138. case *pg.Node_VacuumStmt:
  3139. return convertVacuumStmt(n.VacuumStmt)
  3140. case *pg.Node_Var:
  3141. return convertVar(n.Var)
  3142. case *pg.Node_VariableSetStmt:
  3143. return convertVariableSetStmt(n.VariableSetStmt)
  3144. case *pg.Node_VariableShowStmt:
  3145. return convertVariableShowStmt(n.VariableShowStmt)
  3146. case *pg.Node_ViewStmt:
  3147. return convertViewStmt(n.ViewStmt)
  3148. case *pg.Node_WindowClause:
  3149. return convertWindowClause(n.WindowClause)
  3150. case *pg.Node_WindowDef:
  3151. return convertWindowDef(n.WindowDef)
  3152. case *pg.Node_WindowFunc:
  3153. return convertWindowFunc(n.WindowFunc)
  3154. case *pg.Node_WithCheckOption:
  3155. return convertWithCheckOption(n.WithCheckOption)
  3156. case *pg.Node_WithClause:
  3157. return convertWithClause(n.WithClause)
  3158. case *pg.Node_XmlExpr:
  3159. return convertXmlExpr(n.XmlExpr)
  3160. case *pg.Node_XmlSerialize:
  3161. return convertXmlSerialize(n.XmlSerialize)
  3162. default:
  3163. return &ast.TODO{}
  3164. }
  3165. }