Mercurial > urweb
comparison src/urweb.grm @ 1776:8f28c3295148
Compiled a window function use
author | Adam Chlipala <adam@chlipala.net> |
---|---|
date | Sat, 02 Jun 2012 16:00:50 -0400 |
parents | f8ddaa296115 |
children | 59b07fdae1ff |
comparison
equal
deleted
inserted
replaced
1775:6bc2a8cb3a67 | 1776:8f28c3295148 |
---|---|
330 | 330 |
331 | SELECT | DISTINCT | FROM | AS | CWHERE | GROUP | ORDER | BY | HAVING | 331 | SELECT | DISTINCT | FROM | AS | CWHERE | GROUP | ORDER | BY | HAVING |
332 | UNION | INTERSECT | EXCEPT | 332 | UNION | INTERSECT | EXCEPT |
333 | LIMIT | OFFSET | ALL | 333 | LIMIT | OFFSET | ALL |
334 | TRUE | FALSE | CAND | OR | NOT | 334 | TRUE | FALSE | CAND | OR | NOT |
335 | COUNT | AVG | SUM | MIN | MAX | 335 | COUNT | AVG | SUM | MIN | MAX | RANK |
336 | ASC | DESC | RANDOM | 336 | ASC | DESC | RANDOM |
337 | INSERT | INTO | VALUES | UPDATE | SET | DELETE | NULL | IS | COALESCE | LIKE | 337 | INSERT | INTO | VALUES | UPDATE | SET | DELETE | NULL | IS | COALESCE | LIKE |
338 | CURRENT_TIMESTAMP | 338 | CURRENT_TIMESTAMP |
339 | NE | LT | LE | GT | GE | 339 | NE | LT | LE | GT | GE |
340 | CCONSTRAINT | UNIQUE | CHECK | PRIMARY | FOREIGN | KEY | ON | NO | ACTION | RESTRICT | CASCADE | REFERENCES | 340 | CCONSTRAINT | UNIQUE | CHECK | PRIMARY | FOREIGN | KEY | ON | NO | ACTION | RESTRICT | CASCADE | REFERENCES |
341 | JOIN | INNER | CROSS | OUTER | LEFT | RIGHT | FULL | 341 | JOIN | INNER | CROSS | OUTER | LEFT | RIGHT | FULL |
342 | CIF | CTHEN | CELSE | 342 | CIF | CTHEN | CELSE |
343 | OVER | PARTITION | |
343 | 344 |
344 %nonterm | 345 %nonterm |
345 file of decl list | 346 file of decl list |
346 | decls of decl list | 347 | decls of decl list |
347 | decl of decl list | 348 | decl of decl list |
453 | fident of con | 454 | fident of con |
454 | seli of select_item | 455 | seli of select_item |
455 | selis of select_item list | 456 | selis of select_item list |
456 | select of select | 457 | select of select |
457 | sqlexp of exp | 458 | sqlexp of exp |
459 | window of unit option | |
458 | wopt of exp | 460 | wopt of exp |
459 | groupi of group_item | 461 | groupi of group_item |
460 | groupis of group_item list | 462 | groupis of group_item list |
461 | gopt of group_item list option | 463 | gopt of group_item list option |
462 | hopt of exp | 464 | hopt of exp |
2023 | LPAREN sqlexp RPAREN (sqlexp) | 2025 | LPAREN sqlexp RPAREN (sqlexp) |
2024 | 2026 |
2025 | NULL (sql_inject ((EVar (["Basis"], "None", Infer), | 2027 | NULL (sql_inject ((EVar (["Basis"], "None", Infer), |
2026 s (NULLleft, NULLright)))) | 2028 s (NULLleft, NULLright)))) |
2027 | 2029 |
2028 | COUNT LPAREN STAR RPAREN (let | 2030 | COUNT LPAREN STAR RPAREN window (let |
2029 val loc = s (COUNTleft, RPARENright) | 2031 val loc = s (COUNTleft, windowright) |
2030 in | 2032 in |
2031 (EVar (["Basis"], "sql_count", Infer), loc) | 2033 case window of |
2032 end) | 2034 NONE => (EVar (["Basis"], "sql_count", Infer), loc) |
2033 | COUNT LPAREN sqlexp RPAREN (let | 2035 | SOME _ => |
2034 val loc = s (COUNTleft, RPARENright) | 2036 let |
2035 | 2037 val e = (EVar (["Basis"], "sql_window_count", Infer), loc) |
2036 val e = (EVar (["Basis"], "sql_count_col", Infer), loc) | 2038 in |
2037 val e = (EApp ((EVar (["Basis"], "sql_aggregate", Infer), loc), | 2039 (EApp ((EVar (["Basis"], "sql_window", Infer), loc), e), loc) |
2038 e), loc) | 2040 end |
2039 in | 2041 end) |
2040 (EApp (e, sqlexp), loc) | 2042 | RANK UNIT window (let |
2041 end) | 2043 val loc = s (RANKleft, windowright) |
2042 | sqlagg LPAREN sqlexp RPAREN (let | 2044 val e = (EVar (["Basis"], "sql_window_rank", Infer), loc) |
2043 val loc = s (sqlaggleft, RPARENright) | 2045 in |
2044 | 2046 (EApp ((EVar (["Basis"], "sql_window", Infer), loc), e), loc) |
2045 val e = (EVar (["Basis"], "sql_" ^ sqlagg, Infer), loc) | 2047 end) |
2046 val e = (EApp ((EVar (["Basis"], "sql_aggregate", Infer), loc), | 2048 | COUNT LPAREN sqlexp RPAREN window (let |
2047 e), loc) | 2049 val loc = s (COUNTleft, windowright) |
2048 in | 2050 |
2049 (EApp (e, sqlexp), loc) | 2051 val e = (EVar (["Basis"], "sql_count_col", Infer), loc) |
2050 end) | 2052 in |
2053 case window of | |
2054 NONE => | |
2055 let | |
2056 val e = (EApp ((EVar (["Basis"], "sql_aggregate", Infer), loc), | |
2057 e), loc) | |
2058 in | |
2059 (EApp (e, sqlexp), loc) | |
2060 end | |
2061 | SOME _ => | |
2062 let | |
2063 val e = (EApp ((EVar (["Basis"], "sql_window_aggregate", Infer), loc), | |
2064 e), loc) | |
2065 val e = (EApp (e, sqlexp), loc) | |
2066 in | |
2067 (EApp ((EVar (["Basis"], "sql_window", Infer), loc), e), loc) | |
2068 end | |
2069 end) | |
2070 | sqlagg LPAREN sqlexp RPAREN window (let | |
2071 val loc = s (sqlaggleft, windowright) | |
2072 | |
2073 val e = (EVar (["Basis"], "sql_" ^ sqlagg, Infer), loc) | |
2074 in | |
2075 case window of | |
2076 NONE => | |
2077 let | |
2078 val e = (EApp ((EVar (["Basis"], "sql_aggregate", Infer), loc), | |
2079 e), loc) | |
2080 in | |
2081 (EApp (e, sqlexp), loc) | |
2082 end | |
2083 | SOME _ => | |
2084 let | |
2085 val e = (EApp ((EVar (["Basis"], "sql_window_aggregate", Infer), loc), | |
2086 e), loc) | |
2087 val e = (EApp (e, sqlexp), loc) | |
2088 in | |
2089 (EApp ((EVar (["Basis"], "sql_window", Infer), loc), e), loc) | |
2090 end | |
2091 end) | |
2051 | COALESCE LPAREN sqlexp COMMA sqlexp RPAREN | 2092 | COALESCE LPAREN sqlexp COMMA sqlexp RPAREN |
2052 (let | 2093 (let |
2053 val loc = s (COALESCEright, sqlexp2right) | 2094 val loc = s (COALESCEright, sqlexp2right) |
2054 val e = (EVar (["Basis"], "sql_coalesce", Infer), loc) | 2095 val e = (EVar (["Basis"], "sql_coalesce", Infer), loc) |
2055 val e = (EApp (e, sqlexp1), loc) | 2096 val e = (EApp (e, sqlexp1), loc) |
2069 | 2110 |
2070 val e = (EVar (["Basis"], "sql_subquery", Infer), loc) | 2111 val e = (EVar (["Basis"], "sql_subquery", Infer), loc) |
2071 in | 2112 in |
2072 (EApp (e, query), loc) | 2113 (EApp (e, query), loc) |
2073 end) | 2114 end) |
2115 | |
2116 window : (NONE) | |
2117 | OVER LPAREN RPAREN (SOME ()) | |
2074 | 2118 |
2075 fname : SYMBOL (EVar (["Basis"], "sql_" ^ SYMBOL, Infer), s (SYMBOLleft, SYMBOLright)) | 2119 fname : SYMBOL (EVar (["Basis"], "sql_" ^ SYMBOL, Infer), s (SYMBOLleft, SYMBOLright)) |
2076 | LBRACE eexp RBRACE (eexp) | 2120 | LBRACE eexp RBRACE (eexp) |
2077 | 2121 |
2078 wopt : (sql_inject (EVar (["Basis"], "True", Infer), | 2122 wopt : (sql_inject (EVar (["Basis"], "True", Infer), |