2
0

expr.pikchr 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400
  1. linerad = 10px
  2. linewid *= 0.5
  3. $h = 0.21
  4. margin = 1cm
  5. debug_label_color = Red
  6. color = lightgray
  7. circle radius 10%
  8. OUT: 6.3in right of previous.e # FIX ME
  9. IN_X: linerad east of first circle.e
  10. # The literal-value line
  11. arrow
  12. LTV: box "literal-value" fit
  13. arrow right even with linerad+2*arrowht east of OUT
  14. circle same
  15. # The bind-parameter line
  16. right
  17. BNDP: oval "bind-parameter" fit with .w at 1.25*$h below LTV.w
  18. arrow right even with OUT; line right linerad then up linerad
  19. arrow from first circle.e right linerad then down even with BNDP \
  20. then to BNDP.w
  21. # The table column reference line
  22. right
  23. SN: oval "schema-name" fit with .w at 2.0*$h below BNDP.w
  24. arrow 2*arrowht
  25. oval "." bold fit
  26. arrow
  27. TN: oval "table-name" fit
  28. arrow right 2*arrowht
  29. oval "." bold fit
  30. arrow
  31. CN: oval "column-name" fit
  32. arrow right even with OUT; line right linerad then up linerad
  33. arrow from (IN_X,SN.n) down even with SN then to SN.w
  34. TN_Y: 0.375*$h above TN.n
  35. arrow from (IN_X,linerad above TN_Y) down linerad \
  36. then right even with SN
  37. arrow right right even with TN
  38. line right even with linerad+arrowht west of CN.w \
  39. then down even with CN then right linerad
  40. line from (linerad+2*arrowht left of TN.w,TN_Y) right linerad \
  41. then down even with TN then right linerad
  42. # Unary operators
  43. right
  44. UOP: oval "unary-operator" fit with .w at 1.25*$h below SN.w
  45. arrow right even with OUT; line right linerad then up linerad
  46. arrow from (IN_X,UOP.n) down even with UOP then to UOP.w
  47. # Binary operators
  48. right
  49. BINY: box "expr" fit with .w at 1.25*$h below UOP.w
  50. arrow 2*arrowht
  51. oval "binary-operator" fit
  52. arrow 2*arrowht
  53. box "expr" fit
  54. arrow right even with OUT; line right linerad then up linerad
  55. arrow from (IN_X,BINY.n) down even with BINY then to BINY.w
  56. # Function calls
  57. right
  58. FUNC: oval "function-name" fit with .w at 2.0*$h below BINY.w
  59. arrow 1.5*arrowht
  60. FLP: oval "(" bold fit
  61. arrow
  62. FDCT: oval "DISTINCT" fit
  63. arrow
  64. FEXP: box "expr" fit
  65. arrow 150%
  66. FRP: oval ")" bold fit
  67. arrow right linerad then down $h then right 2*arrowht
  68. FFC: box "filter-clause" fit
  69. FA1: arrow right linerad then up even with FUNC then right 2*arrowht
  70. arrow right linerad then down $h then right 2*arrowht
  71. FOC: box "over-clause" fit
  72. arrow right even with OUT; line right linerad then up linerad
  73. arrow from (IN_X,FUNC.n) down even with FUNC then to FUNC.w
  74. # filter clause bypass
  75. arrow from FRP.e right even with FFC
  76. line to arrowht left of FA1.end
  77. # over clause bypass
  78. arrow from FA1.end right even with OUT
  79. line right linerad then up linerad
  80. # expr loop
  81. FCMA: oval "," bold fit at 1.25*$h above FEXP
  82. arrow from FEXP.e right linerad then up even with FCMA \
  83. then to FCMA.e
  84. line from FCMA.w left even with 2*arrowht west of FEXP.w \
  85. then down even with FEXP then right linerad
  86. # "*" argument list
  87. FSTR: oval "*" bold fit with .w at 1.25*$h below FDCT.w
  88. arrow from FLP.e right linerad then down even with FSTR \
  89. then to FSTR.w
  90. FA2: arrow from FSTR.e right even with linerad+2*arrowht west of FRP.w
  91. line right linerad then up even with FRP then right linerad
  92. # empty argument list
  93. arrow from (linerad east of FLP.e,FSTR.n) \
  94. down even with $h below FSTR then right even with FDCT.w
  95. arrow right even with FA2.end
  96. line right linerad then up even with FSTR.n
  97. # parenthesized and vector expressions
  98. right
  99. PRN: oval "(" bold fit with .w at 3.0*$h below FUNC.w
  100. arrow
  101. PEXP: box "expr" fit
  102. arrow
  103. oval ")" bold fit
  104. arrow right even with OUT; line right linerad then up linerad
  105. arrow from (IN_X,PRN.n) down even with PRN then to PRN.w
  106. # expr loop
  107. PCMA: oval "," bold fit at 1.25*$h above PEXP
  108. arrow from PEXP.e right linerad then up even with PCMA \
  109. then to PCMA.e
  110. line from PCMA.w left even with 2*arrowht left of PEXP.w \
  111. then down even with PEXP then right linerad
  112. # CAST expression
  113. right
  114. CAST: oval "CAST" fit with .w at 1.25*$h below PRN.w
  115. arrow 2*arrowht
  116. oval "(" bold fit
  117. arrow 2*arrowht
  118. box "expr" fit
  119. arrow 2*arrowht
  120. oval "AS" fit
  121. arrow 2*arrowht
  122. box "type-name" fit
  123. arrow 2*arrowht
  124. oval ")" bold fit
  125. arrow right even with OUT; line right linerad then up linerad
  126. arrow from (IN_X,CAST.n) down even with CAST then to CAST.w
  127. # COLLATE expression
  128. right
  129. COLL: box "expr" fit with .w at 1.25*$h below CAST.w
  130. arrow 2*arrowht
  131. oval "COLLATE" fit
  132. arrow 2*arrowht
  133. oval "collation-name" fit
  134. arrow right even with OUT; line right linerad then up linerad
  135. arrow from (IN_X,COLL.n) down even with COLL then to COLL.w
  136. # LIKE expressions
  137. right
  138. LIKE: box "expr" fit with .w at 1.25*$h below COLL.w
  139. arrow
  140. LNOT: oval "NOT" fit
  141. arrow 150%
  142. LOP1: oval "LIKE" fit
  143. LOP2: oval "GLOB" fit with .w at 1.25*$h below LOP1.w
  144. LOP3: oval "REGEXP" fit with .w at 1.25*$h below LOP2.w
  145. LOP4: oval "MATCH" fit with .w at 1.25*$h below LOP3.w
  146. LE2: box "expr" fit with .w at (4*arrowht+linerad east of LOP3.e,LIKE)
  147. arrow from LE2.e right linerad then down $h then right 2*arrowht
  148. LESC: oval "ESCAPE" fit
  149. arrow 2*arrowht
  150. box "expr" fit
  151. LA1: arrow right linerad then up even with LIKE then right
  152. arrow right even with OUT; line right linerad then up linerad
  153. arrow from (IN_X,LIKE.n) down even with LIKE then to LIKE.w
  154. # NOT bypass
  155. line from linerad*2 west of LNOT.w \
  156. right linerad then down $h \
  157. then right even with arrowht east of LNOT.e \
  158. then up even with LNOT then right linerad
  159. # Inputs to the operators
  160. LX1: 2*arrowht west of LOP1.w
  161. arrow from linerad west of LX1 right linerad \
  162. then down even with LOP4 then to LOP4.w
  163. arrow from (LX1,LOP2.n) down even with LOP2 then to LOP2.w
  164. arrow from (LX1,LOP3.n) down even with LOP3 then to LOP3.w
  165. # Outputs from the operators
  166. LX2: 2*arrowht east of LOP3.e
  167. arrow from LOP4.e right even with LX2
  168. arrow right linerad then up even with LE2 then to LE2.w
  169. arrow from LOP3.e right even with LX2
  170. line right linerad then up linerad
  171. arrow from LOP2.e right even with LX2
  172. line right linerad then up linerad
  173. line from LOP1.e to arrowht west of LE2.w
  174. # ESCAPE bypass
  175. arrow from LE2.e right even with LESC
  176. line to arrowht left of LA1.end
  177. # ISNULL and NOTNULL operators
  178. right
  179. NNUL: box "expr" fit with .w at 5.0*$h below LIKE.w
  180. arrow
  181. NN1: oval "ISNULL" fit
  182. arrow right even with OUT; line right linerad then up linerad
  183. arrow from (IN_X,NNUL.n) down even with NNUL then to NNUL.w
  184. NN2: oval "NOTNULL" fit with .w at 1.25*$h below NN1.w
  185. right
  186. NN3: oval "NOT" fit with .w at 1.25*$h below NN2.w
  187. arrow 2*arrowht
  188. NN3B: oval "NULL" fit
  189. NNA1: arrow 2*arrowht
  190. arrow right linerad then up even with NN1 then right
  191. arrow from NN2.e right even with NNA1.end
  192. line right linerad then up linerad
  193. arrow from NNUL.e right linerad then down even with NN3 then to NN3.w
  194. arrow from NNUL.e right linerad then down even with NN2 then to NN2.w
  195. # The IS operator
  196. right
  197. IS: box "expr" fit with .w at 3.75*$h below NNUL.w
  198. arrow 2*arrowht
  199. oval "IS" fit
  200. arrow
  201. ISN: oval "NOT" fit
  202. arrow
  203. box "expr" fit
  204. arrow right even with OUT; line right linerad then up linerad
  205. arrow from (IN_X,IS.n) down even with IS then to IS.w
  206. # NOT bypass
  207. line from 3*arrowht west of ISN.w right linerad \
  208. then down 0.8*$h then right even with arrowht east of ISN.e \
  209. then up even with ISN then right linerad
  210. # The BETWEEN operator
  211. right
  212. BTW: box "expr" fit with .w at 1.5*$h below IS.w
  213. arrow
  214. BTWN: oval "NOT" fit
  215. arrow
  216. oval "BETWEEN" fit
  217. arrow 2*arrowht
  218. box "expr" fit
  219. arrow 2*arrowht
  220. oval "AND" fit
  221. arrow 2*arrowht
  222. box "expr" fit
  223. arrow right even with OUT; line right linerad then up linerad
  224. arrow from (IN_X,BTW.n) down even with BTW then to BTW.w
  225. # NOT bypass
  226. line from 3*arrowht west of BTWN.w right linerad \
  227. then down 0.8*$h then right even with arrowht east of BTWN.e \
  228. then up even with BTWN then right linerad
  229. # The IN operator
  230. right
  231. IN: box "expr" fit with .w at 1.75*$h below BTW.w
  232. arrow
  233. INNT: oval "NOT" fit
  234. arrow
  235. ININ: oval "IN" fit
  236. arrow
  237. INLP: oval "(" bold fit
  238. arrow
  239. INSS: box "select-stmt" fit
  240. arrow
  241. oval ")" bold fit
  242. arrow right even with OUT; line right linerad then up linerad
  243. arrow from (IN_X,IN.n) down even with IN then to IN.w
  244. # NOT bypass
  245. line from 3*arrowht west of INNT.w right linerad \
  246. then down 0.8*$h then right even with arrowht east of INNT.e \
  247. then up even with INNT then right linerad
  248. # select-stmt bypass
  249. line from 3*arrowht west of INSS.w right linerad \
  250. then up 0.8*$h then right even with arrowht east of INSS.e \
  251. then up even with INSS then right linerad
  252. # expr list instead of select-stmt
  253. INE1: box "expr" fit at 1.25*$h below INSS
  254. arrow from 3*arrowht west of INSS.w right linerad \
  255. then down even with INE1 then to INE1.w
  256. line from INE1.e right even with arrowht east of INSS.e \
  257. then up even with INSS then right linerad
  258. # expr loop
  259. INC1: oval "," bold fit at 1.25*$h below INE1
  260. arrow from INE1.e right linerad then down even with INC1 \
  261. then to INC1.e
  262. line from INC1.w left even with 2*arrowht west of INE1.w \
  263. then up even with INE1 then right linerad
  264. # reference-to-table choice as RHS
  265. INSN: oval "schema-name" fit with .w at 4.25*$h below INLP.w
  266. arrow from INSN.e right 1.5*arrowht
  267. INDT: oval "." bold fit
  268. arrow 150%
  269. INTF: oval "table-function" fit
  270. arrow 1.5*arrowht
  271. INL2: oval "(" bold fit
  272. arrow 125%
  273. INE2: box "expr" fit
  274. arrow 125%
  275. INR2: oval ")" bold fit
  276. arrow right even with OUT; line right linerad then up linerad
  277. # table reference branch
  278. right
  279. INTB: oval "table-name" fit with .w at 2*$h above INTF.w
  280. arrow right even with OUT; line right linerad then up linerad
  281. arrow from linerad+2*arrowht west of INTF.w right linerad \
  282. then up even with INTB then to INTB.w
  283. # expr-list no table-valued-functions
  284. INC2: oval "," bold fit at 1.1*$h above INE2
  285. arrow from INE2.e right linerad then up even with INC2 \
  286. then to INC2.e
  287. line from INC2.w right even with 2*arrowht west of INE2.w \
  288. then down even with INE2 then right linerad
  289. # expr-list bypass for table-valued functions
  290. line from INL2.e right linerad then down .7*$h \
  291. then right even with 2*arrowht left of INR2.w \
  292. then up even with INR2 then right linerad
  293. # links from IN operator to table references
  294. arrow from ININ.e right linerad then down even with INSN \
  295. then to INSN.w
  296. # schema-name bypass
  297. INY3: 0.45*$h above INSN.n
  298. arrow from (linerad east of ININ.e,linerad above INY3) \
  299. down linerad then right even with arrowht right of INSN.e
  300. line right even with arrowht east of INDT.e \
  301. then down even with INDT then right linerad
  302. # NOT? EXISTS? (SELECT) clause
  303. right
  304. NE: oval "NOT" fit with .w at (IN.w,1.5*$h below INSN)
  305. arrow
  306. NEE: oval "EXISTS" fit
  307. arrow
  308. NELP: oval "(" bold fit
  309. arrow 2*arrowht
  310. box "select-stmt" fit
  311. arrow 2*arrowht
  312. oval ")" bold fit
  313. arrow right even with OUT; line right linerad then up linerad
  314. arrow from (IN_X,NE.n) down even with NE then to NE.w
  315. NE_Y: 0.375*$h above NE.n
  316. arrow from (IN_X,linerad above NE_Y) down linerad \
  317. then right even with NE
  318. line right even with linerad+arrowht west of NELP.w \
  319. then down even with NELP then right linerad
  320. line from (linerad+2*arrowht left of NEE.w,NE_Y) right linerad \
  321. then down even with NEE then right linerad
  322. # CASE expressions
  323. right
  324. CS: oval "CASE" fit with .w at 1.25*$h below NE.w
  325. arrow
  326. CSE1: box "expr" fit
  327. arrow 150%
  328. CSW: oval "WHEN" fit
  329. arrow 2*arrowht
  330. CSE2: box "expr" fit
  331. arrow 2*arrowht
  332. oval "THEN" fit
  333. arrow 2*arrowht
  334. CSE3: box "expr" fit
  335. arrow 200%
  336. CSEL: oval "ELSE" fit
  337. arrow 2*arrowht
  338. CSE4: box "expr" fit
  339. arrow
  340. oval "END" fit
  341. arrow right even with OUT; line right linerad then up linerad
  342. arrow from (IN_X,CS.n) down even with CS then to CS.w
  343. # first expr bypass
  344. CSY: 0.9*$h below CS
  345. line from CS.e right linerad then down even with CSY \
  346. then right even with arrowht east of CSE1.e then up even with CSE1 \
  347. then right linerad
  348. # when clause loop
  349. arrow from CSE3.e right linerad then down even with CSY \
  350. then left even with CSE2
  351. line left even with 2*arrowht west of CSW.w \
  352. then up even with CSW then right linerad
  353. # ELSE clause bypass
  354. line from linerad+2*arrowht west of CSEL.w right linerad \
  355. then down even with CSY then right even with arrowht east of CSE4.e \
  356. then up even with CSE4 then right linerad
  357. # The RAISE function
  358. right
  359. RSE: box "raise-function" fit with .w at 1.9*$h below CS.w
  360. arrow right even with OUT;
  361. line right linerad then up even with first circle then right linerad
  362. arrow from (IN_X,BNDP.n) down even with RSE then to RSE.w