Documentation Source Text

Check-in [b28d410e7d]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Tweaks to the syntax diagrams to make them more readable.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b28d410e7dc7185dd54402bedb652ea70ad44b64
User & Date: drh 2009-02-14 19:00:18
Context
2009-02-16
16:16
Additional clarifications to the syntax diagrams. check-in: 1495fead09 user: drh tags: trunk
2009-02-14
19:00
Tweaks to the syntax diagrams to make them more readable. check-in: b28d410e7d user: drh tags: trunk
2009-02-13
22:41
Improvements to the join-op syntax diagram. Do not show the RIGHT and FULL outer join options, since SQLite does not do them (yet). check-in: 122764735d user: drh tags: trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to art/syntax/alter-table-stmt.gif.

cannot compute difference between binary files

Changes to art/syntax/bubble-generator.tcl.

    98     98             {tailbranch
    99     99               {line ( {loop column-def ,} {loop {} {, table-constraint}} )}
   100    100               {line AS select-stmt}
   101    101             }
   102    102          }
   103    103     }
   104    104     column-def {
   105         -    line /column-name {or type-name nil} {loop {} column-constraint}
          105  +    line /column-name {or type-name nil} {loop nil {nil column-constraint nil}}
   106    106     }
   107    107     type-name {
   108    108        line {loop /name {}} {or {}
   109    109           {line ( signed-number )}
   110    110           {line ( signed-number , signed-number )}
   111    111        }
   112    112     }
................................................................................
   319    319                /collation-name
   320    320                {line {optx /database-name .}
   321    321                    {tailbranch /table-name /index-name}
   322    322                }
   323    323             }
   324    324     }
   325    325     select-stmt {
   326         -     stack
   327         -       {loop
   328         -          {indentstack
   329         -             {line SELECT {or nil DISTINCT ALL} {loop result-column ,}}
   330         -             {optx FROM join-source}
   331         -             {optx WHERE expr}
   332         -             {optx GROUP BY {loop ordering-term ,} {optx HAVING expr}}
   333         -          } compound-operator
   334         -       }
          326  +    stack
          327  +       {loop {line nil select-core nil} {nil compound-operator nil}}
   335    328          {optx ORDER BY {loop ordering-term ,}}
   336    329          {optx LIMIT /integer {optx {or OFFSET ,} /integer}}
          330  +  }
          331  +  select-core {
          332  +     stack
          333  +       {line SELECT {or nil DISTINCT ALL} {loop result-column ,}}
          334  +       {optx FROM join-source}
          335  +       {optx WHERE expr}
          336  +       {optx GROUP BY {loop ordering-term ,} {optx HAVING expr}}
   337    337           
   338    338     }
   339    339     result-column {
   340    340        or
   341    341           *
   342    342           {line /table-name . *}
   343    343           {line expr {optx {optx AS} /column-alias}}
................................................................................
   444    444     if {$y0 + 2*$RADIUS < $y1} {
   445    445       set xr0 [expr {$x-$RADIUS}]
   446    446       set xr1 [expr {$x+$RADIUS}]
   447    447       .c create arc $xr0 $y0 $xr1 [expr {$y0+2*$RADIUS}] \
   448    448             -width 2 -start 90 -extent -90 -tags $tag -style arc
   449    449       set yr0 [expr {$y0+$RADIUS}]
   450    450       set yr1 [expr {$y1-$RADIUS}]
   451         -    .c create line $xr1 $yr0 $xr1 $yr1 -width 2 -tags $tag
          451  +    if {abs($yr1-$yr0)>$RADIUS*2} {
          452  +      set half_y [expr {($yr1+$yr0)/2}]
          453  +      .c create line $xr1 $yr0 $xr1 $half_y -width 2 -tags $tag -arrow last
          454  +      .c create line $xr1 $half_y $xr1 $yr1 -width 2 -tags $tag
          455  +    } else {
          456  +      .c create line $xr1 $yr0 $xr1 $yr1 -width 2 -tags $tag
          457  +    }
   452    458       .c create arc $xr0 [expr {$y1-2*$RADIUS}] $xr1 $y1 \
   453    459             -width 2 -start 0 -extent -90 -tags $tag -style arc
   454    460     } else { 
   455    461       set r [expr {($y1-$y0)/2.0}]
   456    462       set x0 [expr {$x-$r}]
   457    463       set x1 [expr {$x+$r}]
   458    464       .c create arc $x0 $y0 $x1 $y1 \
   459    465             -width 2 -start 90 -extent -180 -tags $tag -style arc
   460    466     }
   461    467   }
   462    468   
   463    469   # Draw a left-hand turn around.  Approximatley a "("
   464    470   #
   465         -proc draw_left_turnback {tag x y0 y1} {
          471  +proc draw_left_turnback {tag x y0 y1 dir} {
   466    472     global RADIUS
   467    473     if {$y0 + 2*$RADIUS < $y1} {
   468    474       set xr0 [expr {$x-$RADIUS}]
   469    475       set xr1 [expr {$x+$RADIUS}]
   470    476       .c create arc $xr0 $y0 $xr1 [expr {$y0+2*$RADIUS}] \
   471    477             -width 2 -start 90 -extent 90 -tags $tag -style arc
   472    478       set yr0 [expr {$y0+$RADIUS}]
   473    479       set yr1 [expr {$y1-$RADIUS}]
   474         -    .c create line $xr0 $yr0 $xr0 $yr1 -width 2 -tags $tag
          480  +    if {abs($yr1-$yr0)>$RADIUS*3} {
          481  +      set half_y [expr {($yr1+$yr0)/2}]
          482  +      if {$dir=="down"} {
          483  +        .c create line $xr0 $yr0 $xr0 $half_y -width 2 -tags $tag -arrow last
          484  +        .c create line $xr0 $half_y $xr0 $yr1 -width 2 -tags $tag
          485  +      } else {
          486  +        .c create line $xr0 $yr1 $xr0 $half_y -width 2 -tags $tag -arrow last
          487  +        .c create line $xr0 $half_y $xr0 $yr0 -width 2 -tags $tag
          488  +      }
          489  +    } else {
          490  +      .c create line $xr0 $yr0 $xr0 $yr1 -width 2 -tags $tag
          491  +    }
          492  +    # .c create line $xr0 $yr0 $xr0 $yr1 -width 2 -tags $tag
   475    493       .c create arc $xr0 [expr {$y1-2*$RADIUS}] $xr1 $y1 \
   476    494             -width 2 -start 180 -extent 90 -tags $tag -style arc
   477    495     } else { 
   478    496       set r [expr {($y1-$y0)/2.0}]
   479    497       set x0 [expr {$x-$r}]
   480    498       set x1 [expr {$x+$r}]
   481    499       .c create arc $x0 $y0 $x1 $y1 \
................................................................................
   619    637   # Draw a sequence of terms from top to bottom.
   620    638   #
   621    639   proc draw_stack {indent lx} {
   622    640     global tagcnt RADIUS VSEP
   623    641     incr tagcnt
   624    642     set tag x$tagcnt
   625    643   
   626         -  set sep $VSEP
          644  +  set sep [expr {$VSEP*2}]
   627    645     set btm 0
   628    646     set n [llength $lx]
   629    647     set i 0
   630    648     set next_bypass_y 0
          649  +
   631    650     foreach term $lx {
   632    651       set bypass_y $next_bypass_y
   633         -    if {$i>0 && $i<$n-1 && [llength $term]>1 &&
          652  +    if {$i>0 && $i<$n && [llength $term]>1 &&
   634    653           ([lindex $term 0]=="opt" || [lindex $term 0]=="optx")} {
   635    654         set bypass 1
   636    655         set term "line [lrange $term 1 end]"
   637    656       } else {
   638    657         set bypass 0
   639    658         set next_bypass_y 0
   640    659       }
................................................................................
   648    667       } else {
   649    668         set enter_y [expr {$btm - $ty0 + $sep*2 + 2}]
   650    669         if {$bypass} {set next_bypass_y [expr {$enter_y - $RADIUS}]}
   651    670         set enter_x [expr {$sep*2 + $indent}]
   652    671         set back_y [expr {$btm + $sep + 1}]
   653    672         if {$bypass_y>0} {
   654    673            set mid_y [expr {($bypass_y+$RADIUS+$back_y)/2}]
   655         -         .c create line $indent $bypass_y $indent $mid_y \
          674  +         .c create line $bypass_x $bypass_y $bypass_x $mid_y \
   656    675               -width 2 -tags $tag -arrow last
   657         -         .c create line $indent $mid_y $indent [expr {$back_y+$RADIUS}] \
          676  +         .c create line $bypass_x $mid_y $bypass_x [expr {$back_y+$RADIUS}] \
   658    677                -tags $tag -width 2
   659    678         }
   660    679         .c move $t $enter_x $enter_y
   661    680         set e2 [expr {$exit_x + $sep}]
   662    681         .c create line $exit_x $exit_y $e2 $exit_y \
   663    682               -width 2 -tags $tag
   664    683         draw_right_turnback $tag $e2 $exit_y $back_y
   665    684         set e3 [expr {$enter_x-$sep}]
          685  +      set bypass_x [expr {$e3-$RADIUS}]
   666    686         set emid [expr {($e2+$e3)/2}]
   667    687         .c create line $e2 $back_y $emid $back_y \
   668    688                    -width 2 -tags $tag -arrow last
   669    689         .c create line $emid $back_y $e3 $back_y \
   670    690                    -width 2 -tags $tag
   671    691         set r2 [expr {($enter_y - $back_y)/2.0}]
   672         -      draw_left_turnback $tag $e3 $back_y $enter_y
          692  +      draw_left_turnback $tag $e3 $back_y $enter_y down
   673    693         .c create line $e3 $enter_y $enter_x $enter_y \
   674    694                    -arrow last -width 2 -tags $tag
   675    695         set exit_x [expr {$enter_x + $exx}]
   676    696         set exit_y [expr {$enter_y + $exy}]
   677    697       }
   678    698       .c addtag $tag withtag $t
   679    699       .c dtag $t $t
   680    700       set btm [lindex [.c bbox $tag] 3]
   681    701       incr i
   682    702     }
          703  +  if {$bypass} {
          704  +    set fwd_y [expr {$btm + $sep + 1}]
          705  +    set mid_y [expr {($next_bypass_y+$RADIUS+$fwd_y)/2}]
          706  +    set descender_x [expr {$exit_x+$RADIUS}]
          707  +    .c create line $bypass_x $next_bypass_y $bypass_x $mid_y \
          708  +        -width 2 -tags $tag -arrow last
          709  +    .c create line $bypass_x $mid_y $bypass_x [expr {$fwd_y-$RADIUS}] \
          710  +        -tags $tag -width 2
          711  +    .c create arc $bypass_x [expr {$fwd_y-2*$RADIUS}] \
          712  +                  [expr {$bypass_x+2*$RADIUS}] $fwd_y \
          713  +        -width 2 -start 180 -extent 90 -tags $tag -style arc
          714  +    .c create arc [expr {$exit_x-$RADIUS}] $exit_y \
          715  +                  $descender_x [expr {$exit_y+2*$RADIUS}] \
          716  +        -width 2 -start 90 -extent -90 -tags $tag -style arc
          717  +    .c create arc $descender_x [expr {$fwd_y-2*$RADIUS}] \
          718  +                  [expr {$descender_x+2*$RADIUS}] $fwd_y \
          719  +        -width 2 -start 180 -extent 90 -tags $tag -style arc
          720  +    set exit_x [expr {$exit_x+2*$RADIUS}]
          721  +    set half_x [expr {($exit_x+$indent)/2}]
          722  +    .c create line [expr {$bypass_x+$RADIUS}] $fwd_y $half_x $fwd_y \
          723  +        -width 2 -tags $tag -arrow last
          724  +    .c create line $half_x $fwd_y $exit_x $fwd_y \
          725  +        -width 2 -tags $tag
          726  +    .c create line $descender_x [expr {$exit_y+$RADIUS}] \
          727  +                   $descender_x [expr {$fwd_y-$RADIUS}] \
          728  +        -width 2 -tags $tag -arrow last
          729  +    set exit_y $fwd_y
          730  +  }
   683    731     set width [lindex [.c bbox $tag] 2]
   684    732     return [list $tag $exit_x $exit_y]
   685    733   }
   686    734   
   687    735   proc draw_loop {forward back} {
   688    736     global tagcnt
   689    737     incr tagcnt
   690    738     set tag x$tagcnt
   691    739     set sep $::HSEP
   692    740     set vsep $::VSEP
          741  +  if {$back==","} {
          742  +    set vsep 0
          743  +  } elseif {$back=="nil"} {
          744  +    set vsep [expr {$vsep/2}]
          745  +  }
   693    746   
   694    747     foreach {ft fexx fexy} [draw_diagram $forward] break
   695    748     foreach {fx0 fy0 fx1 fy1} [.c bbox $ft] break
   696    749     set fw [expr {$fx1-$fx0}]
   697    750     foreach {bt bexx bexy} [draw_backwards_line $back] break
   698    751     foreach {bx0 by0 bx1 by1} [.c bbox $bt] break
   699    752     set bw [expr {$bx1-$bx0}]
................................................................................
   720    773         .c create line $bexx $bexy $fx1 $bexy -width 2 -tags $bt -arrow first
   721    774         set mxx $fexx
   722    775       }
   723    776     } elseif {$bw>$fw} {
   724    777       set dx [expr {($bw-$fw)/2}]
   725    778       .c move $ft $dx 0
   726    779       set fexx [expr {$dx+$fexx}]
   727         -    .c create line 0 0 $dx $fexy -width 2 -tags $ft
          780  +    .c create line 0 0 $dx $fexy -width 2 -tags $ft -arrow last
   728    781       .c create line $fexx $fexy $bx1 $fexy -width 2 -tags $ft
   729    782       set mxx $bexx
   730    783     }
   731    784     .c addtag $tag withtag $bt
   732    785     .c addtag $tag withtag $ft
   733    786     .c dtag $bt $bt
   734    787     .c dtag $ft $ft
   735    788     .c move $tag $sep 0
   736    789     set mxx [expr {$mxx+$sep}]
   737    790     .c create line 0 0 $sep 0 -width 2 -tags $tag
   738         -  draw_left_turnback $tag $sep 0 $biny
          791  +  draw_left_turnback $tag $sep 0 $biny up
   739    792     draw_right_turnback $tag $mxx $fexy $bexy
   740    793     foreach {x0 y0 x1 y1} [.c bbox $tag] break
   741    794     set exit_x [expr {$mxx+$::RADIUS}]
   742    795     .c create line $mxx $fexy $exit_x $fexy -width 2 -tags $tag
   743    796     return [list $tag $exit_x $fexy]
   744    797   }
   745    798   
................................................................................
   781    834     .c addtag $tag withtag $bt
   782    835     .c addtag $tag withtag $ft
   783    836     .c dtag $bt $bt
   784    837     .c dtag $ft $ft
   785    838     .c move $tag $sep 0
   786    839     set mxx [expr {$mxx+$sep}]
   787    840     .c create line 0 0 $sep 0 -width 2 -tags $tag
   788         -  draw_left_turnback $tag $sep 0 $biny
          841  +  draw_left_turnback $tag $sep 0 $biny down
   789    842     draw_right_turnback $tag $mxx $fexy $bexy
   790    843     foreach {x0 y0 x1 y1} [.c bbox $tag] break
   791    844     .c create line $mxx $fexy $x1 $fexy -width 2 -tags $tag
   792    845     return [list $tag $x1 $fexy]
   793    846   }
   794    847   
   795    848   proc draw_or {lx} {

Changes to art/syntax/column-constraint.gif.

cannot compute difference between binary files

Changes to art/syntax/column-def.gif.

cannot compute difference between binary files

Changes to art/syntax/comment-syntax.gif.

cannot compute difference between binary files

Changes to art/syntax/create-index-stmt.gif.

cannot compute difference between binary files

Changes to art/syntax/create-table-stmt.gif.

cannot compute difference between binary files

Changes to art/syntax/create-trigger-stmt.gif.

cannot compute difference between binary files

Changes to art/syntax/create-view-stmt.gif.

cannot compute difference between binary files

Changes to art/syntax/create-virtual-table-stmt.gif.

cannot compute difference between binary files

Changes to art/syntax/delete-stmt-limited.gif.

cannot compute difference between binary files

Changes to art/syntax/expr.gif.

cannot compute difference between binary files

Changes to art/syntax/foreign-key-clause.gif.

cannot compute difference between binary files

Changes to art/syntax/insert-stmt.gif.

cannot compute difference between binary files

Changes to art/syntax/join-constraint.gif.

cannot compute difference between binary files

Changes to art/syntax/join-source.gif.

cannot compute difference between binary files

Added art/syntax/select-core.gif.

cannot compute difference between binary files

Changes to art/syntax/select-stmt.gif.

cannot compute difference between binary files

Changes to art/syntax/syntax_linkage.tcl.

    16     16   set syntax_linkage(delete-stmt) {{expr qualified-table-name} {create-trigger-stmt sql-stmt}}
    17     17   set syntax_linkage(delete-stmt-limited) {{expr ordering-term qualified-table-name} sql-stmt}
    18     18   set syntax_linkage(detach-stmt) {{} sql-stmt}
    19     19   set syntax_linkage(drop-index-stmt) {{} sql-stmt}
    20     20   set syntax_linkage(drop-table-stmt) {{} sql-stmt}
    21     21   set syntax_linkage(drop-trigger-stmt) {{} sql-stmt}
    22     22   set syntax_linkage(drop-view-stmt) {{} sql-stmt}
    23         -set syntax_linkage(expr) {{literal-value raise-function select-stmt type-name} {column-constraint create-trigger-stmt delete-stmt delete-stmt-limited insert-stmt join-constraint ordering-term result-column select-stmt table-constraint update-stmt update-stmt-limited}}
           23  +set syntax_linkage(expr) {{literal-value raise-function select-stmt type-name} {column-constraint create-trigger-stmt delete-stmt delete-stmt-limited insert-stmt join-constraint ordering-term result-column select-core table-constraint update-stmt update-stmt-limited}}
    24     24   set syntax_linkage(foreign-key-clause) {{} {column-constraint table-constraint}}
    25     25   set syntax_linkage(indexed-column) {{} {create-index-stmt table-constraint}}
    26     26   set syntax_linkage(insert-stmt) {{expr select-stmt} {create-trigger-stmt sql-stmt}}
    27     27   set syntax_linkage(join-constraint) {expr join-source}
    28     28   set syntax_linkage(join-op) {{} join-source}
    29         -set syntax_linkage(join-source) {{join-constraint join-op single-source} {select-stmt single-source}}
           29  +set syntax_linkage(join-source) {{join-constraint join-op single-source} {select-core single-source}}
    30     30   set syntax_linkage(literal-value) {{} {column-constraint expr}}
    31         -set syntax_linkage(ordering-term) {expr {delete-stmt-limited select-stmt update-stmt-limited}}
           31  +set syntax_linkage(ordering-term) {expr {delete-stmt-limited select-core select-stmt update-stmt-limited}}
    32     32   set syntax_linkage(pragma-stmt) {pragma-value sql-stmt}
    33     33   set syntax_linkage(pragma-value) {signed-number pragma-stmt}
    34     34   set syntax_linkage(qualified-table-name) {{} {delete-stmt delete-stmt-limited update-stmt update-stmt-limited}}
    35     35   set syntax_linkage(raise-function) {{} expr}
    36     36   set syntax_linkage(reindex-stmt) {{} sql-stmt}
    37     37   set syntax_linkage(release-stmt) {{} sql-stmt}
    38         -set syntax_linkage(result-column) {expr select-stmt}
           38  +set syntax_linkage(result-column) {expr select-core}
    39     39   set syntax_linkage(rollback-stmt) {{} sql-stmt}
    40     40   set syntax_linkage(savepoint-stmt) {{} sql-stmt}
    41         -set syntax_linkage(select-stmt) {{compound-operator expr join-source ordering-term result-column} {create-table-stmt create-trigger-stmt create-view-stmt expr insert-stmt single-source sql-stmt}}
           41  +set syntax_linkage(select-core) {{expr join-source ordering-term result-column} select-stmt}
           42  +set syntax_linkage(select-stmt) {{compound-operator ordering-term select-core} {create-table-stmt create-trigger-stmt create-view-stmt expr insert-stmt single-source sql-stmt}}
    42     43   set syntax_linkage(signed-number) {{} {column-constraint pragma-value type-name}}
    43     44   set syntax_linkage(single-source) {{join-source select-stmt} join-source}
    44     45   set syntax_linkage(sql-stmt) {{alter-table-stmt analyze-stmt attach-stmt begin-stmt commit-stmt create-index-stmt create-table-stmt create-trigger-stmt create-view-stmt create-virtual-table-stmt delete-stmt delete-stmt-limited detach-stmt drop-index-stmt drop-table-stmt drop-trigger-stmt drop-view-stmt insert-stmt pragma-stmt reindex-stmt release-stmt rollback-stmt savepoint-stmt select-stmt update-stmt update-stmt-limited vacuum-stmt} sql-stmt-list}
    45     46   set syntax_linkage(sql-stmt-list) {sql-stmt {}}
    46     47   set syntax_linkage(table-constraint) {{conflict-clause expr foreign-key-clause indexed-column} create-table-stmt}
    47     48   set syntax_linkage(type-name) {signed-number {column-def expr}}
    48     49   set syntax_linkage(update-stmt) {{expr qualified-table-name} {create-trigger-stmt sql-stmt}}
    49     50   set syntax_linkage(update-stmt-limited) {{expr ordering-term qualified-table-name} sql-stmt}
    50     51   set syntax_linkage(vacuum-stmt) {{} sql-stmt}
    51         -set syntax_order {sql-stmt-list sql-stmt alter-table-stmt analyze-stmt attach-stmt begin-stmt commit-stmt rollback-stmt savepoint-stmt release-stmt create-index-stmt indexed-column create-table-stmt column-def type-name column-constraint signed-number table-constraint foreign-key-clause conflict-clause create-trigger-stmt create-view-stmt create-virtual-table-stmt delete-stmt delete-stmt-limited detach-stmt drop-index-stmt drop-table-stmt drop-trigger-stmt drop-view-stmt expr raise-function literal-value insert-stmt pragma-stmt pragma-value reindex-stmt select-stmt result-column join-source single-source join-op join-constraint ordering-term compound-operator update-stmt update-stmt-limited qualified-table-name vacuum-stmt comment-syntax}
           52  +set syntax_order {sql-stmt-list sql-stmt alter-table-stmt analyze-stmt attach-stmt begin-stmt commit-stmt rollback-stmt savepoint-stmt release-stmt create-index-stmt indexed-column create-table-stmt column-def type-name column-constraint signed-number table-constraint foreign-key-clause conflict-clause create-trigger-stmt create-view-stmt create-virtual-table-stmt delete-stmt delete-stmt-limited detach-stmt drop-index-stmt drop-table-stmt drop-trigger-stmt drop-view-stmt expr raise-function literal-value insert-stmt pragma-stmt pragma-value reindex-stmt select-stmt select-core result-column join-source single-source join-op join-constraint ordering-term compound-operator update-stmt update-stmt-limited qualified-table-name vacuum-stmt comment-syntax}

Changes to art/syntax/table-constraint.gif.

cannot compute difference between binary files

Changes to art/syntax/update-stmt-limited.gif.

cannot compute difference between binary files

Changes to art/syntax/update-stmt.gif.

cannot compute difference between binary files

Changes to pages/lang.in.

  2103   2103   information.</p>  
  2104   2104   
  2105   2105   <tcl>
  2106   2106   ###############################################################################
  2107   2107   Section SELECT select {SELECT query}
  2108   2108   
  2109   2109   BubbleDiagram select-stmt 1
         2110  +BubbleDiagram select-core
  2110   2111   BubbleDiagram result-column
  2111   2112   BubbleDiagram join-source
  2112   2113   BubbleDiagram single-source
  2113   2114   BubbleDiagram join-op
  2114   2115   BubbleDiagram join-constraint
  2115   2116   BubbleDiagram ordering-term
  2116   2117   BubbleDiagram compound-operator