union.err 46 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436
  1. Registering pre-existing tables
  2. int4_tbl
  3. INT4_TBL
  4. tenk1
  5. text_tbl
  6. VARCHAR_TBL
  7. float8_tbl
  8. CHAR_TBL
  9. TEXT_TBL
  10. FLOAT8_TBL
  11. varchar_tbl
  12. int8_tbl
  13. <sql-statement>
  14. --
  15. -- UNION (also INTERSECT, EXCEPT)
  16. --
  17. -- Simple UNION constructs
  18. SELECT 1 AS two UNION SELECT 2 ORDER BY 1;
  19. </sql-statement>
  20. <sql-statement>
  21. SELECT 1 AS one UNION SELECT 1 ORDER BY 1;
  22. </sql-statement>
  23. <sql-statement>
  24. SELECT 1 AS two UNION ALL SELECT 2;
  25. </sql-statement>
  26. <sql-statement>
  27. SELECT 1 AS two UNION ALL SELECT 1;
  28. </sql-statement>
  29. <sql-statement>
  30. SELECT 1 AS three UNION SELECT 2 UNION SELECT 3 ORDER BY 1;
  31. </sql-statement>
  32. <sql-statement>
  33. SELECT 1 AS two UNION SELECT 2 UNION SELECT 2 ORDER BY 1;
  34. </sql-statement>
  35. <sql-statement>
  36. SELECT 1 AS three UNION SELECT 2 UNION ALL SELECT 2 ORDER BY 1;
  37. </sql-statement>
  38. <sql-statement>
  39. SELECT 1.1 AS two UNION SELECT 2.2 ORDER BY 1;
  40. </sql-statement>
  41. <sql-statement>
  42. -- Mixed types
  43. SELECT 1.1 AS two UNION SELECT 2 ORDER BY 1;
  44. </sql-statement>
  45. <sql-statement>
  46. SELECT 1 AS two UNION SELECT 2.2 ORDER BY 1;
  47. </sql-statement>
  48. <sql-statement>
  49. SELECT 1 AS one UNION SELECT 1.0::float8 ORDER BY 1;
  50. </sql-statement>
  51. <sql-statement>
  52. SELECT 1.1 AS two UNION ALL SELECT 2 ORDER BY 1;
  53. </sql-statement>
  54. <sql-statement>
  55. SELECT 1.0::float8 AS two UNION ALL SELECT 1 ORDER BY 1;
  56. </sql-statement>
  57. <sql-statement>
  58. SELECT 1.1 AS three UNION SELECT 2 UNION SELECT 3 ORDER BY 1;
  59. </sql-statement>
  60. <sql-statement>
  61. SELECT 1.1::float8 AS two UNION SELECT 2 UNION SELECT 2.0::float8 ORDER BY 1;
  62. </sql-statement>
  63. <sql-statement>
  64. SELECT 1.1 AS three UNION SELECT 2 UNION ALL SELECT 2 ORDER BY 1;
  65. </sql-statement>
  66. <sql-statement>
  67. SELECT 1.1 AS two UNION (SELECT 2 UNION ALL SELECT 2) ORDER BY 1;
  68. </sql-statement>
  69. <sql-statement>
  70. --
  71. -- Try testing from tables...
  72. --
  73. SELECT f1 AS five FROM FLOAT8_TBL
  74. UNION
  75. SELECT f1 FROM FLOAT8_TBL
  76. ORDER BY 1;
  77. </sql-statement>
  78. <sql-statement>
  79. SELECT f1 AS ten FROM FLOAT8_TBL
  80. UNION ALL
  81. SELECT f1 FROM FLOAT8_TBL;
  82. </sql-statement>
  83. <sql-statement>
  84. SELECT f1 AS nine FROM FLOAT8_TBL
  85. UNION
  86. SELECT f1 FROM INT4_TBL
  87. ORDER BY 1;
  88. </sql-statement>
  89. <sql-statement>
  90. SELECT f1 AS ten FROM FLOAT8_TBL
  91. UNION ALL
  92. SELECT f1 FROM INT4_TBL;
  93. </sql-statement>
  94. <sql-statement>
  95. SELECT f1 AS five FROM FLOAT8_TBL
  96. WHERE f1 BETWEEN -1e6 AND 1e6
  97. UNION
  98. SELECT f1 FROM INT4_TBL
  99. WHERE f1 BETWEEN 0 AND 1000000
  100. ORDER BY 1;
  101. </sql-statement>
  102. -stdin-:<main>: Error: Type annotation
  103. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  104. SELECT f1 AS five FROM FLOAT8_TBL
  105. ^
  106. -stdin-:<main>: Error: At function: PgSetItem
  107. -stdin-:<main>:1:1: Error: At function: PgWhere
  108. SELECT f1 AS five FROM FLOAT8_TBL
  109. ^
  110. -stdin-:<main>:2:12: Error: At function: PgBetween
  111. WHERE f1 BETWEEN -1e6 AND 1e6
  112. ^
  113. -stdin-:<main>:2:12: Error: Mismatch of type of between elements: float8 and numeric
  114. WHERE f1 BETWEEN -1e6 AND 1e6
  115. ^
  116. <sql-statement>
  117. SELECT CAST(f1 AS char(4)) AS three FROM VARCHAR_TBL
  118. UNION
  119. SELECT f1 FROM CHAR_TBL
  120. ORDER BY 1;
  121. </sql-statement>
  122. <sql-statement>
  123. SELECT f1 AS three FROM VARCHAR_TBL
  124. UNION
  125. SELECT CAST(f1 AS varchar) FROM CHAR_TBL
  126. ORDER BY 1;
  127. </sql-statement>
  128. <sql-statement>
  129. SELECT f1 AS eight FROM VARCHAR_TBL
  130. UNION ALL
  131. SELECT f1 FROM CHAR_TBL;
  132. </sql-statement>
  133. <sql-statement>
  134. SELECT f1 AS five FROM TEXT_TBL
  135. UNION
  136. SELECT f1 FROM VARCHAR_TBL
  137. UNION
  138. SELECT TRIM(TRAILING FROM f1) FROM CHAR_TBL
  139. ORDER BY 1;
  140. </sql-statement>
  141. <sql-statement>
  142. --
  143. -- INTERSECT and EXCEPT
  144. --
  145. SELECT q2 FROM int8_tbl INTERSECT SELECT q1 FROM int8_tbl ORDER BY 1;
  146. </sql-statement>
  147. <sql-statement>
  148. SELECT q2 FROM int8_tbl INTERSECT ALL SELECT q1 FROM int8_tbl ORDER BY 1;
  149. </sql-statement>
  150. <sql-statement>
  151. SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1;
  152. </sql-statement>
  153. <sql-statement>
  154. SELECT q2 FROM int8_tbl EXCEPT ALL SELECT q1 FROM int8_tbl ORDER BY 1;
  155. </sql-statement>
  156. <sql-statement>
  157. SELECT q2 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q1 FROM int8_tbl ORDER BY 1;
  158. </sql-statement>
  159. <sql-statement>
  160. SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY 1;
  161. </sql-statement>
  162. <sql-statement>
  163. SELECT q1 FROM int8_tbl EXCEPT ALL SELECT q2 FROM int8_tbl ORDER BY 1;
  164. </sql-statement>
  165. <sql-statement>
  166. SELECT q1 FROM int8_tbl EXCEPT ALL SELECT DISTINCT q2 FROM int8_tbl ORDER BY 1;
  167. </sql-statement>
  168. <sql-statement>
  169. SELECT q1 FROM int8_tbl EXCEPT ALL SELECT q1 FROM int8_tbl FOR NO KEY UPDATE;
  170. </sql-statement>
  171. <sql-statement>
  172. -- nested cases
  173. (SELECT 1,2,3 UNION SELECT 4,5,6) INTERSECT SELECT 4,5,6;
  174. </sql-statement>
  175. <sql-statement>
  176. (SELECT 1,2,3 UNION SELECT 4,5,6 ORDER BY 1,2) INTERSECT SELECT 4,5,6;
  177. </sql-statement>
  178. <sql-statement>
  179. (SELECT 1,2,3 UNION SELECT 4,5,6) EXCEPT SELECT 4,5,6;
  180. </sql-statement>
  181. <sql-statement>
  182. (SELECT 1,2,3 UNION SELECT 4,5,6 ORDER BY 1,2) EXCEPT SELECT 4,5,6;
  183. </sql-statement>
  184. <sql-statement>
  185. -- exercise both hashed and sorted implementations of UNION/INTERSECT/EXCEPT
  186. set enable_hashagg to on;
  187. </sql-statement>
  188. -stdin-:<main>: Error: Parse Sql
  189. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashagg
  190. -- exercise both hashed and sorted implementations of UNION/INTERSECT/EXCEPT
  191. ^
  192. <sql-statement>
  193. explain (costs off)
  194. select count(*) from
  195. ( select unique1 from tenk1 union select fivethous from tenk1 ) ss;
  196. </sql-statement>
  197. -stdin-:<main>: Error: Parse Sql
  198. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  199. explain (costs off)
  200. ^
  201. <sql-statement>
  202. select count(*) from
  203. ( select unique1 from tenk1 union select fivethous from tenk1 ) ss;
  204. </sql-statement>
  205. <sql-statement>
  206. explain (costs off)
  207. select count(*) from
  208. ( select unique1 from tenk1 intersect select fivethous from tenk1 ) ss;
  209. </sql-statement>
  210. -stdin-:<main>: Error: Parse Sql
  211. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  212. explain (costs off)
  213. ^
  214. <sql-statement>
  215. select count(*) from
  216. ( select unique1 from tenk1 intersect select fivethous from tenk1 ) ss;
  217. </sql-statement>
  218. <sql-statement>
  219. explain (costs off)
  220. select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10;
  221. </sql-statement>
  222. -stdin-:<main>: Error: Parse Sql
  223. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  224. explain (costs off)
  225. ^
  226. <sql-statement>
  227. select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10;
  228. </sql-statement>
  229. <sql-statement>
  230. set enable_hashagg to off;
  231. </sql-statement>
  232. -stdin-:<main>: Error: Parse Sql
  233. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashagg
  234. set enable_hashagg to off;
  235. ^
  236. <sql-statement>
  237. explain (costs off)
  238. select count(*) from
  239. ( select unique1 from tenk1 union select fivethous from tenk1 ) ss;
  240. </sql-statement>
  241. -stdin-:<main>: Error: Parse Sql
  242. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  243. explain (costs off)
  244. ^
  245. <sql-statement>
  246. select count(*) from
  247. ( select unique1 from tenk1 union select fivethous from tenk1 ) ss;
  248. </sql-statement>
  249. <sql-statement>
  250. explain (costs off)
  251. select count(*) from
  252. ( select unique1 from tenk1 intersect select fivethous from tenk1 ) ss;
  253. </sql-statement>
  254. -stdin-:<main>: Error: Parse Sql
  255. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  256. explain (costs off)
  257. ^
  258. <sql-statement>
  259. select count(*) from
  260. ( select unique1 from tenk1 intersect select fivethous from tenk1 ) ss;
  261. </sql-statement>
  262. <sql-statement>
  263. explain (costs off)
  264. select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10;
  265. </sql-statement>
  266. -stdin-:<main>: Error: Parse Sql
  267. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  268. explain (costs off)
  269. ^
  270. <sql-statement>
  271. select unique1 from tenk1 except select unique2 from tenk1 where unique2 != 10;
  272. </sql-statement>
  273. <sql-statement>
  274. reset enable_hashagg;
  275. </sql-statement>
  276. -stdin-:<main>: Error: Parse Sql
  277. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  278. reset enable_hashagg;
  279. ^
  280. <sql-statement>
  281. -- non-hashable type
  282. set enable_hashagg to on;
  283. </sql-statement>
  284. -stdin-:<main>: Error: Parse Sql
  285. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashagg
  286. -- non-hashable type
  287. ^
  288. <sql-statement>
  289. explain (costs off)
  290. select x from (values (100::money), (200::money)) _(x) union select x from (values (100::money), (300::money)) _(x);
  291. </sql-statement>
  292. -stdin-:<main>: Error: Parse Sql
  293. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  294. explain (costs off)
  295. ^
  296. <sql-statement>
  297. set enable_hashagg to off;
  298. </sql-statement>
  299. -stdin-:<main>: Error: Parse Sql
  300. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashagg
  301. set enable_hashagg to off;
  302. ^
  303. <sql-statement>
  304. explain (costs off)
  305. select x from (values (100::money), (200::money)) _(x) union select x from (values (100::money), (300::money)) _(x);
  306. </sql-statement>
  307. -stdin-:<main>: Error: Parse Sql
  308. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  309. explain (costs off)
  310. ^
  311. <sql-statement>
  312. reset enable_hashagg;
  313. </sql-statement>
  314. -stdin-:<main>: Error: Parse Sql
  315. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  316. reset enable_hashagg;
  317. ^
  318. <sql-statement>
  319. -- arrays
  320. set enable_hashagg to on;
  321. </sql-statement>
  322. -stdin-:<main>: Error: Parse Sql
  323. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashagg
  324. -- arrays
  325. ^
  326. <sql-statement>
  327. explain (costs off)
  328. select x from (values (array[1, 2]), (array[1, 3])) _(x) union select x from (values (array[1, 2]), (array[1, 4])) _(x);
  329. </sql-statement>
  330. -stdin-:<main>: Error: Parse Sql
  331. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  332. explain (costs off)
  333. ^
  334. <sql-statement>
  335. select x from (values (array[1, 2]), (array[1, 3])) _(x) union select x from (values (array[1, 2]), (array[1, 4])) _(x);
  336. </sql-statement>
  337. <sql-statement>
  338. explain (costs off)
  339. select x from (values (array[1, 2]), (array[1, 3])) _(x) intersect select x from (values (array[1, 2]), (array[1, 4])) _(x);
  340. </sql-statement>
  341. -stdin-:<main>: Error: Parse Sql
  342. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  343. explain (costs off)
  344. ^
  345. <sql-statement>
  346. select x from (values (array[1, 2]), (array[1, 3])) _(x) intersect select x from (values (array[1, 2]), (array[1, 4])) _(x);
  347. </sql-statement>
  348. <sql-statement>
  349. explain (costs off)
  350. select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (values (array[1, 2]), (array[1, 4])) _(x);
  351. </sql-statement>
  352. -stdin-:<main>: Error: Parse Sql
  353. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  354. explain (costs off)
  355. ^
  356. <sql-statement>
  357. select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (values (array[1, 2]), (array[1, 4])) _(x);
  358. </sql-statement>
  359. <sql-statement>
  360. -- non-hashable type
  361. explain (costs off)
  362. select x from (values (array[100::money]), (array[200::money])) _(x) union select x from (values (array[100::money]), (array[300::money])) _(x);
  363. </sql-statement>
  364. -stdin-:<main>: Error: Parse Sql
  365. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  366. -- non-hashable type
  367. ^
  368. <sql-statement>
  369. select x from (values (array[100::money]), (array[200::money])) _(x) union select x from (values (array[100::money]), (array[300::money])) _(x);
  370. </sql-statement>
  371. -stdin-:<main>: Error: Type annotation
  372. -stdin-:<main>:1:1: Error: At function: AssumeColumnOrder, At function: AssumeColumnOrder, At function: OrderedMap, At function: OrderedFilter, At function: CountedAggregateAll
  373. select x from (values (array[100::money]), (array[200::money])) _(x) union select x from (values (array[100::money]), (array[300::money])) _(x);
  374. ^
  375. -stdin-:<main>:1:1: Error: Expected hashable and equatable type for key column: x, but got: _pgmoney
  376. select x from (values (array[100::money]), (array[200::money])) _(x) union select x from (values (array[100::money]), (array[300::money])) _(x);
  377. ^
  378. <sql-statement>
  379. set enable_hashagg to off;
  380. </sql-statement>
  381. -stdin-:<main>: Error: Parse Sql
  382. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashagg
  383. set enable_hashagg to off;
  384. ^
  385. <sql-statement>
  386. explain (costs off)
  387. select x from (values (array[1, 2]), (array[1, 3])) _(x) union select x from (values (array[1, 2]), (array[1, 4])) _(x);
  388. </sql-statement>
  389. -stdin-:<main>: Error: Parse Sql
  390. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  391. explain (costs off)
  392. ^
  393. <sql-statement>
  394. select x from (values (array[1, 2]), (array[1, 3])) _(x) union select x from (values (array[1, 2]), (array[1, 4])) _(x);
  395. </sql-statement>
  396. <sql-statement>
  397. explain (costs off)
  398. select x from (values (array[1, 2]), (array[1, 3])) _(x) intersect select x from (values (array[1, 2]), (array[1, 4])) _(x);
  399. </sql-statement>
  400. -stdin-:<main>: Error: Parse Sql
  401. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  402. explain (costs off)
  403. ^
  404. <sql-statement>
  405. select x from (values (array[1, 2]), (array[1, 3])) _(x) intersect select x from (values (array[1, 2]), (array[1, 4])) _(x);
  406. </sql-statement>
  407. <sql-statement>
  408. explain (costs off)
  409. select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (values (array[1, 2]), (array[1, 4])) _(x);
  410. </sql-statement>
  411. -stdin-:<main>: Error: Parse Sql
  412. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  413. explain (costs off)
  414. ^
  415. <sql-statement>
  416. select x from (values (array[1, 2]), (array[1, 3])) _(x) except select x from (values (array[1, 2]), (array[1, 4])) _(x);
  417. </sql-statement>
  418. <sql-statement>
  419. reset enable_hashagg;
  420. </sql-statement>
  421. -stdin-:<main>: Error: Parse Sql
  422. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  423. reset enable_hashagg;
  424. ^
  425. <sql-statement>
  426. -- records
  427. set enable_hashagg to on;
  428. </sql-statement>
  429. -stdin-:<main>: Error: Parse Sql
  430. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashagg
  431. -- records
  432. ^
  433. <sql-statement>
  434. explain (costs off)
  435. select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x);
  436. </sql-statement>
  437. -stdin-:<main>: Error: Parse Sql
  438. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  439. explain (costs off)
  440. ^
  441. <sql-statement>
  442. select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x);
  443. </sql-statement>
  444. -stdin-:<main>: Error: Parse Sql
  445. -stdin-:<main>:1:1: Error: alternative is not implemented yet : 138
  446. select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x);
  447. ^
  448. -stdin-:<main>: Error: Type annotation
  449. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  450. select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x);
  451. ^
  452. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  453. select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x);
  454. ^
  455. <sql-statement>
  456. explain (costs off)
  457. select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x);
  458. </sql-statement>
  459. -stdin-:<main>: Error: Parse Sql
  460. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  461. explain (costs off)
  462. ^
  463. <sql-statement>
  464. select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x);
  465. </sql-statement>
  466. -stdin-:<main>: Error: Parse Sql
  467. -stdin-:<main>:1:1: Error: alternative is not implemented yet : 138
  468. select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x);
  469. ^
  470. -stdin-:<main>: Error: Type annotation
  471. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  472. select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x);
  473. ^
  474. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  475. select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x);
  476. ^
  477. <sql-statement>
  478. explain (costs off)
  479. select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x);
  480. </sql-statement>
  481. -stdin-:<main>: Error: Parse Sql
  482. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  483. explain (costs off)
  484. ^
  485. <sql-statement>
  486. select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x);
  487. </sql-statement>
  488. -stdin-:<main>: Error: Parse Sql
  489. -stdin-:<main>:1:1: Error: alternative is not implemented yet : 138
  490. select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x);
  491. ^
  492. -stdin-:<main>: Error: Type annotation
  493. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  494. select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x);
  495. ^
  496. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  497. select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x);
  498. ^
  499. <sql-statement>
  500. -- non-hashable type
  501. -- With an anonymous row type, the typcache does not report that the
  502. -- type is hashable. (Otherwise, this would fail at execution time.)
  503. explain (costs off)
  504. select x from (values (row(100::money)), (row(200::money))) _(x) union select x from (values (row(100::money)), (row(300::money))) _(x);
  505. </sql-statement>
  506. -stdin-:<main>: Error: Parse Sql
  507. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  508. -- non-hashable type
  509. ^
  510. <sql-statement>
  511. select x from (values (row(100::money)), (row(200::money))) _(x) union select x from (values (row(100::money)), (row(300::money))) _(x);
  512. </sql-statement>
  513. -stdin-:<main>: Error: Parse Sql
  514. -stdin-:<main>:1:1: Error: alternative is not implemented yet : 138
  515. select x from (values (row(100::money)), (row(200::money))) _(x) union select x from (values (row(100::money)), (row(300::money))) _(x);
  516. ^
  517. -stdin-:<main>: Error: Type annotation
  518. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  519. select x from (values (row(100::money)), (row(200::money))) _(x) union select x from (values (row(100::money)), (row(300::money))) _(x);
  520. ^
  521. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  522. select x from (values (row(100::money)), (row(200::money))) _(x) union select x from (values (row(100::money)), (row(300::money))) _(x);
  523. ^
  524. <sql-statement>
  525. -- With a defined row type, the typcache can inspect the type's fields
  526. -- for hashability.
  527. create type ct1 as (f1 money);
  528. </sql-statement>
  529. -stdin-:<main>: Error: Parse Sql
  530. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 314
  531. -- With a defined row type, the typcache can inspect the type's fields
  532. ^
  533. <sql-statement>
  534. explain (costs off)
  535. select x from (values (row(100::money)::ct1), (row(200::money)::ct1)) _(x) union select x from (values (row(100::money)::ct1), (row(300::money)::ct1)) _(x);
  536. </sql-statement>
  537. -stdin-:<main>: Error: Parse Sql
  538. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  539. explain (costs off)
  540. ^
  541. <sql-statement>
  542. select x from (values (row(100::money)::ct1), (row(200::money)::ct1)) _(x) union select x from (values (row(100::money)::ct1), (row(300::money)::ct1)) _(x);
  543. </sql-statement>
  544. -stdin-:<main>: Error: Parse Sql
  545. -stdin-:<main>:1:41: Error: alternative is not implemented yet : 138
  546. select x from (values (row(100::money)::ct1), (row(200::money)::ct1)) _(x) union select x from (values (row(100::money)::ct1), (row(300::money)::ct1)) _(x);
  547. ^
  548. -stdin-:<main>:1:122: Error: alternative is not implemented yet : 138
  549. select x from (values (row(100::money)::ct1), (row(200::money)::ct1)) _(x) union select x from (values (row(100::money)::ct1), (row(300::money)::ct1)) _(x);
  550. ^
  551. -stdin-:<main>: Error: Type annotation
  552. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  553. select x from (values (row(100::money)::ct1), (row(200::money)::ct1)) _(x) union select x from (values (row(100::money)::ct1), (row(300::money)::ct1)) _(x);
  554. ^
  555. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  556. select x from (values (row(100::money)::ct1), (row(200::money)::ct1)) _(x) union select x from (values (row(100::money)::ct1), (row(300::money)::ct1)) _(x);
  557. ^
  558. <sql-statement>
  559. drop type ct1;
  560. </sql-statement>
  561. -stdin-:<main>: Error: Parse Sql
  562. -stdin-:<main>:1:1: Error: DropStmt: alternative is not implemented yet : 373
  563. drop type ct1;
  564. ^
  565. <sql-statement>
  566. set enable_hashagg to off;
  567. </sql-statement>
  568. -stdin-:<main>: Error: Parse Sql
  569. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashagg
  570. set enable_hashagg to off;
  571. ^
  572. <sql-statement>
  573. explain (costs off)
  574. select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x);
  575. </sql-statement>
  576. -stdin-:<main>: Error: Parse Sql
  577. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  578. explain (costs off)
  579. ^
  580. <sql-statement>
  581. select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x);
  582. </sql-statement>
  583. -stdin-:<main>: Error: Parse Sql
  584. -stdin-:<main>:1:1: Error: alternative is not implemented yet : 138
  585. select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x);
  586. ^
  587. -stdin-:<main>: Error: Type annotation
  588. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  589. select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x);
  590. ^
  591. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  592. select x from (values (row(1, 2)), (row(1, 3))) _(x) union select x from (values (row(1, 2)), (row(1, 4))) _(x);
  593. ^
  594. <sql-statement>
  595. explain (costs off)
  596. select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x);
  597. </sql-statement>
  598. -stdin-:<main>: Error: Parse Sql
  599. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  600. explain (costs off)
  601. ^
  602. <sql-statement>
  603. select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x);
  604. </sql-statement>
  605. -stdin-:<main>: Error: Parse Sql
  606. -stdin-:<main>:1:1: Error: alternative is not implemented yet : 138
  607. select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x);
  608. ^
  609. -stdin-:<main>: Error: Type annotation
  610. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  611. select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x);
  612. ^
  613. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  614. select x from (values (row(1, 2)), (row(1, 3))) _(x) intersect select x from (values (row(1, 2)), (row(1, 4))) _(x);
  615. ^
  616. <sql-statement>
  617. explain (costs off)
  618. select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x);
  619. </sql-statement>
  620. -stdin-:<main>: Error: Parse Sql
  621. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  622. explain (costs off)
  623. ^
  624. <sql-statement>
  625. select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x);
  626. </sql-statement>
  627. -stdin-:<main>: Error: Parse Sql
  628. -stdin-:<main>:1:1: Error: alternative is not implemented yet : 138
  629. select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x);
  630. ^
  631. -stdin-:<main>: Error: Type annotation
  632. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  633. select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x);
  634. ^
  635. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  636. select x from (values (row(1, 2)), (row(1, 3))) _(x) except select x from (values (row(1, 2)), (row(1, 4))) _(x);
  637. ^
  638. <sql-statement>
  639. reset enable_hashagg;
  640. </sql-statement>
  641. -stdin-:<main>: Error: Parse Sql
  642. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  643. reset enable_hashagg;
  644. ^
  645. <sql-statement>
  646. --
  647. -- Mixed types
  648. --
  649. SELECT f1 FROM float8_tbl INTERSECT SELECT f1 FROM int4_tbl ORDER BY 1;
  650. </sql-statement>
  651. <sql-statement>
  652. SELECT f1 FROM float8_tbl EXCEPT SELECT f1 FROM int4_tbl ORDER BY 1;
  653. </sql-statement>
  654. <sql-statement>
  655. --
  656. -- Operator precedence and (((((extra))))) parentheses
  657. --
  658. SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl ORDER BY 1;
  659. </sql-statement>
  660. <sql-statement>
  661. SELECT q1 FROM int8_tbl INTERSECT (((SELECT q2 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl))) ORDER BY 1;
  662. </sql-statement>
  663. <sql-statement>
  664. (((SELECT q1 FROM int8_tbl INTERSECT SELECT q2 FROM int8_tbl ORDER BY 1))) UNION ALL SELECT q2 FROM int8_tbl;
  665. </sql-statement>
  666. <sql-statement>
  667. SELECT q1 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1;
  668. </sql-statement>
  669. <sql-statement>
  670. SELECT q1 FROM int8_tbl UNION ALL (((SELECT q2 FROM int8_tbl EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1)));
  671. </sql-statement>
  672. <sql-statement>
  673. (((SELECT q1 FROM int8_tbl UNION ALL SELECT q2 FROM int8_tbl))) EXCEPT SELECT q1 FROM int8_tbl ORDER BY 1;
  674. </sql-statement>
  675. <sql-statement>
  676. --
  677. -- Subqueries with ORDER BY & LIMIT clauses
  678. --
  679. -- In this syntax, ORDER BY/LIMIT apply to the result of the EXCEPT
  680. SELECT q1,q2 FROM int8_tbl EXCEPT SELECT q2,q1 FROM int8_tbl
  681. ORDER BY q2,q1;
  682. </sql-statement>
  683. <sql-statement>
  684. -- This should fail, because q2 isn't a name of an EXCEPT output column
  685. SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1;
  686. </sql-statement>
  687. -stdin-:<main>: Error: Type annotation
  688. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  689. -- This should fail, because q2 isn't a name of an EXCEPT output column
  690. ^
  691. -stdin-:<main>:2:65: Error: No such column: q2
  692. SELECT q1 FROM int8_tbl EXCEPT SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1;
  693. ^
  694. <sql-statement>
  695. -- But this should work:
  696. SELECT q1 FROM int8_tbl EXCEPT (((SELECT q2 FROM int8_tbl ORDER BY q2 LIMIT 1))) ORDER BY 1;
  697. </sql-statement>
  698. -stdin-:<main>: Error: Parse Sql
  699. -stdin-:<main>:1:1: Error: SelectStmt: sortClause should be used only on top
  700. -- But this should work:
  701. ^
  702. <sql-statement>
  703. --
  704. -- New syntaxes (7.1) permit new tests
  705. --
  706. (((((select * from int8_tbl)))));
  707. </sql-statement>
  708. <sql-statement>
  709. --
  710. -- Check behavior with empty select list (allowed since 9.4)
  711. --
  712. select union select;
  713. </sql-statement>
  714. -stdin-:<main>: Error: Parse Sql
  715. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  716. --
  717. ^
  718. <sql-statement>
  719. select intersect select;
  720. </sql-statement>
  721. -stdin-:<main>: Error: Parse Sql
  722. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  723. select intersect select;
  724. ^
  725. <sql-statement>
  726. select except select;
  727. </sql-statement>
  728. -stdin-:<main>: Error: Parse Sql
  729. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  730. select except select;
  731. ^
  732. <sql-statement>
  733. -- check hashed implementation
  734. set enable_hashagg = true;
  735. </sql-statement>
  736. -stdin-:<main>: Error: Parse Sql
  737. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashagg
  738. -- check hashed implementation
  739. ^
  740. <sql-statement>
  741. set enable_sort = false;
  742. </sql-statement>
  743. -stdin-:<main>: Error: Parse Sql
  744. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_sort
  745. set enable_sort = false;
  746. ^
  747. <sql-statement>
  748. explain (costs off)
  749. select from generate_series(1,5) union select from generate_series(1,3);
  750. </sql-statement>
  751. -stdin-:<main>: Error: Parse Sql
  752. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  753. explain (costs off)
  754. ^
  755. <sql-statement>
  756. explain (costs off)
  757. select from generate_series(1,5) intersect select from generate_series(1,3);
  758. </sql-statement>
  759. -stdin-:<main>: Error: Parse Sql
  760. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  761. explain (costs off)
  762. ^
  763. <sql-statement>
  764. select from generate_series(1,5) union select from generate_series(1,3);
  765. </sql-statement>
  766. -stdin-:<main>: Error: Parse Sql
  767. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  768. select from generate_series(1,5) union select from generate_series(1,3);
  769. ^
  770. <sql-statement>
  771. select from generate_series(1,5) union all select from generate_series(1,3);
  772. </sql-statement>
  773. -stdin-:<main>: Error: Parse Sql
  774. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  775. select from generate_series(1,5) union all select from generate_series(1,3);
  776. ^
  777. <sql-statement>
  778. select from generate_series(1,5) intersect select from generate_series(1,3);
  779. </sql-statement>
  780. -stdin-:<main>: Error: Parse Sql
  781. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  782. select from generate_series(1,5) intersect select from generate_series(1,3);
  783. ^
  784. <sql-statement>
  785. select from generate_series(1,5) intersect all select from generate_series(1,3);
  786. </sql-statement>
  787. -stdin-:<main>: Error: Parse Sql
  788. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  789. select from generate_series(1,5) intersect all select from generate_series(1,3);
  790. ^
  791. <sql-statement>
  792. select from generate_series(1,5) except select from generate_series(1,3);
  793. </sql-statement>
  794. -stdin-:<main>: Error: Parse Sql
  795. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  796. select from generate_series(1,5) except select from generate_series(1,3);
  797. ^
  798. <sql-statement>
  799. select from generate_series(1,5) except all select from generate_series(1,3);
  800. </sql-statement>
  801. -stdin-:<main>: Error: Parse Sql
  802. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  803. select from generate_series(1,5) except all select from generate_series(1,3);
  804. ^
  805. <sql-statement>
  806. -- check sorted implementation
  807. set enable_hashagg = false;
  808. </sql-statement>
  809. -stdin-:<main>: Error: Parse Sql
  810. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_hashagg
  811. -- check sorted implementation
  812. ^
  813. <sql-statement>
  814. set enable_sort = true;
  815. </sql-statement>
  816. -stdin-:<main>: Error: Parse Sql
  817. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_sort
  818. set enable_sort = true;
  819. ^
  820. <sql-statement>
  821. explain (costs off)
  822. select from generate_series(1,5) union select from generate_series(1,3);
  823. </sql-statement>
  824. -stdin-:<main>: Error: Parse Sql
  825. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  826. explain (costs off)
  827. ^
  828. <sql-statement>
  829. explain (costs off)
  830. select from generate_series(1,5) intersect select from generate_series(1,3);
  831. </sql-statement>
  832. -stdin-:<main>: Error: Parse Sql
  833. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  834. explain (costs off)
  835. ^
  836. <sql-statement>
  837. select from generate_series(1,5) union select from generate_series(1,3);
  838. </sql-statement>
  839. -stdin-:<main>: Error: Parse Sql
  840. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  841. select from generate_series(1,5) union select from generate_series(1,3);
  842. ^
  843. <sql-statement>
  844. select from generate_series(1,5) union all select from generate_series(1,3);
  845. </sql-statement>
  846. -stdin-:<main>: Error: Parse Sql
  847. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  848. select from generate_series(1,5) union all select from generate_series(1,3);
  849. ^
  850. <sql-statement>
  851. select from generate_series(1,5) intersect select from generate_series(1,3);
  852. </sql-statement>
  853. -stdin-:<main>: Error: Parse Sql
  854. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  855. select from generate_series(1,5) intersect select from generate_series(1,3);
  856. ^
  857. <sql-statement>
  858. select from generate_series(1,5) intersect all select from generate_series(1,3);
  859. </sql-statement>
  860. -stdin-:<main>: Error: Parse Sql
  861. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  862. select from generate_series(1,5) intersect all select from generate_series(1,3);
  863. ^
  864. <sql-statement>
  865. select from generate_series(1,5) except select from generate_series(1,3);
  866. </sql-statement>
  867. -stdin-:<main>: Error: Parse Sql
  868. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  869. select from generate_series(1,5) except select from generate_series(1,3);
  870. ^
  871. <sql-statement>
  872. select from generate_series(1,5) except all select from generate_series(1,3);
  873. </sql-statement>
  874. -stdin-:<main>: Error: Parse Sql
  875. -stdin-:<main>:1:1: Error: SelectStmt: both values_list and target_list are not allowed to be empty
  876. select from generate_series(1,5) except all select from generate_series(1,3);
  877. ^
  878. <sql-statement>
  879. reset enable_hashagg;
  880. </sql-statement>
  881. -stdin-:<main>: Error: Parse Sql
  882. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  883. reset enable_hashagg;
  884. ^
  885. <sql-statement>
  886. reset enable_sort;
  887. </sql-statement>
  888. -stdin-:<main>: Error: Parse Sql
  889. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  890. reset enable_sort;
  891. ^
  892. <sql-statement>
  893. --
  894. -- Check handling of a case with unknown constants. We don't guarantee
  895. -- an undecorated constant will work in all cases, but historically this
  896. -- usage has worked, so test we don't break it.
  897. --
  898. SELECT a.f1 FROM (SELECT 'test' AS f1 FROM varchar_tbl) a
  899. UNION
  900. SELECT b.f1 FROM (SELECT f1 FROM varchar_tbl) b
  901. ORDER BY 1;
  902. </sql-statement>
  903. <sql-statement>
  904. -- This should fail, but it should produce an error cursor
  905. SELECT '3.4'::numeric UNION SELECT 'foo';
  906. </sql-statement>
  907. -stdin-:<main>: Fatal: Execution
  908. -stdin-:<main>:1:1: Fatal: Execution of node: Result
  909. -- This should fail, but it should produce an error cursor
  910. ^
  911. -stdin-:<main>:1:1: Fatal: ERROR: invalid input syntax for type numeric: "foo"
  912. -- This should fail, but it should produce an error cursor
  913. ^
  914. <sql-statement>
  915. --
  916. -- Test that expression-index constraints can be pushed down through
  917. -- UNION or UNION ALL
  918. --
  919. CREATE TEMP TABLE t1 (a text, b text);
  920. </sql-statement>
  921. <sql-statement>
  922. CREATE INDEX t1_ab_idx on t1 ((a || b));
  923. </sql-statement>
  924. -stdin-:<main>: Error: Parse Sql
  925. -stdin-:<main>:1:1: Error: index expression is not supported yet
  926. CREATE INDEX t1_ab_idx on t1 ((a || b));
  927. ^
  928. <sql-statement>
  929. CREATE TEMP TABLE t2 (ab text primary key);
  930. </sql-statement>
  931. <sql-statement>
  932. INSERT INTO t1 VALUES ('a', 'b'), ('x', 'y');
  933. </sql-statement>
  934. <sql-statement>
  935. INSERT INTO t2 VALUES ('ab'), ('xy');
  936. </sql-statement>
  937. <sql-statement>
  938. set enable_seqscan = off;
  939. </sql-statement>
  940. -stdin-:<main>: Error: Parse Sql
  941. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_seqscan
  942. set enable_seqscan = off;
  943. ^
  944. <sql-statement>
  945. set enable_indexscan = on;
  946. </sql-statement>
  947. -stdin-:<main>: Error: Parse Sql
  948. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_indexscan
  949. set enable_indexscan = on;
  950. ^
  951. <sql-statement>
  952. set enable_bitmapscan = off;
  953. </sql-statement>
  954. -stdin-:<main>: Error: Parse Sql
  955. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_bitmapscan
  956. set enable_bitmapscan = off;
  957. ^
  958. <sql-statement>
  959. explain (costs off)
  960. SELECT * FROM
  961. (SELECT a || b AS ab FROM t1
  962. UNION ALL
  963. SELECT * FROM t2) t
  964. WHERE ab = 'ab';
  965. </sql-statement>
  966. -stdin-:<main>: Error: Parse Sql
  967. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  968. explain (costs off)
  969. ^
  970. <sql-statement>
  971. explain (costs off)
  972. SELECT * FROM
  973. (SELECT a || b AS ab FROM t1
  974. UNION
  975. SELECT * FROM t2) t
  976. WHERE ab = 'ab';
  977. </sql-statement>
  978. -stdin-:<main>: Error: Parse Sql
  979. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  980. explain (costs off)
  981. ^
  982. <sql-statement>
  983. --
  984. -- Test that ORDER BY for UNION ALL can be pushed down to inheritance
  985. -- children.
  986. --
  987. CREATE TEMP TABLE t1c (b text, a text);
  988. </sql-statement>
  989. <sql-statement>
  990. ALTER TABLE t1c INHERIT t1;
  991. </sql-statement>
  992. -stdin-:<main>: Error: Parse Sql
  993. -stdin-:<main>:1:1: Error: alternative is not implemented yet : 245
  994. ALTER TABLE t1c INHERIT t1;
  995. ^
  996. <sql-statement>
  997. CREATE TEMP TABLE t2c (primary key (ab)) INHERITS (t2);
  998. </sql-statement>
  999. -stdin-:<main>: Error: Parse Sql
  1000. -stdin-:<main>:1:1: Error: table inheritance not supported
  1001. CREATE TEMP TABLE t2c (primary key (ab)) INHERITS (t2);
  1002. ^
  1003. <sql-statement>
  1004. INSERT INTO t1c VALUES ('v', 'w'), ('c', 'd'), ('m', 'n'), ('e', 'f');
  1005. </sql-statement>
  1006. <sql-statement>
  1007. INSERT INTO t2c VALUES ('vw'), ('cd'), ('mn'), ('ef');
  1008. </sql-statement>
  1009. -stdin-:<main>: Fatal: Table metadata loading
  1010. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.t2c
  1011. <sql-statement>
  1012. CREATE INDEX t1c_ab_idx on t1c ((a || b));
  1013. </sql-statement>
  1014. -stdin-:<main>: Error: Parse Sql
  1015. -stdin-:<main>:1:1: Error: index expression is not supported yet
  1016. CREATE INDEX t1c_ab_idx on t1c ((a || b));
  1017. ^
  1018. <sql-statement>
  1019. set enable_seqscan = on;
  1020. </sql-statement>
  1021. -stdin-:<main>: Error: Parse Sql
  1022. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_seqscan
  1023. set enable_seqscan = on;
  1024. ^
  1025. <sql-statement>
  1026. set enable_indexonlyscan = off;
  1027. </sql-statement>
  1028. -stdin-:<main>: Error: Parse Sql
  1029. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported name: enable_indexonlyscan
  1030. set enable_indexonlyscan = off;
  1031. ^
  1032. <sql-statement>
  1033. explain (costs off)
  1034. SELECT * FROM
  1035. (SELECT a || b AS ab FROM t1
  1036. UNION ALL
  1037. SELECT ab FROM t2) t
  1038. ORDER BY 1 LIMIT 8;
  1039. </sql-statement>
  1040. -stdin-:<main>: Error: Parse Sql
  1041. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1042. explain (costs off)
  1043. ^
  1044. <sql-statement>
  1045. SELECT * FROM
  1046. (SELECT a || b AS ab FROM t1
  1047. UNION ALL
  1048. SELECT ab FROM t2) t
  1049. ORDER BY 1 LIMIT 8;
  1050. </sql-statement>
  1051. <sql-statement>
  1052. reset enable_seqscan;
  1053. </sql-statement>
  1054. -stdin-:<main>: Error: Parse Sql
  1055. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  1056. reset enable_seqscan;
  1057. ^
  1058. <sql-statement>
  1059. reset enable_indexscan;
  1060. </sql-statement>
  1061. -stdin-:<main>: Error: Parse Sql
  1062. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  1063. reset enable_indexscan;
  1064. ^
  1065. <sql-statement>
  1066. reset enable_bitmapscan;
  1067. </sql-statement>
  1068. -stdin-:<main>: Error: Parse Sql
  1069. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  1070. reset enable_bitmapscan;
  1071. ^
  1072. <sql-statement>
  1073. -- This simpler variant of the above test has been observed to fail differently
  1074. create table events (event_id int primary key);
  1075. </sql-statement>
  1076. <sql-statement>
  1077. create table other_events (event_id int primary key);
  1078. </sql-statement>
  1079. <sql-statement>
  1080. create table events_child () inherits (events);
  1081. </sql-statement>
  1082. -stdin-:<main>: Error: Parse Sql
  1083. -stdin-:<main>:1:1: Error: table inheritance not supported
  1084. create table events_child () inherits (events);
  1085. ^
  1086. <sql-statement>
  1087. explain (costs off)
  1088. select event_id
  1089. from (select event_id from events
  1090. union all
  1091. select event_id from other_events) ss
  1092. order by event_id;
  1093. </sql-statement>
  1094. -stdin-:<main>: Error: Parse Sql
  1095. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1096. explain (costs off)
  1097. ^
  1098. <sql-statement>
  1099. drop table events_child, events, other_events;
  1100. </sql-statement>
  1101. <sql-statement>
  1102. reset enable_indexonlyscan;
  1103. </sql-statement>
  1104. -stdin-:<main>: Error: Parse Sql
  1105. -stdin-:<main>:1:1: Error: VariableSetStmt, not supported kind: 4
  1106. reset enable_indexonlyscan;
  1107. ^
  1108. <sql-statement>
  1109. -- Test constraint exclusion of UNION ALL subqueries
  1110. explain (costs off)
  1111. SELECT * FROM
  1112. (SELECT 1 AS t, * FROM tenk1 a
  1113. UNION ALL
  1114. SELECT 2 AS t, * FROM tenk1 b) c
  1115. WHERE t = 2;
  1116. </sql-statement>
  1117. -stdin-:<main>: Error: Parse Sql
  1118. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1119. -- Test constraint exclusion of UNION ALL subqueries
  1120. ^
  1121. <sql-statement>
  1122. -- Test that we push quals into UNION sub-selects only when it's safe
  1123. explain (costs off)
  1124. SELECT * FROM
  1125. (SELECT 1 AS t, 2 AS x
  1126. UNION
  1127. SELECT 2 AS t, 4 AS x) ss
  1128. WHERE x < 4
  1129. ORDER BY x;
  1130. </sql-statement>
  1131. -stdin-:<main>: Error: Parse Sql
  1132. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1133. -- Test that we push quals into UNION sub-selects only when it's safe
  1134. ^
  1135. <sql-statement>
  1136. SELECT * FROM
  1137. (SELECT 1 AS t, 2 AS x
  1138. UNION
  1139. SELECT 2 AS t, 4 AS x) ss
  1140. WHERE x < 4
  1141. ORDER BY x;
  1142. </sql-statement>
  1143. <sql-statement>
  1144. explain (costs off)
  1145. SELECT * FROM
  1146. (SELECT 1 AS t, generate_series(1,10) AS x
  1147. UNION
  1148. SELECT 2 AS t, 4 AS x) ss
  1149. WHERE x < 4
  1150. ORDER BY x;
  1151. </sql-statement>
  1152. -stdin-:<main>: Error: Parse Sql
  1153. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1154. explain (costs off)
  1155. ^
  1156. <sql-statement>
  1157. SELECT * FROM
  1158. (SELECT 1 AS t, generate_series(1,10) AS x
  1159. UNION
  1160. SELECT 2 AS t, 4 AS x) ss
  1161. WHERE x < 4
  1162. ORDER BY x;
  1163. </sql-statement>
  1164. -stdin-:<main>: Error: Parse Sql
  1165. -stdin-:<main>:2:19: Error: Generator functions are not allowed in: SELECT
  1166. (SELECT 1 AS t, generate_series(1,10) AS x
  1167. ^
  1168. -stdin-:<main>: Error: Type annotation
  1169. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  1170. SELECT * FROM
  1171. ^
  1172. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  1173. SELECT * FROM
  1174. ^
  1175. <sql-statement>
  1176. explain (costs off)
  1177. SELECT * FROM
  1178. (SELECT 1 AS t, (random()*3)::int AS x
  1179. UNION
  1180. SELECT 2 AS t, 4 AS x) ss
  1181. WHERE x > 3
  1182. ORDER BY x;
  1183. </sql-statement>
  1184. -stdin-:<main>: Error: Parse Sql
  1185. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1186. explain (costs off)
  1187. ^
  1188. <sql-statement>
  1189. SELECT * FROM
  1190. (SELECT 1 AS t, (random()*3)::int AS x
  1191. UNION
  1192. SELECT 2 AS t, 4 AS x) ss
  1193. WHERE x > 3
  1194. ORDER BY x;
  1195. </sql-statement>
  1196. <sql-statement>
  1197. -- Test cases where the native ordering of a sub-select has more pathkeys
  1198. -- than the outer query cares about
  1199. explain (costs off)
  1200. select distinct q1 from
  1201. (select distinct * from int8_tbl i81
  1202. union all
  1203. select distinct * from int8_tbl i82) ss
  1204. where q2 = q2;
  1205. </sql-statement>
  1206. -stdin-:<main>: Error: Parse Sql
  1207. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1208. -- Test cases where the native ordering of a sub-select has more pathkeys
  1209. ^
  1210. <sql-statement>
  1211. select distinct q1 from
  1212. (select distinct * from int8_tbl i81
  1213. union all
  1214. select distinct * from int8_tbl i82) ss
  1215. where q2 = q2;
  1216. </sql-statement>
  1217. <sql-statement>
  1218. explain (costs off)
  1219. select distinct q1 from
  1220. (select distinct * from int8_tbl i81
  1221. union all
  1222. select distinct * from int8_tbl i82) ss
  1223. where -q1 = q2;
  1224. </sql-statement>
  1225. -stdin-:<main>: Error: Parse Sql
  1226. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1227. explain (costs off)
  1228. ^
  1229. <sql-statement>
  1230. select distinct q1 from
  1231. (select distinct * from int8_tbl i81
  1232. union all
  1233. select distinct * from int8_tbl i82) ss
  1234. where -q1 = q2;
  1235. </sql-statement>
  1236. <sql-statement>
  1237. -- Test proper handling of parameterized appendrel paths when the
  1238. -- potential join qual is expensive
  1239. create function expensivefunc(int) returns int
  1240. language plpgsql immutable strict cost 10000
  1241. as $$begin return $1; end$$;
  1242. </sql-statement>
  1243. -stdin-:<main>: Error: Parse Sql
  1244. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
  1245. -- Test proper handling of parameterized appendrel paths when the
  1246. ^
  1247. <sql-statement>
  1248. create temp table t3 as select generate_series(-1000,1000) as x;
  1249. </sql-statement>
  1250. -stdin-:<main>: Error: Parse Sql
  1251. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 277
  1252. create temp table t3 as select generate_series(-1000,1000) as x;
  1253. ^
  1254. <sql-statement>
  1255. create index t3i on t3 (expensivefunc(x));
  1256. </sql-statement>
  1257. -stdin-:<main>: Error: Parse Sql
  1258. -stdin-:<main>:1:1: Error: index expression is not supported yet
  1259. create index t3i on t3 (expensivefunc(x));
  1260. ^
  1261. <sql-statement>
  1262. analyze t3;
  1263. </sql-statement>
  1264. -stdin-:<main>: Error: Parse Sql
  1265. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  1266. analyze t3;
  1267. ^
  1268. <sql-statement>
  1269. explain (costs off)
  1270. select * from
  1271. (select * from t3 a union all select * from t3 b) ss
  1272. join int4_tbl on f1 = expensivefunc(x);
  1273. </sql-statement>
  1274. -stdin-:<main>: Error: Parse Sql
  1275. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1276. explain (costs off)
  1277. ^
  1278. <sql-statement>
  1279. select * from
  1280. (select * from t3 a union all select * from t3 b) ss
  1281. join int4_tbl on f1 = expensivefunc(x);
  1282. </sql-statement>
  1283. -stdin-:<main>: Fatal: Table metadata loading
  1284. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.t3
  1285. <sql-statement>
  1286. drop table t3;
  1287. </sql-statement>
  1288. <sql-statement>
  1289. drop function expensivefunc(int);
  1290. </sql-statement>
  1291. -stdin-:<main>: Error: Parse Sql
  1292. -stdin-:<main>:1:1: Error: DropStmt: alternative is not implemented yet : 386
  1293. drop function expensivefunc(int);
  1294. ^
  1295. <sql-statement>
  1296. -- Test handling of appendrel quals that const-simplify into an AND
  1297. explain (costs off)
  1298. select * from
  1299. (select *, 0 as x from int8_tbl a
  1300. union all
  1301. select *, 1 as x from int8_tbl b) ss
  1302. where (x = 0) or (q1 >= q2 and q1 <= q2);
  1303. </sql-statement>
  1304. -stdin-:<main>: Error: Parse Sql
  1305. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1306. -- Test handling of appendrel quals that const-simplify into an AND
  1307. ^
  1308. <sql-statement>
  1309. select * from
  1310. (select *, 0 as x from int8_tbl a
  1311. union all
  1312. select *, 1 as x from int8_tbl b) ss
  1313. where (x = 0) or (q1 >= q2 and q1 <= q2);
  1314. </sql-statement>