join.err 153 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097
  1. Registering pre-existing tables
  2. onek
  3. int4_tbl
  4. INT4_TBL
  5. tenk1
  6. text_tbl
  7. float8_tbl
  8. INT2_TBL
  9. tenk2
  10. int2_tbl
  11. TEXT_TBL
  12. FLOAT8_TBL
  13. int8_tbl
  14. <sql-statement>
  15. --
  16. -- JOIN
  17. -- Test JOIN clauses
  18. --
  19. CREATE TABLE J1_TBL (
  20. i integer,
  21. j integer,
  22. t text
  23. );
  24. </sql-statement>
  25. <sql-statement>
  26. CREATE TABLE J2_TBL (
  27. i integer,
  28. k integer
  29. );
  30. </sql-statement>
  31. <sql-statement>
  32. INSERT INTO J1_TBL VALUES (1, 4, 'one');
  33. </sql-statement>
  34. <sql-statement>
  35. INSERT INTO J1_TBL VALUES (2, 3, 'two');
  36. </sql-statement>
  37. <sql-statement>
  38. INSERT INTO J1_TBL VALUES (3, 2, 'three');
  39. </sql-statement>
  40. <sql-statement>
  41. INSERT INTO J1_TBL VALUES (4, 1, 'four');
  42. </sql-statement>
  43. <sql-statement>
  44. INSERT INTO J1_TBL VALUES (5, 0, 'five');
  45. </sql-statement>
  46. <sql-statement>
  47. INSERT INTO J1_TBL VALUES (6, 6, 'six');
  48. </sql-statement>
  49. <sql-statement>
  50. INSERT INTO J1_TBL VALUES (7, 7, 'seven');
  51. </sql-statement>
  52. <sql-statement>
  53. INSERT INTO J1_TBL VALUES (8, 8, 'eight');
  54. </sql-statement>
  55. <sql-statement>
  56. INSERT INTO J1_TBL VALUES (0, NULL, 'zero');
  57. </sql-statement>
  58. <sql-statement>
  59. INSERT INTO J1_TBL VALUES (NULL, NULL, 'null');
  60. </sql-statement>
  61. <sql-statement>
  62. INSERT INTO J1_TBL VALUES (NULL, 0, 'zero');
  63. </sql-statement>
  64. <sql-statement>
  65. INSERT INTO J2_TBL VALUES (1, -1);
  66. </sql-statement>
  67. <sql-statement>
  68. INSERT INTO J2_TBL VALUES (2, 2);
  69. </sql-statement>
  70. <sql-statement>
  71. INSERT INTO J2_TBL VALUES (3, -3);
  72. </sql-statement>
  73. <sql-statement>
  74. INSERT INTO J2_TBL VALUES (2, 4);
  75. </sql-statement>
  76. <sql-statement>
  77. INSERT INTO J2_TBL VALUES (5, -5);
  78. </sql-statement>
  79. <sql-statement>
  80. INSERT INTO J2_TBL VALUES (5, -5);
  81. </sql-statement>
  82. <sql-statement>
  83. INSERT INTO J2_TBL VALUES (0, NULL);
  84. </sql-statement>
  85. <sql-statement>
  86. INSERT INTO J2_TBL VALUES (NULL, NULL);
  87. </sql-statement>
  88. <sql-statement>
  89. INSERT INTO J2_TBL VALUES (NULL, 0);
  90. </sql-statement>
  91. <sql-statement>
  92. -- useful in some tests below
  93. create temp table onerow();
  94. </sql-statement>
  95. <sql-statement>
  96. insert into onerow default values;
  97. </sql-statement>
  98. -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'default_values' not found in enum NYql::EYtSettingType. Valid options are: 'initial', 'infer_scheme', 'force_infer_schema', 'do_not_fail_on_invalid_schema', 'direct_read', 'view', 'mode', 'scheme', 'weak_concat', 'anonymous', 'with_qb', 'inline', 'sample', 'joinLabel', 'ignore_non_existing', 'warn_non_existing', 'xlock', 'unordered', 'nonUnique', 'userschema', 'usercolumns', 'statcolumns', 'syscolumns', 'ignoretypev3', 'memUsage', 'itemsCount', 'rowFactor', 'ordered', 'keyFilter', 'keyFilter2', 'take', 'skip', 'limit', 'sortLimitBy', 'sortBy', 'reduceBy', 'reduceFilterBy', 'forceTransform', 'weakFields', 'sharded', 'combineChunks', 'jobCount', 'joinReduce', 'firstAsPrimary', 'flow', 'keepSorted', 'keySwitch', 'uniqueBy', 'opHash', 'mapOutputType', 'reduceInputType', 'noDq', 'split', 'compression_codec', 'erasure_codec', 'expiration', 'replication_factor', 'user_attrs', 'media', 'primary_medium', 'keep_meta', 'monotonic_keys', 'mutationid'.
  99. <sql-statement>
  100. analyze onerow;
  101. </sql-statement>
  102. -stdin-:<main>: Error: Parse Sql
  103. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  104. analyze onerow;
  105. ^
  106. <sql-statement>
  107. --
  108. -- CORRELATION NAMES
  109. -- Make sure that table/column aliases are supported
  110. -- before diving into more complex join syntax.
  111. --
  112. SELECT *
  113. FROM J1_TBL AS tx;
  114. </sql-statement>
  115. <sql-statement>
  116. SELECT *
  117. FROM J1_TBL tx;
  118. </sql-statement>
  119. <sql-statement>
  120. SELECT *
  121. FROM J1_TBL AS t1 (a, b, c);
  122. </sql-statement>
  123. <sql-statement>
  124. SELECT *
  125. FROM J1_TBL t1 (a, b, c);
  126. </sql-statement>
  127. <sql-statement>
  128. SELECT *
  129. FROM J1_TBL t1 (a, b, c), J2_TBL t2 (d, e);
  130. </sql-statement>
  131. <sql-statement>
  132. SELECT t1.a, t2.e
  133. FROM J1_TBL t1 (a, b, c), J2_TBL t2 (d, e)
  134. WHERE t1.a = t2.d;
  135. </sql-statement>
  136. <sql-statement>
  137. --
  138. -- CROSS JOIN
  139. -- Qualifications are not allowed on cross joins,
  140. -- which degenerate into a standard unqualified inner join.
  141. --
  142. SELECT *
  143. FROM J1_TBL CROSS JOIN J2_TBL;
  144. </sql-statement>
  145. -stdin-:<main>: Error: Type annotation
  146. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  147. --
  148. ^
  149. -stdin-:<main>:1:1: Error: Duplicated member: i
  150. --
  151. ^
  152. <sql-statement>
  153. -- ambiguous column
  154. SELECT i, k, t
  155. FROM J1_TBL CROSS JOIN J2_TBL;
  156. </sql-statement>
  157. -stdin-:<main>: Error: Type annotation
  158. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  159. -- ambiguous column
  160. ^
  161. -stdin-:<main>:2:8: Error: Column reference is ambiguous: i
  162. SELECT i, k, t
  163. ^
  164. <sql-statement>
  165. -- resolve previous ambiguity by specifying the table name
  166. SELECT t1.i, k, t
  167. FROM J1_TBL t1 CROSS JOIN J2_TBL t2;
  168. </sql-statement>
  169. <sql-statement>
  170. SELECT ii, tt, kk
  171. FROM (J1_TBL CROSS JOIN J2_TBL)
  172. AS tx (ii, jj, tt, ii2, kk);
  173. </sql-statement>
  174. -stdin-:<main>: Error: Parse Sql
  175. -stdin-:<main>:1:1: Error: JoinExpr: unsupported alias
  176. SELECT ii, tt, kk
  177. ^
  178. <sql-statement>
  179. SELECT tx.ii, tx.jj, tx.kk
  180. FROM (J1_TBL t1 (a, b, c) CROSS JOIN J2_TBL t2 (d, e))
  181. AS tx (ii, jj, tt, ii2, kk);
  182. </sql-statement>
  183. -stdin-:<main>: Error: Parse Sql
  184. -stdin-:<main>:1:1: Error: JoinExpr: unsupported alias
  185. SELECT tx.ii, tx.jj, tx.kk
  186. ^
  187. <sql-statement>
  188. SELECT *
  189. FROM J1_TBL CROSS JOIN J2_TBL a CROSS JOIN J2_TBL b;
  190. </sql-statement>
  191. -stdin-:<main>: Error: Type annotation
  192. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  193. SELECT *
  194. ^
  195. -stdin-:<main>:1:1: Error: Duplicated member: i
  196. SELECT *
  197. ^
  198. <sql-statement>
  199. --
  200. --
  201. -- Inner joins (equi-joins)
  202. --
  203. --
  204. --
  205. -- Inner joins (equi-joins) with USING clause
  206. -- The USING syntax changes the shape of the resulting table
  207. -- by including a column in the USING clause only once in the result.
  208. --
  209. -- Inner equi-join on specified column
  210. SELECT *
  211. FROM J1_TBL INNER JOIN J2_TBL USING (i);
  212. </sql-statement>
  213. <sql-statement>
  214. -- Same as above, slightly different syntax
  215. SELECT *
  216. FROM J1_TBL JOIN J2_TBL USING (i);
  217. </sql-statement>
  218. <sql-statement>
  219. SELECT *
  220. FROM J1_TBL t1 (a, b, c) JOIN J2_TBL t2 (a, d) USING (a)
  221. ORDER BY a, d;
  222. </sql-statement>
  223. <sql-statement>
  224. SELECT *
  225. FROM J1_TBL t1 (a, b, c) JOIN J2_TBL t2 (a, b) USING (b)
  226. ORDER BY b, t1.a;
  227. </sql-statement>
  228. -stdin-:<main>: Error: Type annotation
  229. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  230. SELECT *
  231. ^
  232. -stdin-:<main>:1:1: Error: Duplicated member: a
  233. SELECT *
  234. ^
  235. <sql-statement>
  236. -- test join using aliases
  237. SELECT * FROM J1_TBL JOIN J2_TBL USING (i) WHERE J1_TBL.t = 'one'; -- ok
  238. </sql-statement>
  239. <sql-statement>
  240. SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one'; -- ok
  241. </sql-statement>
  242. -stdin-:<main>: Error: Parse Sql
  243. -stdin-:<main>:1:1: Error: join USING: unsupported AS
  244. SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one'; -- ok
  245. ^
  246. <sql-statement>
  247. SELECT * FROM (J1_TBL JOIN J2_TBL USING (i)) AS x WHERE J1_TBL.t = 'one'; -- error
  248. </sql-statement>
  249. -stdin-:<main>: Error: Parse Sql
  250. -stdin-:<main>:1:1: Error: JoinExpr: unsupported alias
  251. SELECT * FROM (J1_TBL JOIN J2_TBL USING (i)) AS x WHERE J1_TBL.t = 'one'; -- error
  252. ^
  253. <sql-statement>
  254. SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.i = 1; -- ok
  255. </sql-statement>
  256. -stdin-:<main>: Error: Parse Sql
  257. -stdin-:<main>:1:1: Error: join USING: unsupported AS
  258. SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.i = 1; -- ok
  259. ^
  260. <sql-statement>
  261. SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.t = 'one'; -- error
  262. </sql-statement>
  263. -stdin-:<main>: Error: Parse Sql
  264. -stdin-:<main>:1:1: Error: join USING: unsupported AS
  265. SELECT * FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE x.t = 'one'; -- error
  266. ^
  267. <sql-statement>
  268. SELECT * FROM (J1_TBL JOIN J2_TBL USING (i) AS x) AS xx WHERE x.i = 1; -- error (XXX could use better hint)
  269. </sql-statement>
  270. -stdin-:<main>: Error: Parse Sql
  271. -stdin-:<main>:1:1: Error: JoinExpr: unsupported alias
  272. SELECT * FROM (J1_TBL JOIN J2_TBL USING (i) AS x) AS xx WHERE x.i = 1; -- error (XXX could use better hint)
  273. ^
  274. <sql-statement>
  275. SELECT * FROM J1_TBL a1 JOIN J2_TBL a2 USING (i) AS a1; -- error
  276. </sql-statement>
  277. -stdin-:<main>: Error: Parse Sql
  278. -stdin-:<main>:1:1: Error: join USING: unsupported AS
  279. SELECT * FROM J1_TBL a1 JOIN J2_TBL a2 USING (i) AS a1; -- error
  280. ^
  281. <sql-statement>
  282. SELECT x.* FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one';
  283. </sql-statement>
  284. -stdin-:<main>: Error: Parse Sql
  285. -stdin-:<main>:1:1: Error: join USING: unsupported AS
  286. SELECT x.* FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one';
  287. ^
  288. <sql-statement>
  289. SELECT ROW(x.*) FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one';
  290. </sql-statement>
  291. -stdin-:<main>: Error: Parse Sql
  292. -stdin-:<main>:1:1: Error: join USING: unsupported AS
  293. SELECT ROW(x.*) FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one';
  294. ^
  295. <sql-statement>
  296. SELECT row_to_json(x.*) FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one';
  297. </sql-statement>
  298. -stdin-:<main>: Error: Parse Sql
  299. -stdin-:<main>:1:1: Error: join USING: unsupported AS
  300. SELECT row_to_json(x.*) FROM J1_TBL JOIN J2_TBL USING (i) AS x WHERE J1_TBL.t = 'one';
  301. ^
  302. <sql-statement>
  303. --
  304. -- NATURAL JOIN
  305. -- Inner equi-join on all columns with the same name
  306. --
  307. SELECT *
  308. FROM J1_TBL NATURAL JOIN J2_TBL;
  309. </sql-statement>
  310. -stdin-:<main>: Error: Parse Sql
  311. -stdin-:<main>:1:1: Error: JoinExpr: unsupported isNatural
  312. --
  313. ^
  314. <sql-statement>
  315. SELECT *
  316. FROM J1_TBL t1 (a, b, c) NATURAL JOIN J2_TBL t2 (a, d);
  317. </sql-statement>
  318. -stdin-:<main>: Error: Parse Sql
  319. -stdin-:<main>:1:1: Error: JoinExpr: unsupported isNatural
  320. SELECT *
  321. ^
  322. <sql-statement>
  323. SELECT *
  324. FROM J1_TBL t1 (a, b, c) NATURAL JOIN J2_TBL t2 (d, a);
  325. </sql-statement>
  326. -stdin-:<main>: Error: Parse Sql
  327. -stdin-:<main>:1:1: Error: JoinExpr: unsupported isNatural
  328. SELECT *
  329. ^
  330. <sql-statement>
  331. -- mismatch number of columns
  332. -- currently, Postgres will fill in with underlying names
  333. SELECT *
  334. FROM J1_TBL t1 (a, b) NATURAL JOIN J2_TBL t2 (a);
  335. </sql-statement>
  336. -stdin-:<main>: Error: Parse Sql
  337. -stdin-:<main>:1:1: Error: JoinExpr: unsupported isNatural
  338. -- mismatch number of columns
  339. ^
  340. <sql-statement>
  341. --
  342. -- Inner joins (equi-joins)
  343. --
  344. SELECT *
  345. FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i = J2_TBL.i);
  346. </sql-statement>
  347. -stdin-:<main>: Error: Type annotation
  348. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  349. --
  350. ^
  351. -stdin-:<main>:1:1: Error: Duplicated member: i
  352. --
  353. ^
  354. <sql-statement>
  355. SELECT *
  356. FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i = J2_TBL.k);
  357. </sql-statement>
  358. -stdin-:<main>: Error: Type annotation
  359. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  360. SELECT *
  361. ^
  362. -stdin-:<main>:1:1: Error: Duplicated member: i
  363. SELECT *
  364. ^
  365. <sql-statement>
  366. --
  367. -- Non-equi-joins
  368. --
  369. SELECT *
  370. FROM J1_TBL JOIN J2_TBL ON (J1_TBL.i <= J2_TBL.k);
  371. </sql-statement>
  372. -stdin-:<main>: Error: Type annotation
  373. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  374. --
  375. ^
  376. -stdin-:<main>:1:1: Error: Duplicated member: i
  377. --
  378. ^
  379. <sql-statement>
  380. --
  381. -- Outer joins
  382. -- Note that OUTER is a noise word
  383. --
  384. SELECT *
  385. FROM J1_TBL LEFT OUTER JOIN J2_TBL USING (i)
  386. ORDER BY i, k, t;
  387. </sql-statement>
  388. <sql-statement>
  389. SELECT *
  390. FROM J1_TBL LEFT JOIN J2_TBL USING (i)
  391. ORDER BY i, k, t;
  392. </sql-statement>
  393. <sql-statement>
  394. SELECT *
  395. FROM J1_TBL RIGHT OUTER JOIN J2_TBL USING (i);
  396. </sql-statement>
  397. <sql-statement>
  398. SELECT *
  399. FROM J1_TBL RIGHT JOIN J2_TBL USING (i);
  400. </sql-statement>
  401. <sql-statement>
  402. SELECT *
  403. FROM J1_TBL FULL OUTER JOIN J2_TBL USING (i)
  404. ORDER BY i, k, t;
  405. </sql-statement>
  406. <sql-statement>
  407. SELECT *
  408. FROM J1_TBL FULL JOIN J2_TBL USING (i)
  409. ORDER BY i, k, t;
  410. </sql-statement>
  411. <sql-statement>
  412. SELECT *
  413. FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (k = 1);
  414. </sql-statement>
  415. <sql-statement>
  416. SELECT *
  417. FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (i = 1);
  418. </sql-statement>
  419. -stdin-:<main>: Error: Type annotation
  420. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  421. SELECT *
  422. ^
  423. -stdin-:<main>:2:49: Error: Column reference is ambiguous: i
  424. FROM J1_TBL LEFT JOIN J2_TBL USING (i) WHERE (i = 1);
  425. ^
  426. <sql-statement>
  427. --
  428. -- semijoin selectivity for <>
  429. --
  430. explain (costs off)
  431. select * from int4_tbl i4, tenk1 a
  432. where exists(select * from tenk1 b
  433. where a.twothousand = b.twothousand and a.fivethous <> b.fivethous)
  434. and i4.f1 = a.tenthous;
  435. </sql-statement>
  436. -stdin-:<main>: Error: Parse Sql
  437. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  438. --
  439. ^
  440. <sql-statement>
  441. --
  442. -- More complicated constructs
  443. --
  444. --
  445. -- Multiway full join
  446. --
  447. CREATE TABLE t1 (name TEXT, n INTEGER);
  448. </sql-statement>
  449. <sql-statement>
  450. CREATE TABLE t2 (name TEXT, n INTEGER);
  451. </sql-statement>
  452. <sql-statement>
  453. CREATE TABLE t3 (name TEXT, n INTEGER);
  454. </sql-statement>
  455. <sql-statement>
  456. INSERT INTO t1 VALUES ( 'bb', 11 );
  457. </sql-statement>
  458. <sql-statement>
  459. INSERT INTO t2 VALUES ( 'bb', 12 );
  460. </sql-statement>
  461. <sql-statement>
  462. INSERT INTO t2 VALUES ( 'cc', 22 );
  463. </sql-statement>
  464. <sql-statement>
  465. INSERT INTO t2 VALUES ( 'ee', 42 );
  466. </sql-statement>
  467. <sql-statement>
  468. INSERT INTO t3 VALUES ( 'bb', 13 );
  469. </sql-statement>
  470. <sql-statement>
  471. INSERT INTO t3 VALUES ( 'cc', 23 );
  472. </sql-statement>
  473. <sql-statement>
  474. INSERT INTO t3 VALUES ( 'dd', 33 );
  475. </sql-statement>
  476. <sql-statement>
  477. SELECT * FROM t1 FULL JOIN t2 USING (name) FULL JOIN t3 USING (name);
  478. </sql-statement>
  479. -stdin-:<main>: Error: Type annotation
  480. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  481. SELECT * FROM t1 FULL JOIN t2 USING (name) FULL JOIN t3 USING (name);
  482. ^
  483. -stdin-:<main>:1:1: Error: Duplicated member: n
  484. SELECT * FROM t1 FULL JOIN t2 USING (name) FULL JOIN t3 USING (name);
  485. ^
  486. <sql-statement>
  487. --
  488. -- Test interactions of join syntax and subqueries
  489. --
  490. -- Basic cases (we expect planner to pull up the subquery here)
  491. SELECT * FROM
  492. (SELECT * FROM t2) as s2
  493. INNER JOIN
  494. (SELECT * FROM t3) s3
  495. USING (name);
  496. </sql-statement>
  497. -stdin-:<main>: Error: Type annotation
  498. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  499. --
  500. ^
  501. -stdin-:<main>:1:1: Error: Duplicated member: n
  502. --
  503. ^
  504. <sql-statement>
  505. SELECT * FROM
  506. (SELECT * FROM t2) as s2
  507. LEFT JOIN
  508. (SELECT * FROM t3) s3
  509. USING (name);
  510. </sql-statement>
  511. -stdin-:<main>: Error: Type annotation
  512. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  513. SELECT * FROM
  514. ^
  515. -stdin-:<main>:1:1: Error: Duplicated member: n
  516. SELECT * FROM
  517. ^
  518. <sql-statement>
  519. SELECT * FROM
  520. (SELECT * FROM t2) as s2
  521. FULL JOIN
  522. (SELECT * FROM t3) s3
  523. USING (name);
  524. </sql-statement>
  525. -stdin-:<main>: Error: Type annotation
  526. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  527. SELECT * FROM
  528. ^
  529. -stdin-:<main>:1:1: Error: Duplicated member: n
  530. SELECT * FROM
  531. ^
  532. <sql-statement>
  533. -- Cases with non-nullable expressions in subquery results;
  534. -- make sure these go to null as expected
  535. SELECT * FROM
  536. (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
  537. NATURAL INNER JOIN
  538. (SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3;
  539. </sql-statement>
  540. -stdin-:<main>: Error: Parse Sql
  541. -stdin-:<main>:1:1: Error: JoinExpr: unsupported isNatural
  542. -- Cases with non-nullable expressions in subquery results;
  543. ^
  544. <sql-statement>
  545. SELECT * FROM
  546. (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
  547. NATURAL LEFT JOIN
  548. (SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3;
  549. </sql-statement>
  550. -stdin-:<main>: Error: Parse Sql
  551. -stdin-:<main>:1:1: Error: JoinExpr: unsupported isNatural
  552. SELECT * FROM
  553. ^
  554. <sql-statement>
  555. SELECT * FROM
  556. (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
  557. NATURAL FULL JOIN
  558. (SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3;
  559. </sql-statement>
  560. -stdin-:<main>: Error: Parse Sql
  561. -stdin-:<main>:1:1: Error: JoinExpr: unsupported isNatural
  562. SELECT * FROM
  563. ^
  564. <sql-statement>
  565. SELECT * FROM
  566. (SELECT name, n as s1_n, 1 as s1_1 FROM t1) as s1
  567. NATURAL INNER JOIN
  568. (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
  569. NATURAL INNER JOIN
  570. (SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3;
  571. </sql-statement>
  572. -stdin-:<main>: Error: Parse Sql
  573. -stdin-:<main>:1:1: Error: JoinExpr: unsupported isNatural
  574. SELECT * FROM
  575. ^
  576. <sql-statement>
  577. SELECT * FROM
  578. (SELECT name, n as s1_n, 1 as s1_1 FROM t1) as s1
  579. NATURAL FULL JOIN
  580. (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
  581. NATURAL FULL JOIN
  582. (SELECT name, n as s3_n, 3 as s3_2 FROM t3) s3;
  583. </sql-statement>
  584. -stdin-:<main>: Error: Parse Sql
  585. -stdin-:<main>:1:1: Error: JoinExpr: unsupported isNatural
  586. SELECT * FROM
  587. ^
  588. <sql-statement>
  589. SELECT * FROM
  590. (SELECT name, n as s1_n FROM t1) as s1
  591. NATURAL FULL JOIN
  592. (SELECT * FROM
  593. (SELECT name, n as s2_n FROM t2) as s2
  594. NATURAL FULL JOIN
  595. (SELECT name, n as s3_n FROM t3) as s3
  596. ) ss2;
  597. </sql-statement>
  598. -stdin-:<main>: Error: Parse Sql
  599. -stdin-:<main>:1:1: Error: JoinExpr: unsupported isNatural
  600. SELECT * FROM
  601. ^
  602. <sql-statement>
  603. SELECT * FROM
  604. (SELECT name, n as s1_n FROM t1) as s1
  605. NATURAL FULL JOIN
  606. (SELECT * FROM
  607. (SELECT name, n as s2_n, 2 as s2_2 FROM t2) as s2
  608. NATURAL FULL JOIN
  609. (SELECT name, n as s3_n FROM t3) as s3
  610. ) ss2;
  611. </sql-statement>
  612. -stdin-:<main>: Error: Parse Sql
  613. -stdin-:<main>:1:1: Error: JoinExpr: unsupported isNatural
  614. SELECT * FROM
  615. ^
  616. <sql-statement>
  617. -- Constants as join keys can also be problematic
  618. SELECT * FROM
  619. (SELECT name, n as s1_n FROM t1) as s1
  620. FULL JOIN
  621. (SELECT name, 2 as s2_n FROM t2) as s2
  622. ON (s1_n = s2_n);
  623. </sql-statement>
  624. -stdin-:<main>: Error: Type annotation
  625. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  626. -- Constants as join keys can also be problematic
  627. ^
  628. -stdin-:<main>:1:1: Error: Duplicated member: name
  629. -- Constants as join keys can also be problematic
  630. ^
  631. <sql-statement>
  632. -- Test for propagation of nullability constraints into sub-joins
  633. create temp table x (x1 int, x2 int);
  634. </sql-statement>
  635. <sql-statement>
  636. insert into x values (1,11);
  637. </sql-statement>
  638. <sql-statement>
  639. insert into x values (2,22);
  640. </sql-statement>
  641. <sql-statement>
  642. insert into x values (3,null);
  643. </sql-statement>
  644. <sql-statement>
  645. insert into x values (4,44);
  646. </sql-statement>
  647. <sql-statement>
  648. insert into x values (5,null);
  649. </sql-statement>
  650. <sql-statement>
  651. create temp table y (y1 int, y2 int);
  652. </sql-statement>
  653. <sql-statement>
  654. insert into y values (1,111);
  655. </sql-statement>
  656. <sql-statement>
  657. insert into y values (2,222);
  658. </sql-statement>
  659. <sql-statement>
  660. insert into y values (3,333);
  661. </sql-statement>
  662. <sql-statement>
  663. insert into y values (4,null);
  664. </sql-statement>
  665. <sql-statement>
  666. select * from x;
  667. </sql-statement>
  668. <sql-statement>
  669. select * from y;
  670. </sql-statement>
  671. <sql-statement>
  672. select * from x left join y on (x1 = y1 and x2 is not null);
  673. </sql-statement>
  674. <sql-statement>
  675. select * from x left join y on (x1 = y1 and y2 is not null);
  676. </sql-statement>
  677. <sql-statement>
  678. select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
  679. on (x1 = xx1);
  680. </sql-statement>
  681. <sql-statement>
  682. select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
  683. on (x1 = xx1 and x2 is not null);
  684. </sql-statement>
  685. <sql-statement>
  686. select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
  687. on (x1 = xx1 and y2 is not null);
  688. </sql-statement>
  689. <sql-statement>
  690. select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
  691. on (x1 = xx1 and xx2 is not null);
  692. </sql-statement>
  693. <sql-statement>
  694. -- these should NOT give the same answers as above
  695. select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
  696. on (x1 = xx1) where (x2 is not null);
  697. </sql-statement>
  698. <sql-statement>
  699. select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
  700. on (x1 = xx1) where (y2 is not null);
  701. </sql-statement>
  702. <sql-statement>
  703. select * from (x left join y on (x1 = y1)) left join x xx(xx1,xx2)
  704. on (x1 = xx1) where (xx2 is not null);
  705. </sql-statement>
  706. <sql-statement>
  707. --
  708. -- regression test: check for bug with propagation of implied equality
  709. -- to outside an IN
  710. --
  711. select count(*) from tenk1 a where unique1 in
  712. (select unique1 from tenk1 b join tenk1 c using (unique1)
  713. where b.unique2 = 42);
  714. </sql-statement>
  715. <sql-statement>
  716. --
  717. -- regression test: check for failure to generate a plan with multiple
  718. -- degenerate IN clauses
  719. --
  720. select count(*) from tenk1 x where
  721. x.unique1 in (select a.f1 from int4_tbl a,float8_tbl b where a.f1=b.f1) and
  722. x.unique1 = 0 and
  723. x.unique1 in (select aa.f1 from int4_tbl aa,float8_tbl bb where aa.f1=bb.f1);
  724. </sql-statement>
  725. <sql-statement>
  726. -- try that with GEQO too
  727. begin;
  728. </sql-statement>
  729. <sql-statement>
  730. set geqo = on;
  731. </sql-statement>
  732. -stdin-:<main>: Error: Parse Sql
  733. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: geqo
  734. set geqo = on;
  735. ^
  736. <sql-statement>
  737. set geqo_threshold = 2;
  738. </sql-statement>
  739. -stdin-:<main>: Error: Parse Sql
  740. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: geqo_threshold
  741. set geqo_threshold = 2;
  742. ^
  743. <sql-statement>
  744. select count(*) from tenk1 x where
  745. x.unique1 in (select a.f1 from int4_tbl a,float8_tbl b where a.f1=b.f1) and
  746. x.unique1 = 0 and
  747. x.unique1 in (select aa.f1 from int4_tbl aa,float8_tbl bb where aa.f1=bb.f1);
  748. </sql-statement>
  749. <sql-statement>
  750. rollback;
  751. </sql-statement>
  752. <sql-statement>
  753. --
  754. -- regression test: be sure we cope with proven-dummy append rels
  755. --
  756. explain (costs off)
  757. select aa, bb, unique1, unique1
  758. from tenk1 right join b on aa = unique1
  759. where bb < bb and bb is null;
  760. </sql-statement>
  761. -stdin-:<main>: Error: Parse Sql
  762. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  763. --
  764. ^
  765. <sql-statement>
  766. select aa, bb, unique1, unique1
  767. from tenk1 right join b on aa = unique1
  768. where bb < bb and bb is null;
  769. </sql-statement>
  770. -stdin-:<main>: Fatal: Table metadata loading
  771. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.b
  772. <sql-statement>
  773. --
  774. -- regression test: check handling of empty-FROM subquery underneath outer join
  775. --
  776. explain (costs off)
  777. select * from int8_tbl i1 left join (int8_tbl i2 join
  778. (select 123 as x) ss on i2.q1 = x) on i1.q2 = i2.q2
  779. order by 1, 2;
  780. </sql-statement>
  781. -stdin-:<main>: Error: Parse Sql
  782. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  783. --
  784. ^
  785. <sql-statement>
  786. select * from int8_tbl i1 left join (int8_tbl i2 join
  787. (select 123 as x) ss on i2.q1 = x) on i1.q2 = i2.q2
  788. order by 1, 2;
  789. </sql-statement>
  790. -stdin-:<main>: Error: Type annotation
  791. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  792. select * from int8_tbl i1 left join (int8_tbl i2 join
  793. ^
  794. -stdin-:<main>:1:1: Error: Duplicated member: q1
  795. select * from int8_tbl i1 left join (int8_tbl i2 join
  796. ^
  797. <sql-statement>
  798. --
  799. -- regression test: check a case where join_clause_is_movable_into() gives
  800. -- an imprecise result, causing an assertion failure
  801. --
  802. select count(*)
  803. from
  804. (select t3.tenthous as x1, coalesce(t1.stringu1, t2.stringu1) as x2
  805. from tenk1 t1
  806. left join tenk1 t2 on t1.unique1 = t2.unique1
  807. join tenk1 t3 on t1.unique2 = t3.unique2) ss,
  808. tenk1 t4,
  809. tenk1 t5
  810. where t4.thousand = t5.unique1 and ss.x1 = t4.tenthous and ss.x2 = t5.stringu1;
  811. </sql-statement>
  812. <sql-statement>
  813. --
  814. -- regression test: check a case where we formerly missed including an EC
  815. -- enforcement clause because it was expected to be handled at scan level
  816. --
  817. explain (costs off)
  818. select a.f1, b.f1, t.thousand, t.tenthous from
  819. tenk1 t,
  820. (select sum(f1)+1 as f1 from int4_tbl i4a) a,
  821. (select sum(f1) as f1 from int4_tbl i4b) b
  822. where b.f1 = t.thousand and a.f1 = b.f1 and (a.f1+b.f1+999) = t.tenthous;
  823. </sql-statement>
  824. -stdin-:<main>: Error: Parse Sql
  825. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  826. --
  827. ^
  828. <sql-statement>
  829. select a.f1, b.f1, t.thousand, t.tenthous from
  830. tenk1 t,
  831. (select sum(f1)+1 as f1 from int4_tbl i4a) a,
  832. (select sum(f1) as f1 from int4_tbl i4b) b
  833. where b.f1 = t.thousand and a.f1 = b.f1 and (a.f1+b.f1+999) = t.tenthous;
  834. </sql-statement>
  835. -stdin-:<main>: Error: Type annotation
  836. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  837. select a.f1, b.f1, t.thousand, t.tenthous from
  838. ^
  839. -stdin-:<main>:1:1: Error: Duplicated member: f1
  840. select a.f1, b.f1, t.thousand, t.tenthous from
  841. ^
  842. <sql-statement>
  843. --
  844. -- check a case where we formerly got confused by conflicting sort orders
  845. -- in redundant merge join path keys
  846. --
  847. explain (costs off)
  848. select * from
  849. j1_tbl full join
  850. (select * from j2_tbl order by j2_tbl.i desc, j2_tbl.k asc) j2_tbl
  851. on j1_tbl.i = j2_tbl.i and j1_tbl.i = j2_tbl.k;
  852. </sql-statement>
  853. -stdin-:<main>: Error: Parse Sql
  854. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  855. --
  856. ^
  857. <sql-statement>
  858. select * from
  859. j1_tbl full join
  860. (select * from j2_tbl order by j2_tbl.i desc, j2_tbl.k asc) j2_tbl
  861. on j1_tbl.i = j2_tbl.i and j1_tbl.i = j2_tbl.k;
  862. </sql-statement>
  863. -stdin-:<main>: Fatal: Table metadata loading
  864. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.j1_tbl
  865. <sql-statement>
  866. --
  867. -- a different check for handling of redundant sort keys in merge joins
  868. --
  869. explain (costs off)
  870. select count(*) from
  871. (select * from tenk1 x order by x.thousand, x.twothousand, x.fivethous) x
  872. left join
  873. (select * from tenk1 y order by y.unique2) y
  874. on x.thousand = y.unique2 and x.twothousand = y.hundred and x.fivethous = y.unique2;
  875. </sql-statement>
  876. -stdin-:<main>: Error: Parse Sql
  877. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  878. --
  879. ^
  880. <sql-statement>
  881. select count(*) from
  882. (select * from tenk1 x order by x.thousand, x.twothousand, x.fivethous) x
  883. left join
  884. (select * from tenk1 y order by y.unique2) y
  885. on x.thousand = y.unique2 and x.twothousand = y.hundred and x.fivethous = y.unique2;
  886. </sql-statement>
  887. <sql-statement>
  888. --
  889. -- Clean up
  890. --
  891. DROP TABLE t1;
  892. </sql-statement>
  893. <sql-statement>
  894. DROP TABLE t2;
  895. </sql-statement>
  896. <sql-statement>
  897. DROP TABLE t3;
  898. </sql-statement>
  899. <sql-statement>
  900. DROP TABLE J1_TBL;
  901. </sql-statement>
  902. <sql-statement>
  903. DROP TABLE J2_TBL;
  904. </sql-statement>
  905. <sql-statement>
  906. -- Both DELETE and UPDATE allow the specification of additional tables
  907. -- to "join" against to determine which rows should be modified.
  908. CREATE TEMP TABLE t1 (a int, b int);
  909. </sql-statement>
  910. <sql-statement>
  911. CREATE TEMP TABLE t2 (a int, b int);
  912. </sql-statement>
  913. <sql-statement>
  914. CREATE TEMP TABLE t3 (x int, y int);
  915. </sql-statement>
  916. <sql-statement>
  917. INSERT INTO t1 VALUES (5, 10);
  918. </sql-statement>
  919. <sql-statement>
  920. INSERT INTO t1 VALUES (15, 20);
  921. </sql-statement>
  922. <sql-statement>
  923. INSERT INTO t1 VALUES (100, 100);
  924. </sql-statement>
  925. <sql-statement>
  926. INSERT INTO t1 VALUES (200, 1000);
  927. </sql-statement>
  928. <sql-statement>
  929. INSERT INTO t2 VALUES (200, 2000);
  930. </sql-statement>
  931. <sql-statement>
  932. INSERT INTO t3 VALUES (5, 20);
  933. </sql-statement>
  934. <sql-statement>
  935. INSERT INTO t3 VALUES (6, 7);
  936. </sql-statement>
  937. <sql-statement>
  938. INSERT INTO t3 VALUES (7, 8);
  939. </sql-statement>
  940. <sql-statement>
  941. INSERT INTO t3 VALUES (500, 100);
  942. </sql-statement>
  943. <sql-statement>
  944. DELETE FROM t3 USING t1 table1 WHERE t3.x = table1.a;
  945. </sql-statement>
  946. -stdin-:<main>: Error: Parse Sql
  947. -stdin-:<main>:1:1: Error: using is not supported
  948. DELETE FROM t3 USING t1 table1 WHERE t3.x = table1.a;
  949. ^
  950. <sql-statement>
  951. SELECT * FROM t3;
  952. </sql-statement>
  953. <sql-statement>
  954. DELETE FROM t3 USING t1 JOIN t2 USING (a) WHERE t3.x > t1.a;
  955. </sql-statement>
  956. -stdin-:<main>: Error: Parse Sql
  957. -stdin-:<main>:1:1: Error: using is not supported
  958. DELETE FROM t3 USING t1 JOIN t2 USING (a) WHERE t3.x > t1.a;
  959. ^
  960. <sql-statement>
  961. SELECT * FROM t3;
  962. </sql-statement>
  963. <sql-statement>
  964. DELETE FROM t3 USING t3 t3_other WHERE t3.x = t3_other.x AND t3.y = t3_other.y;
  965. </sql-statement>
  966. -stdin-:<main>: Error: Parse Sql
  967. -stdin-:<main>:1:1: Error: using is not supported
  968. DELETE FROM t3 USING t3 t3_other WHERE t3.x = t3_other.x AND t3.y = t3_other.y;
  969. ^
  970. <sql-statement>
  971. SELECT * FROM t3;
  972. </sql-statement>
  973. <sql-statement>
  974. -- Test join against inheritance tree
  975. create temp table t2a () inherits (t2);
  976. </sql-statement>
  977. -stdin-:<main>: Error: Parse Sql
  978. -stdin-:<main>:1:1: Error: table inheritance not supported
  979. -- Test join against inheritance tree
  980. ^
  981. <sql-statement>
  982. insert into t2a values (200, 2001);
  983. </sql-statement>
  984. -stdin-:<main>: Fatal: Table metadata loading
  985. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.t2a
  986. <sql-statement>
  987. select * from t1 left join t2 on (t1.a = t2.a);
  988. </sql-statement>
  989. -stdin-:<main>: Error: Type annotation
  990. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  991. select * from t1 left join t2 on (t1.a = t2.a);
  992. ^
  993. -stdin-:<main>:1:1: Error: Duplicated member: a
  994. select * from t1 left join t2 on (t1.a = t2.a);
  995. ^
  996. <sql-statement>
  997. -- Test matching of column name with wrong alias
  998. select t1.x from t1 join t3 on (t1.a = t3.x);
  999. </sql-statement>
  1000. -stdin-:<main>: Error: Type annotation
  1001. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  1002. -- Test matching of column name with wrong alias
  1003. ^
  1004. -stdin-:<main>:2:8: Error: No such column: x
  1005. select t1.x from t1 join t3 on (t1.a = t3.x);
  1006. ^
  1007. <sql-statement>
  1008. -- Test matching of locking clause with wrong alias
  1009. select t1.*, t2.*, unnamed_join.* from
  1010. t1 join t2 on (t1.a = t2.a), t3 as unnamed_join
  1011. for update of unnamed_join;
  1012. </sql-statement>
  1013. -stdin-:<main>: Warning: Parse Sql
  1014. -stdin-:<main>:1:1: Warning: SelectStmt: lockingClause is ignored
  1015. -- Test matching of locking clause with wrong alias
  1016. ^
  1017. -stdin-:<main>: Error: Type annotation
  1018. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  1019. -- Test matching of locking clause with wrong alias
  1020. ^
  1021. -stdin-:<main>:1:1: Error: Duplicated member: a
  1022. -- Test matching of locking clause with wrong alias
  1023. ^
  1024. <sql-statement>
  1025. select foo.*, unnamed_join.* from
  1026. t1 join t2 using (a) as foo, t3 as unnamed_join
  1027. for update of unnamed_join;
  1028. </sql-statement>
  1029. -stdin-:<main>: Error: Parse Sql
  1030. -stdin-:<main>:1:1: Error: join USING: unsupported AS
  1031. select foo.*, unnamed_join.* from
  1032. ^
  1033. <sql-statement>
  1034. select foo.*, unnamed_join.* from
  1035. t1 join t2 using (a) as foo, t3 as unnamed_join
  1036. for update of foo;
  1037. </sql-statement>
  1038. -stdin-:<main>: Error: Parse Sql
  1039. -stdin-:<main>:1:1: Error: join USING: unsupported AS
  1040. select foo.*, unnamed_join.* from
  1041. ^
  1042. <sql-statement>
  1043. select bar.*, unnamed_join.* from
  1044. (t1 join t2 using (a) as foo) as bar, t3 as unnamed_join
  1045. for update of foo;
  1046. </sql-statement>
  1047. -stdin-:<main>: Error: Parse Sql
  1048. -stdin-:<main>:1:1: Error: JoinExpr: unsupported alias
  1049. select bar.*, unnamed_join.* from
  1050. ^
  1051. <sql-statement>
  1052. select bar.*, unnamed_join.* from
  1053. (t1 join t2 using (a) as foo) as bar, t3 as unnamed_join
  1054. for update of bar;
  1055. </sql-statement>
  1056. -stdin-:<main>: Error: Parse Sql
  1057. -stdin-:<main>:1:1: Error: JoinExpr: unsupported alias
  1058. select bar.*, unnamed_join.* from
  1059. ^
  1060. <sql-statement>
  1061. --
  1062. -- regression test for 8.1 merge right join bug
  1063. --
  1064. CREATE TEMP TABLE tt1 ( tt1_id int4, joincol int4 );
  1065. </sql-statement>
  1066. <sql-statement>
  1067. INSERT INTO tt1 VALUES (1, 11);
  1068. </sql-statement>
  1069. <sql-statement>
  1070. INSERT INTO tt1 VALUES (2, NULL);
  1071. </sql-statement>
  1072. <sql-statement>
  1073. CREATE TEMP TABLE tt2 ( tt2_id int4, joincol int4 );
  1074. </sql-statement>
  1075. <sql-statement>
  1076. INSERT INTO tt2 VALUES (21, 11);
  1077. </sql-statement>
  1078. <sql-statement>
  1079. INSERT INTO tt2 VALUES (22, 11);
  1080. </sql-statement>
  1081. <sql-statement>
  1082. set enable_hashjoin to off;
  1083. </sql-statement>
  1084. -stdin-:<main>: Error: Parse Sql
  1085. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashjoin
  1086. set enable_hashjoin to off;
  1087. ^
  1088. <sql-statement>
  1089. set enable_nestloop to off;
  1090. </sql-statement>
  1091. -stdin-:<main>: Error: Parse Sql
  1092. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_nestloop
  1093. set enable_nestloop to off;
  1094. ^
  1095. <sql-statement>
  1096. -- these should give the same results
  1097. select tt1.*, tt2.* from tt1 left join tt2 on tt1.joincol = tt2.joincol;
  1098. </sql-statement>
  1099. -stdin-:<main>: Error: Type annotation
  1100. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  1101. -- these should give the same results
  1102. ^
  1103. -stdin-:<main>:1:1: Error: Duplicated member: joincol
  1104. -- these should give the same results
  1105. ^
  1106. <sql-statement>
  1107. select tt1.*, tt2.* from tt2 right join tt1 on tt1.joincol = tt2.joincol;
  1108. </sql-statement>
  1109. -stdin-:<main>: Error: Type annotation
  1110. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  1111. select tt1.*, tt2.* from tt2 right join tt1 on tt1.joincol = tt2.joincol;
  1112. ^
  1113. -stdin-:<main>:1:1: Error: Duplicated member: joincol
  1114. select tt1.*, tt2.* from tt2 right join tt1 on tt1.joincol = tt2.joincol;
  1115. ^
  1116. <sql-statement>
  1117. reset enable_hashjoin;
  1118. </sql-statement>
  1119. -stdin-:<main>: Error: Parse Sql
  1120. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  1121. reset enable_hashjoin;
  1122. ^
  1123. <sql-statement>
  1124. reset enable_nestloop;
  1125. </sql-statement>
  1126. -stdin-:<main>: Error: Parse Sql
  1127. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  1128. reset enable_nestloop;
  1129. ^
  1130. <sql-statement>
  1131. --
  1132. -- regression test for bug #13908 (hash join with skew tuples & nbatch increase)
  1133. --
  1134. set work_mem to '64kB';
  1135. </sql-statement>
  1136. -stdin-:<main>: Error: Parse Sql
  1137. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: work_mem
  1138. --
  1139. ^
  1140. <sql-statement>
  1141. set enable_mergejoin to off;
  1142. </sql-statement>
  1143. -stdin-:<main>: Error: Parse Sql
  1144. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_mergejoin
  1145. set enable_mergejoin to off;
  1146. ^
  1147. <sql-statement>
  1148. set enable_memoize to off;
  1149. </sql-statement>
  1150. -stdin-:<main>: Error: Parse Sql
  1151. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_memoize
  1152. set enable_memoize to off;
  1153. ^
  1154. <sql-statement>
  1155. explain (costs off)
  1156. select count(*) from tenk1 a, tenk1 b
  1157. where a.hundred = b.thousand and (b.fivethous % 10) < 10;
  1158. </sql-statement>
  1159. -stdin-:<main>: Error: Parse Sql
  1160. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1161. explain (costs off)
  1162. ^
  1163. <sql-statement>
  1164. select count(*) from tenk1 a, tenk1 b
  1165. where a.hundred = b.thousand and (b.fivethous % 10) < 10;
  1166. </sql-statement>
  1167. <sql-statement>
  1168. reset work_mem;
  1169. </sql-statement>
  1170. -stdin-:<main>: Error: Parse Sql
  1171. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  1172. reset work_mem;
  1173. ^
  1174. <sql-statement>
  1175. reset enable_mergejoin;
  1176. </sql-statement>
  1177. -stdin-:<main>: Error: Parse Sql
  1178. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  1179. reset enable_mergejoin;
  1180. ^
  1181. <sql-statement>
  1182. reset enable_memoize;
  1183. </sql-statement>
  1184. -stdin-:<main>: Error: Parse Sql
  1185. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  1186. reset enable_memoize;
  1187. ^
  1188. <sql-statement>
  1189. --
  1190. -- regression test for 8.2 bug with improper re-ordering of left joins
  1191. --
  1192. create temp table tt3(f1 int, f2 text);
  1193. </sql-statement>
  1194. <sql-statement>
  1195. insert into tt3 select x, repeat('xyzzy', 100) from generate_series(1,10000) x;
  1196. </sql-statement>
  1197. <sql-statement>
  1198. create index tt3i on tt3(f1);
  1199. </sql-statement>
  1200. <sql-statement>
  1201. analyze tt3;
  1202. </sql-statement>
  1203. -stdin-:<main>: Error: Parse Sql
  1204. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  1205. analyze tt3;
  1206. ^
  1207. <sql-statement>
  1208. create temp table tt4(f1 int);
  1209. </sql-statement>
  1210. <sql-statement>
  1211. insert into tt4 values (0),(1),(9999);
  1212. </sql-statement>
  1213. <sql-statement>
  1214. analyze tt4;
  1215. </sql-statement>
  1216. -stdin-:<main>: Error: Parse Sql
  1217. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  1218. analyze tt4;
  1219. ^
  1220. <sql-statement>
  1221. SELECT a.f1
  1222. FROM tt4 a
  1223. LEFT JOIN (
  1224. SELECT b.f1
  1225. FROM tt3 b LEFT JOIN tt3 c ON (b.f1 = c.f1)
  1226. WHERE c.f1 IS NULL
  1227. ) AS d ON (a.f1 = d.f1)
  1228. WHERE d.f1 IS NULL;
  1229. </sql-statement>
  1230. <sql-statement>
  1231. --
  1232. -- regression test for proper handling of outer joins within antijoins
  1233. --
  1234. create temp table tt4x(c1 int, c2 int, c3 int);
  1235. </sql-statement>
  1236. <sql-statement>
  1237. explain (costs off)
  1238. select * from tt4x t1
  1239. where not exists (
  1240. select 1 from tt4x t2
  1241. left join tt4x t3 on t2.c3 = t3.c1
  1242. left join ( select t5.c1 as c1
  1243. from tt4x t4 left join tt4x t5 on t4.c2 = t5.c1
  1244. ) a1 on t3.c2 = a1.c1
  1245. where t1.c1 = t2.c2
  1246. );
  1247. </sql-statement>
  1248. -stdin-:<main>: Error: Parse Sql
  1249. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1250. explain (costs off)
  1251. ^
  1252. <sql-statement>
  1253. --
  1254. -- regression test for problems of the sort depicted in bug #3494
  1255. --
  1256. create temp table tt5(f1 int, f2 int);
  1257. </sql-statement>
  1258. <sql-statement>
  1259. create temp table tt6(f1 int, f2 int);
  1260. </sql-statement>
  1261. <sql-statement>
  1262. insert into tt5 values(1, 10);
  1263. </sql-statement>
  1264. <sql-statement>
  1265. insert into tt5 values(1, 11);
  1266. </sql-statement>
  1267. <sql-statement>
  1268. insert into tt6 values(1, 9);
  1269. </sql-statement>
  1270. <sql-statement>
  1271. insert into tt6 values(1, 2);
  1272. </sql-statement>
  1273. <sql-statement>
  1274. insert into tt6 values(2, 9);
  1275. </sql-statement>
  1276. <sql-statement>
  1277. select * from tt5,tt6 where tt5.f1 = tt6.f1 and tt5.f1 = tt5.f2 - tt6.f2;
  1278. </sql-statement>
  1279. -stdin-:<main>: Error: Type annotation
  1280. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  1281. select * from tt5,tt6 where tt5.f1 = tt6.f1 and tt5.f1 = tt5.f2 - tt6.f2;
  1282. ^
  1283. -stdin-:<main>:1:1: Error: Duplicated member: f1
  1284. select * from tt5,tt6 where tt5.f1 = tt6.f1 and tt5.f1 = tt5.f2 - tt6.f2;
  1285. ^
  1286. <sql-statement>
  1287. --
  1288. -- regression test for problems of the sort depicted in bug #3588
  1289. --
  1290. create temp table xx (pkxx int);
  1291. </sql-statement>
  1292. <sql-statement>
  1293. create temp table yy (pkyy int, pkxx int);
  1294. </sql-statement>
  1295. <sql-statement>
  1296. insert into xx values (1);
  1297. </sql-statement>
  1298. <sql-statement>
  1299. insert into xx values (2);
  1300. </sql-statement>
  1301. <sql-statement>
  1302. insert into xx values (3);
  1303. </sql-statement>
  1304. <sql-statement>
  1305. insert into yy values (101, 1);
  1306. </sql-statement>
  1307. <sql-statement>
  1308. insert into yy values (201, 2);
  1309. </sql-statement>
  1310. <sql-statement>
  1311. insert into yy values (301, NULL);
  1312. </sql-statement>
  1313. <sql-statement>
  1314. select yy.pkyy as yy_pkyy, yy.pkxx as yy_pkxx, yya.pkyy as yya_pkyy,
  1315. xxa.pkxx as xxa_pkxx, xxb.pkxx as xxb_pkxx
  1316. from yy
  1317. left join (SELECT * FROM yy where pkyy = 101) as yya ON yy.pkyy = yya.pkyy
  1318. left join xx xxa on yya.pkxx = xxa.pkxx
  1319. left join xx xxb on coalesce (xxa.pkxx, 1) = xxb.pkxx;
  1320. </sql-statement>
  1321. <sql-statement>
  1322. --
  1323. -- regression test for improper pushing of constants across outer-join clauses
  1324. -- (as seen in early 8.2.x releases)
  1325. --
  1326. create temp table zt1 (f1 int primary key);
  1327. </sql-statement>
  1328. <sql-statement>
  1329. create temp table zt2 (f2 int primary key);
  1330. </sql-statement>
  1331. <sql-statement>
  1332. create temp table zt3 (f3 int primary key);
  1333. </sql-statement>
  1334. <sql-statement>
  1335. insert into zt1 values(53);
  1336. </sql-statement>
  1337. <sql-statement>
  1338. insert into zt2 values(53);
  1339. </sql-statement>
  1340. <sql-statement>
  1341. select * from
  1342. zt2 left join zt3 on (f2 = f3)
  1343. left join zt1 on (f3 = f1)
  1344. where f2 = 53;
  1345. </sql-statement>
  1346. <sql-statement>
  1347. create temp view zv1 as select *,'dummy'::text AS junk from zt1;
  1348. </sql-statement>
  1349. -stdin-:<main>: Error: Parse Sql
  1350. -stdin-:<main>:1:1: Error: expected at least one target column
  1351. create temp view zv1 as select *,'dummy'::text AS junk from zt1;
  1352. ^
  1353. <sql-statement>
  1354. select * from
  1355. zt2 left join zt3 on (f2 = f3)
  1356. left join zv1 on (f3 = f1)
  1357. where f2 = 53;
  1358. </sql-statement>
  1359. -stdin-:<main>: Fatal: Table metadata loading
  1360. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.zv1
  1361. <sql-statement>
  1362. --
  1363. -- regression test for improper extraction of OR indexqual conditions
  1364. -- (as seen in early 8.3.x releases)
  1365. --
  1366. select a.unique2, a.ten, b.tenthous, b.unique2, b.hundred
  1367. from tenk1 a left join tenk1 b on a.unique2 = b.tenthous
  1368. where a.unique1 = 42 and
  1369. ((b.unique2 is null and a.ten = 2) or b.hundred = 3);
  1370. </sql-statement>
  1371. -stdin-:<main>: Error: Type annotation
  1372. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  1373. --
  1374. ^
  1375. -stdin-:<main>:1:1: Error: Duplicated member: unique2
  1376. --
  1377. ^
  1378. <sql-statement>
  1379. --
  1380. -- test proper positioning of one-time quals in EXISTS (8.4devel bug)
  1381. --
  1382. prepare foo(bool) as
  1383. select count(*) from tenk1 a left join tenk1 b
  1384. on (a.unique2 = b.unique1 and exists
  1385. (select 1 from tenk1 c where c.thousand = b.unique2 and $1));
  1386. </sql-statement>
  1387. -stdin-:<main>: Error: Parse Sql
  1388. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 301
  1389. --
  1390. ^
  1391. <sql-statement>
  1392. execute foo(true);
  1393. </sql-statement>
  1394. -stdin-:<main>: Error: Parse Sql
  1395. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 302
  1396. execute foo(true);
  1397. ^
  1398. <sql-statement>
  1399. execute foo(false);
  1400. </sql-statement>
  1401. -stdin-:<main>: Error: Parse Sql
  1402. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 302
  1403. execute foo(false);
  1404. ^
  1405. <sql-statement>
  1406. --
  1407. -- test for sane behavior with noncanonical merge clauses, per bug #4926
  1408. --
  1409. begin;
  1410. </sql-statement>
  1411. <sql-statement>
  1412. set enable_mergejoin = 1;
  1413. </sql-statement>
  1414. -stdin-:<main>: Error: Parse Sql
  1415. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_mergejoin
  1416. set enable_mergejoin = 1;
  1417. ^
  1418. <sql-statement>
  1419. set enable_hashjoin = 0;
  1420. </sql-statement>
  1421. -stdin-:<main>: Error: Parse Sql
  1422. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashjoin
  1423. set enable_hashjoin = 0;
  1424. ^
  1425. <sql-statement>
  1426. set enable_nestloop = 0;
  1427. </sql-statement>
  1428. -stdin-:<main>: Error: Parse Sql
  1429. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_nestloop
  1430. set enable_nestloop = 0;
  1431. ^
  1432. <sql-statement>
  1433. create temp table a (i integer);
  1434. </sql-statement>
  1435. <sql-statement>
  1436. create temp table b (x integer, y integer);
  1437. </sql-statement>
  1438. <sql-statement>
  1439. select * from a left join b on i = x and i = y and x = i;
  1440. </sql-statement>
  1441. <sql-statement>
  1442. rollback;
  1443. </sql-statement>
  1444. <sql-statement>
  1445. --
  1446. -- test handling of merge clauses using record_ops
  1447. --
  1448. begin;
  1449. </sql-statement>
  1450. <sql-statement>
  1451. create type mycomptype as (id int, v bigint);
  1452. </sql-statement>
  1453. -stdin-:<main>: Error: Parse Sql
  1454. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 314
  1455. create type mycomptype as (id int, v bigint);
  1456. ^
  1457. <sql-statement>
  1458. create temp table tidv (idv mycomptype);
  1459. </sql-statement>
  1460. <sql-statement>
  1461. create index on tidv (idv);
  1462. </sql-statement>
  1463. <sql-statement>
  1464. explain (costs off)
  1465. select a.idv, b.idv from tidv a, tidv b where a.idv = b.idv;
  1466. </sql-statement>
  1467. -stdin-:<main>: Error: Parse Sql
  1468. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1469. explain (costs off)
  1470. ^
  1471. <sql-statement>
  1472. set enable_mergejoin = 0;
  1473. </sql-statement>
  1474. -stdin-:<main>: Error: Parse Sql
  1475. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_mergejoin
  1476. set enable_mergejoin = 0;
  1477. ^
  1478. <sql-statement>
  1479. set enable_hashjoin = 0;
  1480. </sql-statement>
  1481. -stdin-:<main>: Error: Parse Sql
  1482. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashjoin
  1483. set enable_hashjoin = 0;
  1484. ^
  1485. <sql-statement>
  1486. explain (costs off)
  1487. select a.idv, b.idv from tidv a, tidv b where a.idv = b.idv;
  1488. </sql-statement>
  1489. -stdin-:<main>: Error: Parse Sql
  1490. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1491. explain (costs off)
  1492. ^
  1493. <sql-statement>
  1494. rollback;
  1495. </sql-statement>
  1496. <sql-statement>
  1497. --
  1498. -- test NULL behavior of whole-row Vars, per bug #5025
  1499. --
  1500. select t1.q2, count(t2.*)
  1501. from int8_tbl t1 left join int8_tbl t2 on (t1.q2 = t2.q1)
  1502. group by t1.q2 order by 1;
  1503. </sql-statement>
  1504. -stdin-:<main>: Error: Type annotation
  1505. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
  1506. --
  1507. ^
  1508. -stdin-:<main>:4:15: Error: At function: PgAgg
  1509. select t1.q2, count(t2.*)
  1510. ^
  1511. -stdin-:<main>:4:21: Error: Expected PG type, but got: Struct
  1512. select t1.q2, count(t2.*)
  1513. ^
  1514. <sql-statement>
  1515. select t1.q2, count(t2.*)
  1516. from int8_tbl t1 left join (select * from int8_tbl) t2 on (t1.q2 = t2.q1)
  1517. group by t1.q2 order by 1;
  1518. </sql-statement>
  1519. -stdin-:<main>: Error: Type annotation
  1520. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
  1521. select t1.q2, count(t2.*)
  1522. ^
  1523. -stdin-:<main>:1:15: Error: At function: PgAgg
  1524. select t1.q2, count(t2.*)
  1525. ^
  1526. -stdin-:<main>:1:21: Error: Expected PG type, but got: Struct
  1527. select t1.q2, count(t2.*)
  1528. ^
  1529. <sql-statement>
  1530. select t1.q2, count(t2.*)
  1531. from int8_tbl t1 left join (select * from int8_tbl offset 0) t2 on (t1.q2 = t2.q1)
  1532. group by t1.q2 order by 1;
  1533. </sql-statement>
  1534. -stdin-:<main>: Error: Type annotation
  1535. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
  1536. select t1.q2, count(t2.*)
  1537. ^
  1538. -stdin-:<main>:1:15: Error: At function: PgAgg
  1539. select t1.q2, count(t2.*)
  1540. ^
  1541. -stdin-:<main>:1:21: Error: Expected PG type, but got: Struct
  1542. select t1.q2, count(t2.*)
  1543. ^
  1544. <sql-statement>
  1545. select t1.q2, count(t2.*)
  1546. from int8_tbl t1 left join
  1547. (select q1, case when q2=1 then 1 else q2 end as q2 from int8_tbl) t2
  1548. on (t1.q2 = t2.q1)
  1549. group by t1.q2 order by 1;
  1550. </sql-statement>
  1551. -stdin-:<main>: Error: Type annotation
  1552. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
  1553. select t1.q2, count(t2.*)
  1554. ^
  1555. -stdin-:<main>:1:15: Error: At function: PgAgg
  1556. select t1.q2, count(t2.*)
  1557. ^
  1558. -stdin-:<main>:1:21: Error: Expected PG type, but got: Struct
  1559. select t1.q2, count(t2.*)
  1560. ^
  1561. <sql-statement>
  1562. --
  1563. -- test incorrect failure to NULL pulled-up subexpressions
  1564. --
  1565. begin;
  1566. </sql-statement>
  1567. <sql-statement>
  1568. create temp table a (
  1569. code char not null,
  1570. constraint a_pk primary key (code)
  1571. );
  1572. </sql-statement>
  1573. <sql-statement>
  1574. create temp table b (
  1575. a char not null,
  1576. num integer not null,
  1577. constraint b_pk primary key (a, num)
  1578. );
  1579. </sql-statement>
  1580. <sql-statement>
  1581. create temp table c (
  1582. name char not null,
  1583. a char,
  1584. constraint c_pk primary key (name)
  1585. );
  1586. </sql-statement>
  1587. <sql-statement>
  1588. insert into a (code) values ('p');
  1589. </sql-statement>
  1590. <sql-statement>
  1591. insert into a (code) values ('q');
  1592. </sql-statement>
  1593. <sql-statement>
  1594. insert into b (a, num) values ('p', 1);
  1595. </sql-statement>
  1596. <sql-statement>
  1597. insert into b (a, num) values ('p', 2);
  1598. </sql-statement>
  1599. <sql-statement>
  1600. insert into c (name, a) values ('A', 'p');
  1601. </sql-statement>
  1602. <sql-statement>
  1603. insert into c (name, a) values ('B', 'q');
  1604. </sql-statement>
  1605. <sql-statement>
  1606. insert into c (name, a) values ('C', null);
  1607. </sql-statement>
  1608. <sql-statement>
  1609. select c.name, ss.code, ss.b_cnt, ss.const
  1610. from c left join
  1611. (select a.code, coalesce(b_grp.cnt, 0) as b_cnt, -1 as const
  1612. from a left join
  1613. (select count(1) as cnt, b.a from b group by b.a) as b_grp
  1614. on a.code = b_grp.a
  1615. ) as ss
  1616. on (c.a = ss.code)
  1617. order by c.name;
  1618. </sql-statement>
  1619. -stdin-:<main>: Error: Type annotation
  1620. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgSelect, At function: PgSetItem, At function: PgSelect, At function: PgSetItem
  1621. select c.name, ss.code, ss.b_cnt, ss.const
  1622. ^
  1623. -stdin-:<main>:5:51: Error: No such column: a
  1624. (select count(1) as cnt, b.a from b group by b.a) as b_grp
  1625. ^
  1626. <sql-statement>
  1627. rollback;
  1628. </sql-statement>
  1629. <sql-statement>
  1630. --
  1631. -- test incorrect handling of placeholders that only appear in targetlists,
  1632. -- per bug #6154
  1633. --
  1634. SELECT * FROM
  1635. ( SELECT 1 as key1 ) sub1
  1636. LEFT JOIN
  1637. ( SELECT sub3.key3, sub4.value2, COALESCE(sub4.value2, 66) as value3 FROM
  1638. ( SELECT 1 as key3 ) sub3
  1639. LEFT JOIN
  1640. ( SELECT sub5.key5, COALESCE(sub6.value1, 1) as value2 FROM
  1641. ( SELECT 1 as key5 ) sub5
  1642. LEFT JOIN
  1643. ( SELECT 2 as key6, 42 as value1 ) sub6
  1644. ON sub5.key5 = sub6.key6
  1645. ) sub4
  1646. ON sub4.key5 = sub3.key3
  1647. ) sub2
  1648. ON sub1.key1 = sub2.key3;
  1649. </sql-statement>
  1650. <sql-statement>
  1651. -- test the path using join aliases, too
  1652. SELECT * FROM
  1653. ( SELECT 1 as key1 ) sub1
  1654. LEFT JOIN
  1655. ( SELECT sub3.key3, value2, COALESCE(value2, 66) as value3 FROM
  1656. ( SELECT 1 as key3 ) sub3
  1657. LEFT JOIN
  1658. ( SELECT sub5.key5, COALESCE(sub6.value1, 1) as value2 FROM
  1659. ( SELECT 1 as key5 ) sub5
  1660. LEFT JOIN
  1661. ( SELECT 2 as key6, 42 as value1 ) sub6
  1662. ON sub5.key5 = sub6.key6
  1663. ) sub4
  1664. ON sub4.key5 = sub3.key3
  1665. ) sub2
  1666. ON sub1.key1 = sub2.key3;
  1667. </sql-statement>
  1668. <sql-statement>
  1669. --
  1670. -- test case where a PlaceHolderVar is used as a nestloop parameter
  1671. --
  1672. EXPLAIN (COSTS OFF)
  1673. SELECT qq, unique1
  1674. FROM
  1675. ( SELECT COALESCE(q1, 0) AS qq FROM int8_tbl a ) AS ss1
  1676. FULL OUTER JOIN
  1677. ( SELECT COALESCE(q2, -1) AS qq FROM int8_tbl b ) AS ss2
  1678. USING (qq)
  1679. INNER JOIN tenk1 c ON qq = unique2;
  1680. </sql-statement>
  1681. -stdin-:<main>: Error: Parse Sql
  1682. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1683. --
  1684. ^
  1685. <sql-statement>
  1686. SELECT qq, unique1
  1687. FROM
  1688. ( SELECT COALESCE(q1, 0) AS qq FROM int8_tbl a ) AS ss1
  1689. FULL OUTER JOIN
  1690. ( SELECT COALESCE(q2, -1) AS qq FROM int8_tbl b ) AS ss2
  1691. USING (qq)
  1692. INNER JOIN tenk1 c ON qq = unique2;
  1693. </sql-statement>
  1694. -stdin-:<main>: Error: Type annotation
  1695. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  1696. SELECT qq, unique1
  1697. ^
  1698. -stdin-:<main>:7:25: Error: Column reference is ambiguous: qq
  1699. INNER JOIN tenk1 c ON qq = unique2;
  1700. ^
  1701. <sql-statement>
  1702. --
  1703. -- nested nestloops can require nested PlaceHolderVars
  1704. --
  1705. create temp table nt1 (
  1706. id int primary key,
  1707. a1 boolean,
  1708. a2 boolean
  1709. );
  1710. </sql-statement>
  1711. <sql-statement>
  1712. create temp table nt2 (
  1713. id int primary key,
  1714. nt1_id int,
  1715. b1 boolean,
  1716. b2 boolean,
  1717. foreign key (nt1_id) references nt1(id)
  1718. );
  1719. </sql-statement>
  1720. -stdin-:<main>: Error: Parse Sql
  1721. -stdin-:<main>:1:1: Error: table constraint not supported
  1722. create temp table nt2 (
  1723. ^
  1724. <sql-statement>
  1725. create temp table nt3 (
  1726. id int primary key,
  1727. nt2_id int,
  1728. c1 boolean,
  1729. foreign key (nt2_id) references nt2(id)
  1730. );
  1731. </sql-statement>
  1732. -stdin-:<main>: Error: Parse Sql
  1733. -stdin-:<main>:1:1: Error: table constraint not supported
  1734. create temp table nt3 (
  1735. ^
  1736. <sql-statement>
  1737. insert into nt1 values (1,true,true);
  1738. </sql-statement>
  1739. <sql-statement>
  1740. insert into nt1 values (2,true,false);
  1741. </sql-statement>
  1742. <sql-statement>
  1743. insert into nt1 values (3,false,false);
  1744. </sql-statement>
  1745. <sql-statement>
  1746. insert into nt2 values (1,1,true,true);
  1747. </sql-statement>
  1748. -stdin-:<main>: Fatal: Table metadata loading
  1749. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.nt2
  1750. <sql-statement>
  1751. insert into nt2 values (2,2,true,false);
  1752. </sql-statement>
  1753. -stdin-:<main>: Fatal: Table metadata loading
  1754. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.nt2
  1755. <sql-statement>
  1756. insert into nt2 values (3,3,false,false);
  1757. </sql-statement>
  1758. -stdin-:<main>: Fatal: Table metadata loading
  1759. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.nt2
  1760. <sql-statement>
  1761. insert into nt3 values (1,1,true);
  1762. </sql-statement>
  1763. -stdin-:<main>: Fatal: Table metadata loading
  1764. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.nt3
  1765. <sql-statement>
  1766. insert into nt3 values (2,2,false);
  1767. </sql-statement>
  1768. -stdin-:<main>: Fatal: Table metadata loading
  1769. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.nt3
  1770. <sql-statement>
  1771. insert into nt3 values (3,3,true);
  1772. </sql-statement>
  1773. -stdin-:<main>: Fatal: Table metadata loading
  1774. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.nt3
  1775. <sql-statement>
  1776. explain (costs off)
  1777. select nt3.id
  1778. from nt3 as nt3
  1779. left join
  1780. (select nt2.*, (nt2.b1 and ss1.a3) AS b3
  1781. from nt2 as nt2
  1782. left join
  1783. (select nt1.*, (nt1.id is not null) as a3 from nt1) as ss1
  1784. on ss1.id = nt2.nt1_id
  1785. ) as ss2
  1786. on ss2.id = nt3.nt2_id
  1787. where nt3.id = 1 and ss2.b3;
  1788. </sql-statement>
  1789. -stdin-:<main>: Error: Parse Sql
  1790. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1791. explain (costs off)
  1792. ^
  1793. <sql-statement>
  1794. select nt3.id
  1795. from nt3 as nt3
  1796. left join
  1797. (select nt2.*, (nt2.b1 and ss1.a3) AS b3
  1798. from nt2 as nt2
  1799. left join
  1800. (select nt1.*, (nt1.id is not null) as a3 from nt1) as ss1
  1801. on ss1.id = nt2.nt1_id
  1802. ) as ss2
  1803. on ss2.id = nt3.nt2_id
  1804. where nt3.id = 1 and ss2.b3;
  1805. </sql-statement>
  1806. -stdin-:<main>: Fatal: Table metadata loading
  1807. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.nt2
  1808. <sql-statement>
  1809. --
  1810. -- test case where a PlaceHolderVar is propagated into a subquery
  1811. --
  1812. explain (costs off)
  1813. select * from
  1814. int8_tbl t1 left join
  1815. (select q1 as x, 42 as y from int8_tbl t2) ss
  1816. on t1.q2 = ss.x
  1817. where
  1818. 1 = (select 1 from int8_tbl t3 where ss.y is not null limit 1)
  1819. order by 1,2;
  1820. </sql-statement>
  1821. -stdin-:<main>: Error: Parse Sql
  1822. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1823. --
  1824. ^
  1825. <sql-statement>
  1826. select * from
  1827. int8_tbl t1 left join
  1828. (select q1 as x, 42 as y from int8_tbl t2) ss
  1829. on t1.q2 = ss.x
  1830. where
  1831. 1 = (select 1 from int8_tbl t3 where ss.y is not null limit 1)
  1832. order by 1,2;
  1833. </sql-statement>
  1834. <sql-statement>
  1835. --
  1836. -- variant where a PlaceHolderVar is needed at a join, but not above the join
  1837. --
  1838. explain (costs off)
  1839. select * from
  1840. int4_tbl as i41,
  1841. lateral
  1842. (select 1 as x from
  1843. (select i41.f1 as lat,
  1844. i42.f1 as loc from
  1845. int8_tbl as i81, int4_tbl as i42) as ss1
  1846. right join int4_tbl as i43 on (i43.f1 > 1)
  1847. where ss1.loc = ss1.lat) as ss2
  1848. where i41.f1 > 0;
  1849. </sql-statement>
  1850. -stdin-:<main>: Error: Parse Sql
  1851. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1852. --
  1853. ^
  1854. <sql-statement>
  1855. select * from
  1856. int4_tbl as i41,
  1857. lateral
  1858. (select 1 as x from
  1859. (select i41.f1 as lat,
  1860. i42.f1 as loc from
  1861. int8_tbl as i81, int4_tbl as i42) as ss1
  1862. right join int4_tbl as i43 on (i43.f1 > 1)
  1863. where ss1.loc = ss1.lat) as ss2
  1864. where i41.f1 > 0;
  1865. </sql-statement>
  1866. -stdin-:<main>: Error: Parse Sql
  1867. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  1868. select * from
  1869. ^
  1870. <sql-statement>
  1871. --
  1872. -- test the corner cases FULL JOIN ON TRUE and FULL JOIN ON FALSE
  1873. --
  1874. select * from int4_tbl a full join int4_tbl b on true;
  1875. </sql-statement>
  1876. -stdin-:<main>: Error: Type annotation
  1877. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  1878. --
  1879. ^
  1880. -stdin-:<main>:1:1: Error: Duplicated member: f1
  1881. --
  1882. ^
  1883. <sql-statement>
  1884. select * from int4_tbl a full join int4_tbl b on false;
  1885. </sql-statement>
  1886. -stdin-:<main>: Error: Type annotation
  1887. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  1888. select * from int4_tbl a full join int4_tbl b on false;
  1889. ^
  1890. -stdin-:<main>:1:1: Error: Duplicated member: f1
  1891. select * from int4_tbl a full join int4_tbl b on false;
  1892. ^
  1893. <sql-statement>
  1894. --
  1895. -- test for ability to use a cartesian join when necessary
  1896. --
  1897. create temp table q1 as select 1 as q1;
  1898. </sql-statement>
  1899. -stdin-:<main>: Error: Parse Sql
  1900. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
  1901. --
  1902. ^
  1903. <sql-statement>
  1904. create temp table q2 as select 0 as q2;
  1905. </sql-statement>
  1906. -stdin-:<main>: Error: Parse Sql
  1907. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
  1908. create temp table q2 as select 0 as q2;
  1909. ^
  1910. <sql-statement>
  1911. analyze q1;
  1912. </sql-statement>
  1913. -stdin-:<main>: Error: Parse Sql
  1914. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  1915. analyze q1;
  1916. ^
  1917. <sql-statement>
  1918. analyze q2;
  1919. </sql-statement>
  1920. -stdin-:<main>: Error: Parse Sql
  1921. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  1922. analyze q2;
  1923. ^
  1924. <sql-statement>
  1925. explain (costs off)
  1926. select * from
  1927. tenk1 join int4_tbl on f1 = twothousand,
  1928. q1, q2
  1929. where q1 = thousand or q2 = thousand;
  1930. </sql-statement>
  1931. -stdin-:<main>: Error: Parse Sql
  1932. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1933. explain (costs off)
  1934. ^
  1935. <sql-statement>
  1936. explain (costs off)
  1937. select * from
  1938. tenk1 join int4_tbl on f1 = twothousand,
  1939. q1, q2
  1940. where thousand = (q1 + q2);
  1941. </sql-statement>
  1942. -stdin-:<main>: Error: Parse Sql
  1943. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1944. explain (costs off)
  1945. ^
  1946. <sql-statement>
  1947. --
  1948. -- test ability to generate a suitable plan for a star-schema query
  1949. --
  1950. explain (costs off)
  1951. select * from
  1952. tenk1, int8_tbl a, int8_tbl b
  1953. where thousand = a.q1 and tenthous = b.q1 and a.q2 = 1 and b.q2 = 2;
  1954. </sql-statement>
  1955. -stdin-:<main>: Error: Parse Sql
  1956. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1957. --
  1958. ^
  1959. <sql-statement>
  1960. --
  1961. -- test a corner case in which we shouldn't apply the star-schema optimization
  1962. --
  1963. explain (costs off)
  1964. select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from
  1965. tenk1 t1
  1966. inner join int4_tbl i1
  1967. left join (select v1.x2, v2.y1, 11 AS d1
  1968. from (select 1,0 from onerow) v1(x1,x2)
  1969. left join (select 3,1 from onerow) v2(y1,y2)
  1970. on v1.x1 = v2.y2) subq1
  1971. on (i1.f1 = subq1.x2)
  1972. on (t1.unique2 = subq1.d1)
  1973. left join tenk1 t2
  1974. on (subq1.y1 = t2.unique1)
  1975. where t1.unique2 < 42 and t1.stringu1 > t2.stringu2;
  1976. </sql-statement>
  1977. -stdin-:<main>: Error: Parse Sql
  1978. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1979. --
  1980. ^
  1981. <sql-statement>
  1982. select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from
  1983. tenk1 t1
  1984. inner join int4_tbl i1
  1985. left join (select v1.x2, v2.y1, 11 AS d1
  1986. from (select 1,0 from onerow) v1(x1,x2)
  1987. left join (select 3,1 from onerow) v2(y1,y2)
  1988. on v1.x1 = v2.y2) subq1
  1989. on (i1.f1 = subq1.x2)
  1990. on (t1.unique2 = subq1.d1)
  1991. left join tenk1 t2
  1992. on (subq1.y1 = t2.unique1)
  1993. where t1.unique2 < 42 and t1.stringu1 > t2.stringu2;
  1994. </sql-statement>
  1995. <sql-statement>
  1996. -- variant that isn't quite a star-schema case
  1997. select ss1.d1 from
  1998. tenk1 as t1
  1999. inner join tenk1 as t2
  2000. on t1.tenthous = t2.ten
  2001. inner join
  2002. int8_tbl as i8
  2003. left join int4_tbl as i4
  2004. inner join (select 64::information_schema.cardinal_number as d1
  2005. from tenk1 t3,
  2006. lateral (select abs(t3.unique1) + random()) ss0(x)
  2007. where t3.fivethous < 0) as ss1
  2008. on i4.f1 = ss1.d1
  2009. on i8.q1 = i4.f1
  2010. on t1.tenthous = ss1.d1
  2011. where t1.unique1 < i4.f1;
  2012. </sql-statement>
  2013. -stdin-:<main>: Error: Parse Sql
  2014. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  2015. -- variant that isn't quite a star-schema case
  2016. ^
  2017. -stdin-:<main>: Error: Type annotation
  2018. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  2019. -- variant that isn't quite a star-schema case
  2020. ^
  2021. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  2022. -- variant that isn't quite a star-schema case
  2023. ^
  2024. <sql-statement>
  2025. -- this variant is foldable by the remove-useless-RESULT-RTEs code
  2026. explain (costs off)
  2027. select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from
  2028. tenk1 t1
  2029. inner join int4_tbl i1
  2030. left join (select v1.x2, v2.y1, 11 AS d1
  2031. from (values(1,0)) v1(x1,x2)
  2032. left join (values(3,1)) v2(y1,y2)
  2033. on v1.x1 = v2.y2) subq1
  2034. on (i1.f1 = subq1.x2)
  2035. on (t1.unique2 = subq1.d1)
  2036. left join tenk1 t2
  2037. on (subq1.y1 = t2.unique1)
  2038. where t1.unique2 < 42 and t1.stringu1 > t2.stringu2;
  2039. </sql-statement>
  2040. -stdin-:<main>: Error: Parse Sql
  2041. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2042. -- this variant is foldable by the remove-useless-RESULT-RTEs code
  2043. ^
  2044. <sql-statement>
  2045. select t1.unique2, t1.stringu1, t2.unique1, t2.stringu2 from
  2046. tenk1 t1
  2047. inner join int4_tbl i1
  2048. left join (select v1.x2, v2.y1, 11 AS d1
  2049. from (values(1,0)) v1(x1,x2)
  2050. left join (values(3,1)) v2(y1,y2)
  2051. on v1.x1 = v2.y2) subq1
  2052. on (i1.f1 = subq1.x2)
  2053. on (t1.unique2 = subq1.d1)
  2054. left join tenk1 t2
  2055. on (subq1.y1 = t2.unique1)
  2056. where t1.unique2 < 42 and t1.stringu1 > t2.stringu2;
  2057. </sql-statement>
  2058. <sql-statement>
  2059. -- Here's a variant that we can't fold too aggressively, though,
  2060. -- or we end up with noplace to evaluate the lateral PHV
  2061. explain (verbose, costs off)
  2062. select * from
  2063. (select 1 as x) ss1 left join (select 2 as y) ss2 on (true),
  2064. lateral (select ss2.y as z limit 1) ss3;
  2065. </sql-statement>
  2066. -stdin-:<main>: Error: Parse Sql
  2067. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2068. -- Here's a variant that we can't fold too aggressively, though,
  2069. ^
  2070. <sql-statement>
  2071. select * from
  2072. (select 1 as x) ss1 left join (select 2 as y) ss2 on (true),
  2073. lateral (select ss2.y as z limit 1) ss3;
  2074. </sql-statement>
  2075. -stdin-:<main>: Error: Parse Sql
  2076. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  2077. select * from
  2078. ^
  2079. <sql-statement>
  2080. -- Test proper handling of appendrel PHVs during useless-RTE removal
  2081. explain (costs off)
  2082. select * from
  2083. (select 0 as z) as t1
  2084. left join
  2085. (select true as a) as t2
  2086. on true,
  2087. lateral (select true as b
  2088. union all
  2089. select a as b) as t3
  2090. where b;
  2091. </sql-statement>
  2092. -stdin-:<main>: Error: Parse Sql
  2093. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2094. -- Test proper handling of appendrel PHVs during useless-RTE removal
  2095. ^
  2096. <sql-statement>
  2097. select * from
  2098. (select 0 as z) as t1
  2099. left join
  2100. (select true as a) as t2
  2101. on true,
  2102. lateral (select true as b
  2103. union all
  2104. select a as b) as t3
  2105. where b;
  2106. </sql-statement>
  2107. -stdin-:<main>: Error: Parse Sql
  2108. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  2109. select * from
  2110. ^
  2111. <sql-statement>
  2112. --
  2113. -- test inlining of immutable functions
  2114. --
  2115. create function f_immutable_int4(i integer) returns integer as
  2116. $$ begin return i; end; $$ language plpgsql immutable;
  2117. </sql-statement>
  2118. -stdin-:<main>: Error: Parse Sql
  2119. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
  2120. --
  2121. ^
  2122. <sql-statement>
  2123. -- check optimization of function scan with join
  2124. explain (costs off)
  2125. select unique1 from tenk1, (select * from f_immutable_int4(1) x) x
  2126. where x = unique1;
  2127. </sql-statement>
  2128. -stdin-:<main>: Error: Parse Sql
  2129. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2130. -- check optimization of function scan with join
  2131. ^
  2132. <sql-statement>
  2133. explain (verbose, costs off)
  2134. select unique1, x.*
  2135. from tenk1, (select *, random() from f_immutable_int4(1) x) x
  2136. where x = unique1;
  2137. </sql-statement>
  2138. -stdin-:<main>: Error: Parse Sql
  2139. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2140. explain (verbose, costs off)
  2141. ^
  2142. <sql-statement>
  2143. explain (costs off)
  2144. select unique1 from tenk1, f_immutable_int4(1) x where x = unique1;
  2145. </sql-statement>
  2146. -stdin-:<main>: Error: Parse Sql
  2147. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2148. explain (costs off)
  2149. ^
  2150. <sql-statement>
  2151. explain (costs off)
  2152. select unique1 from tenk1, lateral f_immutable_int4(1) x where x = unique1;
  2153. </sql-statement>
  2154. -stdin-:<main>: Error: Parse Sql
  2155. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2156. explain (costs off)
  2157. ^
  2158. <sql-statement>
  2159. explain (costs off)
  2160. select unique1 from tenk1, lateral f_immutable_int4(1) x where x in (select 17);
  2161. </sql-statement>
  2162. -stdin-:<main>: Error: Parse Sql
  2163. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2164. explain (costs off)
  2165. ^
  2166. <sql-statement>
  2167. explain (costs off)
  2168. select unique1, x from tenk1 join f_immutable_int4(1) x on unique1 = x;
  2169. </sql-statement>
  2170. -stdin-:<main>: Error: Parse Sql
  2171. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2172. explain (costs off)
  2173. ^
  2174. <sql-statement>
  2175. explain (costs off)
  2176. select unique1, x from tenk1 left join f_immutable_int4(1) x on unique1 = x;
  2177. </sql-statement>
  2178. -stdin-:<main>: Error: Parse Sql
  2179. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2180. explain (costs off)
  2181. ^
  2182. <sql-statement>
  2183. explain (costs off)
  2184. select unique1, x from tenk1 right join f_immutable_int4(1) x on unique1 = x;
  2185. </sql-statement>
  2186. -stdin-:<main>: Error: Parse Sql
  2187. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2188. explain (costs off)
  2189. ^
  2190. <sql-statement>
  2191. explain (costs off)
  2192. select unique1, x from tenk1 full join f_immutable_int4(1) x on unique1 = x;
  2193. </sql-statement>
  2194. -stdin-:<main>: Error: Parse Sql
  2195. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2196. explain (costs off)
  2197. ^
  2198. <sql-statement>
  2199. -- check that pullup of a const function allows further const-folding
  2200. explain (costs off)
  2201. select unique1 from tenk1, f_immutable_int4(1) x where x = 42;
  2202. </sql-statement>
  2203. -stdin-:<main>: Error: Parse Sql
  2204. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2205. -- check that pullup of a const function allows further const-folding
  2206. ^
  2207. <sql-statement>
  2208. -- test inlining of immutable functions with PlaceHolderVars
  2209. explain (costs off)
  2210. select nt3.id
  2211. from nt3 as nt3
  2212. left join
  2213. (select nt2.*, (nt2.b1 or i4 = 42) AS b3
  2214. from nt2 as nt2
  2215. left join
  2216. f_immutable_int4(0) i4
  2217. on i4 = nt2.nt1_id
  2218. ) as ss2
  2219. on ss2.id = nt3.nt2_id
  2220. where nt3.id = 1 and ss2.b3;
  2221. </sql-statement>
  2222. -stdin-:<main>: Error: Parse Sql
  2223. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2224. -- test inlining of immutable functions with PlaceHolderVars
  2225. ^
  2226. <sql-statement>
  2227. drop function f_immutable_int4(int);
  2228. </sql-statement>
  2229. -stdin-:<main>: Error: Parse Sql
  2230. -stdin-:<main>:1:1: Error: DropStmt: alternative is not implemented yet : 386
  2231. drop function f_immutable_int4(int);
  2232. ^
  2233. <sql-statement>
  2234. -- test inlining when function returns composite
  2235. create function mki8(bigint, bigint) returns int8_tbl as
  2236. $$select row($1,$2)::int8_tbl$$ language sql;
  2237. </sql-statement>
  2238. -stdin-:<main>: Error: Parse Sql
  2239. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
  2240. -- test inlining when function returns composite
  2241. ^
  2242. <sql-statement>
  2243. create function mki4(int) returns int4_tbl as
  2244. $$select row($1)::int4_tbl$$ language sql;
  2245. </sql-statement>
  2246. -stdin-:<main>: Error: Parse Sql
  2247. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
  2248. create function mki4(int) returns int4_tbl as
  2249. ^
  2250. <sql-statement>
  2251. explain (verbose, costs off)
  2252. select * from mki8(1,2);
  2253. </sql-statement>
  2254. -stdin-:<main>: Error: Parse Sql
  2255. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2256. explain (verbose, costs off)
  2257. ^
  2258. <sql-statement>
  2259. select * from mki8(1,2);
  2260. </sql-statement>
  2261. -stdin-:<main>: Error: Type annotation
  2262. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  2263. select * from mki8(1,2);
  2264. ^
  2265. -stdin-:<main>:1:15: Error: At function: PgCall
  2266. select * from mki8(1,2);
  2267. ^
  2268. -stdin-:<main>:1:15: Error: No such proc: mki8
  2269. select * from mki8(1,2);
  2270. ^
  2271. <sql-statement>
  2272. explain (verbose, costs off)
  2273. select * from mki4(42);
  2274. </sql-statement>
  2275. -stdin-:<main>: Error: Parse Sql
  2276. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2277. explain (verbose, costs off)
  2278. ^
  2279. <sql-statement>
  2280. select * from mki4(42);
  2281. </sql-statement>
  2282. -stdin-:<main>: Error: Type annotation
  2283. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  2284. select * from mki4(42);
  2285. ^
  2286. -stdin-:<main>:1:15: Error: At function: PgCall
  2287. select * from mki4(42);
  2288. ^
  2289. -stdin-:<main>:1:15: Error: No such proc: mki4
  2290. select * from mki4(42);
  2291. ^
  2292. <sql-statement>
  2293. drop function mki8(bigint, bigint);
  2294. </sql-statement>
  2295. -stdin-:<main>: Error: Parse Sql
  2296. -stdin-:<main>:1:1: Error: DropStmt: alternative is not implemented yet : 386
  2297. drop function mki8(bigint, bigint);
  2298. ^
  2299. <sql-statement>
  2300. drop function mki4(int);
  2301. </sql-statement>
  2302. -stdin-:<main>: Error: Parse Sql
  2303. -stdin-:<main>:1:1: Error: DropStmt: alternative is not implemented yet : 386
  2304. drop function mki4(int);
  2305. ^
  2306. <sql-statement>
  2307. --
  2308. -- test extraction of restriction OR clauses from join OR clause
  2309. -- (we used to only do this for indexable clauses)
  2310. --
  2311. explain (costs off)
  2312. select * from tenk1 a join tenk1 b on
  2313. (a.unique1 = 1 and b.unique1 = 2) or (a.unique2 = 3 and b.hundred = 4);
  2314. </sql-statement>
  2315. -stdin-:<main>: Error: Parse Sql
  2316. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2317. --
  2318. ^
  2319. <sql-statement>
  2320. explain (costs off)
  2321. select * from tenk1 a join tenk1 b on
  2322. (a.unique1 = 1 and b.unique1 = 2) or (a.unique2 = 3 and b.ten = 4);
  2323. </sql-statement>
  2324. -stdin-:<main>: Error: Parse Sql
  2325. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2326. explain (costs off)
  2327. ^
  2328. <sql-statement>
  2329. explain (costs off)
  2330. select * from tenk1 a join tenk1 b on
  2331. (a.unique1 = 1 and b.unique1 = 2) or
  2332. ((a.unique2 = 3 or a.unique2 = 7) and b.hundred = 4);
  2333. </sql-statement>
  2334. -stdin-:<main>: Error: Parse Sql
  2335. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2336. explain (costs off)
  2337. ^
  2338. <sql-statement>
  2339. --
  2340. -- test placement of movable quals in a parameterized join tree
  2341. --
  2342. explain (costs off)
  2343. select * from tenk1 t1 left join
  2344. (tenk1 t2 join tenk1 t3 on t2.thousand = t3.unique2)
  2345. on t1.hundred = t2.hundred and t1.ten = t3.ten
  2346. where t1.unique1 = 1;
  2347. </sql-statement>
  2348. -stdin-:<main>: Error: Parse Sql
  2349. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2350. --
  2351. ^
  2352. <sql-statement>
  2353. explain (costs off)
  2354. select * from tenk1 t1 left join
  2355. (tenk1 t2 join tenk1 t3 on t2.thousand = t3.unique2)
  2356. on t1.hundred = t2.hundred and t1.ten + t2.ten = t3.ten
  2357. where t1.unique1 = 1;
  2358. </sql-statement>
  2359. -stdin-:<main>: Error: Parse Sql
  2360. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2361. explain (costs off)
  2362. ^
  2363. <sql-statement>
  2364. explain (costs off)
  2365. select count(*) from
  2366. tenk1 a join tenk1 b on a.unique1 = b.unique2
  2367. left join tenk1 c on a.unique2 = b.unique1 and c.thousand = a.thousand
  2368. join int4_tbl on b.thousand = f1;
  2369. </sql-statement>
  2370. -stdin-:<main>: Error: Parse Sql
  2371. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2372. explain (costs off)
  2373. ^
  2374. <sql-statement>
  2375. select count(*) from
  2376. tenk1 a join tenk1 b on a.unique1 = b.unique2
  2377. left join tenk1 c on a.unique2 = b.unique1 and c.thousand = a.thousand
  2378. join int4_tbl on b.thousand = f1;
  2379. </sql-statement>
  2380. <sql-statement>
  2381. explain (costs off)
  2382. select b.unique1 from
  2383. tenk1 a join tenk1 b on a.unique1 = b.unique2
  2384. left join tenk1 c on b.unique1 = 42 and c.thousand = a.thousand
  2385. join int4_tbl i1 on b.thousand = f1
  2386. right join int4_tbl i2 on i2.f1 = b.tenthous
  2387. order by 1;
  2388. </sql-statement>
  2389. -stdin-:<main>: Error: Parse Sql
  2390. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2391. explain (costs off)
  2392. ^
  2393. <sql-statement>
  2394. select b.unique1 from
  2395. tenk1 a join tenk1 b on a.unique1 = b.unique2
  2396. left join tenk1 c on b.unique1 = 42 and c.thousand = a.thousand
  2397. join int4_tbl i1 on b.thousand = f1
  2398. right join int4_tbl i2 on i2.f1 = b.tenthous
  2399. order by 1;
  2400. </sql-statement>
  2401. <sql-statement>
  2402. explain (costs off)
  2403. select * from
  2404. (
  2405. select unique1, q1, coalesce(unique1, -1) + q1 as fault
  2406. from int8_tbl left join tenk1 on (q2 = unique2)
  2407. ) ss
  2408. where fault = 122
  2409. order by fault;
  2410. </sql-statement>
  2411. -stdin-:<main>: Error: Parse Sql
  2412. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2413. explain (costs off)
  2414. ^
  2415. <sql-statement>
  2416. select * from
  2417. (
  2418. select unique1, q1, coalesce(unique1, -1) + q1 as fault
  2419. from int8_tbl left join tenk1 on (q2 = unique2)
  2420. ) ss
  2421. where fault = 122
  2422. order by fault;
  2423. </sql-statement>
  2424. -stdin-:<main>: Error: Type annotation
  2425. -stdin-:<main>:1:1: Error: At function: PgSelect, At function: PgSetItem, At function: AssumeColumnOrder, At function: PgReplaceUnknown, At function: OrderedMap, At function: OrderedMap, At function: EquiJoin
  2426. select * from
  2427. ^
  2428. -stdin-:<main>:1:1: Error: Cannot compare key columns (a._alias_int8_tbl.q2 has type: pgint8, b._alias_tenk1.unique2 has type: pgint4)
  2429. select * from
  2430. ^
  2431. <sql-statement>
  2432. explain (costs off)
  2433. select * from
  2434. (values (1, array[10,20]), (2, array[20,30])) as v1(v1x,v1ys)
  2435. left join (values (1, 10), (2, 20)) as v2(v2x,v2y) on v2x = v1x
  2436. left join unnest(v1ys) as u1(u1y) on u1y = v2y;
  2437. </sql-statement>
  2438. -stdin-:<main>: Error: Parse Sql
  2439. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2440. explain (costs off)
  2441. ^
  2442. <sql-statement>
  2443. select * from
  2444. (values (1, array[10,20]), (2, array[20,30])) as v1(v1x,v1ys)
  2445. left join (values (1, 10), (2, 20)) as v2(v2x,v2y) on v2x = v1x
  2446. left join unnest(v1ys) as u1(u1y) on u1y = v2y;
  2447. </sql-statement>
  2448. -stdin-:<main>: Error: Parse Sql
  2449. -stdin-:<main>:4:18: Error: Columns are not allowed in: RANGE FUNCTION
  2450. left join unnest(v1ys) as u1(u1y) on u1y = v2y;
  2451. ^
  2452. <sql-statement>
  2453. --
  2454. -- test handling of potential equivalence clauses above outer joins
  2455. --
  2456. explain (costs off)
  2457. select q1, unique2, thousand, hundred
  2458. from int8_tbl a left join tenk1 b on q1 = unique2
  2459. where coalesce(thousand,123) = q1 and q1 = coalesce(hundred,123);
  2460. </sql-statement>
  2461. -stdin-:<main>: Error: Parse Sql
  2462. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2463. --
  2464. ^
  2465. <sql-statement>
  2466. select q1, unique2, thousand, hundred
  2467. from int8_tbl a left join tenk1 b on q1 = unique2
  2468. where coalesce(thousand,123) = q1 and q1 = coalesce(hundred,123);
  2469. </sql-statement>
  2470. -stdin-:<main>: Error: Type annotation
  2471. -stdin-:<main>:1:1: Error: At function: AssumeColumnOrder, At function: PgReplaceUnknown, At function: OrderedMap, At function: OrderedFilter, At function: OrderedMap, At function: EquiJoin
  2472. select q1, unique2, thousand, hundred
  2473. ^
  2474. -stdin-:<main>:1:1: Error: Cannot compare key columns (a._alias_a.q1 has type: pgint8, b._alias_b.unique2 has type: pgint4)
  2475. select q1, unique2, thousand, hundred
  2476. ^
  2477. <sql-statement>
  2478. explain (costs off)
  2479. select f1, unique2, case when unique2 is null then f1 else 0 end
  2480. from int4_tbl a left join tenk1 b on f1 = unique2
  2481. where (case when unique2 is null then f1 else 0 end) = 0;
  2482. </sql-statement>
  2483. -stdin-:<main>: Error: Parse Sql
  2484. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2485. explain (costs off)
  2486. ^
  2487. <sql-statement>
  2488. select f1, unique2, case when unique2 is null then f1 else 0 end
  2489. from int4_tbl a left join tenk1 b on f1 = unique2
  2490. where (case when unique2 is null then f1 else 0 end) = 0;
  2491. </sql-statement>
  2492. <sql-statement>
  2493. --
  2494. -- another case with equivalence clauses above outer joins (bug #8591)
  2495. --
  2496. explain (costs off)
  2497. select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand)
  2498. from tenk1 a left join tenk1 b on b.thousand = a.unique1 left join tenk1 c on c.unique2 = coalesce(b.twothousand, a.twothousand)
  2499. where a.unique2 < 10 and coalesce(b.twothousand, a.twothousand) = 44;
  2500. </sql-statement>
  2501. -stdin-:<main>: Error: Parse Sql
  2502. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2503. --
  2504. ^
  2505. <sql-statement>
  2506. select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand)
  2507. from tenk1 a left join tenk1 b on b.thousand = a.unique1 left join tenk1 c on c.unique2 = coalesce(b.twothousand, a.twothousand)
  2508. where a.unique2 < 10 and coalesce(b.twothousand, a.twothousand) = 44;
  2509. </sql-statement>
  2510. -stdin-:<main>: Error: Type annotation
  2511. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  2512. select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand)
  2513. ^
  2514. -stdin-:<main>:1:1: Error: Duplicated member: unique1
  2515. select a.unique1, b.unique1, c.unique1, coalesce(b.twothousand, a.twothousand)
  2516. ^
  2517. <sql-statement>
  2518. --
  2519. -- check handling of join aliases when flattening multiple levels of subquery
  2520. --
  2521. explain (verbose, costs off)
  2522. select foo1.join_key as foo1_id, foo3.join_key AS foo3_id, bug_field from
  2523. (values (0),(1)) foo1(join_key)
  2524. left join
  2525. (select join_key, bug_field from
  2526. (select ss1.join_key, ss1.bug_field from
  2527. (select f1 as join_key, 666 as bug_field from int4_tbl i1) ss1
  2528. ) foo2
  2529. left join
  2530. (select unique2 as join_key from tenk1 i2) ss2
  2531. using (join_key)
  2532. ) foo3
  2533. using (join_key);
  2534. </sql-statement>
  2535. -stdin-:<main>: Error: Parse Sql
  2536. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2537. --
  2538. ^
  2539. <sql-statement>
  2540. select foo1.join_key as foo1_id, foo3.join_key AS foo3_id, bug_field from
  2541. (values (0),(1)) foo1(join_key)
  2542. left join
  2543. (select join_key, bug_field from
  2544. (select ss1.join_key, ss1.bug_field from
  2545. (select f1 as join_key, 666 as bug_field from int4_tbl i1) ss1
  2546. ) foo2
  2547. left join
  2548. (select unique2 as join_key from tenk1 i2) ss2
  2549. using (join_key)
  2550. ) foo3
  2551. using (join_key);
  2552. </sql-statement>
  2553. <sql-statement>
  2554. --
  2555. -- test successful handling of nested outer joins with degenerate join quals
  2556. --
  2557. explain (verbose, costs off)
  2558. select t1.* from
  2559. text_tbl t1
  2560. left join (select *, '***'::text as d1 from int8_tbl i8b1) b1
  2561. left join int8_tbl i8
  2562. left join (select *, null::int as d2 from int8_tbl i8b2) b2
  2563. on (i8.q1 = b2.q1)
  2564. on (b2.d2 = b1.q2)
  2565. on (t1.f1 = b1.d1)
  2566. left join int4_tbl i4
  2567. on (i8.q2 = i4.f1);
  2568. </sql-statement>
  2569. -stdin-:<main>: Error: Parse Sql
  2570. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2571. --
  2572. ^
  2573. <sql-statement>
  2574. select t1.* from
  2575. text_tbl t1
  2576. left join (select *, '***'::text as d1 from int8_tbl i8b1) b1
  2577. left join int8_tbl i8
  2578. left join (select *, null::int as d2 from int8_tbl i8b2) b2
  2579. on (i8.q1 = b2.q1)
  2580. on (b2.d2 = b1.q2)
  2581. on (t1.f1 = b1.d1)
  2582. left join int4_tbl i4
  2583. on (i8.q2 = i4.f1);
  2584. </sql-statement>
  2585. -stdin-:<main>: Error: Type annotation
  2586. -stdin-:<main>:1:1: Error: At function: AssumeColumnOrder, At function: PgReplaceUnknown, At function: OrderedMap, At function: OrderedMap, At function: EquiJoin, At function: OrderedMap, At function: EquiJoin, At function: OrderedMap, At function: EquiJoin
  2587. select t1.* from
  2588. ^
  2589. -stdin-:<main>:1:1: Error: Cannot compare key columns (a._alias_b1.q2 has type: pgint8, b._alias_b2.d2 has type: pgint4)
  2590. select t1.* from
  2591. ^
  2592. <sql-statement>
  2593. explain (verbose, costs off)
  2594. select t1.* from
  2595. text_tbl t1
  2596. left join (select *, '***'::text as d1 from int8_tbl i8b1) b1
  2597. left join int8_tbl i8
  2598. left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2) b2
  2599. on (i8.q1 = b2.q1)
  2600. on (b2.d2 = b1.q2)
  2601. on (t1.f1 = b1.d1)
  2602. left join int4_tbl i4
  2603. on (i8.q2 = i4.f1);
  2604. </sql-statement>
  2605. -stdin-:<main>: Error: Parse Sql
  2606. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2607. explain (verbose, costs off)
  2608. ^
  2609. <sql-statement>
  2610. select t1.* from
  2611. text_tbl t1
  2612. left join (select *, '***'::text as d1 from int8_tbl i8b1) b1
  2613. left join int8_tbl i8
  2614. left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2) b2
  2615. on (i8.q1 = b2.q1)
  2616. on (b2.d2 = b1.q2)
  2617. on (t1.f1 = b1.d1)
  2618. left join int4_tbl i4
  2619. on (i8.q2 = i4.f1);
  2620. </sql-statement>
  2621. -stdin-:<main>: Error: Type annotation
  2622. -stdin-:<main>:1:1: Error: At function: AssumeColumnOrder, At function: PgReplaceUnknown, At function: OrderedMap, At function: OrderedMap, At function: EquiJoin, At function: OrderedMap, At function: EquiJoin, At function: OrderedMap, At function: EquiJoin
  2623. select t1.* from
  2624. ^
  2625. -stdin-:<main>:1:1: Error: Cannot compare key columns (a._alias_b1.q2 has type: pgint8, b._alias_b2.d2 has type: pgint4)
  2626. select t1.* from
  2627. ^
  2628. <sql-statement>
  2629. explain (verbose, costs off)
  2630. select t1.* from
  2631. text_tbl t1
  2632. left join (select *, '***'::text as d1 from int8_tbl i8b1) b1
  2633. left join int8_tbl i8
  2634. left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2
  2635. where q1 = f1) b2
  2636. on (i8.q1 = b2.q1)
  2637. on (b2.d2 = b1.q2)
  2638. on (t1.f1 = b1.d1)
  2639. left join int4_tbl i4
  2640. on (i8.q2 = i4.f1);
  2641. </sql-statement>
  2642. -stdin-:<main>: Error: Parse Sql
  2643. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2644. explain (verbose, costs off)
  2645. ^
  2646. <sql-statement>
  2647. select t1.* from
  2648. text_tbl t1
  2649. left join (select *, '***'::text as d1 from int8_tbl i8b1) b1
  2650. left join int8_tbl i8
  2651. left join (select *, null::int as d2 from int8_tbl i8b2, int4_tbl i4b2
  2652. where q1 = f1) b2
  2653. on (i8.q1 = b2.q1)
  2654. on (b2.d2 = b1.q2)
  2655. on (t1.f1 = b1.d1)
  2656. left join int4_tbl i4
  2657. on (i8.q2 = i4.f1);
  2658. </sql-statement>
  2659. -stdin-:<main>: Error: Type annotation
  2660. -stdin-:<main>:1:1: Error: At function: AssumeColumnOrder, At function: PgReplaceUnknown, At function: OrderedMap, At function: OrderedMap, At function: EquiJoin, At function: OrderedMap, At function: EquiJoin, At function: OrderedMap, At function: EquiJoin
  2661. select t1.* from
  2662. ^
  2663. -stdin-:<main>:1:1: Error: Cannot compare key columns (a._alias_b1.q2 has type: pgint8, b._alias_b2.d2 has type: pgint4)
  2664. select t1.* from
  2665. ^
  2666. <sql-statement>
  2667. explain (verbose, costs off)
  2668. select * from
  2669. text_tbl t1
  2670. inner join int8_tbl i8
  2671. on i8.q2 = 456
  2672. right join text_tbl t2
  2673. on t1.f1 = 'doh!'
  2674. left join int4_tbl i4
  2675. on i8.q1 = i4.f1;
  2676. </sql-statement>
  2677. -stdin-:<main>: Error: Parse Sql
  2678. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2679. explain (verbose, costs off)
  2680. ^
  2681. <sql-statement>
  2682. select * from
  2683. text_tbl t1
  2684. inner join int8_tbl i8
  2685. on i8.q2 = 456
  2686. right join text_tbl t2
  2687. on t1.f1 = 'doh!'
  2688. left join int4_tbl i4
  2689. on i8.q1 = i4.f1;
  2690. </sql-statement>
  2691. -stdin-:<main>: Error: Type annotation
  2692. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  2693. select * from
  2694. ^
  2695. -stdin-:<main>:1:1: Error: Duplicated member: f1
  2696. select * from
  2697. ^
  2698. <sql-statement>
  2699. --
  2700. -- test for appropriate join order in the presence of lateral references
  2701. --
  2702. explain (verbose, costs off)
  2703. select * from
  2704. text_tbl t1
  2705. left join int8_tbl i8
  2706. on i8.q2 = 123,
  2707. lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss
  2708. where t1.f1 = ss.f1;
  2709. </sql-statement>
  2710. -stdin-:<main>: Error: Parse Sql
  2711. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2712. --
  2713. ^
  2714. <sql-statement>
  2715. select * from
  2716. text_tbl t1
  2717. left join int8_tbl i8
  2718. on i8.q2 = 123,
  2719. lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss
  2720. where t1.f1 = ss.f1;
  2721. </sql-statement>
  2722. -stdin-:<main>: Error: Parse Sql
  2723. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  2724. select * from
  2725. ^
  2726. <sql-statement>
  2727. explain (verbose, costs off)
  2728. select * from
  2729. text_tbl t1
  2730. left join int8_tbl i8
  2731. on i8.q2 = 123,
  2732. lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss1,
  2733. lateral (select ss1.* from text_tbl t3 limit 1) as ss2
  2734. where t1.f1 = ss2.f1;
  2735. </sql-statement>
  2736. -stdin-:<main>: Error: Parse Sql
  2737. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2738. explain (verbose, costs off)
  2739. ^
  2740. <sql-statement>
  2741. select * from
  2742. text_tbl t1
  2743. left join int8_tbl i8
  2744. on i8.q2 = 123,
  2745. lateral (select i8.q1, t2.f1 from text_tbl t2 limit 1) as ss1,
  2746. lateral (select ss1.* from text_tbl t3 limit 1) as ss2
  2747. where t1.f1 = ss2.f1;
  2748. </sql-statement>
  2749. -stdin-:<main>: Error: Parse Sql
  2750. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  2751. select * from
  2752. ^
  2753. <sql-statement>
  2754. explain (verbose, costs off)
  2755. select 1 from
  2756. text_tbl as tt1
  2757. inner join text_tbl as tt2 on (tt1.f1 = 'foo')
  2758. left join text_tbl as tt3 on (tt3.f1 = 'foo')
  2759. left join text_tbl as tt4 on (tt3.f1 = tt4.f1),
  2760. lateral (select tt4.f1 as c0 from text_tbl as tt5 limit 1) as ss1
  2761. where tt1.f1 = ss1.c0;
  2762. </sql-statement>
  2763. -stdin-:<main>: Error: Parse Sql
  2764. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2765. explain (verbose, costs off)
  2766. ^
  2767. <sql-statement>
  2768. select 1 from
  2769. text_tbl as tt1
  2770. inner join text_tbl as tt2 on (tt1.f1 = 'foo')
  2771. left join text_tbl as tt3 on (tt3.f1 = 'foo')
  2772. left join text_tbl as tt4 on (tt3.f1 = tt4.f1),
  2773. lateral (select tt4.f1 as c0 from text_tbl as tt5 limit 1) as ss1
  2774. where tt1.f1 = ss1.c0;
  2775. </sql-statement>
  2776. -stdin-:<main>: Error: Parse Sql
  2777. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  2778. select 1 from
  2779. ^
  2780. <sql-statement>
  2781. --
  2782. -- check a case in which a PlaceHolderVar forces join order
  2783. --
  2784. explain (verbose, costs off)
  2785. select ss2.* from
  2786. int4_tbl i41
  2787. left join int8_tbl i8
  2788. join (select i42.f1 as c1, i43.f1 as c2, 42 as c3
  2789. from int4_tbl i42, int4_tbl i43) ss1
  2790. on i8.q1 = ss1.c2
  2791. on i41.f1 = ss1.c1,
  2792. lateral (select i41.*, i8.*, ss1.* from text_tbl limit 1) ss2
  2793. where ss1.c2 = 0;
  2794. </sql-statement>
  2795. -stdin-:<main>: Error: Parse Sql
  2796. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2797. --
  2798. ^
  2799. <sql-statement>
  2800. select ss2.* from
  2801. int4_tbl i41
  2802. left join int8_tbl i8
  2803. join (select i42.f1 as c1, i43.f1 as c2, 42 as c3
  2804. from int4_tbl i42, int4_tbl i43) ss1
  2805. on i8.q1 = ss1.c2
  2806. on i41.f1 = ss1.c1,
  2807. lateral (select i41.*, i8.*, ss1.* from text_tbl limit 1) ss2
  2808. where ss1.c2 = 0;
  2809. </sql-statement>
  2810. -stdin-:<main>: Error: Parse Sql
  2811. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  2812. select ss2.* from
  2813. ^
  2814. <sql-statement>
  2815. --
  2816. -- test successful handling of full join underneath left join (bug #14105)
  2817. --
  2818. explain (costs off)
  2819. select * from
  2820. (select 1 as id) as xx
  2821. left join
  2822. (tenk1 as a1 full join (select 1 as id) as yy on (a1.unique1 = yy.id))
  2823. on (xx.id = coalesce(yy.id));
  2824. </sql-statement>
  2825. -stdin-:<main>: Error: Parse Sql
  2826. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2827. --
  2828. ^
  2829. <sql-statement>
  2830. select * from
  2831. (select 1 as id) as xx
  2832. left join
  2833. (tenk1 as a1 full join (select 1 as id) as yy on (a1.unique1 = yy.id))
  2834. on (xx.id = coalesce(yy.id));
  2835. </sql-statement>
  2836. -stdin-:<main>: Error: Type annotation
  2837. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  2838. select * from
  2839. ^
  2840. -stdin-:<main>:1:1: Error: Duplicated member: id
  2841. select * from
  2842. ^
  2843. <sql-statement>
  2844. --
  2845. -- test ability to push constants through outer join clauses
  2846. --
  2847. explain (costs off)
  2848. select * from int4_tbl a left join tenk1 b on f1 = unique2 where f1 = 0;
  2849. </sql-statement>
  2850. -stdin-:<main>: Error: Parse Sql
  2851. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2852. --
  2853. ^
  2854. <sql-statement>
  2855. explain (costs off)
  2856. select * from tenk1 a full join tenk1 b using(unique2) where unique2 = 42;
  2857. </sql-statement>
  2858. -stdin-:<main>: Error: Parse Sql
  2859. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2860. explain (costs off)
  2861. ^
  2862. <sql-statement>
  2863. --
  2864. -- test that quals attached to an outer join have correct semantics,
  2865. -- specifically that they don't re-use expressions computed below the join;
  2866. -- we force a mergejoin so that coalesce(b.q1, 1) appears as a join input
  2867. --
  2868. set enable_hashjoin to off;
  2869. </sql-statement>
  2870. -stdin-:<main>: Error: Parse Sql
  2871. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashjoin
  2872. --
  2873. ^
  2874. <sql-statement>
  2875. set enable_nestloop to off;
  2876. </sql-statement>
  2877. -stdin-:<main>: Error: Parse Sql
  2878. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_nestloop
  2879. set enable_nestloop to off;
  2880. ^
  2881. <sql-statement>
  2882. explain (verbose, costs off)
  2883. select a.q2, b.q1
  2884. from int8_tbl a left join int8_tbl b on a.q2 = coalesce(b.q1, 1)
  2885. where coalesce(b.q1, 1) > 0;
  2886. </sql-statement>
  2887. -stdin-:<main>: Error: Parse Sql
  2888. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2889. explain (verbose, costs off)
  2890. ^
  2891. <sql-statement>
  2892. select a.q2, b.q1
  2893. from int8_tbl a left join int8_tbl b on a.q2 = coalesce(b.q1, 1)
  2894. where coalesce(b.q1, 1) > 0;
  2895. </sql-statement>
  2896. <sql-statement>
  2897. reset enable_hashjoin;
  2898. </sql-statement>
  2899. -stdin-:<main>: Error: Parse Sql
  2900. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  2901. reset enable_hashjoin;
  2902. ^
  2903. <sql-statement>
  2904. reset enable_nestloop;
  2905. </sql-statement>
  2906. -stdin-:<main>: Error: Parse Sql
  2907. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  2908. reset enable_nestloop;
  2909. ^
  2910. <sql-statement>
  2911. --
  2912. -- test join removal
  2913. --
  2914. begin;
  2915. </sql-statement>
  2916. <sql-statement>
  2917. CREATE TEMP TABLE a (id int PRIMARY KEY, b_id int);
  2918. </sql-statement>
  2919. <sql-statement>
  2920. CREATE TEMP TABLE b (id int PRIMARY KEY, c_id int);
  2921. </sql-statement>
  2922. <sql-statement>
  2923. CREATE TEMP TABLE c (id int PRIMARY KEY);
  2924. </sql-statement>
  2925. <sql-statement>
  2926. CREATE TEMP TABLE d (a int, b int);
  2927. </sql-statement>
  2928. <sql-statement>
  2929. INSERT INTO a VALUES (0, 0), (1, NULL);
  2930. </sql-statement>
  2931. -stdin-:<main>: Error: Type annotation
  2932. -stdin-:<main>:1:1: Error: At function: YtWriteTable!
  2933. INSERT INTO a VALUES (0, 0), (1, NULL);
  2934. ^
  2935. -stdin-:<main>:1:1: Error: values have 2 columns, INSERT INTO expects: 1
  2936. INSERT INTO a VALUES (0, 0), (1, NULL);
  2937. ^
  2938. <sql-statement>
  2939. INSERT INTO b VALUES (0, 0), (1, NULL);
  2940. </sql-statement>
  2941. <sql-statement>
  2942. INSERT INTO c VALUES (0), (1);
  2943. </sql-statement>
  2944. <sql-statement>
  2945. INSERT INTO d VALUES (1,3), (2,2), (3,1);
  2946. </sql-statement>
  2947. <sql-statement>
  2948. -- all three cases should be optimizable into a simple seqscan
  2949. explain (costs off) SELECT a.* FROM a LEFT JOIN b ON a.b_id = b.id;
  2950. </sql-statement>
  2951. -stdin-:<main>: Error: Parse Sql
  2952. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2953. -- all three cases should be optimizable into a simple seqscan
  2954. ^
  2955. <sql-statement>
  2956. explain (costs off) SELECT b.* FROM b LEFT JOIN c ON b.c_id = c.id;
  2957. </sql-statement>
  2958. -stdin-:<main>: Error: Parse Sql
  2959. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2960. explain (costs off) SELECT b.* FROM b LEFT JOIN c ON b.c_id = c.id;
  2961. ^
  2962. <sql-statement>
  2963. explain (costs off)
  2964. SELECT a.* FROM a LEFT JOIN (b left join c on b.c_id = c.id)
  2965. ON (a.b_id = b.id);
  2966. </sql-statement>
  2967. -stdin-:<main>: Error: Parse Sql
  2968. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2969. explain (costs off)
  2970. ^
  2971. <sql-statement>
  2972. -- check optimization of outer join within another special join
  2973. explain (costs off)
  2974. select id from a where id in (
  2975. select b.id from b left join c on b.id = c.id
  2976. );
  2977. </sql-statement>
  2978. -stdin-:<main>: Error: Parse Sql
  2979. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2980. -- check optimization of outer join within another special join
  2981. ^
  2982. <sql-statement>
  2983. -- check that join removal works for a left join when joining a subquery
  2984. -- that is guaranteed to be unique by its GROUP BY clause
  2985. explain (costs off)
  2986. select d.* from d left join (select * from b group by b.id, b.c_id) s
  2987. on d.a = s.id and d.b = s.c_id;
  2988. </sql-statement>
  2989. -stdin-:<main>: Error: Parse Sql
  2990. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  2991. -- check that join removal works for a left join when joining a subquery
  2992. ^
  2993. <sql-statement>
  2994. -- similarly, but keying off a DISTINCT clause
  2995. explain (costs off)
  2996. select d.* from d left join (select distinct * from b) s
  2997. on d.a = s.id and d.b = s.c_id;
  2998. </sql-statement>
  2999. -stdin-:<main>: Error: Parse Sql
  3000. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3001. -- similarly, but keying off a DISTINCT clause
  3002. ^
  3003. <sql-statement>
  3004. -- join removal is not possible when the GROUP BY contains a column that is
  3005. -- not in the join condition. (Note: as of 9.6, we notice that b.id is a
  3006. -- primary key and so drop b.c_id from the GROUP BY of the resulting plan;
  3007. -- but this happens too late for join removal in the outer plan level.)
  3008. explain (costs off)
  3009. select d.* from d left join (select * from b group by b.id, b.c_id) s
  3010. on d.a = s.id;
  3011. </sql-statement>
  3012. -stdin-:<main>: Error: Parse Sql
  3013. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3014. -- join removal is not possible when the GROUP BY contains a column that is
  3015. ^
  3016. <sql-statement>
  3017. -- similarly, but keying off a DISTINCT clause
  3018. explain (costs off)
  3019. select d.* from d left join (select distinct * from b) s
  3020. on d.a = s.id;
  3021. </sql-statement>
  3022. -stdin-:<main>: Error: Parse Sql
  3023. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3024. -- similarly, but keying off a DISTINCT clause
  3025. ^
  3026. <sql-statement>
  3027. -- check join removal works when uniqueness of the join condition is enforced
  3028. -- by a UNION
  3029. explain (costs off)
  3030. select d.* from d left join (select id from a union select id from b) s
  3031. on d.a = s.id;
  3032. </sql-statement>
  3033. -stdin-:<main>: Error: Parse Sql
  3034. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3035. -- check join removal works when uniqueness of the join condition is enforced
  3036. ^
  3037. <sql-statement>
  3038. -- check join removal with a cross-type comparison operator
  3039. explain (costs off)
  3040. select i8.* from int8_tbl i8 left join (select f1 from int4_tbl group by f1) i4
  3041. on i8.q1 = i4.f1;
  3042. </sql-statement>
  3043. -stdin-:<main>: Error: Parse Sql
  3044. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3045. -- check join removal with a cross-type comparison operator
  3046. ^
  3047. <sql-statement>
  3048. -- check join removal with lateral references
  3049. explain (costs off)
  3050. select 1 from (select a.id FROM a left join b on a.b_id = b.id) q,
  3051. lateral generate_series(1, q.id) gs(i) where q.id = gs.i;
  3052. </sql-statement>
  3053. -stdin-:<main>: Error: Parse Sql
  3054. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3055. -- check join removal with lateral references
  3056. ^
  3057. <sql-statement>
  3058. rollback;
  3059. </sql-statement>
  3060. <sql-statement>
  3061. create temp table parent (k int primary key, pd int);
  3062. </sql-statement>
  3063. <sql-statement>
  3064. create temp table child (k int unique, cd int);
  3065. </sql-statement>
  3066. <sql-statement>
  3067. insert into parent values (1, 10), (2, 20), (3, 30);
  3068. </sql-statement>
  3069. <sql-statement>
  3070. insert into child values (1, 100), (4, 400);
  3071. </sql-statement>
  3072. <sql-statement>
  3073. -- this case is optimizable
  3074. select p.* from parent p left join child c on (p.k = c.k);
  3075. </sql-statement>
  3076. <sql-statement>
  3077. explain (costs off)
  3078. select p.* from parent p left join child c on (p.k = c.k);
  3079. </sql-statement>
  3080. -stdin-:<main>: Error: Parse Sql
  3081. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3082. explain (costs off)
  3083. ^
  3084. <sql-statement>
  3085. -- this case is not
  3086. select p.*, linked from parent p
  3087. left join (select c.*, true as linked from child c) as ss
  3088. on (p.k = ss.k);
  3089. </sql-statement>
  3090. <sql-statement>
  3091. explain (costs off)
  3092. select p.*, linked from parent p
  3093. left join (select c.*, true as linked from child c) as ss
  3094. on (p.k = ss.k);
  3095. </sql-statement>
  3096. -stdin-:<main>: Error: Parse Sql
  3097. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3098. explain (costs off)
  3099. ^
  3100. <sql-statement>
  3101. -- check for a 9.0rc1 bug: join removal breaks pseudoconstant qual handling
  3102. select p.* from
  3103. parent p left join child c on (p.k = c.k)
  3104. where p.k = 1 and p.k = 2;
  3105. </sql-statement>
  3106. <sql-statement>
  3107. explain (costs off)
  3108. select p.* from
  3109. parent p left join child c on (p.k = c.k)
  3110. where p.k = 1 and p.k = 2;
  3111. </sql-statement>
  3112. -stdin-:<main>: Error: Parse Sql
  3113. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3114. explain (costs off)
  3115. ^
  3116. <sql-statement>
  3117. select p.* from
  3118. (parent p left join child c on (p.k = c.k)) join parent x on p.k = x.k
  3119. where p.k = 1 and p.k = 2;
  3120. </sql-statement>
  3121. <sql-statement>
  3122. explain (costs off)
  3123. select p.* from
  3124. (parent p left join child c on (p.k = c.k)) join parent x on p.k = x.k
  3125. where p.k = 1 and p.k = 2;
  3126. </sql-statement>
  3127. -stdin-:<main>: Error: Parse Sql
  3128. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3129. explain (costs off)
  3130. ^
  3131. <sql-statement>
  3132. -- bug 5255: this is not optimizable by join removal
  3133. begin;
  3134. </sql-statement>
  3135. <sql-statement>
  3136. CREATE TEMP TABLE a (id int PRIMARY KEY);
  3137. </sql-statement>
  3138. <sql-statement>
  3139. CREATE TEMP TABLE b (id int PRIMARY KEY, a_id int);
  3140. </sql-statement>
  3141. <sql-statement>
  3142. INSERT INTO a VALUES (0), (1);
  3143. </sql-statement>
  3144. <sql-statement>
  3145. INSERT INTO b VALUES (0, 0), (1, NULL);
  3146. </sql-statement>
  3147. <sql-statement>
  3148. SELECT * FROM b LEFT JOIN a ON (b.a_id = a.id) WHERE (a.id IS NULL OR a.id > 0);
  3149. </sql-statement>
  3150. -stdin-:<main>: Error: Type annotation
  3151. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  3152. SELECT * FROM b LEFT JOIN a ON (b.a_id = a.id) WHERE (a.id IS NULL OR a.id > 0);
  3153. ^
  3154. -stdin-:<main>:1:33: Error: No such column: a_id
  3155. SELECT * FROM b LEFT JOIN a ON (b.a_id = a.id) WHERE (a.id IS NULL OR a.id > 0);
  3156. ^
  3157. -stdin-:<main>:1:42: Error: No such column: id
  3158. SELECT * FROM b LEFT JOIN a ON (b.a_id = a.id) WHERE (a.id IS NULL OR a.id > 0);
  3159. ^
  3160. <sql-statement>
  3161. SELECT b.* FROM b LEFT JOIN a ON (b.a_id = a.id) WHERE (a.id IS NULL OR a.id > 0);
  3162. </sql-statement>
  3163. -stdin-:<main>: Error: Type annotation
  3164. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  3165. SELECT b.* FROM b LEFT JOIN a ON (b.a_id = a.id) WHERE (a.id IS NULL OR a.id > 0);
  3166. ^
  3167. -stdin-:<main>:1:35: Error: No such column: a_id
  3168. SELECT b.* FROM b LEFT JOIN a ON (b.a_id = a.id) WHERE (a.id IS NULL OR a.id > 0);
  3169. ^
  3170. -stdin-:<main>:1:44: Error: No such column: id
  3171. SELECT b.* FROM b LEFT JOIN a ON (b.a_id = a.id) WHERE (a.id IS NULL OR a.id > 0);
  3172. ^
  3173. <sql-statement>
  3174. rollback;
  3175. </sql-statement>
  3176. <sql-statement>
  3177. -- another join removal bug: this is not optimizable, either
  3178. begin;
  3179. </sql-statement>
  3180. <sql-statement>
  3181. create temp table innertab (id int8 primary key, dat1 int8);
  3182. </sql-statement>
  3183. <sql-statement>
  3184. insert into innertab values(123, 42);
  3185. </sql-statement>
  3186. <sql-statement>
  3187. SELECT * FROM
  3188. (SELECT 1 AS x) ss1
  3189. LEFT JOIN
  3190. (SELECT q1, q2, COALESCE(dat1, q1) AS y
  3191. FROM int8_tbl LEFT JOIN innertab ON q2 = id) ss2
  3192. ON true;
  3193. </sql-statement>
  3194. <sql-statement>
  3195. rollback;
  3196. </sql-statement>
  3197. <sql-statement>
  3198. -- another join removal bug: we must clean up correctly when removing a PHV
  3199. begin;
  3200. </sql-statement>
  3201. <sql-statement>
  3202. create temp table uniquetbl (f1 text unique);
  3203. </sql-statement>
  3204. <sql-statement>
  3205. explain (costs off)
  3206. select t1.* from
  3207. uniquetbl as t1
  3208. left join (select *, '***'::text as d1 from uniquetbl) t2
  3209. on t1.f1 = t2.f1
  3210. left join uniquetbl t3
  3211. on t2.d1 = t3.f1;
  3212. </sql-statement>
  3213. -stdin-:<main>: Error: Parse Sql
  3214. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3215. explain (costs off)
  3216. ^
  3217. <sql-statement>
  3218. explain (costs off)
  3219. select t0.*
  3220. from
  3221. text_tbl t0
  3222. left join
  3223. (select case t1.ten when 0 then 'doh!'::text else null::text end as case1,
  3224. t1.stringu2
  3225. from tenk1 t1
  3226. join int4_tbl i4 ON i4.f1 = t1.unique2
  3227. left join uniquetbl u1 ON u1.f1 = t1.string4) ss
  3228. on t0.f1 = ss.case1
  3229. where ss.stringu2 !~* ss.case1;
  3230. </sql-statement>
  3231. -stdin-:<main>: Error: Parse Sql
  3232. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3233. explain (costs off)
  3234. ^
  3235. <sql-statement>
  3236. select t0.*
  3237. from
  3238. text_tbl t0
  3239. left join
  3240. (select case t1.ten when 0 then 'doh!'::text else null::text end as case1,
  3241. t1.stringu2
  3242. from tenk1 t1
  3243. join int4_tbl i4 ON i4.f1 = t1.unique2
  3244. left join uniquetbl u1 ON u1.f1 = t1.string4) ss
  3245. on t0.f1 = ss.case1
  3246. where ss.stringu2 !~* ss.case1;
  3247. </sql-statement>
  3248. -stdin-:<main>: Error: Type annotation
  3249. -stdin-:<main>:1:1: Error: At function: PgSelect, At function: PgSetItem, At function: AssumeColumnOrder, At function: PgReplaceUnknown, At function: OrderedMap, At function: OrderedMap, At function: EquiJoin
  3250. select t0.*
  3251. ^
  3252. -stdin-:<main>:1:1: Error: Cannot compare key columns (a._alias_t1.string4 has type: pgname, b._alias_u1.f1 has type: pgtext)
  3253. select t0.*
  3254. ^
  3255. <sql-statement>
  3256. rollback;
  3257. </sql-statement>
  3258. <sql-statement>
  3259. -- test case to expose miscomputation of required relid set for a PHV
  3260. explain (verbose, costs off)
  3261. select i8.*, ss.v, t.unique2
  3262. from int8_tbl i8
  3263. left join int4_tbl i4 on i4.f1 = 1
  3264. left join lateral (select i4.f1 + 1 as v) as ss on true
  3265. left join tenk1 t on t.unique2 = ss.v
  3266. where q2 = 456;
  3267. </sql-statement>
  3268. -stdin-:<main>: Error: Parse Sql
  3269. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3270. -- test case to expose miscomputation of required relid set for a PHV
  3271. ^
  3272. <sql-statement>
  3273. select i8.*, ss.v, t.unique2
  3274. from int8_tbl i8
  3275. left join int4_tbl i4 on i4.f1 = 1
  3276. left join lateral (select i4.f1 + 1 as v) as ss on true
  3277. left join tenk1 t on t.unique2 = ss.v
  3278. where q2 = 456;
  3279. </sql-statement>
  3280. -stdin-:<main>: Error: Parse Sql
  3281. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3282. select i8.*, ss.v, t.unique2
  3283. ^
  3284. <sql-statement>
  3285. -- and check a related issue where we miscompute required relids for
  3286. -- a PHV that's been translated to a child rel
  3287. create temp table parttbl (a integer primary key) partition by range (a);
  3288. </sql-statement>
  3289. -stdin-:<main>: Error: Parse Sql
  3290. -stdin-:<main>:1:1: Error: PARTITION BY clause not supported
  3291. -- and check a related issue where we miscompute required relids for
  3292. ^
  3293. <sql-statement>
  3294. create temp table parttbl1 partition of parttbl for values from (1) to (100);
  3295. </sql-statement>
  3296. -stdin-:<main>: Error: Parse Sql
  3297. -stdin-:<main>:1:1: Error: table inheritance not supported
  3298. create temp table parttbl1 partition of parttbl for values from (1) to (100);
  3299. ^
  3300. <sql-statement>
  3301. insert into parttbl values (11), (12);
  3302. </sql-statement>
  3303. -stdin-:<main>: Fatal: Table metadata loading
  3304. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.parttbl
  3305. <sql-statement>
  3306. explain (costs off)
  3307. select * from
  3308. (select *, 12 as phv from parttbl) as ss
  3309. right join int4_tbl on true
  3310. where ss.a = ss.phv and f1 = 0;
  3311. </sql-statement>
  3312. -stdin-:<main>: Error: Parse Sql
  3313. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3314. explain (costs off)
  3315. ^
  3316. <sql-statement>
  3317. select * from
  3318. (select *, 12 as phv from parttbl) as ss
  3319. right join int4_tbl on true
  3320. where ss.a = ss.phv and f1 = 0;
  3321. </sql-statement>
  3322. -stdin-:<main>: Fatal: Table metadata loading
  3323. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.parttbl
  3324. <sql-statement>
  3325. -- bug #8444: we've historically allowed duplicate aliases within aliased JOINs
  3326. select * from
  3327. int8_tbl x join (int4_tbl x cross join int4_tbl y) j on q1 = f1; -- error
  3328. </sql-statement>
  3329. -stdin-:<main>: Error: Parse Sql
  3330. -stdin-:<main>:1:1: Error: JoinExpr: unsupported alias
  3331. -- bug #8444: we've historically allowed duplicate aliases within aliased JOINs
  3332. ^
  3333. <sql-statement>
  3334. select * from
  3335. int8_tbl x join (int4_tbl x cross join int4_tbl y) j on q1 = y.f1; -- error
  3336. </sql-statement>
  3337. -stdin-:<main>: Error: Parse Sql
  3338. -stdin-:<main>:1:1: Error: JoinExpr: unsupported alias
  3339. select * from
  3340. ^
  3341. <sql-statement>
  3342. select * from
  3343. int8_tbl x join (int4_tbl x cross join int4_tbl y(ff)) j on q1 = f1; -- ok
  3344. </sql-statement>
  3345. -stdin-:<main>: Error: Parse Sql
  3346. -stdin-:<main>:1:1: Error: JoinExpr: unsupported alias
  3347. select * from
  3348. ^
  3349. <sql-statement>
  3350. --
  3351. -- Test hints given on incorrect column references are useful
  3352. --
  3353. select t1.uunique1 from
  3354. tenk1 t1 join tenk2 t2 on t1.two = t2.two; -- error, prefer "t1" suggestion
  3355. </sql-statement>
  3356. -stdin-:<main>: Error: Type annotation
  3357. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  3358. --
  3359. ^
  3360. -stdin-:<main>:4:8: Error: No such column: uunique1
  3361. select t1.uunique1 from
  3362. ^
  3363. <sql-statement>
  3364. select t2.uunique1 from
  3365. tenk1 t1 join tenk2 t2 on t1.two = t2.two; -- error, prefer "t2" suggestion
  3366. </sql-statement>
  3367. -stdin-:<main>: Error: Type annotation
  3368. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  3369. select t2.uunique1 from
  3370. ^
  3371. -stdin-:<main>:1:8: Error: No such column: uunique1
  3372. select t2.uunique1 from
  3373. ^
  3374. <sql-statement>
  3375. select uunique1 from
  3376. tenk1 t1 join tenk2 t2 on t1.two = t2.two; -- error, suggest both at once
  3377. </sql-statement>
  3378. -stdin-:<main>: Error: Type annotation
  3379. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  3380. select uunique1 from
  3381. ^
  3382. -stdin-:<main>:1:8: Error: No such column: uunique1
  3383. select uunique1 from
  3384. ^
  3385. <sql-statement>
  3386. --
  3387. -- Take care to reference the correct RTE
  3388. --
  3389. select atts.relid::regclass, s.* from pg_stats s join
  3390. pg_attribute a on s.attname = a.attname and s.tablename =
  3391. a.attrelid::regclass::text join (select unnest(indkey) attnum,
  3392. indexrelid from pg_index i) atts on atts.attnum = a.attnum where
  3393. schemaname != 'pg_catalog';
  3394. </sql-statement>
  3395. -stdin-:<main>: Error: Parse Sql
  3396. -stdin-:<main>:6:45: Error: Generator functions are not allowed in: SELECT
  3397. a.attrelid::regclass::text join (select unnest(indkey) attnum,
  3398. ^
  3399. -stdin-:<main>: Error: Type annotation
  3400. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  3401. --
  3402. ^
  3403. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  3404. --
  3405. ^
  3406. <sql-statement>
  3407. --
  3408. -- Test LATERAL
  3409. --
  3410. select unique2, x.*
  3411. from tenk1 a, lateral (select * from int4_tbl b where f1 = a.unique1) x;
  3412. </sql-statement>
  3413. -stdin-:<main>: Error: Parse Sql
  3414. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3415. --
  3416. ^
  3417. <sql-statement>
  3418. explain (costs off)
  3419. select unique2, x.*
  3420. from tenk1 a, lateral (select * from int4_tbl b where f1 = a.unique1) x;
  3421. </sql-statement>
  3422. -stdin-:<main>: Error: Parse Sql
  3423. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3424. explain (costs off)
  3425. ^
  3426. <sql-statement>
  3427. select unique2, x.*
  3428. from int4_tbl x, lateral (select unique2 from tenk1 where f1 = unique1) ss;
  3429. </sql-statement>
  3430. -stdin-:<main>: Error: Parse Sql
  3431. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3432. select unique2, x.*
  3433. ^
  3434. <sql-statement>
  3435. explain (costs off)
  3436. select unique2, x.*
  3437. from int4_tbl x, lateral (select unique2 from tenk1 where f1 = unique1) ss;
  3438. </sql-statement>
  3439. -stdin-:<main>: Error: Parse Sql
  3440. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3441. explain (costs off)
  3442. ^
  3443. <sql-statement>
  3444. explain (costs off)
  3445. select unique2, x.*
  3446. from int4_tbl x cross join lateral (select unique2 from tenk1 where f1 = unique1) ss;
  3447. </sql-statement>
  3448. -stdin-:<main>: Error: Parse Sql
  3449. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3450. explain (costs off)
  3451. ^
  3452. <sql-statement>
  3453. select unique2, x.*
  3454. from int4_tbl x left join lateral (select unique1, unique2 from tenk1 where f1 = unique1) ss on true;
  3455. </sql-statement>
  3456. -stdin-:<main>: Error: Parse Sql
  3457. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3458. select unique2, x.*
  3459. ^
  3460. <sql-statement>
  3461. explain (costs off)
  3462. select unique2, x.*
  3463. from int4_tbl x left join lateral (select unique1, unique2 from tenk1 where f1 = unique1) ss on true;
  3464. </sql-statement>
  3465. -stdin-:<main>: Error: Parse Sql
  3466. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3467. explain (costs off)
  3468. ^
  3469. <sql-statement>
  3470. -- check scoping of lateral versus parent references
  3471. -- the first of these should return int8_tbl.q2, the second int8_tbl.q1
  3472. select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl;
  3473. </sql-statement>
  3474. -stdin-:<main>: Error: Type annotation
  3475. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
  3476. -- check scoping of lateral versus parent references
  3477. ^
  3478. -stdin-:<main>:3:11: Error: At function: PgSubLink, At function: PgSelect
  3479. select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl;
  3480. ^
  3481. -stdin-:<main>:3:11: Error: At function: PgSetItem, At function: PgSelect, At function: PgSetItem
  3482. select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl;
  3483. ^
  3484. -stdin-:<main>:3:34: Error: Column reference can't be used without FROM
  3485. select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl;
  3486. ^
  3487. -stdin-:<main>:3:11: Error: At function: PgSelect, At function: PgSetItem
  3488. select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl;
  3489. ^
  3490. -stdin-:<main>:3:55: Error: Column reference can't be used without FROM
  3491. select *, (select r from (select q1 as q2) x, (select q2 as r) y) from int8_tbl;
  3492. ^
  3493. <sql-statement>
  3494. select *, (select r from (select q1 as q2) x, lateral (select q2 as r) y) from int8_tbl;
  3495. </sql-statement>
  3496. -stdin-:<main>: Error: Parse Sql
  3497. -stdin-:<main>:1:11: Error: RangeSubselect: unsupported lateral
  3498. select *, (select r from (select q1 as q2) x, lateral (select q2 as r) y) from int8_tbl;
  3499. ^
  3500. <sql-statement>
  3501. -- lateral with function in FROM
  3502. select count(*) from tenk1 a, lateral generate_series(1,two) g;
  3503. </sql-statement>
  3504. -stdin-:<main>: Error: Parse Sql
  3505. -stdin-:<main>:1:1: Error: RangeFunction: unsupported lateral
  3506. -- lateral with function in FROM
  3507. ^
  3508. <sql-statement>
  3509. explain (costs off)
  3510. select count(*) from tenk1 a, lateral generate_series(1,two) g;
  3511. </sql-statement>
  3512. -stdin-:<main>: Error: Parse Sql
  3513. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3514. explain (costs off)
  3515. ^
  3516. <sql-statement>
  3517. explain (costs off)
  3518. select count(*) from tenk1 a cross join lateral generate_series(1,two) g;
  3519. </sql-statement>
  3520. -stdin-:<main>: Error: Parse Sql
  3521. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3522. explain (costs off)
  3523. ^
  3524. <sql-statement>
  3525. -- don't need the explicit LATERAL keyword for functions
  3526. explain (costs off)
  3527. select count(*) from tenk1 a, generate_series(1,two) g;
  3528. </sql-statement>
  3529. -stdin-:<main>: Error: Parse Sql
  3530. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3531. -- don't need the explicit LATERAL keyword for functions
  3532. ^
  3533. <sql-statement>
  3534. -- lateral with UNION ALL subselect
  3535. explain (costs off)
  3536. select * from generate_series(100,200) g,
  3537. lateral (select * from int8_tbl a where g = q1 union all
  3538. select * from int8_tbl b where g = q2) ss;
  3539. </sql-statement>
  3540. -stdin-:<main>: Error: Parse Sql
  3541. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3542. -- lateral with UNION ALL subselect
  3543. ^
  3544. <sql-statement>
  3545. select * from generate_series(100,200) g,
  3546. lateral (select * from int8_tbl a where g = q1 union all
  3547. select * from int8_tbl b where g = q2) ss;
  3548. </sql-statement>
  3549. -stdin-:<main>: Error: Parse Sql
  3550. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3551. select * from generate_series(100,200) g,
  3552. ^
  3553. <sql-statement>
  3554. -- lateral with VALUES
  3555. explain (costs off)
  3556. select count(*) from tenk1 a,
  3557. tenk1 b join lateral (values(a.unique1)) ss(x) on b.unique2 = ss.x;
  3558. </sql-statement>
  3559. -stdin-:<main>: Error: Parse Sql
  3560. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3561. -- lateral with VALUES
  3562. ^
  3563. <sql-statement>
  3564. select count(*) from tenk1 a,
  3565. tenk1 b join lateral (values(a.unique1)) ss(x) on b.unique2 = ss.x;
  3566. </sql-statement>
  3567. -stdin-:<main>: Error: Parse Sql
  3568. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3569. select count(*) from tenk1 a,
  3570. ^
  3571. <sql-statement>
  3572. -- lateral with VALUES, no flattening possible
  3573. explain (costs off)
  3574. select count(*) from tenk1 a,
  3575. tenk1 b join lateral (values(a.unique1),(-1)) ss(x) on b.unique2 = ss.x;
  3576. </sql-statement>
  3577. -stdin-:<main>: Error: Parse Sql
  3578. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3579. -- lateral with VALUES, no flattening possible
  3580. ^
  3581. <sql-statement>
  3582. select count(*) from tenk1 a,
  3583. tenk1 b join lateral (values(a.unique1),(-1)) ss(x) on b.unique2 = ss.x;
  3584. </sql-statement>
  3585. -stdin-:<main>: Error: Parse Sql
  3586. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3587. select count(*) from tenk1 a,
  3588. ^
  3589. <sql-statement>
  3590. -- lateral injecting a strange outer join condition
  3591. explain (costs off)
  3592. select * from int8_tbl a,
  3593. int8_tbl x left join lateral (select a.q1 from int4_tbl y) ss(z)
  3594. on x.q2 = ss.z
  3595. order by a.q1, a.q2, x.q1, x.q2, ss.z;
  3596. </sql-statement>
  3597. -stdin-:<main>: Error: Parse Sql
  3598. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3599. -- lateral injecting a strange outer join condition
  3600. ^
  3601. <sql-statement>
  3602. select * from int8_tbl a,
  3603. int8_tbl x left join lateral (select a.q1 from int4_tbl y) ss(z)
  3604. on x.q2 = ss.z
  3605. order by a.q1, a.q2, x.q1, x.q2, ss.z;
  3606. </sql-statement>
  3607. -stdin-:<main>: Error: Parse Sql
  3608. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3609. select * from int8_tbl a,
  3610. ^
  3611. <sql-statement>
  3612. -- lateral reference to a join alias variable
  3613. select * from (select f1/2 as x from int4_tbl) ss1 join int4_tbl i4 on x = f1,
  3614. lateral (select x) ss2(y);
  3615. </sql-statement>
  3616. -stdin-:<main>: Error: Parse Sql
  3617. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3618. -- lateral reference to a join alias variable
  3619. ^
  3620. <sql-statement>
  3621. select * from (select f1 as x from int4_tbl) ss1 join int4_tbl i4 on x = f1,
  3622. lateral (values(x)) ss2(y);
  3623. </sql-statement>
  3624. -stdin-:<main>: Error: Parse Sql
  3625. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3626. select * from (select f1 as x from int4_tbl) ss1 join int4_tbl i4 on x = f1,
  3627. ^
  3628. <sql-statement>
  3629. select * from ((select f1/2 as x from int4_tbl) ss1 join int4_tbl i4 on x = f1) j,
  3630. lateral (select x) ss2(y);
  3631. </sql-statement>
  3632. -stdin-:<main>: Error: Parse Sql
  3633. -stdin-:<main>:1:1: Error: JoinExpr: unsupported alias
  3634. select * from ((select f1/2 as x from int4_tbl) ss1 join int4_tbl i4 on x = f1) j,
  3635. ^
  3636. <sql-statement>
  3637. -- lateral references requiring pullup
  3638. select * from (values(1)) x(lb),
  3639. lateral generate_series(lb,4) x4;
  3640. </sql-statement>
  3641. -stdin-:<main>: Error: Parse Sql
  3642. -stdin-:<main>:1:1: Error: RangeFunction: unsupported lateral
  3643. -- lateral references requiring pullup
  3644. ^
  3645. <sql-statement>
  3646. select * from (select f1/1000000000 from int4_tbl) x(lb),
  3647. lateral generate_series(lb,4) x4;
  3648. </sql-statement>
  3649. -stdin-:<main>: Error: Parse Sql
  3650. -stdin-:<main>:1:1: Error: RangeFunction: unsupported lateral
  3651. select * from (select f1/1000000000 from int4_tbl) x(lb),
  3652. ^
  3653. <sql-statement>
  3654. select * from (values(1)) x(lb),
  3655. lateral (values(lb)) y(lbcopy);
  3656. </sql-statement>
  3657. -stdin-:<main>: Error: Parse Sql
  3658. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3659. select * from (values(1)) x(lb),
  3660. ^
  3661. <sql-statement>
  3662. select * from (values(1)) x(lb),
  3663. lateral (select lb from int4_tbl) y(lbcopy);
  3664. </sql-statement>
  3665. -stdin-:<main>: Error: Parse Sql
  3666. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3667. select * from (values(1)) x(lb),
  3668. ^
  3669. <sql-statement>
  3670. select * from
  3671. int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1,
  3672. lateral (values(x.q1,y.q1,y.q2)) v(xq1,yq1,yq2);
  3673. </sql-statement>
  3674. -stdin-:<main>: Error: Parse Sql
  3675. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3676. select * from
  3677. ^
  3678. <sql-statement>
  3679. select * from
  3680. int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1,
  3681. lateral (select x.q1,y.q1,y.q2) v(xq1,yq1,yq2);
  3682. </sql-statement>
  3683. -stdin-:<main>: Error: Parse Sql
  3684. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3685. select * from
  3686. ^
  3687. <sql-statement>
  3688. select x.* from
  3689. int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1,
  3690. lateral (select x.q1,y.q1,y.q2) v(xq1,yq1,yq2);
  3691. </sql-statement>
  3692. -stdin-:<main>: Error: Parse Sql
  3693. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3694. select x.* from
  3695. ^
  3696. <sql-statement>
  3697. select v.* from
  3698. (int8_tbl x left join (select q1,coalesce(q2,0) q2 from int8_tbl) y on x.q2 = y.q1)
  3699. left join int4_tbl z on z.f1 = x.q2,
  3700. lateral (select x.q1,y.q1 union all select x.q2,y.q2) v(vx,vy);
  3701. </sql-statement>
  3702. -stdin-:<main>: Error: Parse Sql
  3703. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3704. select v.* from
  3705. ^
  3706. <sql-statement>
  3707. select v.* from
  3708. (int8_tbl x left join (select q1,(select coalesce(q2,0)) q2 from int8_tbl) y on x.q2 = y.q1)
  3709. left join int4_tbl z on z.f1 = x.q2,
  3710. lateral (select x.q1,y.q1 union all select x.q2,y.q2) v(vx,vy);
  3711. </sql-statement>
  3712. -stdin-:<main>: Error: Parse Sql
  3713. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3714. select v.* from
  3715. ^
  3716. <sql-statement>
  3717. select v.* from
  3718. (int8_tbl x left join (select q1,(select coalesce(q2,0)) q2 from int8_tbl) y on x.q2 = y.q1)
  3719. left join int4_tbl z on z.f1 = x.q2,
  3720. lateral (select x.q1,y.q1 from onerow union all select x.q2,y.q2 from onerow) v(vx,vy);
  3721. </sql-statement>
  3722. -stdin-:<main>: Error: Parse Sql
  3723. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3724. select v.* from
  3725. ^
  3726. <sql-statement>
  3727. explain (verbose, costs off)
  3728. select * from
  3729. int8_tbl a left join
  3730. lateral (select *, a.q2 as x from int8_tbl b) ss on a.q2 = ss.q1;
  3731. </sql-statement>
  3732. -stdin-:<main>: Error: Parse Sql
  3733. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3734. explain (verbose, costs off)
  3735. ^
  3736. <sql-statement>
  3737. select * from
  3738. int8_tbl a left join
  3739. lateral (select *, a.q2 as x from int8_tbl b) ss on a.q2 = ss.q1;
  3740. </sql-statement>
  3741. -stdin-:<main>: Error: Parse Sql
  3742. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3743. select * from
  3744. ^
  3745. <sql-statement>
  3746. explain (verbose, costs off)
  3747. select * from
  3748. int8_tbl a left join
  3749. lateral (select *, coalesce(a.q2, 42) as x from int8_tbl b) ss on a.q2 = ss.q1;
  3750. </sql-statement>
  3751. -stdin-:<main>: Error: Parse Sql
  3752. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3753. explain (verbose, costs off)
  3754. ^
  3755. <sql-statement>
  3756. select * from
  3757. int8_tbl a left join
  3758. lateral (select *, coalesce(a.q2, 42) as x from int8_tbl b) ss on a.q2 = ss.q1;
  3759. </sql-statement>
  3760. -stdin-:<main>: Error: Parse Sql
  3761. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3762. select * from
  3763. ^
  3764. <sql-statement>
  3765. -- lateral can result in join conditions appearing below their
  3766. -- real semantic level
  3767. explain (verbose, costs off)
  3768. select * from int4_tbl i left join
  3769. lateral (select * from int2_tbl j where i.f1 = j.f1) k on true;
  3770. </sql-statement>
  3771. -stdin-:<main>: Error: Parse Sql
  3772. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3773. -- lateral can result in join conditions appearing below their
  3774. ^
  3775. <sql-statement>
  3776. select * from int4_tbl i left join
  3777. lateral (select * from int2_tbl j where i.f1 = j.f1) k on true;
  3778. </sql-statement>
  3779. -stdin-:<main>: Error: Parse Sql
  3780. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3781. select * from int4_tbl i left join
  3782. ^
  3783. <sql-statement>
  3784. explain (verbose, costs off)
  3785. select * from int4_tbl i left join
  3786. lateral (select coalesce(i) from int2_tbl j where i.f1 = j.f1) k on true;
  3787. </sql-statement>
  3788. -stdin-:<main>: Error: Parse Sql
  3789. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3790. explain (verbose, costs off)
  3791. ^
  3792. <sql-statement>
  3793. select * from int4_tbl i left join
  3794. lateral (select coalesce(i) from int2_tbl j where i.f1 = j.f1) k on true;
  3795. </sql-statement>
  3796. -stdin-:<main>: Error: Parse Sql
  3797. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3798. select * from int4_tbl i left join
  3799. ^
  3800. <sql-statement>
  3801. explain (verbose, costs off)
  3802. select * from int4_tbl a,
  3803. lateral (
  3804. select * from int4_tbl b left join int8_tbl c on (b.f1 = q1 and a.f1 = q2)
  3805. ) ss;
  3806. </sql-statement>
  3807. -stdin-:<main>: Error: Parse Sql
  3808. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3809. explain (verbose, costs off)
  3810. ^
  3811. <sql-statement>
  3812. select * from int4_tbl a,
  3813. lateral (
  3814. select * from int4_tbl b left join int8_tbl c on (b.f1 = q1 and a.f1 = q2)
  3815. ) ss;
  3816. </sql-statement>
  3817. -stdin-:<main>: Error: Parse Sql
  3818. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3819. select * from int4_tbl a,
  3820. ^
  3821. <sql-statement>
  3822. -- lateral reference in a PlaceHolderVar evaluated at join level
  3823. explain (verbose, costs off)
  3824. select * from
  3825. int8_tbl a left join lateral
  3826. (select b.q1 as bq1, c.q1 as cq1, least(a.q1,b.q1,c.q1) from
  3827. int8_tbl b cross join int8_tbl c) ss
  3828. on a.q2 = ss.bq1;
  3829. </sql-statement>
  3830. -stdin-:<main>: Error: Parse Sql
  3831. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3832. -- lateral reference in a PlaceHolderVar evaluated at join level
  3833. ^
  3834. <sql-statement>
  3835. select * from
  3836. int8_tbl a left join lateral
  3837. (select b.q1 as bq1, c.q1 as cq1, least(a.q1,b.q1,c.q1) from
  3838. int8_tbl b cross join int8_tbl c) ss
  3839. on a.q2 = ss.bq1;
  3840. </sql-statement>
  3841. -stdin-:<main>: Error: Parse Sql
  3842. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3843. select * from
  3844. ^
  3845. <sql-statement>
  3846. -- case requiring nested PlaceHolderVars
  3847. explain (verbose, costs off)
  3848. select * from
  3849. int8_tbl c left join (
  3850. int8_tbl a left join (select q1, coalesce(q2,42) as x from int8_tbl b) ss1
  3851. on a.q2 = ss1.q1
  3852. cross join
  3853. lateral (select q1, coalesce(ss1.x,q2) as y from int8_tbl d) ss2
  3854. ) on c.q2 = ss2.q1,
  3855. lateral (select ss2.y offset 0) ss3;
  3856. </sql-statement>
  3857. -stdin-:<main>: Error: Parse Sql
  3858. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3859. -- case requiring nested PlaceHolderVars
  3860. ^
  3861. <sql-statement>
  3862. -- case that breaks the old ph_may_need optimization
  3863. explain (verbose, costs off)
  3864. select c.*,a.*,ss1.q1,ss2.q1,ss3.* from
  3865. int8_tbl c left join (
  3866. int8_tbl a left join
  3867. (select q1, coalesce(q2,f1) as x from int8_tbl b, int4_tbl b2
  3868. where q1 < f1) ss1
  3869. on a.q2 = ss1.q1
  3870. cross join
  3871. lateral (select q1, coalesce(ss1.x,q2) as y from int8_tbl d) ss2
  3872. ) on c.q2 = ss2.q1,
  3873. lateral (select * from int4_tbl i where ss2.y > f1) ss3;
  3874. </sql-statement>
  3875. -stdin-:<main>: Error: Parse Sql
  3876. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3877. -- case that breaks the old ph_may_need optimization
  3878. ^
  3879. <sql-statement>
  3880. -- check processing of postponed quals (bug #9041)
  3881. explain (verbose, costs off)
  3882. select * from
  3883. (select 1 as x offset 0) x cross join (select 2 as y offset 0) y
  3884. left join lateral (
  3885. select * from (select 3 as z offset 0) z where z.z = x.x
  3886. ) zz on zz.z = y.y;
  3887. </sql-statement>
  3888. -stdin-:<main>: Error: Parse Sql
  3889. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3890. -- check processing of postponed quals (bug #9041)
  3891. ^
  3892. <sql-statement>
  3893. -- check dummy rels with lateral references (bug #15694)
  3894. explain (verbose, costs off)
  3895. select * from int8_tbl i8 left join lateral
  3896. (select *, i8.q2 from int4_tbl where false) ss on true;
  3897. </sql-statement>
  3898. -stdin-:<main>: Error: Parse Sql
  3899. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3900. -- check dummy rels with lateral references (bug #15694)
  3901. ^
  3902. <sql-statement>
  3903. explain (verbose, costs off)
  3904. select * from int8_tbl i8 left join lateral
  3905. (select *, i8.q2 from int4_tbl i1, int4_tbl i2 where false) ss on true;
  3906. </sql-statement>
  3907. -stdin-:<main>: Error: Parse Sql
  3908. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3909. explain (verbose, costs off)
  3910. ^
  3911. <sql-statement>
  3912. -- check handling of nested appendrels inside LATERAL
  3913. select * from
  3914. ((select 2 as v) union all (select 3 as v)) as q1
  3915. cross join lateral
  3916. ((select * from
  3917. ((select 4 as v) union all (select 5 as v)) as q3)
  3918. union all
  3919. (select q1.v)
  3920. ) as q2;
  3921. </sql-statement>
  3922. -stdin-:<main>: Error: Parse Sql
  3923. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3924. -- check handling of nested appendrels inside LATERAL
  3925. ^
  3926. <sql-statement>
  3927. -- check the number of columns specified
  3928. SELECT * FROM (int8_tbl i cross join int4_tbl j) ss(a,b,c,d);
  3929. </sql-statement>
  3930. -stdin-:<main>: Error: Parse Sql
  3931. -stdin-:<main>:1:1: Error: JoinExpr: unsupported alias
  3932. -- check the number of columns specified
  3933. ^
  3934. <sql-statement>
  3935. -- check we don't try to do a unique-ified semijoin with LATERAL
  3936. explain (verbose, costs off)
  3937. select * from
  3938. (values (0,9998), (1,1000)) v(id,x),
  3939. lateral (select f1 from int4_tbl
  3940. where f1 = any (select unique1 from tenk1
  3941. where unique2 = v.x offset 0)) ss;
  3942. </sql-statement>
  3943. -stdin-:<main>: Error: Parse Sql
  3944. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3945. -- check we don't try to do a unique-ified semijoin with LATERAL
  3946. ^
  3947. <sql-statement>
  3948. select * from
  3949. (values (0,9998), (1,1000)) v(id,x),
  3950. lateral (select f1 from int4_tbl
  3951. where f1 = any (select unique1 from tenk1
  3952. where unique2 = v.x offset 0)) ss;
  3953. </sql-statement>
  3954. -stdin-:<main>: Error: Parse Sql
  3955. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3956. select * from
  3957. ^
  3958. <sql-statement>
  3959. -- check proper extParam/allParam handling (this isn't exactly a LATERAL issue,
  3960. -- but we can make the test case much more compact with LATERAL)
  3961. explain (verbose, costs off)
  3962. select * from (values (0), (1)) v(id),
  3963. lateral (select * from int8_tbl t1,
  3964. lateral (select * from
  3965. (select * from int8_tbl t2
  3966. where q1 = any (select q2 from int8_tbl t3
  3967. where q2 = (select greatest(t1.q1,t2.q2))
  3968. and (select v.id=0)) offset 0) ss2) ss
  3969. where t1.q1 = ss.q2) ss0;
  3970. </sql-statement>
  3971. -stdin-:<main>: Error: Parse Sql
  3972. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  3973. -- check proper extParam/allParam handling (this isn't exactly a LATERAL issue,
  3974. ^
  3975. <sql-statement>
  3976. select * from (values (0), (1)) v(id),
  3977. lateral (select * from int8_tbl t1,
  3978. lateral (select * from
  3979. (select * from int8_tbl t2
  3980. where q1 = any (select q2 from int8_tbl t3
  3981. where q2 = (select greatest(t1.q1,t2.q2))
  3982. and (select v.id=0)) offset 0) ss2) ss
  3983. where t1.q1 = ss.q2) ss0;
  3984. </sql-statement>
  3985. -stdin-:<main>: Error: Parse Sql
  3986. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  3987. select * from (values (0), (1)) v(id),
  3988. ^
  3989. <sql-statement>
  3990. -- test some error cases where LATERAL should have been used but wasn't
  3991. select f1,g from int4_tbl a, (select f1 as g) ss;
  3992. </sql-statement>
  3993. -stdin-:<main>: Error: Type annotation
  3994. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgSelect, At function: PgSetItem
  3995. -- test some error cases where LATERAL should have been used but wasn't
  3996. ^
  3997. -stdin-:<main>:2:38: Error: Column reference can't be used without FROM
  3998. select f1,g from int4_tbl a, (select f1 as g) ss;
  3999. ^
  4000. <sql-statement>
  4001. select f1,g from int4_tbl a, (select a.f1 as g) ss;
  4002. </sql-statement>
  4003. -stdin-:<main>: Error: Type annotation
  4004. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgSelect, At function: PgSetItem
  4005. select f1,g from int4_tbl a, (select a.f1 as g) ss;
  4006. ^
  4007. -stdin-:<main>:1:38: Error: Column reference can't be used without FROM
  4008. select f1,g from int4_tbl a, (select a.f1 as g) ss;
  4009. ^
  4010. <sql-statement>
  4011. select f1,g from int4_tbl a cross join (select f1 as g) ss;
  4012. </sql-statement>
  4013. -stdin-:<main>: Error: Type annotation
  4014. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgSelect, At function: PgSetItem
  4015. select f1,g from int4_tbl a cross join (select f1 as g) ss;
  4016. ^
  4017. -stdin-:<main>:1:48: Error: Column reference can't be used without FROM
  4018. select f1,g from int4_tbl a cross join (select f1 as g) ss;
  4019. ^
  4020. <sql-statement>
  4021. select f1,g from int4_tbl a cross join (select a.f1 as g) ss;
  4022. </sql-statement>
  4023. -stdin-:<main>: Error: Type annotation
  4024. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgSelect, At function: PgSetItem
  4025. select f1,g from int4_tbl a cross join (select a.f1 as g) ss;
  4026. ^
  4027. -stdin-:<main>:1:48: Error: Column reference can't be used without FROM
  4028. select f1,g from int4_tbl a cross join (select a.f1 as g) ss;
  4029. ^
  4030. <sql-statement>
  4031. -- SQL:2008 says the left table is in scope but illegal to access here
  4032. select f1,g from int4_tbl a right join lateral generate_series(0, a.f1) g on true;
  4033. </sql-statement>
  4034. -stdin-:<main>: Error: Parse Sql
  4035. -stdin-:<main>:1:1: Error: RangeFunction: unsupported lateral
  4036. -- SQL:2008 says the left table is in scope but illegal to access here
  4037. ^
  4038. <sql-statement>
  4039. select f1,g from int4_tbl a full join lateral generate_series(0, a.f1) g on true;
  4040. </sql-statement>
  4041. -stdin-:<main>: Error: Parse Sql
  4042. -stdin-:<main>:1:1: Error: RangeFunction: unsupported lateral
  4043. select f1,g from int4_tbl a full join lateral generate_series(0, a.f1) g on true;
  4044. ^
  4045. <sql-statement>
  4046. -- check we complain about ambiguous table references
  4047. select * from
  4048. int8_tbl x cross join (int4_tbl x cross join lateral (select x.f1) ss);
  4049. </sql-statement>
  4050. -stdin-:<main>: Error: Parse Sql
  4051. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  4052. -- check we complain about ambiguous table references
  4053. ^
  4054. <sql-statement>
  4055. -- LATERAL can be used to put an aggregate into the FROM clause of its query
  4056. select 1 from tenk1 a, lateral (select max(a.unique1) from int4_tbl b) ss;
  4057. </sql-statement>
  4058. -stdin-:<main>: Error: Parse Sql
  4059. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  4060. -- LATERAL can be used to put an aggregate into the FROM clause of its query
  4061. ^
  4062. <sql-statement>
  4063. -- check behavior of LATERAL in UPDATE/DELETE
  4064. create temp table xx1 as select f1 as x1, -f1 as x2 from int4_tbl;
  4065. </sql-statement>
  4066. -stdin-:<main>: Error: Parse Sql
  4067. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
  4068. -- check behavior of LATERAL in UPDATE/DELETE
  4069. ^
  4070. <sql-statement>
  4071. -- error, can't do this:
  4072. update xx1 set x2 = f1 from (select * from int4_tbl where f1 = x1) ss;
  4073. </sql-statement>
  4074. -stdin-:<main>: Fatal: Pre type annotation
  4075. -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_update' not found in enum NYql::EYtSettingType. Valid options are: 'initial', 'infer_scheme', 'force_infer_schema', 'do_not_fail_on_invalid_schema', 'direct_read', 'view', 'mode', 'scheme', 'weak_concat', 'anonymous', 'with_qb', 'inline', 'sample', 'joinLabel', 'ignore_non_existing', 'warn_non_existing', 'xlock', 'unordered', 'nonUnique', 'userschema', 'usercolumns', 'statcolumns', 'syscolumns', 'ignoretypev3', 'memUsage', 'itemsCount', 'rowFactor', 'ordered', 'keyFilter', 'keyFilter2', 'take', 'skip', 'limit', 'sortLimitBy', 'sortBy', 'reduceBy', 'reduceFilterBy', 'forceTransform', 'weakFields', 'sharded', 'combineChunks', 'jobCount', 'joinReduce', 'firstAsPrimary', 'flow', 'keepSorted', 'keySwitch', 'uniqueBy', 'opHash', 'mapOutputType', 'reduceInputType', 'noDq', 'split', 'compression_codec', 'erasure_codec', 'expiration', 'replication_factor', 'user_attrs', 'media', 'primary_medium', 'keep_meta', 'monotonic_keys', 'mutationid'.
  4076. <sql-statement>
  4077. update xx1 set x2 = f1 from (select * from int4_tbl where f1 = xx1.x1) ss;
  4078. </sql-statement>
  4079. -stdin-:<main>: Fatal: Pre type annotation
  4080. -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_update' not found in enum NYql::EYtSettingType. Valid options are: 'initial', 'infer_scheme', 'force_infer_schema', 'do_not_fail_on_invalid_schema', 'direct_read', 'view', 'mode', 'scheme', 'weak_concat', 'anonymous', 'with_qb', 'inline', 'sample', 'joinLabel', 'ignore_non_existing', 'warn_non_existing', 'xlock', 'unordered', 'nonUnique', 'userschema', 'usercolumns', 'statcolumns', 'syscolumns', 'ignoretypev3', 'memUsage', 'itemsCount', 'rowFactor', 'ordered', 'keyFilter', 'keyFilter2', 'take', 'skip', 'limit', 'sortLimitBy', 'sortBy', 'reduceBy', 'reduceFilterBy', 'forceTransform', 'weakFields', 'sharded', 'combineChunks', 'jobCount', 'joinReduce', 'firstAsPrimary', 'flow', 'keepSorted', 'keySwitch', 'uniqueBy', 'opHash', 'mapOutputType', 'reduceInputType', 'noDq', 'split', 'compression_codec', 'erasure_codec', 'expiration', 'replication_factor', 'user_attrs', 'media', 'primary_medium', 'keep_meta', 'monotonic_keys', 'mutationid'.
  4081. <sql-statement>
  4082. -- can't do it even with LATERAL:
  4083. update xx1 set x2 = f1 from lateral (select * from int4_tbl where f1 = x1) ss;
  4084. </sql-statement>
  4085. -stdin-:<main>: Error: Parse Sql
  4086. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  4087. -- can't do it even with LATERAL:
  4088. ^
  4089. <sql-statement>
  4090. -- we might in future allow something like this, but for now it's an error:
  4091. update xx1 set x2 = f1 from xx1, lateral (select * from int4_tbl where f1 = x1) ss;
  4092. </sql-statement>
  4093. -stdin-:<main>: Error: Parse Sql
  4094. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  4095. -- we might in future allow something like this, but for now it's an error:
  4096. ^
  4097. <sql-statement>
  4098. -- also errors:
  4099. delete from xx1 using (select * from int4_tbl where f1 = x1) ss;
  4100. </sql-statement>
  4101. -stdin-:<main>: Error: Parse Sql
  4102. -stdin-:<main>:1:1: Error: using is not supported
  4103. -- also errors:
  4104. ^
  4105. <sql-statement>
  4106. delete from xx1 using (select * from int4_tbl where f1 = xx1.x1) ss;
  4107. </sql-statement>
  4108. -stdin-:<main>: Error: Parse Sql
  4109. -stdin-:<main>:1:1: Error: using is not supported
  4110. delete from xx1 using (select * from int4_tbl where f1 = xx1.x1) ss;
  4111. ^
  4112. <sql-statement>
  4113. delete from xx1 using lateral (select * from int4_tbl where f1 = x1) ss;
  4114. </sql-statement>
  4115. -stdin-:<main>: Error: Parse Sql
  4116. -stdin-:<main>:1:1: Error: using is not supported
  4117. delete from xx1 using lateral (select * from int4_tbl where f1 = x1) ss;
  4118. ^
  4119. <sql-statement>
  4120. --
  4121. -- test LATERAL reference propagation down a multi-level inheritance hierarchy
  4122. -- produced for a multi-level partitioned table hierarchy.
  4123. --
  4124. create table join_pt1 (a int, b int, c varchar) partition by range(a);
  4125. </sql-statement>
  4126. -stdin-:<main>: Error: Parse Sql
  4127. -stdin-:<main>:1:1: Error: PARTITION BY clause not supported
  4128. --
  4129. ^
  4130. <sql-statement>
  4131. create table join_pt1p1 partition of join_pt1 for values from (0) to (100) partition by range(b);
  4132. </sql-statement>
  4133. -stdin-:<main>: Error: Parse Sql
  4134. -stdin-:<main>:1:1: Error: table inheritance not supported
  4135. create table join_pt1p1 partition of join_pt1 for values from (0) to (100) partition by range(b);
  4136. ^
  4137. <sql-statement>
  4138. create table join_pt1p2 partition of join_pt1 for values from (100) to (200);
  4139. </sql-statement>
  4140. -stdin-:<main>: Error: Parse Sql
  4141. -stdin-:<main>:1:1: Error: table inheritance not supported
  4142. create table join_pt1p2 partition of join_pt1 for values from (100) to (200);
  4143. ^
  4144. <sql-statement>
  4145. create table join_pt1p1p1 partition of join_pt1p1 for values from (0) to (100);
  4146. </sql-statement>
  4147. -stdin-:<main>: Error: Parse Sql
  4148. -stdin-:<main>:1:1: Error: table inheritance not supported
  4149. create table join_pt1p1p1 partition of join_pt1p1 for values from (0) to (100);
  4150. ^
  4151. <sql-statement>
  4152. insert into join_pt1 values (1, 1, 'x'), (101, 101, 'y');
  4153. </sql-statement>
  4154. -stdin-:<main>: Fatal: Table metadata loading
  4155. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.join_pt1
  4156. <sql-statement>
  4157. create table join_ut1 (a int, b int, c varchar);
  4158. </sql-statement>
  4159. <sql-statement>
  4160. insert into join_ut1 values (101, 101, 'y'), (2, 2, 'z');
  4161. </sql-statement>
  4162. <sql-statement>
  4163. explain (verbose, costs off)
  4164. select t1.b, ss.phv from join_ut1 t1 left join lateral
  4165. (select t2.a as t2a, t3.a t3a, least(t1.a, t2.a, t3.a) phv
  4166. from join_pt1 t2 join join_ut1 t3 on t2.a = t3.b) ss
  4167. on t1.a = ss.t2a order by t1.a;
  4168. </sql-statement>
  4169. -stdin-:<main>: Error: Parse Sql
  4170. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4171. explain (verbose, costs off)
  4172. ^
  4173. <sql-statement>
  4174. select t1.b, ss.phv from join_ut1 t1 left join lateral
  4175. (select t2.a as t2a, t3.a t3a, least(t1.a, t2.a, t3.a) phv
  4176. from join_pt1 t2 join join_ut1 t3 on t2.a = t3.b) ss
  4177. on t1.a = ss.t2a order by t1.a;
  4178. </sql-statement>
  4179. -stdin-:<main>: Error: Parse Sql
  4180. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  4181. select t1.b, ss.phv from join_ut1 t1 left join lateral
  4182. ^
  4183. <sql-statement>
  4184. drop table join_pt1;
  4185. </sql-statement>
  4186. <sql-statement>
  4187. drop table join_ut1;
  4188. </sql-statement>
  4189. <sql-statement>
  4190. --
  4191. -- test estimation behavior with multi-column foreign key and constant qual
  4192. --
  4193. begin;
  4194. </sql-statement>
  4195. <sql-statement>
  4196. create table fkest (x integer, x10 integer, x10b integer, x100 integer);
  4197. </sql-statement>
  4198. <sql-statement>
  4199. insert into fkest select x, x/10, x/10, x/100 from generate_series(1,1000) x;
  4200. </sql-statement>
  4201. <sql-statement>
  4202. create unique index on fkest(x, x10, x100);
  4203. </sql-statement>
  4204. -stdin-:<main>: Error: Parse Sql
  4205. -stdin-:<main>:1:1: Error: unique index creation is not supported yet
  4206. create unique index on fkest(x, x10, x100);
  4207. ^
  4208. <sql-statement>
  4209. analyze fkest;
  4210. </sql-statement>
  4211. -stdin-:<main>: Error: Parse Sql
  4212. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  4213. analyze fkest;
  4214. ^
  4215. <sql-statement>
  4216. explain (costs off)
  4217. select * from fkest f1
  4218. join fkest f2 on (f1.x = f2.x and f1.x10 = f2.x10b and f1.x100 = f2.x100)
  4219. join fkest f3 on f1.x = f3.x
  4220. where f1.x100 = 2;
  4221. </sql-statement>
  4222. -stdin-:<main>: Error: Parse Sql
  4223. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4224. explain (costs off)
  4225. ^
  4226. <sql-statement>
  4227. alter table fkest add constraint fk
  4228. foreign key (x, x10b, x100) references fkest (x, x10, x100);
  4229. </sql-statement>
  4230. -stdin-:<main>: Error: Parse Sql
  4231. -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
  4232. alter table fkest add constraint fk
  4233. ^
  4234. <sql-statement>
  4235. explain (costs off)
  4236. select * from fkest f1
  4237. join fkest f2 on (f1.x = f2.x and f1.x10 = f2.x10b and f1.x100 = f2.x100)
  4238. join fkest f3 on f1.x = f3.x
  4239. where f1.x100 = 2;
  4240. </sql-statement>
  4241. -stdin-:<main>: Error: Parse Sql
  4242. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4243. explain (costs off)
  4244. ^
  4245. <sql-statement>
  4246. rollback;
  4247. </sql-statement>
  4248. <sql-statement>
  4249. --
  4250. -- test that foreign key join estimation performs sanely for outer joins
  4251. --
  4252. begin;
  4253. </sql-statement>
  4254. <sql-statement>
  4255. create table fkest (a int, b int, c int unique, primary key(a,b));
  4256. </sql-statement>
  4257. <sql-statement>
  4258. create table fkest1 (a int, b int, primary key(a,b));
  4259. </sql-statement>
  4260. <sql-statement>
  4261. insert into fkest select x/10, x%10, x from generate_series(1,1000) x;
  4262. </sql-statement>
  4263. <sql-statement>
  4264. insert into fkest1 select x/10, x%10 from generate_series(1,1000) x;
  4265. </sql-statement>
  4266. <sql-statement>
  4267. alter table fkest1
  4268. add constraint fkest1_a_b_fkey foreign key (a,b) references fkest;
  4269. </sql-statement>
  4270. -stdin-:<main>: Error: Parse Sql
  4271. -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
  4272. alter table fkest1
  4273. ^
  4274. <sql-statement>
  4275. analyze fkest;
  4276. </sql-statement>
  4277. -stdin-:<main>: Error: Parse Sql
  4278. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  4279. analyze fkest;
  4280. ^
  4281. <sql-statement>
  4282. analyze fkest1;
  4283. </sql-statement>
  4284. -stdin-:<main>: Error: Parse Sql
  4285. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  4286. analyze fkest1;
  4287. ^
  4288. <sql-statement>
  4289. explain (costs off)
  4290. select *
  4291. from fkest f
  4292. left join fkest1 f1 on f.a = f1.a and f.b = f1.b
  4293. left join fkest1 f2 on f.a = f2.a and f.b = f2.b
  4294. left join fkest1 f3 on f.a = f3.a and f.b = f3.b
  4295. where f.c = 1;
  4296. </sql-statement>
  4297. -stdin-:<main>: Error: Parse Sql
  4298. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4299. explain (costs off)
  4300. ^
  4301. <sql-statement>
  4302. rollback;
  4303. </sql-statement>
  4304. <sql-statement>
  4305. --
  4306. -- test planner's ability to mark joins as unique
  4307. --
  4308. create table j1 (id int primary key);
  4309. </sql-statement>
  4310. <sql-statement>
  4311. create table j2 (id int primary key);
  4312. </sql-statement>
  4313. <sql-statement>
  4314. create table j3 (id int);
  4315. </sql-statement>
  4316. <sql-statement>
  4317. insert into j1 values(1),(2),(3);
  4318. </sql-statement>
  4319. <sql-statement>
  4320. insert into j2 values(1),(2),(3);
  4321. </sql-statement>
  4322. <sql-statement>
  4323. insert into j3 values(1),(1);
  4324. </sql-statement>
  4325. <sql-statement>
  4326. analyze j1;
  4327. </sql-statement>
  4328. -stdin-:<main>: Error: Parse Sql
  4329. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  4330. analyze j1;
  4331. ^
  4332. <sql-statement>
  4333. analyze j2;
  4334. </sql-statement>
  4335. -stdin-:<main>: Error: Parse Sql
  4336. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  4337. analyze j2;
  4338. ^
  4339. <sql-statement>
  4340. analyze j3;
  4341. </sql-statement>
  4342. -stdin-:<main>: Error: Parse Sql
  4343. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  4344. analyze j3;
  4345. ^
  4346. <sql-statement>
  4347. -- ensure join is properly marked as unique
  4348. explain (verbose, costs off)
  4349. select * from j1 inner join j2 on j1.id = j2.id;
  4350. </sql-statement>
  4351. -stdin-:<main>: Error: Parse Sql
  4352. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4353. -- ensure join is properly marked as unique
  4354. ^
  4355. <sql-statement>
  4356. -- ensure join is not unique when not an equi-join
  4357. explain (verbose, costs off)
  4358. select * from j1 inner join j2 on j1.id > j2.id;
  4359. </sql-statement>
  4360. -stdin-:<main>: Error: Parse Sql
  4361. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4362. -- ensure join is not unique when not an equi-join
  4363. ^
  4364. <sql-statement>
  4365. -- ensure non-unique rel is not chosen as inner
  4366. explain (verbose, costs off)
  4367. select * from j1 inner join j3 on j1.id = j3.id;
  4368. </sql-statement>
  4369. -stdin-:<main>: Error: Parse Sql
  4370. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4371. -- ensure non-unique rel is not chosen as inner
  4372. ^
  4373. <sql-statement>
  4374. -- ensure left join is marked as unique
  4375. explain (verbose, costs off)
  4376. select * from j1 left join j2 on j1.id = j2.id;
  4377. </sql-statement>
  4378. -stdin-:<main>: Error: Parse Sql
  4379. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4380. -- ensure left join is marked as unique
  4381. ^
  4382. <sql-statement>
  4383. -- ensure right join is marked as unique
  4384. explain (verbose, costs off)
  4385. select * from j1 right join j2 on j1.id = j2.id;
  4386. </sql-statement>
  4387. -stdin-:<main>: Error: Parse Sql
  4388. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4389. -- ensure right join is marked as unique
  4390. ^
  4391. <sql-statement>
  4392. -- ensure full join is marked as unique
  4393. explain (verbose, costs off)
  4394. select * from j1 full join j2 on j1.id = j2.id;
  4395. </sql-statement>
  4396. -stdin-:<main>: Error: Parse Sql
  4397. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4398. -- ensure full join is marked as unique
  4399. ^
  4400. <sql-statement>
  4401. -- a clauseless (cross) join can't be unique
  4402. explain (verbose, costs off)
  4403. select * from j1 cross join j2;
  4404. </sql-statement>
  4405. -stdin-:<main>: Error: Parse Sql
  4406. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4407. -- a clauseless (cross) join can't be unique
  4408. ^
  4409. <sql-statement>
  4410. -- ensure a natural join is marked as unique
  4411. explain (verbose, costs off)
  4412. select * from j1 natural join j2;
  4413. </sql-statement>
  4414. -stdin-:<main>: Error: Parse Sql
  4415. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4416. -- ensure a natural join is marked as unique
  4417. ^
  4418. <sql-statement>
  4419. -- ensure a distinct clause allows the inner to become unique
  4420. explain (verbose, costs off)
  4421. select * from j1
  4422. inner join (select distinct id from j3) j3 on j1.id = j3.id;
  4423. </sql-statement>
  4424. -stdin-:<main>: Error: Parse Sql
  4425. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4426. -- ensure a distinct clause allows the inner to become unique
  4427. ^
  4428. <sql-statement>
  4429. -- ensure group by clause allows the inner to become unique
  4430. explain (verbose, costs off)
  4431. select * from j1
  4432. inner join (select id from j3 group by id) j3 on j1.id = j3.id;
  4433. </sql-statement>
  4434. -stdin-:<main>: Error: Parse Sql
  4435. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4436. -- ensure group by clause allows the inner to become unique
  4437. ^
  4438. <sql-statement>
  4439. drop table j1;
  4440. </sql-statement>
  4441. <sql-statement>
  4442. drop table j2;
  4443. </sql-statement>
  4444. <sql-statement>
  4445. drop table j3;
  4446. </sql-statement>
  4447. <sql-statement>
  4448. -- test more complex permutations of unique joins
  4449. create table j1 (id1 int, id2 int, primary key(id1,id2));
  4450. </sql-statement>
  4451. <sql-statement>
  4452. create table j2 (id1 int, id2 int, primary key(id1,id2));
  4453. </sql-statement>
  4454. <sql-statement>
  4455. create table j3 (id1 int, id2 int, primary key(id1,id2));
  4456. </sql-statement>
  4457. <sql-statement>
  4458. insert into j1 values(1,1),(1,2);
  4459. </sql-statement>
  4460. <sql-statement>
  4461. insert into j2 values(1,1);
  4462. </sql-statement>
  4463. <sql-statement>
  4464. insert into j3 values(1,1);
  4465. </sql-statement>
  4466. <sql-statement>
  4467. analyze j1;
  4468. </sql-statement>
  4469. -stdin-:<main>: Error: Parse Sql
  4470. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  4471. analyze j1;
  4472. ^
  4473. <sql-statement>
  4474. analyze j2;
  4475. </sql-statement>
  4476. -stdin-:<main>: Error: Parse Sql
  4477. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  4478. analyze j2;
  4479. ^
  4480. <sql-statement>
  4481. analyze j3;
  4482. </sql-statement>
  4483. -stdin-:<main>: Error: Parse Sql
  4484. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  4485. analyze j3;
  4486. ^
  4487. <sql-statement>
  4488. -- ensure there's no unique join when not all columns which are part of the
  4489. -- unique index are seen in the join clause
  4490. explain (verbose, costs off)
  4491. select * from j1
  4492. inner join j2 on j1.id1 = j2.id1;
  4493. </sql-statement>
  4494. -stdin-:<main>: Error: Parse Sql
  4495. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4496. -- ensure there's no unique join when not all columns which are part of the
  4497. ^
  4498. <sql-statement>
  4499. -- ensure proper unique detection with multiple join quals
  4500. explain (verbose, costs off)
  4501. select * from j1
  4502. inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2;
  4503. </sql-statement>
  4504. -stdin-:<main>: Error: Parse Sql
  4505. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4506. -- ensure proper unique detection with multiple join quals
  4507. ^
  4508. <sql-statement>
  4509. -- ensure we don't detect the join to be unique when quals are not part of the
  4510. -- join condition
  4511. explain (verbose, costs off)
  4512. select * from j1
  4513. inner join j2 on j1.id1 = j2.id1 where j1.id2 = 1;
  4514. </sql-statement>
  4515. -stdin-:<main>: Error: Parse Sql
  4516. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4517. -- ensure we don't detect the join to be unique when quals are not part of the
  4518. ^
  4519. <sql-statement>
  4520. -- as above, but for left joins.
  4521. explain (verbose, costs off)
  4522. select * from j1
  4523. left join j2 on j1.id1 = j2.id1 where j1.id2 = 1;
  4524. </sql-statement>
  4525. -stdin-:<main>: Error: Parse Sql
  4526. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4527. -- as above, but for left joins.
  4528. ^
  4529. <sql-statement>
  4530. -- validate logic in merge joins which skips mark and restore.
  4531. -- it should only do this if all quals which were used to detect the unique
  4532. -- are present as join quals, and not plain quals.
  4533. set enable_nestloop to 0;
  4534. </sql-statement>
  4535. -stdin-:<main>: Error: Parse Sql
  4536. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_nestloop
  4537. -- validate logic in merge joins which skips mark and restore.
  4538. ^
  4539. <sql-statement>
  4540. set enable_hashjoin to 0;
  4541. </sql-statement>
  4542. -stdin-:<main>: Error: Parse Sql
  4543. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashjoin
  4544. set enable_hashjoin to 0;
  4545. ^
  4546. <sql-statement>
  4547. set enable_sort to 0;
  4548. </sql-statement>
  4549. -stdin-:<main>: Error: Parse Sql
  4550. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_sort
  4551. set enable_sort to 0;
  4552. ^
  4553. <sql-statement>
  4554. -- create indexes that will be preferred over the PKs to perform the join
  4555. create index j1_id1_idx on j1 (id1) where id1 % 1000 = 1;
  4556. </sql-statement>
  4557. -stdin-:<main>: Error: Parse Sql
  4558. -stdin-:<main>:1:1: Error: partial index is not supported yet
  4559. -- create indexes that will be preferred over the PKs to perform the join
  4560. ^
  4561. <sql-statement>
  4562. create index j2_id1_idx on j2 (id1) where id1 % 1000 = 1;
  4563. </sql-statement>
  4564. -stdin-:<main>: Error: Parse Sql
  4565. -stdin-:<main>:1:1: Error: partial index is not supported yet
  4566. create index j2_id1_idx on j2 (id1) where id1 % 1000 = 1;
  4567. ^
  4568. <sql-statement>
  4569. -- need an additional row in j2, if we want j2_id1_idx to be preferred
  4570. insert into j2 values(1,2);
  4571. </sql-statement>
  4572. <sql-statement>
  4573. analyze j2;
  4574. </sql-statement>
  4575. -stdin-:<main>: Error: Parse Sql
  4576. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  4577. analyze j2;
  4578. ^
  4579. <sql-statement>
  4580. explain (costs off) select * from j1
  4581. inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
  4582. where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1;
  4583. </sql-statement>
  4584. -stdin-:<main>: Error: Parse Sql
  4585. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4586. explain (costs off) select * from j1
  4587. ^
  4588. <sql-statement>
  4589. select * from j1
  4590. inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
  4591. where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1;
  4592. </sql-statement>
  4593. -stdin-:<main>: Error: Type annotation
  4594. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  4595. select * from j1
  4596. ^
  4597. -stdin-:<main>:1:1: Error: Duplicated member: id1
  4598. select * from j1
  4599. ^
  4600. <sql-statement>
  4601. -- Exercise array keys mark/restore B-Tree code
  4602. explain (costs off) select * from j1
  4603. inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
  4604. where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 = any (array[1]);
  4605. </sql-statement>
  4606. -stdin-:<main>: Error: Parse Sql
  4607. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4608. -- Exercise array keys mark/restore B-Tree code
  4609. ^
  4610. <sql-statement>
  4611. select * from j1
  4612. inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
  4613. where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 = any (array[1]);
  4614. </sql-statement>
  4615. -stdin-:<main>: Error: Type annotation
  4616. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  4617. select * from j1
  4618. ^
  4619. -stdin-:<main>:1:1: Error: Duplicated member: id1
  4620. select * from j1
  4621. ^
  4622. <sql-statement>
  4623. -- Exercise array keys "find extreme element" B-Tree code
  4624. explain (costs off) select * from j1
  4625. inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
  4626. where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 >= any (array[1,5]);
  4627. </sql-statement>
  4628. -stdin-:<main>: Error: Parse Sql
  4629. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4630. -- Exercise array keys "find extreme element" B-Tree code
  4631. ^
  4632. <sql-statement>
  4633. select * from j1
  4634. inner join j2 on j1.id1 = j2.id1 and j1.id2 = j2.id2
  4635. where j1.id1 % 1000 = 1 and j2.id1 % 1000 = 1 and j2.id1 >= any (array[1,5]);
  4636. </sql-statement>
  4637. -stdin-:<main>: Error: Type annotation
  4638. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  4639. select * from j1
  4640. ^
  4641. -stdin-:<main>:1:1: Error: Duplicated member: id1
  4642. select * from j1
  4643. ^
  4644. <sql-statement>
  4645. reset enable_nestloop;
  4646. </sql-statement>
  4647. -stdin-:<main>: Error: Parse Sql
  4648. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  4649. reset enable_nestloop;
  4650. ^
  4651. <sql-statement>
  4652. reset enable_hashjoin;
  4653. </sql-statement>
  4654. -stdin-:<main>: Error: Parse Sql
  4655. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  4656. reset enable_hashjoin;
  4657. ^
  4658. <sql-statement>
  4659. reset enable_sort;
  4660. </sql-statement>
  4661. -stdin-:<main>: Error: Parse Sql
  4662. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  4663. reset enable_sort;
  4664. ^
  4665. <sql-statement>
  4666. drop table j1;
  4667. </sql-statement>
  4668. <sql-statement>
  4669. drop table j2;
  4670. </sql-statement>
  4671. <sql-statement>
  4672. drop table j3;
  4673. </sql-statement>
  4674. <sql-statement>
  4675. -- check that semijoin inner is not seen as unique for a portion of the outerrel
  4676. explain (verbose, costs off)
  4677. select t1.unique1, t2.hundred
  4678. from onek t1, tenk1 t2
  4679. where exists (select 1 from tenk1 t3
  4680. where t3.thousand = t1.unique1 and t3.tenthous = t2.hundred)
  4681. and t1.unique1 < 1;
  4682. </sql-statement>
  4683. -stdin-:<main>: Error: Parse Sql
  4684. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4685. -- check that semijoin inner is not seen as unique for a portion of the outerrel
  4686. ^
  4687. <sql-statement>
  4688. -- ... unless it actually is unique
  4689. create table j3 as select unique1, tenthous from onek;
  4690. </sql-statement>
  4691. -stdin-:<main>: Error: Parse Sql
  4692. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
  4693. -- ... unless it actually is unique
  4694. ^
  4695. <sql-statement>
  4696. vacuum analyze j3;
  4697. </sql-statement>
  4698. -stdin-:<main>: Error: Parse Sql
  4699. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  4700. vacuum analyze j3;
  4701. ^
  4702. <sql-statement>
  4703. create unique index on j3(unique1, tenthous);
  4704. </sql-statement>
  4705. -stdin-:<main>: Error: Parse Sql
  4706. -stdin-:<main>:1:1: Error: unique index creation is not supported yet
  4707. create unique index on j3(unique1, tenthous);
  4708. ^
  4709. <sql-statement>
  4710. explain (verbose, costs off)
  4711. select t1.unique1, t2.hundred
  4712. from onek t1, tenk1 t2
  4713. where exists (select 1 from j3
  4714. where j3.unique1 = t1.unique1 and j3.tenthous = t2.hundred)
  4715. and t1.unique1 < 1;
  4716. </sql-statement>
  4717. -stdin-:<main>: Error: Parse Sql
  4718. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  4719. explain (verbose, costs off)
  4720. ^
  4721. <sql-statement>
  4722. drop table j3;
  4723. </sql-statement>