2022-08-12 21:08:20 +03:00
|
|
|
/- ast
|
2022-10-21 20:44:14 +03:00
|
|
|
!:
|
2022-08-21 03:29:26 +03:00
|
|
|
|_ current-database=@t :: (parse:parse(current-database '<db>') "<script>")
|
2022-08-29 21:29:37 +03:00
|
|
|
::
|
|
|
|
:: generic urQL command
|
|
|
|
::
|
2022-08-12 21:08:20 +03:00
|
|
|
+$ command-ast
|
|
|
|
$%
|
2022-09-07 22:25:00 +03:00
|
|
|
alter-index:ast
|
|
|
|
alter-namespace:ast
|
2022-09-08 23:48:02 +03:00
|
|
|
alter-table:ast
|
2022-08-13 05:00:44 +03:00
|
|
|
create-database:ast
|
|
|
|
create-index:ast
|
|
|
|
create-namespace:ast
|
|
|
|
create-table:ast
|
|
|
|
create-view:ast
|
2022-08-16 22:18:14 +03:00
|
|
|
drop-database:ast
|
|
|
|
drop-index:ast
|
|
|
|
drop-namespace:ast
|
|
|
|
drop-table:ast
|
|
|
|
drop-view:ast
|
2022-08-23 03:53:59 +03:00
|
|
|
grant:ast
|
2022-09-04 20:53:13 +03:00
|
|
|
insert:ast
|
2022-09-12 22:38:25 +03:00
|
|
|
:: query:ast :: currently fish-loop
|
2022-08-23 18:59:52 +03:00
|
|
|
revoke:ast
|
2022-08-17 20:10:50 +03:00
|
|
|
truncate-table:ast
|
2022-08-12 21:08:20 +03:00
|
|
|
==
|
|
|
|
+$ command
|
|
|
|
$%
|
2022-09-07 22:25:00 +03:00
|
|
|
%alter-index
|
|
|
|
%alter-namespace
|
2022-09-08 23:48:02 +03:00
|
|
|
%alter-table
|
2022-08-12 21:08:20 +03:00
|
|
|
%create-database
|
|
|
|
%create-index
|
|
|
|
%create-namespace
|
|
|
|
%create-table
|
|
|
|
%create-view
|
2022-08-16 22:18:14 +03:00
|
|
|
%drop-database
|
|
|
|
%drop-index
|
|
|
|
%drop-namespace
|
|
|
|
%drop-table
|
|
|
|
%drop-view
|
2022-08-23 03:53:59 +03:00
|
|
|
%grant
|
2022-09-04 20:53:13 +03:00
|
|
|
%insert
|
2022-09-12 22:38:25 +03:00
|
|
|
%query
|
2022-08-23 18:59:52 +03:00
|
|
|
%revoke
|
2022-08-17 20:10:50 +03:00
|
|
|
%truncate-table
|
2022-08-12 21:08:20 +03:00
|
|
|
==
|
2022-08-13 05:00:44 +03:00
|
|
|
::
|
2022-08-29 21:29:37 +03:00
|
|
|
:: helper types
|
|
|
|
::
|
|
|
|
+$ interim-key
|
|
|
|
$:
|
|
|
|
%interim-key
|
2022-09-02 03:14:57 +03:00
|
|
|
is-clustered=?
|
2022-08-29 21:29:37 +03:00
|
|
|
columns=(list ordered-column:ast)
|
|
|
|
==
|
2022-10-21 20:44:14 +03:00
|
|
|
+$ expression ?(qualified-column:ast value-literal:ast value-literal-list:ast aggregate:ast)
|
2022-09-25 18:52:01 +03:00
|
|
|
+$ list6
|
|
|
|
$:
|
|
|
|
%list6
|
|
|
|
l1=*
|
|
|
|
l2=*
|
|
|
|
l3=*
|
|
|
|
l4=*
|
|
|
|
l5=*
|
|
|
|
l6=*
|
|
|
|
==
|
|
|
|
+$ list5
|
|
|
|
$:
|
|
|
|
%list5
|
|
|
|
l1=*
|
|
|
|
l2=*
|
|
|
|
l3=*
|
|
|
|
l4=*
|
|
|
|
l5=*
|
|
|
|
==
|
|
|
|
+$ list4
|
|
|
|
$:
|
|
|
|
%list4
|
|
|
|
l1=*
|
|
|
|
l2=*
|
|
|
|
l3=*
|
|
|
|
l4=*
|
|
|
|
==
|
|
|
|
+$ try-fail %fail
|
|
|
|
+$ try-success
|
|
|
|
$:
|
|
|
|
%try-success
|
|
|
|
result=*
|
|
|
|
==
|
|
|
|
+$ try-result ?(try-success try-fail)
|
2022-08-29 21:29:37 +03:00
|
|
|
::
|
2022-08-22 00:09:24 +03:00
|
|
|
:: get next position in script
|
|
|
|
::
|
|
|
|
++ get-next-cursor
|
|
|
|
|= [last-cursor=[@ud @ud] command-hair=[@ud @ud] end-hair=[@ud @ud]]
|
|
|
|
^- [@ud @ud]
|
|
|
|
=/ next-hair ?: (gth -.command-hair 1) :: if we advanced to next input line
|
|
|
|
[(sub (add -.command-hair -.last-cursor) 1) +.command-hair] :: add lines and use last column
|
|
|
|
[-.command-hair (sub (add +.command-hair +.last-cursor) 1)] :: else add column positions
|
|
|
|
?: (gth -.end-hair 1) :: if we advanced to next input line
|
|
|
|
[(sub (add -.next-hair -.end-hair) 1) +.end-hair] :: add lines and use last column
|
|
|
|
[-.next-hair (sub (add +.next-hair +.end-hair) 1)] :: else add column positions
|
2022-09-07 01:46:28 +03:00
|
|
|
|
2022-09-02 03:14:57 +03:00
|
|
|
::
|
2022-08-17 20:10:50 +03:00
|
|
|
:: parser rules and helpers
|
2022-08-16 22:18:14 +03:00
|
|
|
::
|
2022-09-13 23:29:49 +03:00
|
|
|
++ whitespace ~+ (star ;~(pose gah (just '\09') (just '\0d')))
|
|
|
|
++ prn-less-soz ~+ ;~(less (just `@`39) (just `@`127) (shim 32 256))
|
|
|
|
++ crub-no-text :: crub:so without text parsing
|
2022-09-04 20:53:13 +03:00
|
|
|
~+
|
|
|
|
;~ pose
|
|
|
|
(cook |=(det=date `dime`[%da (year det)]) when:so)
|
|
|
|
::
|
|
|
|
%+ cook
|
|
|
|
|= [a=(list [p=?(%d %h %m %s) q=@]) b=(list @)]
|
|
|
|
=+ rop=`tarp`[0 0 0 0 b]
|
|
|
|
|- ^- dime
|
|
|
|
?~ a
|
|
|
|
[%dr (yule rop)]
|
|
|
|
?- p.i.a
|
|
|
|
%d $(a t.a, d.rop (add q.i.a d.rop))
|
|
|
|
%h $(a t.a, h.rop (add q.i.a h.rop))
|
|
|
|
%m $(a t.a, m.rop (add q.i.a m.rop))
|
|
|
|
%s $(a t.a, s.rop (add q.i.a s.rop))
|
|
|
|
==
|
|
|
|
;~ plug
|
|
|
|
%+ most
|
|
|
|
dot
|
|
|
|
;~ pose
|
|
|
|
;~(pfix (just 'd') (stag %d dim:ag))
|
|
|
|
;~(pfix (just 'h') (stag %h dim:ag))
|
|
|
|
;~(pfix (just 'm') (stag %m dim:ag))
|
|
|
|
;~(pfix (just 's') (stag %s dim:ag))
|
|
|
|
==
|
|
|
|
;~(pose ;~(pfix ;~(plug dot dot) (most dot qix:ab)) (easy ~))
|
|
|
|
==
|
|
|
|
::
|
|
|
|
(stag %p fed:ag)
|
|
|
|
==
|
2022-08-17 20:10:50 +03:00
|
|
|
++ jester :: match a cord, case agnostic, thanks ~tinnus-napbus
|
2022-08-16 22:18:14 +03:00
|
|
|
|= daf=@t
|
|
|
|
|= tub=nail
|
|
|
|
=+ fad=daf
|
|
|
|
|- ^- (like @t)
|
2022-08-28 18:58:03 +03:00
|
|
|
~+
|
2022-08-16 22:18:14 +03:00
|
|
|
?: =(`@`0 daf)
|
|
|
|
[p=p.tub q=[~ u=[p=fad q=tub]]]
|
2022-08-17 20:10:50 +03:00
|
|
|
=+ n=(end 3 daf)
|
|
|
|
?. ?& ?=(^ q.tub)
|
|
|
|
?| =(n i.q.tub)
|
|
|
|
&((lte 97 n) (gte 122 n) =((sub n 32) i.q.tub))
|
|
|
|
&((lte 65 n) (gte 90 n) =((add 32 n) i.q.tub))
|
|
|
|
==
|
|
|
|
==
|
2022-08-16 22:18:14 +03:00
|
|
|
(fail tub)
|
|
|
|
$(p.tub (lust i.q.tub p.tub), q.tub t.q.tub, daf (rsh 3 daf))
|
2022-09-13 23:29:49 +03:00
|
|
|
::
|
|
|
|
:: qualified objects, usually table or view
|
|
|
|
:: maximally qualified by @p.database.namespace
|
|
|
|
:: minimally qualified by namespace
|
|
|
|
::
|
2022-09-02 03:14:57 +03:00
|
|
|
++ cook-qualified-2object :: namespace.object-name
|
|
|
|
|= a=*
|
|
|
|
~+
|
|
|
|
?@ a
|
|
|
|
(qualified-object:ast %qualified-object ~ current-database 'dbo' a)
|
|
|
|
(qualified-object:ast %qualified-object ~ current-database -.a +.a)
|
2022-08-28 18:58:03 +03:00
|
|
|
++ cook-qualified-3object :: database.namespace.object-name
|
2022-08-22 06:25:18 +03:00
|
|
|
|= a=*
|
2022-08-28 18:58:03 +03:00
|
|
|
~+
|
2022-09-12 22:38:25 +03:00
|
|
|
?: ?=([@ @ @] a) :: db.ns.name
|
|
|
|
(qualified-object:ast %qualified-object ~ -.a +<.a +>.a)
|
|
|
|
?: ?=([@ @ @ @] a) :: db..name
|
|
|
|
(qualified-object:ast %qualified-object ~ -.a 'dbo' +>+.a)
|
|
|
|
?: ?=([@ @] a) :: ns.name
|
|
|
|
(qualified-object:ast %qualified-object ~ current-database -.a +.a)
|
|
|
|
?@ a :: name
|
|
|
|
(qualified-object:ast %qualified-object ~ current-database 'dbo' a)
|
2022-08-22 04:03:52 +03:00
|
|
|
!!
|
2022-08-28 18:58:03 +03:00
|
|
|
++ cook-qualified-object :: @p.database.namespace.object-name
|
2022-08-21 03:29:26 +03:00
|
|
|
|= a=*
|
2022-08-28 18:58:03 +03:00
|
|
|
~+
|
2022-09-12 22:38:25 +03:00
|
|
|
?: ?=([@ @ @ @] a)
|
|
|
|
?: =(+<.a '.')
|
|
|
|
(qualified-object:ast %qualified-object ~ -.a 'dbo' +>+.a) :: db..name
|
|
|
|
(qualified-object:ast %qualified-object `-.a +<.a +>-.a +>+.a) :: ~firsub.db.ns.name
|
|
|
|
?: ?=([@ @ @ @ @ @] a) :: ~firsub.db..name
|
|
|
|
(qualified-object:ast %qualified-object `-.a +>-.a 'dbo' +>+>+.a)
|
|
|
|
?: ?=([@ @ @] a)
|
|
|
|
(qualified-object:ast %qualified-object ~ -.a +<.a +>.a) :: db.ns.name
|
|
|
|
?: ?=([@ @] a) :: ns.name
|
|
|
|
(qualified-object:ast %qualified-object ~ current-database -.a +.a)
|
|
|
|
?@ a :: name
|
|
|
|
(qualified-object:ast %qualified-object ~ current-database 'dbo' a)
|
2022-08-21 03:29:26 +03:00
|
|
|
!!
|
2022-09-13 23:29:49 +03:00
|
|
|
++ qualified-namespace ~+ :: database.namespace
|
|
|
|
|= [a=* current-database=@t]
|
|
|
|
~+
|
|
|
|
?: ?=([@ @] [a])
|
|
|
|
a
|
|
|
|
[current-database a]
|
|
|
|
++ parse-qualified-2-name ~+ ;~(pose ;~(pfix whitespace ;~((glue dot) sym sym)) parse-face)
|
|
|
|
++ parse-qualified-3 ~+ ;~ pose :: for when qualifying with ship is not allowed
|
|
|
|
;~((glue dot) sym sym sym)
|
|
|
|
;~(plug sym dot dot sym)
|
|
|
|
;~((glue dot) sym sym)
|
|
|
|
sym
|
|
|
|
==
|
|
|
|
++ parse-qualified-3object ~+ (cook cook-qualified-3object ;~(pfix whitespace parse-qualified-3))
|
|
|
|
++ parse-qualified-object ~+ (cook cook-qualified-object ;~(pose ;~((glue dot) parse-ship sym sym sym) ;~(plug parse-ship:parse dot sym dot dot sym) ;~(plug sym dot dot sym) parse-qualified-3))
|
|
|
|
::
|
2022-09-25 18:52:01 +03:00
|
|
|
:: working with atomic value literals
|
2022-09-13 23:29:49 +03:00
|
|
|
::
|
2022-09-25 18:52:01 +03:00
|
|
|
++ cord-literal ~+
|
|
|
|
(cook |=(a=(list @t) [%t (crip a)]) (ifix [soq soq] (star ;~(pose (cold '\'' (jest '\\\'')) prn-less-soz))))
|
2022-09-13 23:29:49 +03:00
|
|
|
++ numeric-parser ;~ pose
|
|
|
|
(stag %ud (full dem:ag)) :: formatted @ud
|
|
|
|
(stag %ud (full dim:ag)) :: unformatted @ud, no leading 0s
|
|
|
|
(stag %ub (full bay:ag)) :: formatted @ub, no leading 0s
|
|
|
|
(stag %ux ;~(pfix (jest '0x') (full hex:ag))) :: formatted @ux
|
|
|
|
(full tash:so) :: @sd or @sx
|
|
|
|
(stag %rs (full royl-rs:so)) :: @rs
|
|
|
|
(stag %rd (full royl-rd:so)) :: @rd
|
|
|
|
(stag %uw (full wiz:ag)) :: formatted @uw base-64 unsigned
|
|
|
|
==
|
|
|
|
++ non-numeric-parser ;~ pose
|
|
|
|
cord-literal
|
|
|
|
;~(pose ;~(pfix sig crub-no-text) crub-no-text) :: @da, @dr, @p
|
|
|
|
(stag %is ;~(pfix (just '.') bip:ag)) :: @is
|
|
|
|
(stag %if ;~(pfix (just '.') lip:ag)) :: @if
|
|
|
|
(stag %f ;~(pose (cold & (jester 'y')) (cold | (jester 'n')))) :: @if
|
|
|
|
==
|
|
|
|
++ cook-numbers :: works for insert values
|
|
|
|
|= a=(list @t)
|
2022-09-02 03:14:57 +03:00
|
|
|
~+
|
2022-09-13 23:29:49 +03:00
|
|
|
(scan a numeric-parser)
|
|
|
|
++ sear-numbers :: works for predicate values
|
2022-09-04 20:53:13 +03:00
|
|
|
|= a=(list @t)
|
|
|
|
~+
|
2022-09-13 23:29:49 +03:00
|
|
|
=/ parsed (numeric-parser [[1 1] a])
|
|
|
|
?~ q.parsed ~
|
|
|
|
(some (wonk parsed))
|
|
|
|
++ numeric-characters ~+
|
|
|
|
:: including base-64 characters
|
|
|
|
(star ;~(pose (shim 48 57) (shim 65 90) (shim 97 122) dot fas hep lus sig tis))
|
2022-09-25 18:52:01 +03:00
|
|
|
++ parse-value-literal ~+ ;~ pose
|
2022-09-13 23:29:49 +03:00
|
|
|
non-numeric-parser
|
|
|
|
(sear sear-numbers numeric-characters) :: all numeric parsers
|
|
|
|
==
|
|
|
|
++ insert-value ~+ ;~ pose
|
2022-09-05 20:26:35 +03:00
|
|
|
(cold [%default %default] (jester 'default'))
|
2022-09-13 23:29:49 +03:00
|
|
|
;~(pose non-numeric-parser (cook cook-numbers numeric-characters))
|
2022-09-04 20:53:13 +03:00
|
|
|
==
|
2022-09-25 18:52:01 +03:00
|
|
|
++ get-value-literal ;~ pose
|
|
|
|
;~(sfix ;~(pfix whitespace parse-value-literal) whitespace)
|
|
|
|
;~(pfix whitespace parse-value-literal)
|
|
|
|
;~(sfix parse-value-literal whitespace)
|
|
|
|
parse-value-literal
|
|
|
|
==
|
|
|
|
++ cook-literal-list
|
2022-09-30 23:31:56 +03:00
|
|
|
:: 1. all literal types must be the same
|
2022-09-25 18:52:01 +03:00
|
|
|
::
|
2022-09-30 23:31:56 +03:00
|
|
|
:: 2. (a-co:co d) each atom to tape, weld tapes with delimiter, crip final tape
|
2022-10-20 22:46:29 +03:00
|
|
|
:: bad reason for (2): cannot ?=(expression ...) when expression includes a list
|
2022-09-25 18:52:01 +03:00
|
|
|
::
|
|
|
|
|= a=(list value-literal:ast)
|
|
|
|
=/ literal-type=@tas -<.a
|
|
|
|
=/ b a
|
|
|
|
=/ literal-list=tape ~
|
|
|
|
|-
|
|
|
|
?: =(b ~) (value-literal-list:ast %value-literal-list literal-type (crip literal-list))
|
|
|
|
?: =(-<.b literal-type)
|
|
|
|
?: =(literal-list ~)
|
|
|
|
$(b +.b, literal-list (a-co:co ->.b))
|
|
|
|
$(b +.b, literal-list (weld (weld (a-co:co ->.b) ";") literal-list))
|
|
|
|
!!
|
|
|
|
++ value-literal-list
|
|
|
|
(cook cook-literal-list ;~(pose ;~(pfix whitespace (ifix [pal par] (more com get-value-literal))) (ifix [pal par] (more com get-value-literal))))
|
2022-09-13 23:29:49 +03:00
|
|
|
++ parse-insert-value ~+ ;~ pose
|
|
|
|
;~(pfix whitespace ;~(sfix insert-value whitespace))
|
|
|
|
;~(pfix whitespace insert-value)
|
|
|
|
;~(sfix insert-value whitespace)
|
|
|
|
insert-value
|
2022-09-04 20:53:13 +03:00
|
|
|
==
|
2022-09-25 18:52:01 +03:00
|
|
|
::
|
|
|
|
:: used for various commands
|
|
|
|
::
|
|
|
|
++ crash
|
|
|
|
|= msg=tape
|
|
|
|
~& msg
|
|
|
|
!!
|
|
|
|
++ cook-column
|
|
|
|
|= a=*
|
|
|
|
?: ?=([@ @] [a])
|
|
|
|
(column:ast %column -.a +.a)
|
|
|
|
!!
|
|
|
|
++ cook-ordered-column
|
|
|
|
|= a=*
|
|
|
|
?@ a
|
|
|
|
(ordered-column:ast %ordered-column a %.y)
|
|
|
|
?: ?=([@ @] [a])
|
|
|
|
?: =(+.a %asc)
|
|
|
|
(ordered-column:ast %ordered-column -.a %.y)
|
|
|
|
(ordered-column:ast %ordered-column -.a %.n)
|
|
|
|
!!
|
|
|
|
|
|
|
|
++ cook-referential-integrity
|
|
|
|
|= a=*
|
|
|
|
?: ?=([[@ @] @ @] [a]) :: <type> cascade, <type> cascade
|
|
|
|
?: =(%delete -<.a)
|
|
|
|
?: =(%update +<.a)
|
|
|
|
~[%delete-cascade %update-cascade]
|
|
|
|
!!
|
|
|
|
?: =(%update -<.a)
|
|
|
|
?: =(%delete +<.a)
|
|
|
|
~[%delete-cascade %update-cascade]
|
|
|
|
!!
|
|
|
|
!!
|
|
|
|
?: ?=([@ @] [a]) :: <type> cascade
|
|
|
|
?: =(-.a %delete) [%delete-cascade ~] [%update-cascade ~]
|
|
|
|
?: ?=([[@ @] @ @ [@ %~] @] [a]) :: <type> cascade, <type> no action
|
|
|
|
?: =(-<.a %delete) [%delete-cascade ~] [%update-cascade ~]
|
|
|
|
?: ?=([[@ @ [@ %~] @] @ @] [a]) :: <type> no action, <type> cascade
|
|
|
|
?: =(+<.a %delete) [%delete-cascade ~] [%update-cascade ~]
|
|
|
|
?: ?=([@ [@ %~]] a) :: <type> no action
|
|
|
|
~
|
|
|
|
?: ?=([[@ @ [@ %~] @] @ @ [@ %~] @] a) :: <type> no action, <type> no action
|
|
|
|
~
|
|
|
|
!!
|
2022-09-13 23:29:49 +03:00
|
|
|
++ end-or-next-command ~+ (cold %end-command ;~(pose ;~(plug whitespace mic) whitespace mic))
|
2022-09-12 22:38:25 +03:00
|
|
|
++ alias ~+
|
|
|
|
%+ cook
|
|
|
|
|=(a=tape (rap 3 ^-((list ,@) a)))
|
|
|
|
;~(plug alf (star ;~(pose nud alf)))
|
|
|
|
++ parse-alias ~+ ;~(pfix whitespace alias)
|
2022-08-28 18:58:03 +03:00
|
|
|
++ parse-face ~+ ;~(pfix whitespace sym)
|
2022-09-02 03:14:57 +03:00
|
|
|
++ face-list ~+ ;~(pfix whitespace (ifix [pal par] (more com ;~(pose ;~(sfix parse-face whitespace) parse-face))))
|
2022-08-28 18:58:03 +03:00
|
|
|
++ ordering ~+ ;~(pfix whitespace ;~(pose (jester 'asc') (jester 'desc')))
|
2022-09-04 20:53:13 +03:00
|
|
|
++ clustering ~+ ;~(pfix whitespace ;~(pose (jester 'clustered') (jester 'nonclustered')))
|
2022-08-29 21:29:37 +03:00
|
|
|
++ ordered-column-list ~+
|
|
|
|
;~(pfix whitespace (ifix [pal par] (more com (cook cook-ordered-column ;~(pose ;~(sfix ;~(plug parse-face ordering) whitespace) ;~(plug parse-face ordering) ;~(sfix parse-face whitespace) parse-face)))))
|
2022-08-28 18:58:03 +03:00
|
|
|
++ parse-ship ~+ ;~(pfix sig fed:ag)
|
2022-09-04 20:53:13 +03:00
|
|
|
++ ship-list ~+ (more com ;~(pose ;~(sfix ;~(pfix whitespace parse-ship) whitespace) ;~(pfix whitespace parse-ship) ;~(sfix parse-ship whitespace) parse-ship))
|
2022-08-28 18:58:03 +03:00
|
|
|
++ on-database ~+ ;~(plug (jester 'database') parse-face)
|
|
|
|
++ on-namespace ~+
|
2022-08-29 21:29:37 +03:00
|
|
|
;~(plug (jester 'namespace') (cook |=(a=* (qualified-namespace [a current-database])) parse-qualified-2-name))
|
2022-08-28 18:58:03 +03:00
|
|
|
++ grant-object ~+
|
2022-08-29 21:29:37 +03:00
|
|
|
;~(pfix whitespace ;~(pfix (jester 'on') ;~(pfix whitespace ;~(pose on-database on-namespace parse-qualified-3object))))
|
2022-08-28 18:58:03 +03:00
|
|
|
++ parse-aura ~+
|
2022-08-29 21:29:37 +03:00
|
|
|
=/ root-aura ;~ pose
|
|
|
|
(jest '@c')
|
|
|
|
(jest '@da')
|
|
|
|
(jest '@dr')
|
|
|
|
(jest '@d')
|
|
|
|
(jest '@f')
|
|
|
|
(jest '@if')
|
|
|
|
(jest '@is')
|
|
|
|
(jest '@i')
|
|
|
|
(jest '@n')
|
|
|
|
(jest '@p')
|
|
|
|
(jest '@q')
|
|
|
|
(jest '@rh')
|
|
|
|
(jest '@rs')
|
|
|
|
(jest '@rd')
|
|
|
|
(jest '@rq')
|
|
|
|
(jest '@r')
|
|
|
|
(jest '@sb')
|
|
|
|
(jest '@sd')
|
|
|
|
(jest '@sv')
|
|
|
|
(jest '@sw')
|
|
|
|
(jest '@sx')
|
|
|
|
(jest '@s')
|
|
|
|
(jest '@ta')
|
|
|
|
(jest '@tas')
|
|
|
|
(jest '@t')
|
|
|
|
(jest '@ub')
|
|
|
|
(jest '@ud')
|
|
|
|
(jest '@uv')
|
|
|
|
(jest '@uw')
|
|
|
|
(jest '@ux')
|
|
|
|
(jest '@u')
|
|
|
|
(jest '@')
|
|
|
|
==
|
|
|
|
;~ pose
|
|
|
|
;~(plug root-aura (shim 'A' 'J'))
|
|
|
|
root-aura
|
|
|
|
==
|
|
|
|
++ column-defintion-list ~+
|
|
|
|
=/ column-definition ;~ plug
|
|
|
|
sym
|
|
|
|
;~(pfix whitespace parse-aura)
|
|
|
|
==
|
|
|
|
(more com (cook cook-column ;~(pose ;~(pfix whitespace ;~(sfix column-definition whitespace)) ;~(sfix column-definition whitespace) ;~(pfix whitespace column-definition) column-definition)))
|
2022-09-13 23:29:49 +03:00
|
|
|
++ referential-integrity ;~ plug
|
|
|
|
;~(pfix ;~(plug whitespace (jester 'on') whitespace) ;~(pose (jester 'update') (jester 'delete')))
|
|
|
|
;~(pfix whitespace ;~(pose (jester 'cascade') ;~(plug (jester 'no') whitespace (jester 'action'))))
|
|
|
|
==
|
|
|
|
++ column-definitions ~+ ;~(pfix whitespace (ifix [pal par] column-defintion-list))
|
|
|
|
++ alter-columns ~+ ;~ plug
|
|
|
|
(cold %alter-column ;~(plug whitespace (jester 'alter') whitespace (jester 'column')))
|
|
|
|
column-definitions
|
|
|
|
==
|
|
|
|
++ add-columns ~+ ;~ plug
|
|
|
|
(cold %add-column ;~(plug whitespace (jester 'add') whitespace (jester 'column')))
|
|
|
|
column-definitions
|
2022-09-04 20:53:13 +03:00
|
|
|
==
|
2022-09-13 23:29:49 +03:00
|
|
|
++ drop-columns ~+ ;~ plug
|
|
|
|
(cold %drop-column ;~(plug whitespace (jester 'drop') whitespace (jester 'column')))
|
|
|
|
face-list
|
|
|
|
==
|
2022-10-16 02:09:57 +03:00
|
|
|
++ parse-datum ~+ ;~ pose
|
|
|
|
;~(pose ;~(pfix whitespace parse-qualified-column) parse-qualified-column)
|
|
|
|
;~(pose ;~(pfix whitespace parse-value-literal) parse-value-literal)
|
|
|
|
==
|
2022-10-21 20:44:14 +03:00
|
|
|
++ cook-aggregate
|
|
|
|
|= parsed=*
|
|
|
|
(aggregate:ast %aggregate -.parsed +.parsed)
|
2022-10-22 01:37:24 +03:00
|
|
|
++ parse-aggregate ~+ ;~ pose
|
|
|
|
(cook cook-aggregate ;~(pfix whitespace ;~(plug ;~(sfix parse-alias pal) ;~(sfix get-datum par))))
|
2022-10-21 20:44:14 +03:00
|
|
|
(cook cook-aggregate ;~(plug ;~(sfix parse-alias pal) ;~(sfix get-datum par)))
|
2022-10-22 01:37:24 +03:00
|
|
|
==
|
2022-09-13 23:29:49 +03:00
|
|
|
::
|
|
|
|
:: indices
|
|
|
|
::
|
|
|
|
++ cook-primary-key
|
|
|
|
|= a=*
|
|
|
|
?@ -.a
|
|
|
|
?: =(-.a 'clustered') (interim-key %interim-key %.y +.a) (interim-key %interim-key %.n +.a)
|
|
|
|
(interim-key %interim-key %.n a)
|
|
|
|
++ cook-foreign-key
|
|
|
|
|= a=*
|
|
|
|
~+
|
|
|
|
?: ?=([[@ * * [@ @] *] *] [a]) :: foreign key ns.table ... references fk-table ... on action on action
|
|
|
|
(foreign-key:ast %foreign-key -<.a ->-.a ->+<-.a ->+<+.a ->+>.a +.a)
|
|
|
|
?: ?=([[@ [[@ @ @] %~] @ [@ %~]] *] [a]) :: foreign key table ... references fk-table ... on action on action
|
|
|
|
(foreign-key:ast %foreign-key -<.a ->-.a ->+<-.a 'dbo' ->+.a +.a)
|
|
|
|
!!
|
2022-09-07 01:46:28 +03:00
|
|
|
++ build-foreign-keys
|
|
|
|
|= a=[table=qualified-object:ast f-keys=(list *)]
|
|
|
|
=/ f-keys +.a
|
|
|
|
=/ foreign-keys `(list foreign-key:ast)`~
|
|
|
|
|-
|
|
|
|
?: =(~ f-keys)
|
2022-09-10 02:30:41 +03:00
|
|
|
(flop foreign-keys)
|
2022-09-07 01:46:28 +03:00
|
|
|
?@ -<.f-keys
|
|
|
|
%= $ :: foreign key table must be in same DB as table
|
|
|
|
foreign-keys [(foreign-key:ast %foreign-key -<.f-keys -.a ->-.f-keys (qualified-object:ast %qualified-object ~ ->+<.a ->+<+>+<.f-keys ->+<+>+>.f-keys) ->+>.f-keys ~) foreign-keys]
|
|
|
|
f-keys +.f-keys
|
|
|
|
==
|
|
|
|
%= $ :: foreign key table must be in same DB as table
|
|
|
|
foreign-keys [(foreign-key:ast %foreign-key -<-.f-keys -.a -<+<.f-keys (qualified-object:ast %qualified-object ~ ->+<.a -<+>->+>-.f-keys -<+>->+>+.f-keys) -<+>+.f-keys ->.f-keys) foreign-keys]
|
|
|
|
f-keys +.f-keys
|
|
|
|
==
|
2022-09-10 02:30:41 +03:00
|
|
|
++ foreign-key-literal ~+ ;~(plug whitespace (jester 'foreign') whitespace (jester 'key'))
|
|
|
|
++ foreign-key ~+
|
|
|
|
;~(plug parse-face ordered-column-list ;~(pfix ;~(plug whitespace (jester 'references')) ;~(plug (cook cook-qualified-2object parse-qualified-2-name) face-list)))
|
2022-09-07 01:46:28 +03:00
|
|
|
++ full-foreign-key ;~ pose
|
|
|
|
;~(plug foreign-key (cook cook-referential-integrity ;~(plug referential-integrity referential-integrity)))
|
|
|
|
;~(plug foreign-key (cook cook-referential-integrity ;~(plug referential-integrity referential-integrity)))
|
|
|
|
;~(plug foreign-key (cook cook-referential-integrity referential-integrity))
|
|
|
|
;~(plug foreign-key (cook cook-referential-integrity referential-integrity))
|
|
|
|
foreign-key
|
|
|
|
==
|
2022-09-08 23:48:02 +03:00
|
|
|
++ add-foreign-key ~+ ;~ plug
|
|
|
|
(cold %add-fk ;~(plug whitespace (jester 'add')))
|
2022-09-10 02:30:41 +03:00
|
|
|
;~(pfix foreign-key-literal (more com full-foreign-key))
|
2022-09-08 23:48:02 +03:00
|
|
|
==
|
|
|
|
++ drop-foreign-key ~+ ;~ plug
|
|
|
|
(cold %drop-fk ;~(plug whitespace (jester 'drop') whitespace (jester 'foreign') whitespace (jester 'key')))
|
|
|
|
face-list
|
|
|
|
==
|
2022-09-10 02:30:41 +03:00
|
|
|
++ primary-key
|
|
|
|
(cook cook-primary-key ;~(pfix ;~(plug whitespace (jester 'primary') whitespace (jester 'key')) ;~(pose ;~(plug clustering ordered-column-list) ordered-column-list)))
|
|
|
|
++ create-primary-key
|
|
|
|
|= a=[[@ ship=(unit @p) database=@t namespace=@t name=@t] key=*]
|
|
|
|
=/ key-name (crip (weld (weld "ix-primary-" (trip namespace.a)) (weld "-" (trip name.a))))
|
|
|
|
(create-index:ast %create-index key-name (qualified-object:ast %qualified-object ~ database.a namespace.a name.a) %.y +<:key.a +>:key.a)
|
2022-09-13 23:29:49 +03:00
|
|
|
::
|
2022-09-25 18:52:01 +03:00
|
|
|
:: query object and joins
|
2022-09-13 23:29:49 +03:00
|
|
|
::
|
2022-09-25 18:52:01 +03:00
|
|
|
++ query-object ;~ pose
|
|
|
|
;~(plug parse-qualified-object ;~(pfix whitespace ;~(pfix (jester 'as') parse-alias)))
|
|
|
|
;~(plug parse-qualified-object ;~(pfix whitespace ;~(less ;~(pose (jester 'join') (jester 'left') (jester 'right') (jester 'outer') (jester 'cross')) parse-alias)))
|
|
|
|
parse-qualified-object
|
|
|
|
==
|
2022-09-12 22:38:25 +03:00
|
|
|
++ parse-query-object ~+ ;~ pfix
|
|
|
|
whitespace
|
2022-09-25 18:52:01 +03:00
|
|
|
(cook build-query-object query-object)
|
2022-09-12 22:38:25 +03:00
|
|
|
==
|
2022-09-13 23:29:49 +03:00
|
|
|
++ parse-join-type ;~ pfix whitespace ;~ pose
|
|
|
|
(cold %join (jester 'join'))
|
|
|
|
(cold %left-join ;~(plug (jester 'left') whitespace (jester 'join')))
|
|
|
|
(cold %right-join ;~(plug (jester 'right') whitespace (jester 'join')))
|
|
|
|
(cold %outer-join-all ;~(plug (jester 'outer') whitespace (jester 'join') whitespace (jester 'all')))
|
|
|
|
(cold %outer-join ;~(plug (jester 'outer') whitespace (jester 'join')))
|
|
|
|
==
|
|
|
|
==
|
2022-09-25 18:52:01 +03:00
|
|
|
++ parse-cross-join-type ;~ pfix
|
|
|
|
whitespace
|
|
|
|
(cold %cross-join ;~(plug (jester 'cross') whitespace (jester 'join')))
|
|
|
|
==
|
2022-09-13 23:29:49 +03:00
|
|
|
++ build-query-object ~+
|
|
|
|
|= parsed=*
|
|
|
|
?: ?=([@ @ @ @ @] parsed)
|
|
|
|
(query-object:ast %query-object parsed ~)
|
|
|
|
?: ?=([[@ @ @ @ @] @] parsed)
|
|
|
|
(query-object:ast %query-object -.parsed `+.parsed)
|
|
|
|
!!
|
2022-09-25 18:52:01 +03:00
|
|
|
++ parse-cross-joined-object
|
|
|
|
(cook cook-joined-object ;~(plug parse-cross-join-type parse-query-object))
|
|
|
|
++ parse-joined-object ;~ plug
|
|
|
|
parse-join-type
|
|
|
|
parse-query-object
|
|
|
|
;~(pfix whitespace ;~(pfix (jester 'on') parse-predicate))
|
|
|
|
==
|
|
|
|
++ build-joined-object
|
|
|
|
(cook cook-joined-object parse-joined-object)
|
|
|
|
++ cook-joined-object ~+
|
2022-09-13 23:29:49 +03:00
|
|
|
|= parsed=*
|
2022-09-25 18:52:01 +03:00
|
|
|
?: ?=([@ @ [@ @ @ @ @] @ @] parsed)
|
|
|
|
(joined-object:ast %joined-object -.parsed +.parsed ~)
|
|
|
|
?: ?=([@ @ [@ @ @ @ @] @] parsed)
|
|
|
|
(joined-object:ast %joined-object -.parsed +.parsed ~)
|
|
|
|
(joined-object:ast %joined-object -.parsed +<.parsed +>.parsed)
|
|
|
|
++ parse-object-and-joins ;~ plug
|
|
|
|
parse-query-object
|
|
|
|
;~(pose parse-cross-joined-object (star build-joined-object))
|
2022-09-13 23:29:49 +03:00
|
|
|
==
|
|
|
|
::
|
|
|
|
:: column in "join on" or "where" predicate, qualified or aliased
|
|
|
|
:: indeterminate qualification and aliasing is determined later
|
|
|
|
::
|
|
|
|
++ cook-qualified-column
|
|
|
|
|= a=*
|
|
|
|
~+
|
|
|
|
?: ?=([@ @ @ @ @] a) :: @p.db.ns.object.column
|
|
|
|
(qualified-column:ast %qualified-column (qualified-object:ast %qualified-object `-.a +<.a +>-.a +>+<.a) +>+>.a ~)
|
|
|
|
?: ?=([@ @ @ @ @ @] a) :: @p.db..object.column
|
|
|
|
(qualified-column:ast %qualified-column (qualified-object:ast %qualified-object `-.a +<.a 'dbo' +>+>-.a) +>+>+.a ~)
|
|
|
|
?: ?=([@ @ @ @] a) :: db..object.column; db.ns.object.column
|
|
|
|
?: =(+<.a '.')
|
|
|
|
(qualified-column:ast %qualified-column (qualified-object:ast %qualified-object ~ -.a 'dbo' +>-.a) +>+.a ~)
|
|
|
|
(qualified-column:ast %qualified-column (qualified-object:ast %qualified-object ~ -.a +<.a +>-.a) +>+.a ~)
|
|
|
|
?: ?=([@ @ @] a) :: ns.object.column
|
|
|
|
(qualified-column:ast %qualified-column (qualified-object:ast %qualified-object ~ current-database -.a +<.a) +>.a ~)
|
2022-09-25 18:52:01 +03:00
|
|
|
?: ?=([@ @] a) :: something.column (could be table, table alias or cte)
|
|
|
|
(qualified-column:ast %qualified-column (qualified-object:ast %qualified-object ~ 'UNKNOWN' 'COLUMN' -.a) +.a ~)
|
|
|
|
?@ a :: column, column alias, or cte
|
|
|
|
(qualified-column:ast %qualified-column (qualified-object:ast %qualified-object ~ 'UNKNOWN' 'COLUMN-OR-CTE' a) a ~)
|
2022-09-13 23:29:49 +03:00
|
|
|
!!
|
|
|
|
++ parse-column ;~ pose
|
2022-09-12 22:38:25 +03:00
|
|
|
;~((glue dot) parse-ship sym sym sym sym)
|
2022-09-13 23:29:49 +03:00
|
|
|
;~(plug parse-ship ;~(pfix dot sym) dot dot sym ;~(pfix dot sym))
|
2022-09-12 22:38:25 +03:00
|
|
|
;~((glue dot) sym sym sym sym)
|
2022-09-13 23:29:49 +03:00
|
|
|
;~(plug sym dot ;~(pfix dot sym) ;~(pfix dot sym))
|
2022-09-12 22:38:25 +03:00
|
|
|
;~((glue dot) sym sym sym)
|
2022-09-13 23:29:49 +03:00
|
|
|
;~(plug mixed-case-symbol ;~(pfix dot sym))
|
2022-09-12 22:38:25 +03:00
|
|
|
sym
|
|
|
|
==
|
2022-10-17 00:31:55 +03:00
|
|
|
++ parse-qualified-column ~+ (cook cook-qualified-column parse-column)
|
2022-09-25 18:52:01 +03:00
|
|
|
::
|
|
|
|
:: predicate
|
|
|
|
::
|
|
|
|
++ parse-operator ;~ pose
|
|
|
|
:: unary operators
|
|
|
|
(cold %not ;~(plug (jester 'not') whitespace))
|
|
|
|
(cold %exists ;~(plug (jester 'exists') whitespace))
|
|
|
|
(cold %in ;~(plug (jester 'in') whitespace))
|
|
|
|
(cold %any ;~(plug (jester 'any') whitespace))
|
|
|
|
(cold %all ;~(plug (jester 'all') whitespace))
|
|
|
|
:: binary operators
|
|
|
|
(cold %eq (just '='))
|
|
|
|
(cold %neq ;~(pose (jest '<>') (jest '!=')))
|
|
|
|
(cold %gte ;~(pose (jest '>=') (jest '!<')))
|
|
|
|
(cold %lte ;~(pose (jest '<=') (jest '!>')))
|
|
|
|
(cold %gt (just '>'))
|
|
|
|
(cold %lt (just '<'))
|
|
|
|
(cold %and ;~(plug (jester 'and') whitespace))
|
|
|
|
(cold %or ;~(plug (jester 'or') whitespace))
|
|
|
|
(cold %distinct ;~(plug (jester 'is') whitespace (jester 'distinct') whitespace (jester 'from')))
|
|
|
|
(cold %not-distinct ;~(plug (jester 'is') whitespace (jester 'not') whitespace (jester 'distinct') whitespace (jester 'from')))
|
|
|
|
:: ternary operator
|
|
|
|
(cold %between ;~(plug (jester 'between') whitespace))
|
|
|
|
:: nesting directors
|
|
|
|
(cold %pal pal)
|
|
|
|
(cold %par par)
|
|
|
|
==
|
|
|
|
++ resolve-between-operator
|
2022-10-20 22:46:29 +03:00
|
|
|
|= [operator=ternary-operator:ast c1=expression c2=expression c3=expression]
|
2022-09-25 18:52:01 +03:00
|
|
|
^- (tree predicate-component:ast)
|
|
|
|
=/ left `(tree predicate-component:ast)`[%gte `(tree predicate-component:ast)`[c1 ~ ~] `(tree predicate-component:ast)`[c2 ~ ~]]
|
|
|
|
=/ right `(tree predicate-component:ast)`[%lte `(tree predicate-component:ast)`[c1 ~ ~] `(tree predicate-component:ast)`[c3 ~ ~]]
|
|
|
|
`(tree predicate-component:ast)`[operator left right]
|
|
|
|
++ resolve-not-between-operator
|
2022-10-20 22:46:29 +03:00
|
|
|
|= [operator=ternary-operator:ast c1=expression c2=expression c3=expression]
|
2022-09-25 18:52:01 +03:00
|
|
|
^- (tree predicate-component:ast)
|
|
|
|
=/ left `(tree predicate-component:ast)`[%gte `(tree predicate-component:ast)`[c1 ~ ~] `(tree predicate-component:ast)`[c2 ~ ~]]
|
|
|
|
=/ right `(tree predicate-component:ast)`[%lte `(tree predicate-component:ast)`[c1 ~ ~] `(tree predicate-component:ast)`[c3 ~ ~]]
|
|
|
|
`(tree predicate-component:ast)`[%not `(tree predicate-component:ast)`[operator left right] ~]
|
|
|
|
++ resolve-binary-operator
|
2022-10-20 22:46:29 +03:00
|
|
|
|= [operator=binary-operator:ast c1=expression c2=expression]
|
2022-09-25 18:52:01 +03:00
|
|
|
^- (tree predicate-component:ast)
|
|
|
|
`(tree predicate-component:ast)`[operator `(tree predicate-component:ast)`[c1 ~ ~] `(tree predicate-component:ast)`[c2 ~ ~]]
|
|
|
|
++ resolve-all-any
|
2022-10-20 22:46:29 +03:00
|
|
|
|= b=[l1=expression l2=inequality-operator:ast l3=all-any-operator:ast l4=expression]
|
2022-09-25 18:52:01 +03:00
|
|
|
^- (tree predicate-component:ast)
|
|
|
|
=/ all-any `(tree predicate-component:ast)`[l3.b `(tree predicate-component:ast)`[l4.b ~ ~] ~]
|
|
|
|
`(tree predicate-component:ast)`[l2.b `(tree predicate-component:ast)`[l1.b ~ ~] all-any]
|
|
|
|
++ try-not-between-and
|
|
|
|
|= b=list6
|
|
|
|
^- try-result
|
2022-10-20 22:46:29 +03:00
|
|
|
?. ?&(?=(expression l1.b) ?=(%not l2.b) ?=(ternary-operator:ast l3.b) ?=(expression l4.b) ?=(%and l5.b) ?=(expression l6.b))
|
2022-09-25 18:52:01 +03:00
|
|
|
`try-result`%fail
|
|
|
|
(try-success %try-success (resolve-not-between-operator [l3.b l1.b l4.b l6.b]))
|
|
|
|
++ try-5
|
|
|
|
|= b=list5
|
|
|
|
^- try-result
|
2022-10-20 22:46:29 +03:00
|
|
|
?: ?&(?=(expression l1.b) ?=(%not l2.b) ?=(ternary-operator:ast l3.b) ?=(expression l4.b) ?=(expression l5.b))
|
2022-09-25 18:52:01 +03:00
|
|
|
(try-success %try-success (resolve-not-between-operator [l3.b l1.b l4.b l5.b]))
|
2022-10-20 22:46:29 +03:00
|
|
|
?: ?&(?=(expression l1.b) ?=(ternary-operator:ast l2.b) ?=(expression l3.b) ?=(%and l4.b) ?=(expression l5.b))
|
2022-09-25 18:52:01 +03:00
|
|
|
(try-success %try-success (resolve-between-operator [l2.b l1.b l3.b l5.b]))
|
|
|
|
`try-result`%fail
|
|
|
|
++ try-4
|
|
|
|
|= b=list4
|
|
|
|
^- try-result
|
|
|
|
:: expression between expression expression
|
2022-10-20 22:46:29 +03:00
|
|
|
?: ?&(?=(expression l1.b) ?=(ternary-operator:ast l2.b) ?=(expression l3.b) ?=(expression l4.b))
|
2022-09-25 18:52:01 +03:00
|
|
|
(try-success %try-success (resolve-between-operator [l2.b l1.b l3.b l4.b]))
|
|
|
|
:: expression inequality all/any cte-one-column-query
|
2022-10-20 22:46:29 +03:00
|
|
|
?: ?&(?=(expression l1.b) ?=(inequality-operator:ast l2.b) ?=(all-any-operator:ast l3.b) ?=(expression l4.b))
|
2022-09-25 18:52:01 +03:00
|
|
|
(try-success %try-success (resolve-all-any [l1.b l2.b l3.b l4.b]))
|
|
|
|
:: expression not in query or value list
|
2022-10-20 22:46:29 +03:00
|
|
|
?: ?&(?=(expression l1.b) ?=(%not l2.b) ?=(%in l3.b) ?=(expression l4.b))
|
2022-09-25 18:52:01 +03:00
|
|
|
(try-success %try-success `(tree predicate-component:ast)`[%not `(tree predicate-component:ast)`[%in [l1.b ~ ~] [l4.b ~ ~]] ~])
|
|
|
|
`try-result`%fail
|
|
|
|
++ resolve-operators
|
|
|
|
::
|
|
|
|
:: resolve non-unary (and some unary) operators into trees
|
|
|
|
|= a=(list *)
|
2022-09-27 20:07:16 +03:00
|
|
|
^- (list *)
|
2022-09-25 18:52:01 +03:00
|
|
|
=/ resolved=(list *) ~
|
|
|
|
=+ result=`try-result`%fail
|
|
|
|
=+ result2=`try-result`%fail
|
|
|
|
=+ result3=`try-result`%fail
|
|
|
|
|-
|
|
|
|
?: =(a ~) (flop resolved)
|
|
|
|
::
|
|
|
|
:: expression not between expression and expression
|
|
|
|
=. result ?: (gte (lent a) 6)
|
|
|
|
(try-not-between-and (list6 %list6 -.a +<.a +>-.a +>+<.a +>+>-.a +>+>+<.a))
|
|
|
|
`try-result`%fail
|
|
|
|
?: ?=(try-success result) $(a +>+>+>.a, resolved [result.result resolved])
|
|
|
|
::
|
|
|
|
:: expression not between expression expression
|
|
|
|
:: expression between expression and expression
|
|
|
|
=. result2 ?: (gte (lent a) 5)
|
|
|
|
(try-5 (list5 %list5 -.a +<.a +>-.a +>+<.a +>+>-.a))
|
|
|
|
`try-result`%fail
|
|
|
|
?: ?=(try-success result2) $(a +>+>+.a, resolved [result.result2 resolved])
|
|
|
|
::
|
|
|
|
:: expression between expression expression
|
|
|
|
:: expression inequality all/any cte-one-column-query
|
|
|
|
:: expression not in query or value list
|
|
|
|
=. result3 ?: (gte (lent a) 4)
|
|
|
|
(try-4 (list4 %list4 -.a +<.a +>-.a +>+<.a))
|
|
|
|
`try-result`%fail
|
|
|
|
?: ?=(try-success result3) $(a +>+>.a, resolved [result.result3 resolved])
|
|
|
|
::
|
|
|
|
:: expression binary operator expression
|
2022-10-20 22:46:29 +03:00
|
|
|
?: ?&((gte (lent a) 3) ?=(expression -.a) ?=(binary-operator:ast +<.a) ?=(expression +>-.a))
|
2022-09-25 18:52:01 +03:00
|
|
|
$(a +>+.a, resolved [(resolve-binary-operator [+<.a -.a +>-.a]) resolved])
|
|
|
|
::
|
|
|
|
:: not exists column or cte-one-column-query
|
2022-10-20 22:46:29 +03:00
|
|
|
?: ?&((gte (lent a) 3) ?=(%not -.a) ?=(%exists +<.a) ?=(expression +>-.a))
|
2022-09-25 18:52:01 +03:00
|
|
|
$(a +>+.a, resolved [`(tree predicate-component:ast)`[%not `(tree predicate-component:ast)`[%exists [`(tree predicate-component:ast)`[+>-.a ~ ~]] ~] ~] resolved])
|
|
|
|
::
|
|
|
|
:: exists column or cte-one-column-query
|
2022-10-20 22:46:29 +03:00
|
|
|
?: ?&((gte (lent a) 2) ?=(%exists -.a) ?=(expression +<.a))
|
2022-09-25 18:52:01 +03:00
|
|
|
$(a +>.a, resolved [`(tree predicate-component:ast)`[%exists [`(tree predicate-component:ast)`[+<.a ~ ~]] ~] resolved])
|
|
|
|
$(a +.a, resolved [-.a resolved])
|
|
|
|
++ resolve-depth
|
|
|
|
::
|
|
|
|
:: determine deepest parenthesis nesting, eliminating superfluous nesting
|
|
|
|
|= a=(list *)
|
2022-09-27 20:07:16 +03:00
|
|
|
^- [@ud (list *)]
|
2022-09-25 18:52:01 +03:00
|
|
|
=/ resolved=(list *) ~
|
|
|
|
=/ depth 0
|
|
|
|
=/ working-depth 0
|
|
|
|
|-
|
|
|
|
?: =(a ~) [depth (flop resolved)]
|
|
|
|
?: =(-.a %pal)
|
|
|
|
?: ?&((gte (lent +.a) 2) =(+>-.a %par)) :: single parenthesised entity
|
|
|
|
$(a +>+.a, resolved [+<.a resolved])
|
|
|
|
?. (gth (add working-depth 1) depth) $(working-depth (add working-depth 1), a +.a, resolved [-.a resolved])
|
|
|
|
%= $
|
|
|
|
depth (add depth 1)
|
|
|
|
working-depth (add working-depth 1)
|
|
|
|
a +.a
|
|
|
|
resolved [-.a resolved]
|
|
|
|
==
|
|
|
|
?. =(-.a %par) $(a +.a, resolved [-.a resolved])
|
|
|
|
%= $
|
|
|
|
working-depth (sub working-depth 1)
|
|
|
|
a +.a
|
|
|
|
resolved [-.a resolved]
|
|
|
|
==
|
2022-09-27 20:07:16 +03:00
|
|
|
++ resolve-conjunctions
|
|
|
|
::
|
|
|
|
:: when not qualified by () right conjunction takes precedence and "or" takes precedence over "and"
|
|
|
|
::
|
|
|
|
:: 1=1 and 1=3 (false)
|
|
|
|
:: /\
|
|
|
|
:: 1=1 11=3
|
|
|
|
::
|
|
|
|
:: 1=1 and 1=3 and 1=4 (false)
|
|
|
|
:: /\
|
|
|
|
:: & 1=4
|
|
|
|
:: /\
|
|
|
|
:: 1=1 1=3
|
|
|
|
::
|
|
|
|
:: 1=2 and 3=3 and 1=4 or 1=1 (true)
|
|
|
|
:: /\
|
|
|
|
:: & 1=1
|
|
|
|
:: /\
|
|
|
|
:: & 1=4
|
|
|
|
:: /\
|
|
|
|
:: 1=1 3=3
|
|
|
|
::
|
|
|
|
:: 1=2 and 3=3 and 1=4 or 1=1 and 1=4 (false)
|
|
|
|
:: /\
|
|
|
|
:: & 1=1 and 1=4
|
|
|
|
:: /\
|
|
|
|
:: & 1=4
|
|
|
|
:: /\
|
|
|
|
:: 1=2 3=3
|
|
|
|
::
|
|
|
|
:: 1=2 and 3=3 and 1=4 or 1=1 and 1=4 or 2=2 (true)
|
|
|
|
:: /\
|
|
|
|
:: | 2=2
|
|
|
|
:: /\
|
|
|
|
:: & 1=1 and 1=4
|
|
|
|
:: /\
|
|
|
|
:: & 1=4
|
|
|
|
:: /\
|
|
|
|
:: 1=2 3=3
|
|
|
|
::
|
|
|
|
:: 1=2 and 3=3 and 1=4 or 1=1 and 1=4 or 2=2 and 3=2 (false)
|
|
|
|
:: /\
|
|
|
|
:: | 2=2 and 3=2
|
|
|
|
:: /\
|
|
|
|
:: & 1=1 and 1=4
|
|
|
|
:: /\
|
|
|
|
:: & 1=4
|
|
|
|
:: /\
|
|
|
|
:: 1=2 3=3
|
|
|
|
::
|
|
|
|
|= a=[target-depth=@ud b=(list *)]
|
|
|
|
^- (list *)
|
|
|
|
=/ resolved=(list *) ~
|
|
|
|
=/ working-depth 0
|
|
|
|
=/ working-tree=* ~
|
|
|
|
|-
|
|
|
|
?: =(b.a ~) (flop resolved)
|
2022-09-30 23:31:56 +03:00
|
|
|
?: ?&(=(-.b.a %pal) !=(+>-.b.a %par))
|
2022-09-27 20:07:16 +03:00
|
|
|
$(b.a +.b.a, resolved [-.b.a resolved], working-depth (add working-depth 1))
|
|
|
|
?. =(working-depth target-depth.a)
|
|
|
|
$(b.a +.b.a, resolved [-.b.a resolved])
|
|
|
|
|-
|
|
|
|
::
|
|
|
|
:: if there are superfluous levels of nesting we will end up here
|
|
|
|
?: =(b.a ~) ^$(resolved [working-tree resolved])
|
2022-09-30 23:31:56 +03:00
|
|
|
::
|
|
|
|
:: if () enclosed tree is first thing, then it is always the left subtree
|
|
|
|
?: =(-.b.a %pal)
|
|
|
|
?: =(+>-.b.a %par)
|
|
|
|
:: stand-alone tree
|
|
|
|
?: =((lent b.a) 3) ^$(b.a +>+.b.a, resolved [+<.b.a resolved])
|
|
|
|
$(b.a +>+>+.b.a, working-tree [+>+<.b.a +<.b.a +>+>-.b.a])
|
|
|
|
$(b.a +>.b.a, working-tree [+>-.b.a +<.b.a +>+<.b.a])
|
2022-09-27 20:07:16 +03:00
|
|
|
?: =(-.b.a %par)
|
2022-09-30 23:31:56 +03:00
|
|
|
?: =(working-depth 0)
|
|
|
|
%= ^$
|
|
|
|
b.a +.b.a
|
|
|
|
resolved [%par [working-tree resolved]]
|
|
|
|
working-tree ~
|
|
|
|
==
|
2022-09-27 20:07:16 +03:00
|
|
|
%= ^$
|
|
|
|
b.a +.b.a
|
2022-09-30 23:31:56 +03:00
|
|
|
resolved [%par [working-tree resolved]]
|
2022-09-27 20:07:16 +03:00
|
|
|
working-depth (sub working-depth 1)
|
|
|
|
working-tree ~
|
|
|
|
==
|
|
|
|
?@ -.b.a
|
2022-09-30 23:31:56 +03:00
|
|
|
:: "or" the whole tree
|
|
|
|
?: =(-.b.a %or)
|
|
|
|
:: new right is () enclosed tree
|
|
|
|
?: =(%pal +<.b.a) $(b.a +>+>.b.a, working-tree [%or working-tree +>-.b.a])
|
|
|
|
$(b.a +>.b.a, working-tree [%or working-tree +<.b.a])
|
|
|
|
:: working tree is an "or" and we are given an "and"
|
|
|
|
:: "and" the right tree
|
|
|
|
?: ?&(!=(working-tree ~) =(-.working-tree %or))
|
|
|
|
:: new right is () enclosed tree
|
|
|
|
?: =(%pal +<.b.a) $(b.a +>+.b.a, working-tree [%or +<.working-tree [%and +>.working-tree +>-.b.a]])
|
|
|
|
$(b.a +>.b.a, working-tree [%or +<.working-tree [%and +>.working-tree +<.b.a]])
|
2022-09-27 20:07:16 +03:00
|
|
|
:: working tree is an "and" and we are given an "and"
|
2022-09-30 23:31:56 +03:00
|
|
|
:: "and" the whole tree
|
|
|
|
:: new right is () enclosed tree
|
|
|
|
?: =(%pal +<.b.a) $(b.a +>+>.b.a, working-tree [%and working-tree +>-.b.a])
|
|
|
|
$(b.a +>.b.a, working-tree [%and working-tree +<.b.a])
|
|
|
|
:: can only be tree on first time
|
|
|
|
$(b.a +.b.a, working-tree -.b.a)
|
2022-09-25 18:52:01 +03:00
|
|
|
++ cook-predicate
|
|
|
|
::
|
2022-09-27 20:07:16 +03:00
|
|
|
:: 1. resolve operators into trees
|
2022-09-25 18:52:01 +03:00
|
|
|
:: 2. determine deepest parenthesis nesting
|
2022-09-27 20:07:16 +03:00
|
|
|
:: 3. work from deepest nesting up to resolve conjunctions into trees
|
2022-09-25 18:52:01 +03:00
|
|
|
|= a=(list *)
|
|
|
|
=/ b (resolve-depth (resolve-operators a))
|
2022-09-27 20:07:16 +03:00
|
|
|
=/ target-depth -.b
|
|
|
|
=/ working-list +.b
|
|
|
|
|-
|
2022-09-30 23:31:56 +03:00
|
|
|
?. (gth target-depth 0)
|
2022-10-05 23:00:47 +03:00
|
|
|
(snag 0 (resolve-conjunctions [target-depth working-list]))
|
2022-09-27 20:07:16 +03:00
|
|
|
%= $
|
|
|
|
target-depth (sub target-depth 1)
|
|
|
|
working-list (resolve-conjunctions [target-depth working-list])
|
|
|
|
==
|
2022-09-25 18:52:01 +03:00
|
|
|
++ predicate-stop ;~ pose
|
|
|
|
;~(plug whitespace mic)
|
2022-10-05 23:00:47 +03:00
|
|
|
mic
|
2022-09-25 18:52:01 +03:00
|
|
|
;~(plug whitespace (jester 'where'))
|
|
|
|
;~(plug whitespace (jester 'select'))
|
|
|
|
;~(plug whitespace (jester 'as'))
|
|
|
|
;~(plug whitespace (jester 'join'))
|
|
|
|
;~(plug whitespace (jester 'left'))
|
|
|
|
;~(plug whitespace (jester 'right'))
|
|
|
|
;~(plug whitespace (jester 'outer'))
|
2022-10-05 23:00:47 +03:00
|
|
|
;~(plug whitespace (jester 'then'))
|
|
|
|
==
|
2022-10-21 20:44:14 +03:00
|
|
|
++ predicate-part ;~ pose
|
|
|
|
parse-aggregate
|
2022-09-25 18:52:01 +03:00
|
|
|
value-literal-list
|
2022-09-13 23:29:49 +03:00
|
|
|
;~(pose ;~(pfix whitespace parse-operator) parse-operator)
|
2022-10-05 23:00:47 +03:00
|
|
|
parse-datum
|
|
|
|
==
|
|
|
|
++ parse-predicate ~+ (cook cook-predicate (star ;~(less predicate-stop predicate-part)))
|
|
|
|
::
|
|
|
|
:: parse scalar
|
|
|
|
::
|
|
|
|
++ get-datum ~+ ;~ pose
|
|
|
|
;~(sfix parse-qualified-column whitespace)
|
|
|
|
;~(sfix parse-value-literal whitespace)
|
2022-10-16 02:09:57 +03:00
|
|
|
;~(sfix parse-datum whitespace)
|
|
|
|
parse-datum
|
2022-10-05 23:00:47 +03:00
|
|
|
==
|
2022-10-16 02:09:57 +03:00
|
|
|
::++ cook-if
|
|
|
|
:: |= parsed=*
|
|
|
|
:: ^- if-then-else:ast
|
|
|
|
:: (if-then-else:ast %if-then-else -.parsed +>-.parsed +>+>-.parsed)
|
2022-10-13 18:51:22 +03:00
|
|
|
++ parse-if ;~ plug
|
|
|
|
parse-predicate
|
|
|
|
;~(pfix whitespace (cold %then (jester 'then')))
|
|
|
|
;~(pose scalar-body parse-datum)
|
|
|
|
;~(pfix whitespace (cold %else (jester 'else')))
|
|
|
|
;~(pose scalar-body parse-datum)
|
|
|
|
;~(pfix whitespace (cold %endif (jester 'endif')))
|
2022-10-05 23:00:47 +03:00
|
|
|
==
|
|
|
|
++ parse-when-then ;~ plug
|
2022-10-13 18:51:22 +03:00
|
|
|
;~(pfix whitespace (cold %when (jester 'when')))
|
|
|
|
;~(pose parse-predicate parse-datum)
|
|
|
|
;~(pfix whitespace (cold %then (jester 'then')))
|
2022-10-22 01:37:24 +03:00
|
|
|
;~(pose parse-aggregate scalar-body parse-datum)
|
2022-10-05 23:00:47 +03:00
|
|
|
==
|
|
|
|
++ parse-case-else ;~ plug
|
2022-10-13 18:51:22 +03:00
|
|
|
;~(pfix whitespace (cold %else (jester 'else')))
|
2022-10-22 01:37:24 +03:00
|
|
|
;~(pfix whitespace ;~(pose parse-aggregate scalar-body parse-datum))
|
2022-10-13 18:51:22 +03:00
|
|
|
;~(pfix whitespace (cold %end (jester 'end')))
|
2022-10-05 23:00:47 +03:00
|
|
|
==
|
|
|
|
++ cook-case
|
|
|
|
|= parsed=*
|
|
|
|
=/ raw-cases +<.parsed
|
|
|
|
=/ cases=(list case-when-then:ast) ~
|
|
|
|
|-
|
|
|
|
?. =(raw-cases ~)
|
|
|
|
$(cases [(case-when-then:ast ->-.raw-cases ->+>.raw-cases) cases], raw-cases +.raw-cases)
|
|
|
|
?: ?=(qualified-column:ast -.parsed)
|
|
|
|
?: =('else' +>-.parsed) (case:ast %case -.parsed (flop cases) +>+<.parsed)
|
|
|
|
(case:ast %case -.parsed (flop cases) ~)
|
|
|
|
?: ?=(value-literal:ast -.parsed)
|
|
|
|
?: =('else' +>-.parsed) (case:ast %case -.parsed (flop cases) +>+<.parsed)
|
|
|
|
(case:ast %case -.parsed (flop cases) ~)
|
|
|
|
!!
|
|
|
|
++ parse-case ;~ plug
|
|
|
|
parse-datum
|
|
|
|
(star parse-when-then)
|
2022-10-13 18:51:22 +03:00
|
|
|
;~(pose parse-case-else ;~(pfix whitespace (cold %end (jester 'end'))))
|
|
|
|
==
|
|
|
|
::++ cook-coalesce
|
|
|
|
:: |= parsed=(list datum:ast)
|
|
|
|
:: ^- coalesce:ast
|
|
|
|
:: (coalesce:ast %coalesce parsed)
|
|
|
|
++ scalar-token ;~ pose
|
|
|
|
;~(pfix whitespace (cold %end (jester 'end')))
|
|
|
|
;~(pfix whitespace ;~(plug (cold %if (jester 'if')) parse-if))
|
|
|
|
;~(plug (cold %if (jester 'if')) parse-if)
|
|
|
|
;~(pfix whitespace ;~(plug (cold %case (jester 'case')) parse-case))
|
|
|
|
;~(plug (cold %case (jester 'case')) parse-case)
|
|
|
|
;~(pfix whitespace ;~(plug (cold %coalesce (jester 'coalesce')) parse-coalesce))
|
|
|
|
;~(plug (cold %coalesce (jester 'coalesce')) parse-coalesce)
|
|
|
|
(cold %pal ;~(plug whitespace pal))
|
|
|
|
(cold %pal pal)
|
|
|
|
(cold %par ;~(plug whitespace par))
|
|
|
|
(cold %par par)
|
|
|
|
(cold %lus ;~(plug whitespace lus))
|
|
|
|
(cold %lus lus)
|
|
|
|
(cold %hep ;~(plug whitespace hep))
|
|
|
|
(cold %hep hep)
|
|
|
|
(cold %tar ;~(plug whitespace tar))
|
|
|
|
(cold %tar tar)
|
|
|
|
(cold %fas ;~(plug whitespace fas))
|
|
|
|
(cold %fas fas)
|
|
|
|
(cold %ket ;~(plug whitespace ket))
|
|
|
|
(cold %ket ket)
|
|
|
|
parse-datum
|
|
|
|
==
|
2022-10-21 20:44:14 +03:00
|
|
|
++ parse-coalesce ~+ (more com ;~(pose parse-aggregate get-datum))
|
2022-10-13 18:51:22 +03:00
|
|
|
++ parse-math ;~ plug
|
|
|
|
(cold %begin (jester 'begin'))
|
|
|
|
(star scalar-token)
|
|
|
|
==
|
|
|
|
++ parse-scalar-body %+ knee *noun
|
|
|
|
|. ~+
|
|
|
|
;~ pose
|
|
|
|
;~(plug (cold %if (jester 'if')) parse-if)
|
|
|
|
;~(plug (cold %case (jester 'case')) parse-case)
|
|
|
|
;~(plug (cold %coalesce (jester 'coalesce')) parse-coalesce)
|
|
|
|
parse-math
|
2022-10-05 23:00:47 +03:00
|
|
|
==
|
|
|
|
++ scalar-stop ;~ pose
|
|
|
|
;~(plug whitespace (jester 'where'))
|
|
|
|
;~(plug whitespace (jester 'scalar'))
|
2022-10-13 18:51:22 +03:00
|
|
|
;~(plug whitespace (jester 'select'))
|
2022-10-05 23:00:47 +03:00
|
|
|
==
|
|
|
|
++ scalar-body ;~(pfix whitespace parse-scalar-body)
|
|
|
|
++ parse-scalar ;~ pose
|
2022-10-13 18:51:22 +03:00
|
|
|
;~(plug (cold %scalar ;~(pfix whitespace (jester 'scalar'))) parse-face ;~(pfix ;~(plug whitespace (jester 'as')) scalar-body))
|
|
|
|
;~(plug (cold %scalar ;~(pfix whitespace (jester 'scalar'))) parse-face scalar-body)
|
|
|
|
==
|
|
|
|
::
|
|
|
|
:: select
|
|
|
|
::
|
2022-10-17 00:31:55 +03:00
|
|
|
++ select-stop ~+ ;~ pose
|
2022-10-16 02:09:57 +03:00
|
|
|
;~(plug whitespace (jester 'group'))
|
|
|
|
;~(plug whitespace (jester 'into'))
|
|
|
|
;~(plug whitespace (jester 'order'))
|
|
|
|
;~(plug whitespace (jester 'union'))
|
|
|
|
;~(plug whitespace (jester 'combine'))
|
|
|
|
;~(plug whitespace (jester 'except'))
|
|
|
|
;~(plug whitespace (jester 'intersect'))
|
|
|
|
;~(plug whitespace (jester 'divided'))
|
2022-10-17 00:31:55 +03:00
|
|
|
mic
|
2022-10-16 02:09:57 +03:00
|
|
|
==
|
2022-10-21 20:44:14 +03:00
|
|
|
++ parse-aggregate-column ~+ (stag %selected-aggregate parse-aggregate)
|
2022-10-16 22:09:53 +03:00
|
|
|
++ parse-alias-all ~+ (stag %all-columns ;~(sfix parse-alias ;~(plug dot tar)))
|
|
|
|
++ parse-object-all ~+ (stag %all-columns ;~(sfix parse-qualified-object ;~(plug dot tar)))
|
2022-10-21 20:44:14 +03:00
|
|
|
++ parse-selection ~+ ;~ pose
|
|
|
|
;~(plug ;~(sfix parse-aggregate-column whitespace) (cold %as (jester 'as')) ;~(pfix whitespace alias))
|
|
|
|
parse-aggregate-column
|
2022-10-16 22:09:53 +03:00
|
|
|
parse-alias-all
|
|
|
|
parse-object-all
|
2022-10-17 01:40:25 +03:00
|
|
|
;~(plug ;~(sfix ;~(pose parse-qualified-column parse-value-literal) whitespace) (cold %as (jester 'as')) ;~(pfix whitespace alias))
|
2022-10-16 02:09:57 +03:00
|
|
|
get-datum
|
|
|
|
(cold %all tar)
|
|
|
|
==
|
2022-10-17 01:40:25 +03:00
|
|
|
++ select-column ~+ ;~ pose
|
|
|
|
;~(pfix whitespace ;~(sfix parse-selection whitespace))
|
|
|
|
;~(pfix whitespace parse-selection)
|
|
|
|
;~(sfix parse-selection whitespace)
|
|
|
|
parse-selection
|
|
|
|
==
|
2022-10-17 00:31:55 +03:00
|
|
|
++ select-columns ~+ (full (more com select-column))
|
|
|
|
++ select-top-bottom-distinct ~+ ;~ plug
|
2022-10-13 18:51:22 +03:00
|
|
|
(cold %top ;~(plug whitespace (jester 'top')))
|
|
|
|
;~(pfix whitespace dem)
|
|
|
|
(cold %bottom ;~(plug whitespace (jester 'bottom')))
|
|
|
|
;~(pfix whitespace dem)
|
|
|
|
(cold %distinct ;~(plug whitespace (jester 'distinct')))
|
2022-10-16 02:09:57 +03:00
|
|
|
select-columns
|
2022-10-13 18:51:22 +03:00
|
|
|
==
|
2022-10-17 00:31:55 +03:00
|
|
|
++ select-top-bottom ~+ ;~ plug
|
2022-10-13 18:51:22 +03:00
|
|
|
(cold %top ;~(plug whitespace (jester 'top')))
|
|
|
|
;~(pfix whitespace dem)
|
|
|
|
(cold %bottom ;~(plug whitespace (jester 'bottom')))
|
|
|
|
;~(pfix whitespace dem)
|
2022-10-17 01:40:25 +03:00
|
|
|
select-columns
|
2022-10-13 18:51:22 +03:00
|
|
|
==
|
2022-10-17 00:31:55 +03:00
|
|
|
++ select-top-distinct ~+ ;~ plug
|
2022-10-13 18:51:22 +03:00
|
|
|
(cold %top ;~(plug whitespace (jester 'top')))
|
|
|
|
;~(pfix whitespace dem)
|
|
|
|
(cold %distinct ;~(plug whitespace (jester 'distinct')))
|
2022-10-16 02:09:57 +03:00
|
|
|
select-columns
|
2022-10-13 18:51:22 +03:00
|
|
|
==
|
2022-10-17 00:31:55 +03:00
|
|
|
++ select-top ~+ ;~ plug
|
2022-10-13 18:51:22 +03:00
|
|
|
(cold %top ;~(plug whitespace (jester 'top')))
|
2022-10-16 02:09:57 +03:00
|
|
|
;~(pfix whitespace dem)
|
2022-10-17 01:40:25 +03:00
|
|
|
select-columns
|
2022-10-13 18:51:22 +03:00
|
|
|
==
|
2022-10-17 00:31:55 +03:00
|
|
|
++ select-bottom-distinct ~+ ;~ plug
|
2022-10-13 18:51:22 +03:00
|
|
|
(cold %bottom ;~(plug whitespace (jester 'bottom')))
|
|
|
|
;~(pfix whitespace dem)
|
|
|
|
(cold %distinct ;~(plug whitespace (jester 'distinct')))
|
2022-10-16 02:09:57 +03:00
|
|
|
select-columns
|
2022-10-13 18:51:22 +03:00
|
|
|
==
|
2022-10-17 00:31:55 +03:00
|
|
|
++ select-bottom ~+ ;~ plug
|
2022-10-13 18:51:22 +03:00
|
|
|
(cold %bottom ;~(plug whitespace (jester 'bottom')))
|
|
|
|
;~(pfix whitespace dem)
|
2022-10-17 01:40:25 +03:00
|
|
|
select-columns
|
2022-10-13 18:51:22 +03:00
|
|
|
==
|
2022-10-17 00:31:55 +03:00
|
|
|
++ select-distinct ~+ ;~ plug
|
2022-10-13 18:51:22 +03:00
|
|
|
(cold %distinct ;~(plug whitespace (jester 'distinct')))
|
2022-10-16 02:09:57 +03:00
|
|
|
select-columns
|
|
|
|
==
|
2022-10-17 01:40:25 +03:00
|
|
|
++ parse-select ~+ ;~ plug
|
2022-10-16 02:09:57 +03:00
|
|
|
(cold %select ;~(plug whitespace (jester 'select')))
|
2022-10-17 01:40:25 +03:00
|
|
|
;~ less
|
|
|
|
select-stop
|
|
|
|
;~ pose
|
|
|
|
select-top-bottom-distinct
|
|
|
|
select-top-bottom
|
|
|
|
select-top-distinct
|
|
|
|
select-top
|
|
|
|
select-bottom-distinct
|
|
|
|
select-bottom
|
|
|
|
select-distinct
|
|
|
|
select-columns
|
|
|
|
==
|
|
|
|
==
|
2022-09-12 22:38:25 +03:00
|
|
|
==
|
2022-08-28 18:58:03 +03:00
|
|
|
::
|
2022-10-22 22:03:54 +03:00
|
|
|
:: group and order by
|
|
|
|
::
|
|
|
|
++ parse-grouping-column ;~ pose
|
|
|
|
;~(pfix whitespace ;~(sfix ;~(pose parse-qualified-column dem) whitespace))
|
|
|
|
;~(pfix whitespace ;~(pose parse-qualified-column dem))
|
|
|
|
;~(sfix ;~(pose parse-qualified-column dem) whitespace)
|
|
|
|
;~(pose parse-qualified-column dem)
|
|
|
|
==
|
|
|
|
++ parse-group-by ;~ plug
|
|
|
|
(cold %group-by ;~(plug whitespace (jester 'group') whitespace (jester 'by')))
|
|
|
|
(more com parse-grouping-column)
|
|
|
|
==
|
|
|
|
++ cook-ordering-column
|
|
|
|
|= parsed=*
|
|
|
|
?: ?=(qualified-column:ast parsed) (ordering-column:ast %ordering-column parsed %.y)
|
|
|
|
?@ parsed (ordering-column:ast %ordering-column parsed %.y)
|
|
|
|
?: =(+.parsed %asc) (ordering-column:ast %ordering-column -.parsed %.y)
|
|
|
|
(ordering-column:ast %ordering-column -.parsed %.n)
|
|
|
|
++ parse-ordered-column
|
|
|
|
(cook cook-ordering-column ;~(plug ;~(pose parse-qualified-column dem) ;~(pfix whitespace ;~(pose (cold %asc (jester 'asc')) (cold %desc (jester 'desc'))))))
|
|
|
|
++ parse-ordering-column ;~ pose
|
|
|
|
;~(pfix whitespace ;~(sfix parse-ordered-column whitespace))
|
|
|
|
;~(pfix whitespace parse-ordered-column)
|
|
|
|
;~(sfix parse-ordered-column whitespace)
|
|
|
|
parse-ordered-column
|
|
|
|
(cook cook-ordering-column ;~(pfix whitespace ;~(sfix ;~(pose parse-qualified-column dem) whitespace)))
|
|
|
|
(cook cook-ordering-column ;~(pfix whitespace ;~(pose parse-qualified-column dem)))
|
|
|
|
(cook cook-ordering-column ;~(sfix ;~(pose parse-qualified-column dem) whitespace))
|
|
|
|
(cook cook-ordering-column ;~(pose parse-qualified-column dem))
|
|
|
|
==
|
|
|
|
++ parse-order-by ;~ plug
|
|
|
|
(cold %order-by ;~(plug whitespace (jester 'order') whitespace (jester 'by')))
|
|
|
|
(more com parse-ordering-column)
|
|
|
|
==
|
|
|
|
::
|
2022-08-28 18:58:03 +03:00
|
|
|
:: parse urQL command
|
|
|
|
::
|
2022-09-07 22:25:00 +03:00
|
|
|
++ parse-alter-index
|
2022-09-08 23:48:02 +03:00
|
|
|
=/ columns ;~(pfix whitespace ordered-column-list)
|
2022-09-07 22:25:00 +03:00
|
|
|
=/ action ;~(pfix whitespace ;~(pose (jester 'rebuild') (jester 'disable') (jester 'resume')))
|
|
|
|
;~ plug
|
|
|
|
;~(pfix whitespace parse-qualified-3object)
|
|
|
|
;~(pfix whitespace ;~(pfix (jester 'on') ;~(pfix whitespace parse-qualified-3object)))
|
|
|
|
;~(sfix ;~(pose ;~(plug columns action) columns action) end-or-next-command)
|
|
|
|
==
|
|
|
|
++ parse-alter-namespace ;~ plug
|
2022-09-07 23:50:04 +03:00
|
|
|
(cook |=(a=* (qualified-namespace [a current-database])) parse-qualified-2-name)
|
|
|
|
;~(pfix ;~(plug whitespace (jester 'transfer')) ;~(pfix whitespace ;~(pose (jester 'table') (jester 'view'))))
|
2022-09-07 22:25:00 +03:00
|
|
|
;~(sfix ;~(pfix whitespace parse-qualified-3object) end-or-next-command)
|
|
|
|
==
|
2022-09-08 23:48:02 +03:00
|
|
|
++ parse-alter-table ;~ plug
|
|
|
|
;~(pfix whitespace parse-qualified-3object)
|
|
|
|
;~(sfix ;~(pfix whitespace ;~(pose alter-columns add-columns drop-columns add-foreign-key drop-foreign-key)) end-or-next-command)
|
|
|
|
==
|
2022-08-28 18:58:03 +03:00
|
|
|
++ parse-create-namespace ;~ sfix
|
2022-08-29 21:29:37 +03:00
|
|
|
parse-qualified-2-name
|
|
|
|
end-or-next-command
|
|
|
|
==
|
2022-09-07 01:46:28 +03:00
|
|
|
++ parse-create-index
|
2022-08-29 21:29:37 +03:00
|
|
|
=/ is-unique ~+ ;~(pfix whitespace (jester 'unique'))
|
|
|
|
=/ index-name ~+ ;~(pfix whitespace (jester 'index') parse-face)
|
|
|
|
=/ type-and-name ;~ pose
|
|
|
|
;~(plug is-unique clustering index-name)
|
|
|
|
;~(plug is-unique index-name)
|
|
|
|
;~(plug clustering index-name)
|
|
|
|
index-name
|
|
|
|
==
|
|
|
|
;~ plug
|
|
|
|
type-and-name
|
|
|
|
;~(pfix whitespace ;~(pfix (jester 'on') ;~(pfix whitespace parse-qualified-3object)))
|
|
|
|
;~(sfix ordered-column-list end-or-next-command)
|
|
|
|
==
|
2022-09-07 01:46:28 +03:00
|
|
|
++ parse-create-table ;~ plug
|
|
|
|
;~(pfix whitespace parse-qualified-3object)
|
2022-09-08 23:48:02 +03:00
|
|
|
column-definitions
|
2022-09-10 02:30:41 +03:00
|
|
|
;~(sfix ;~(pose ;~(plug primary-key ;~(pfix foreign-key-literal (more com full-foreign-key))) primary-key) end-or-next-command)
|
2022-09-07 01:46:28 +03:00
|
|
|
==
|
2022-08-28 18:58:03 +03:00
|
|
|
++ parse-drop-database ;~ sfix
|
2022-08-29 21:29:37 +03:00
|
|
|
;~(pose ;~(plug ;~(pfix whitespace (jester 'force')) ;~(pfix whitespace sym)) ;~(pfix whitespace sym))
|
|
|
|
end-or-next-command
|
|
|
|
==
|
2022-08-28 18:58:03 +03:00
|
|
|
++ parse-drop-index ;~ sfix
|
2022-08-29 21:29:37 +03:00
|
|
|
;~(pfix whitespace ;~(plug parse-face ;~(pfix whitespace ;~(pfix (jester 'on') ;~(pfix whitespace parse-qualified-3object)))))
|
|
|
|
end-or-next-command
|
|
|
|
==
|
2022-08-28 18:58:03 +03:00
|
|
|
++ parse-drop-namespace ;~ sfix
|
2022-08-29 21:29:37 +03:00
|
|
|
;~(pose ;~(plug ;~(pfix whitespace (cold %force (jester 'force'))) parse-qualified-2-name) parse-qualified-2-name)
|
|
|
|
end-or-next-command
|
|
|
|
==
|
2022-08-28 18:58:03 +03:00
|
|
|
++ drop-table-or-view ;~ sfix
|
2022-08-29 21:29:37 +03:00
|
|
|
;~(pose ;~(pfix whitespace ;~(plug (jester 'force') parse-qualified-3object)) parse-qualified-3object)
|
|
|
|
end-or-next-command
|
|
|
|
==
|
2022-08-28 18:58:03 +03:00
|
|
|
++ parse-grant ;~ plug
|
2022-08-29 21:29:37 +03:00
|
|
|
:: permission
|
|
|
|
;~(pfix whitespace ;~(pose (jester 'adminread') (jester 'readonly') (jester 'readwrite')))
|
|
|
|
:: grantee
|
|
|
|
;~(pfix whitespace ;~(pfix (jester 'to') ;~(pfix whitespace ;~(pose (jester 'parent') (jester 'siblings') (jester 'moons') (stag %ships ship-list)))))
|
|
|
|
;~(sfix grant-object end-or-next-command)
|
|
|
|
==
|
2022-09-12 22:38:25 +03:00
|
|
|
++ parse-insert ;~ plug
|
|
|
|
;~(pfix whitespace parse-qualified-object)
|
|
|
|
;~(pose ;~(plug face-list ;~(pfix whitespace (jester 'values'))) ;~(pfix whitespace (jester 'values')))
|
2022-10-05 23:00:47 +03:00
|
|
|
;~(pfix whitespace (more whitespace (ifix [pal par] (more com parse-insert-value))))
|
2022-09-12 22:38:25 +03:00
|
|
|
end-or-next-command
|
|
|
|
==
|
|
|
|
++ parse-query ;~ plug
|
2022-09-25 18:52:01 +03:00
|
|
|
parse-object-and-joins
|
2022-09-12 22:38:25 +03:00
|
|
|
end-or-next-command
|
|
|
|
==
|
2022-08-28 18:58:03 +03:00
|
|
|
++ parse-revoke ;~ plug
|
2022-08-29 21:29:37 +03:00
|
|
|
:: permission
|
|
|
|
;~(pfix whitespace ;~(pose (jester 'adminread') (jester 'readonly') (jester 'readwrite') (jester 'all')))
|
|
|
|
:: revokee
|
|
|
|
;~(pfix whitespace ;~(pfix (jester 'from') ;~(pfix whitespace ;~(pose (jester 'parent') (jester 'siblings') (jester 'moons') (jester 'all') (stag %ships ship-list)))))
|
|
|
|
;~(sfix grant-object end-or-next-command)
|
|
|
|
==
|
2022-08-28 18:58:03 +03:00
|
|
|
++ parse-truncate-table ;~ sfix
|
2022-08-29 21:29:37 +03:00
|
|
|
;~(pfix whitespace parse-qualified-object)
|
|
|
|
end-or-next-command
|
|
|
|
==
|
2022-08-28 18:58:03 +03:00
|
|
|
::
|
|
|
|
:: parse urQL script
|
|
|
|
::
|
|
|
|
++ parse
|
|
|
|
|= script=tape
|
|
|
|
^- (list command-ast)
|
|
|
|
=/ commands `(list command-ast)`~
|
|
|
|
=/ script-position [1 1]
|
2022-08-29 21:29:37 +03:00
|
|
|
=/ parse-command ;~ pose
|
2022-09-07 22:25:00 +03:00
|
|
|
(cold %alter-index ;~(plug whitespace (jester 'alter') whitespace (jester 'index')))
|
2022-09-07 23:50:04 +03:00
|
|
|
(cold %alter-namespace ;~(plug whitespace (jester 'alter') whitespace (jester 'namespace')))
|
2022-09-08 23:48:02 +03:00
|
|
|
(cold %alter-table ;~(plug whitespace (jester 'alter') whitespace (jester 'table')))
|
2022-08-29 21:29:37 +03:00
|
|
|
(cold %create-database ;~(plug whitespace (jester 'create') whitespace (jester 'database')))
|
|
|
|
(cold %create-namespace ;~(plug whitespace (jester 'create') whitespace (jester 'namespace')))
|
|
|
|
(cold %create-table ;~(plug whitespace (jester 'create') whitespace (jester 'table')))
|
|
|
|
(cold %create-view ;~(plug whitespace (jester 'create') whitespace (jester 'view')))
|
2022-09-07 01:46:28 +03:00
|
|
|
(cold %create-index ;~(plug whitespace (jester 'create'))) :: must be last of creates
|
2022-08-29 21:29:37 +03:00
|
|
|
(cold %drop-database ;~(plug whitespace (jester 'drop') whitespace (jester 'database')))
|
|
|
|
(cold %drop-index ;~(plug whitespace (jester 'drop') whitespace (jester 'index')))
|
|
|
|
(cold %drop-namespace ;~(plug whitespace (jester 'drop') whitespace (jester 'namespace')))
|
|
|
|
(cold %drop-table ;~(plug whitespace (jester 'drop') whitespace (jester 'table')))
|
|
|
|
(cold %drop-view ;~(plug whitespace (jester 'drop') whitespace (jester 'view')))
|
|
|
|
(cold %grant ;~(plug whitespace (jester 'grant')))
|
2022-09-04 20:53:13 +03:00
|
|
|
(cold %insert ;~(plug whitespace (jester 'insert') whitespace (jester 'into')))
|
2022-09-12 22:38:25 +03:00
|
|
|
(cold %query ;~(plug whitespace (jester 'from')))
|
2022-08-29 21:29:37 +03:00
|
|
|
(cold %revoke ;~(plug whitespace (jester 'revoke')))
|
|
|
|
(cold %truncate-table ;~(plug whitespace (jester 'truncate') whitespace (jester 'table')))
|
|
|
|
==
|
2022-08-21 00:09:56 +03:00
|
|
|
~| 'Current database name is not a proper term'
|
2022-08-13 22:08:34 +03:00
|
|
|
=/ dummy (scan (trip current-database) sym)
|
2022-08-13 05:13:25 +03:00
|
|
|
:: main loop
|
2022-08-12 21:08:20 +03:00
|
|
|
::
|
2022-08-06 17:06:18 +03:00
|
|
|
|-
|
2022-08-12 21:08:20 +03:00
|
|
|
?: =(~ script) :: https://github.com/urbit/arvo/issues/1024
|
2022-08-13 05:00:44 +03:00
|
|
|
(flop commands)
|
2022-09-02 03:14:57 +03:00
|
|
|
=/ check-empty u.+3:q.+3:(whitespace [[1 1] script])
|
|
|
|
?: =(0 (lent q.q:check-empty)) :: trailing whitespace after last end-command (;)
|
|
|
|
(flop commands)
|
2022-08-13 05:00:44 +03:00
|
|
|
~| "Error parsing command keyword: {<script-position>}"
|
|
|
|
=/ command-nail u.+3:q.+3:(parse-command [script-position script])
|
2022-08-12 21:08:20 +03:00
|
|
|
?- `command`p.command-nail
|
2022-09-07 22:25:00 +03:00
|
|
|
%alter-index
|
2022-09-13 23:29:49 +03:00
|
|
|
~| "Cannot parse alter-index {<p.q.command-nail>}"
|
2022-09-07 22:25:00 +03:00
|
|
|
=/ index-nail (parse-alter-index [[1 1] q.q.command-nail])
|
|
|
|
=/ parsed (wonk index-nail)
|
|
|
|
=/ next-cursor
|
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:index-nail])
|
2022-09-08 23:48:02 +03:00
|
|
|
?: ?=([[@ @ @ @ @] [@ @ @ @ @] @] [parsed]) ::"alter index action"
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:index-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(alter-index:ast %alter-index -.parsed +<.parsed ~ +>.parsed) commands]
|
|
|
|
==
|
|
|
|
?: ?=([[@ @ @ @ @] [@ @ @ @ @] [[@ @ @] %~]] [parsed]) ::"alter index single column"
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:index-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(alter-index:ast %alter-index -.parsed +<.parsed +>.parsed %rebuild) commands]
|
|
|
|
==
|
2022-09-07 22:25:00 +03:00
|
|
|
?: ?=([[@ @ @ @ @] [@ @ @ @ @] * @] [parsed]) ::"alter index columns action"
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:index-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(alter-index:ast %alter-index -.parsed +<.parsed +>-.parsed +>+.parsed) commands]
|
|
|
|
==
|
2022-09-08 23:48:02 +03:00
|
|
|
?: ?=([[@ @ @ @ @] [@ @ @ @ @] *] [parsed]) ::"alter index multiple columns"
|
2022-09-07 22:25:00 +03:00
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:index-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(alter-index:ast %alter-index -.parsed +<.parsed +>.parsed %rebuild) commands]
|
2022-09-08 23:48:02 +03:00
|
|
|
==
|
2022-09-07 22:25:00 +03:00
|
|
|
!!
|
|
|
|
%alter-namespace
|
|
|
|
~| "Cannot parse namespace {<p.q.command-nail>}"
|
|
|
|
=/ namespace-nail (parse-alter-namespace [[1 1] q.q.command-nail])
|
|
|
|
=/ parsed (wonk namespace-nail)
|
|
|
|
=/ next-cursor
|
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:namespace-nail])
|
2022-09-07 23:50:04 +03:00
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:namespace-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(alter-namespace:ast %alter-namespace -<.parsed ->.parsed +<.parsed +>+>+<.parsed +>+>+>.parsed) commands]
|
|
|
|
==
|
2022-09-08 23:48:02 +03:00
|
|
|
%alter-table
|
|
|
|
~| "Cannot parse table {<p.q.command-nail>}"
|
|
|
|
=/ table-nail (parse-alter-table [[1 1] q.q.command-nail])
|
|
|
|
=/ parsed (wonk table-nail)
|
|
|
|
=/ next-cursor
|
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:table-nail])
|
|
|
|
?: =(+<.parsed %alter-column)
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:table-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(alter-table:ast %alter-table -.parsed +>.parsed ~ ~ ~ ~) commands]
|
|
|
|
==
|
|
|
|
?: =(+<.parsed %add-column)
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:table-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(alter-table:ast %alter-table -.parsed ~ +>.parsed ~ ~ ~) commands]
|
|
|
|
==
|
|
|
|
?: =(+<.parsed %drop-column)
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:table-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(alter-table:ast %alter-table -.parsed ~ ~ +>.parsed ~ ~) commands]
|
|
|
|
==
|
|
|
|
?: =(+<.parsed %add-fk)
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:table-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
2022-09-10 02:30:41 +03:00
|
|
|
[`command-ast`(alter-table:ast %alter-table -.parsed ~ ~ ~ (build-foreign-keys [-.parsed +>.parsed]) ~) commands]
|
2022-09-08 23:48:02 +03:00
|
|
|
==
|
|
|
|
?: =(+<.parsed %drop-fk)
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:table-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
2022-09-10 20:02:00 +03:00
|
|
|
[`command-ast`(alter-table:ast %alter-table -.parsed ~ ~ ~ ~ +>.parsed) commands]
|
2022-09-08 23:48:02 +03:00
|
|
|
==
|
|
|
|
!!
|
2022-08-12 21:08:20 +03:00
|
|
|
%create-database
|
2022-08-14 00:20:30 +03:00
|
|
|
~| 'Create database must be only statement in script'
|
|
|
|
?> =((lent commands) 0)
|
|
|
|
%= $
|
2022-08-16 22:18:14 +03:00
|
|
|
script ""
|
|
|
|
commands
|
|
|
|
[`command-ast`(create-database:ast %create-database p.u.+3:q.+3:(parse-face [[1 1] q.q.command-nail])) commands]
|
2022-08-14 00:20:30 +03:00
|
|
|
==
|
2022-08-12 21:08:20 +03:00
|
|
|
%create-index
|
2022-08-29 21:29:37 +03:00
|
|
|
~| "Cannot parse index {<p.q.command-nail>}"
|
2022-09-07 01:46:28 +03:00
|
|
|
=/ index-nail (parse-create-index [[1 1] q.q.command-nail])
|
2022-08-29 21:29:37 +03:00
|
|
|
=/ parsed (wonk index-nail)
|
|
|
|
=/ next-cursor
|
2022-09-07 22:25:00 +03:00
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:index-nail])
|
2022-08-29 21:29:37 +03:00
|
|
|
?: ?=([@ [* *]] [parsed]) ::"create index ..."
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:index-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(create-index:ast %create-index -.parsed +<.parsed %.n %.n +>.parsed) commands]
|
|
|
|
==
|
|
|
|
?: ?=([[@ @] [* *]] [parsed])
|
|
|
|
?: =(-<.parsed %unique) ::"create unique index ..."
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:index-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(create-index:ast %create-index ->.parsed +<.parsed %.y %.n +>.parsed) commands]
|
|
|
|
==
|
|
|
|
?: =(-<.parsed %clustered) ::"create clustered index ..."
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:index-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(create-index:ast %create-index ->.parsed +<.parsed %.n %.y +>.parsed) commands]
|
|
|
|
==
|
|
|
|
?: =(-<.parsed %nonclustered) ::"create nonclustered index ..."
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:index-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(create-index:ast %create-index ->.parsed +<.parsed %.n %.n +>.parsed) commands]
|
|
|
|
==
|
|
|
|
!!
|
|
|
|
?: ?=([[@ @ @] [* *]] [parsed])
|
|
|
|
?: =(->-.parsed %clustered) ::"create unique clustered index ..."
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:index-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(create-index:ast %create-index ->+.parsed +<.parsed %.y %.y +>.parsed) commands]
|
|
|
|
==
|
|
|
|
?: =(->-.parsed %nonclustered) ::"create unique nonclustered index ..."
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:index-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(create-index:ast %create-index ->+.parsed +<.parsed %.y %.n +>.parsed) commands]
|
|
|
|
==
|
|
|
|
!!
|
2022-08-12 21:08:20 +03:00
|
|
|
!!
|
|
|
|
%create-namespace
|
2022-08-21 22:12:55 +03:00
|
|
|
~| "Cannot parse name to term in create-namespace {<p.q.command-nail>}"
|
2022-08-28 18:58:03 +03:00
|
|
|
=/ create-namespace-nail (parse-create-namespace [[1 1] q.q.command-nail])
|
2022-08-17 20:10:50 +03:00
|
|
|
=/ parsed (wonk create-namespace-nail)
|
2022-08-22 00:09:24 +03:00
|
|
|
=/ next-cursor
|
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:create-namespace-nail])
|
2022-08-17 19:26:46 +03:00
|
|
|
?@ parsed
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:create-namespace-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands [`command-ast`(create-namespace:ast %create-namespace current-database parsed) commands]
|
2022-08-13 05:00:44 +03:00
|
|
|
==
|
|
|
|
%= $
|
2022-08-17 19:26:46 +03:00
|
|
|
script q.q.u.+3.q:create-namespace-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands [`command-ast`(create-namespace:ast %create-namespace -.parsed +.parsed) commands]
|
2022-08-13 05:00:44 +03:00
|
|
|
==
|
2022-08-12 21:08:20 +03:00
|
|
|
%create-table
|
2022-08-25 22:21:07 +03:00
|
|
|
~| "Cannot parse table {<p.q.command-nail>}"
|
2022-09-07 01:46:28 +03:00
|
|
|
=/ table-nail (parse-create-table [[1 1] q.q.command-nail])
|
2022-08-25 22:21:07 +03:00
|
|
|
=/ parsed (wonk table-nail)
|
|
|
|
=/ next-cursor
|
2022-09-07 22:25:00 +03:00
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:table-nail])
|
2022-09-10 02:30:41 +03:00
|
|
|
?: ?=([* * [@ @ *]] parsed)
|
|
|
|
%= $ :: no foreign keys
|
|
|
|
script q.q.u.+3.q:table-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(create-table:ast %create-table -.parsed +<.parsed (create-primary-key [-.parsed +>.parsed]) ~) commands]
|
|
|
|
==
|
2022-09-02 03:14:57 +03:00
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:table-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
2022-09-10 02:30:41 +03:00
|
|
|
[`command-ast`(create-table:ast %create-table -.parsed +<.parsed (create-primary-key [-.parsed +>-.parsed]) (build-foreign-keys [-.parsed +>+.parsed])) commands]
|
2022-09-02 03:14:57 +03:00
|
|
|
==
|
2022-08-12 21:08:20 +03:00
|
|
|
%create-view
|
|
|
|
!!
|
2022-08-16 22:18:14 +03:00
|
|
|
%drop-database
|
2022-08-22 01:01:22 +03:00
|
|
|
~| "Cannot parse drop-database {<p.q.command-nail>}"
|
|
|
|
=/ drop-database-nail (parse-drop-database [[1 1] q.q.command-nail])
|
|
|
|
=/ parsed (wonk drop-database-nail)
|
|
|
|
=/ next-cursor
|
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:drop-database-nail])
|
|
|
|
?@ parsed :: name
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:drop-database-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands [`command-ast`(drop-database:ast %drop-database parsed %.n) commands]
|
|
|
|
==
|
|
|
|
?: ?=([@ @] parsed) :: force name
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:drop-database-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands [`command-ast`(drop-database:ast %drop-database +.parsed %.y) commands]
|
|
|
|
==
|
2022-08-16 22:18:14 +03:00
|
|
|
!!
|
|
|
|
%drop-index
|
2022-08-22 06:25:18 +03:00
|
|
|
~| "Cannot parse drop-index {<p.q.command-nail>}"
|
|
|
|
=/ drop-index-nail (parse-drop-index [[1 1] q.q.command-nail])
|
|
|
|
=/ parsed (wonk drop-index-nail)
|
|
|
|
=/ next-cursor
|
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:drop-index-nail])
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:drop-index-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands [`command-ast`(drop-index:ast %drop-index -.parsed +.parsed) commands]
|
|
|
|
==
|
2022-08-16 22:18:14 +03:00
|
|
|
%drop-namespace
|
2022-08-21 22:12:55 +03:00
|
|
|
~| "Cannot parse drop-namespace {<p.q.command-nail>}"
|
|
|
|
=/ drop-namespace-nail (parse-drop-namespace [[1 1] q.q.command-nail])
|
|
|
|
=/ parsed (wonk drop-namespace-nail)
|
2022-08-22 00:09:24 +03:00
|
|
|
=/ next-cursor
|
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:drop-namespace-nail])
|
|
|
|
?@ parsed :: name
|
2022-08-21 22:12:55 +03:00
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:drop-namespace-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands [`command-ast`(drop-namespace:ast %drop-namespace current-database parsed %.n) commands]
|
|
|
|
==
|
2022-08-22 00:09:24 +03:00
|
|
|
?: ?=([@ @] parsed) :: force name
|
|
|
|
?: =(%force -.parsed)
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:drop-namespace-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands [`command-ast`(drop-namespace:ast %drop-namespace current-database +.parsed %.y) commands]
|
|
|
|
==
|
|
|
|
%= $ :: db.name
|
2022-08-21 22:12:55 +03:00
|
|
|
script q.q.u.+3.q:drop-namespace-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands [`command-ast`(drop-namespace:ast %drop-namespace -.parsed +.parsed %.n) commands]
|
|
|
|
==
|
2022-08-22 00:09:24 +03:00
|
|
|
?: ?=([* [@ @]] parsed) :: force db.name
|
2022-08-21 22:12:55 +03:00
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:drop-namespace-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands [`command-ast`(drop-namespace:ast %drop-namespace +<.parsed +>.parsed %.y) commands]
|
|
|
|
==
|
2022-08-16 22:18:14 +03:00
|
|
|
!!
|
|
|
|
%drop-table
|
2022-08-17 19:35:12 +03:00
|
|
|
~| "Cannot parse drop-table {<p.q.command-nail>}"
|
2022-08-28 18:58:03 +03:00
|
|
|
=/ drop-table-nail (drop-table-or-view [[1 1] q.q.command-nail])
|
2022-08-17 20:10:50 +03:00
|
|
|
=/ parsed (wonk drop-table-nail)
|
2022-08-22 00:09:24 +03:00
|
|
|
=/ next-cursor
|
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:drop-table-nail])
|
2022-08-22 04:03:52 +03:00
|
|
|
?: ?=([@ @ @ @ @ @] parsed) :: force qualified table name
|
2022-08-17 19:35:12 +03:00
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:drop-table-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
2022-08-22 04:03:52 +03:00
|
|
|
[`command-ast`(drop-table:ast %drop-table +.parsed %.y) commands]
|
2022-08-17 19:35:12 +03:00
|
|
|
==
|
2022-08-22 04:03:52 +03:00
|
|
|
?: ?=([@ @ @ @ @] parsed) :: qualified table name
|
2022-08-17 19:35:12 +03:00
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:drop-table-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
2022-08-22 04:03:52 +03:00
|
|
|
[`command-ast`(drop-table:ast %drop-table parsed %.n) commands]
|
2022-08-17 19:35:12 +03:00
|
|
|
==
|
2022-08-16 22:18:14 +03:00
|
|
|
!!
|
|
|
|
%drop-view
|
|
|
|
~| "Cannot parse drop-view {<p.q.command-nail>}"
|
2022-08-28 18:58:03 +03:00
|
|
|
=/ drop-view-nail (drop-table-or-view [[1 1] q.q.command-nail])
|
2022-08-17 20:10:50 +03:00
|
|
|
=/ parsed (wonk drop-view-nail)
|
2022-08-22 00:09:24 +03:00
|
|
|
=/ next-cursor
|
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:drop-view-nail])
|
2022-08-22 04:03:52 +03:00
|
|
|
?: ?=([@ @ @ @ @ @] parsed) :: force qualified view
|
2022-08-16 22:18:14 +03:00
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:drop-view-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
2022-08-22 04:03:52 +03:00
|
|
|
[`command-ast`(drop-view:ast %drop-view +.parsed %.y) commands]
|
2022-08-16 22:18:14 +03:00
|
|
|
==
|
2022-08-22 04:03:52 +03:00
|
|
|
?: ?=([@ @ @ @ @] parsed) :: qualified view
|
2022-08-16 22:18:14 +03:00
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:drop-view-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
2022-08-22 04:03:52 +03:00
|
|
|
[`command-ast`(drop-view:ast %drop-view parsed %.n) commands]
|
2022-08-16 22:18:14 +03:00
|
|
|
==
|
|
|
|
!!
|
2022-08-23 03:53:59 +03:00
|
|
|
%grant
|
|
|
|
~| "Cannot parse grant {<p.q.command-nail>}"
|
|
|
|
=/ grant-nail (parse-grant [[1 1] q.q.command-nail])
|
|
|
|
=/ parsed (wonk grant-nail)
|
|
|
|
=/ next-cursor
|
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:grant-nail])
|
2022-08-24 02:30:27 +03:00
|
|
|
?: ?=([@ [@ [@ %~]] [@ @]] [parsed]) ::"grant adminread to ~sampel-palnet on database db"
|
2022-08-23 03:53:59 +03:00
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:grant-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
2022-08-24 02:30:27 +03:00
|
|
|
[`command-ast`(grant:ast %grant -.parsed +<+.parsed +>.parsed) commands]
|
2022-08-23 03:53:59 +03:00
|
|
|
==
|
|
|
|
?: ?=([@ @ [@ @]] [parsed]) ::"grant adminread to parent on database db"
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:grant-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(grant:ast %grant -.parsed +<.parsed +>.parsed) commands]
|
|
|
|
==
|
2022-08-24 02:30:27 +03:00
|
|
|
?: ?=([@ [@ [@ *]] [@ *]] [parsed]) ::"grant Readwrite to ~zod,~bus,~nec,~sampel-palnet on namespace db.ns"
|
|
|
|
%= $ ::"grant adminread to ~zod,~bus,~nec,~sampel-palnet on namespace ns" (ns previously cooked)
|
|
|
|
script q.q.u.+3.q:grant-nail ::"grant Readwrite to ~zod,~bus,~nec,~sampel-palnet on db.ns.table"
|
2022-08-23 03:53:59 +03:00
|
|
|
script-position next-cursor
|
|
|
|
commands
|
2022-08-24 02:30:27 +03:00
|
|
|
[`command-ast`(grant:ast %grant -.parsed +<+.parsed +>.parsed) commands]
|
2022-08-23 03:53:59 +03:00
|
|
|
==
|
2022-08-23 18:59:52 +03:00
|
|
|
?: ?=([@ @ [@ [@ *]]] [parsed]) ::"grant readonly to siblings on namespace db.ns"
|
|
|
|
%= $ ::"grant readwrite to moons on namespace ns" (ns previously cooked)
|
2022-08-23 03:53:59 +03:00
|
|
|
script q.q.u.+3.q:grant-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(grant:ast %grant -.parsed +<.parsed +>.parsed) commands]
|
|
|
|
==
|
|
|
|
!!
|
2022-09-04 20:53:13 +03:00
|
|
|
%insert
|
|
|
|
~| "Cannot parse insert {<p.q.command-nail>}"
|
|
|
|
=/ insert-nail (parse-insert [[1 1] q.q.command-nail])
|
|
|
|
=/ parsed (wonk insert-nail)
|
|
|
|
=/ next-cursor
|
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:insert-nail])
|
2022-09-13 23:29:49 +03:00
|
|
|
~| "parsed: {<parsed>}"
|
2022-09-05 20:26:35 +03:00
|
|
|
?: ?=([[@ @ @ @ @] @ *] [parsed]) ::"insert rows"
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:insert-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
2022-10-05 23:00:47 +03:00
|
|
|
[`command-ast`(insert:ast %insert -.parsed ~ (insert-values:ast %data +>-.parsed)) commands]
|
2022-09-05 20:26:35 +03:00
|
|
|
==
|
|
|
|
?: ?=([[@ @ @ @ @] [* @] *] [parsed]) ::"insert column names rows"
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:insert-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
2022-10-05 23:00:47 +03:00
|
|
|
[`command-ast`(insert:ast %insert -.parsed `+<-.parsed (insert-values:ast %data +>-.parsed)) commands]
|
2022-09-05 20:26:35 +03:00
|
|
|
==
|
2022-09-04 20:53:13 +03:00
|
|
|
!!
|
2022-09-12 22:38:25 +03:00
|
|
|
%query
|
|
|
|
~| "Cannot parse query {<p.q.command-nail>}"
|
|
|
|
=/ query-nail (parse-query [[1 1] q.q.command-nail])
|
|
|
|
=/ parsed (wonk query-nail)
|
|
|
|
=/ next-cursor
|
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:query-nail])
|
|
|
|
!!
|
2022-08-23 18:59:52 +03:00
|
|
|
%revoke
|
|
|
|
~| "Cannot parse revoke {<p.q.command-nail>}"
|
|
|
|
=/ revoke-nail (parse-revoke [[1 1] q.q.command-nail])
|
|
|
|
=/ parsed (wonk revoke-nail)
|
|
|
|
=/ next-cursor
|
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:revoke-nail])
|
2022-08-24 02:30:27 +03:00
|
|
|
?: ?=([@ [@ [@ %~]] [@ @]] [parsed]) ::"revoke adminread from ~sampel-palnet on database db"
|
2022-08-23 18:59:52 +03:00
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:revoke-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
2022-08-24 02:30:27 +03:00
|
|
|
[`command-ast`(revoke:ast %revoke -.parsed +<+.parsed +>.parsed) commands]
|
2022-08-23 18:59:52 +03:00
|
|
|
==
|
|
|
|
?: ?=([@ @ [@ @]] [parsed]) ::"revoke adminread from parent on database db"
|
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:revoke-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(revoke:ast %revoke -.parsed +<.parsed +>.parsed) commands]
|
|
|
|
==
|
2022-08-24 02:30:27 +03:00
|
|
|
?: ?=([@ [@ [@ *]] [@ *]] [parsed]) ::"revoke Readwrite from ~zod,~bus,~nec,~sampel-palnet on namespace db.ns"
|
|
|
|
%= $ ::"revoke adminread from ~zod,~bus,~nec,~sampel-palnet on namespace ns" (ns previously cooked)
|
|
|
|
script q.q.u.+3.q:revoke-nail ::"revoke Readwrite from ~zod,~bus,~nec,~sampel-palnet on db.ns.table"
|
2022-08-23 18:59:52 +03:00
|
|
|
script-position next-cursor
|
|
|
|
commands
|
2022-08-24 02:30:27 +03:00
|
|
|
[`command-ast`(revoke:ast %revoke -.parsed +<+.parsed +>.parsed) commands]
|
2022-08-23 18:59:52 +03:00
|
|
|
==
|
|
|
|
?: ?=([@ @ [@ [@ *]]] [parsed]) ::"revoke readonly from siblings on namespace db.ns"
|
|
|
|
%= $ ::"revoke readwrite from moons on namespace ns" (ns previously cooked)
|
|
|
|
script q.q.u.+3.q:revoke-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(revoke:ast %revoke -.parsed +<.parsed +>.parsed) commands]
|
|
|
|
==
|
|
|
|
!!
|
2022-08-17 20:10:50 +03:00
|
|
|
%truncate-table
|
|
|
|
~| "Cannot parse truncate-table {<p.q.command-nail>}"
|
|
|
|
=/ truncate-table-nail (parse-truncate-table [[1 1] q.q.command-nail])
|
2022-08-22 00:09:24 +03:00
|
|
|
=/ next-cursor
|
|
|
|
(get-next-cursor [script-position +<.command-nail p.q.u.+3:q.+3:truncate-table-nail])
|
2022-08-21 03:29:26 +03:00
|
|
|
%= $
|
|
|
|
script q.q.u.+3.q:truncate-table-nail
|
|
|
|
script-position next-cursor
|
|
|
|
commands
|
|
|
|
[`command-ast`(truncate-table:ast %truncate-table (wonk truncate-table-nail)) commands]
|
|
|
|
==
|
2022-08-16 22:18:14 +03:00
|
|
|
==
|
2022-08-13 05:13:25 +03:00
|
|
|
--
|