diff --git a/sql/parser.go b/sql/parser.go index 5210a34..11d50d8 100644 --- a/sql/parser.go +++ b/sql/parser.go @@ -1,9 +1,12 @@ +// Code generated by goyacc -o parser.go parser.go.y. DO NOT EDIT. + //line parser.go.y:2 package sql import __yyfmt__ "fmt" //line parser.go.y:2 + //line parser.go.y:5 type yySymType struct { yys int @@ -45,40 +48,43 @@ const COLLATE = 57351 const CONSTRAINT = 57352 const CREATE = 57353 const DEFAULT = 57354 -const DELETE = 57355 -const DESC = 57356 -const FOREIGN = 57357 -const FROM = 57358 -const GLOB = 57359 -const IN = 57360 -const INDEX = 57361 -const IS = 57362 -const KEY = 57363 -const LIKE = 57364 -const MATCH = 57365 -const NO = 57366 -const NOT = 57367 -const NULL = 57368 -const ON = 57369 -const OR = 57370 -const PRIMARY = 57371 -const REFERENCES = 57372 -const REGEXP = 57373 -const RESTRICT = 57374 -const ROWID = 57375 -const SELECT = 57376 -const SET = 57377 -const TABLE = 57378 -const UNIQUE = 57379 -const UPDATE = 57380 -const WHERE = 57381 -const WITHOUT = 57382 -const tBare = 57383 -const tLiteral = 57384 -const tIdentifier = 57385 -const tOperator = 57386 -const tSignedNumber = 57387 -const tFloat = 57388 +const DEFERRABLE = 57355 +const DEFERRED = 57356 +const DELETE = 57357 +const DESC = 57358 +const FOREIGN = 57359 +const FROM = 57360 +const GLOB = 57361 +const IN = 57362 +const INDEX = 57363 +const INITIALLY = 57364 +const IS = 57365 +const KEY = 57366 +const LIKE = 57367 +const MATCH = 57368 +const NO = 57369 +const NOT = 57370 +const NULL = 57371 +const ON = 57372 +const OR = 57373 +const PRIMARY = 57374 +const REFERENCES = 57375 +const REGEXP = 57376 +const RESTRICT = 57377 +const ROWID = 57378 +const SELECT = 57379 +const SET = 57380 +const TABLE = 57381 +const UNIQUE = 57382 +const UPDATE = 57383 +const WHERE = 57384 +const WITHOUT = 57385 +const tBare = 57386 +const tLiteral = 57387 +const tIdentifier = 57388 +const tOperator = 57389 +const tSignedNumber = 57390 +const tFloat = 57391 var yyToknames = [...]string{ "$end", @@ -93,6 +99,8 @@ var yyToknames = [...]string{ "CONSTRAINT", "CREATE", "DEFAULT", + "DEFERRABLE", + "DEFERRED", "DELETE", "DESC", "FOREIGN", @@ -100,6 +108,7 @@ var yyToknames = [...]string{ "GLOB", "IN", "INDEX", + "INITIALLY", "IS", "KEY", "LIKE", @@ -145,64 +154,65 @@ var yyExca = [...]int{ 1, -1, -2, 0, -1, 77, - 50, 6, - -2, 77, + 53, 6, + -2, 81, -1, 78, - 50, 7, - -2, 78, + 53, 7, + -2, 82, } const yyPrivate = 57344 -const yyLast = 182 +const yyLast = 187 var yyAct = [...]int{ - 73, 147, 9, 125, 88, 71, 10, 68, 74, 48, - 127, 61, 75, 132, 18, 144, 69, 10, 21, 132, - 23, 133, 72, 26, 95, 17, 131, 31, 32, 26, - 130, 95, 129, 124, 139, 108, 52, 77, 76, 78, - 106, 62, 82, 80, 81, 59, 79, 102, 95, 99, - 96, 84, 101, 100, 60, 67, 122, 94, 16, 93, - 65, 66, 47, 86, 62, 46, 63, 64, 22, 36, - 28, 37, 91, 92, 62, 82, 80, 81, 99, 65, - 66, 101, 100, 55, 62, 103, 63, 64, 35, 91, - 92, 114, 107, 104, 105, 11, 87, 12, 145, 39, - 149, 136, 115, 111, 51, 117, 118, 119, 121, 10, - 116, 126, 112, 33, 123, 25, 151, 143, 49, 11, - 128, 12, 27, 146, 150, 154, 50, 148, 6, 44, - 13, 15, 45, 10, 58, 135, 134, 137, 56, 153, - 10, 19, 126, 141, 34, 43, 42, 85, 152, 40, - 53, 5, 83, 57, 8, 89, 35, 41, 110, 98, - 155, 120, 70, 90, 113, 140, 142, 29, 38, 109, - 97, 20, 54, 14, 30, 24, 7, 138, 4, 3, - 2, 1, + 73, 152, 9, 125, 88, 71, 10, 68, 74, 127, + 139, 61, 75, 132, 18, 145, 69, 10, 21, 132, + 23, 133, 72, 26, 95, 48, 131, 31, 32, 26, + 130, 95, 129, 124, 108, 106, 52, 77, 76, 78, + 102, 62, 82, 80, 81, 59, 79, 84, 95, 99, + 96, 47, 101, 100, 60, 67, 122, 94, 28, 93, + 65, 66, 46, 36, 62, 37, 63, 64, 62, 82, + 80, 81, 91, 92, 99, 22, 55, 101, 100, 86, + 62, 17, 63, 64, 11, 103, 12, 35, 114, 91, + 92, 150, 107, 104, 105, 65, 66, 13, 15, 154, + 39, 51, 115, 111, 6, 117, 118, 119, 121, 10, + 116, 126, 112, 33, 123, 16, 49, 151, 156, 87, + 128, 11, 136, 12, 50, 44, 155, 149, 45, 153, + 5, 27, 159, 10, 58, 135, 134, 137, 25, 56, + 10, 85, 126, 142, 43, 42, 83, 57, 40, 158, + 53, 144, 19, 157, 89, 8, 41, 147, 141, 35, + 98, 110, 160, 143, 90, 140, 120, 34, 70, 113, + 146, 148, 20, 29, 38, 109, 97, 54, 14, 30, + 24, 7, 138, 4, 3, 2, 1, } var yyPact = [...]int{ - 117, -1000, -1000, -1000, -1000, 54, 94, 9, -1000, -1000, - -1000, -1000, -1000, 54, 122, -1000, 54, 54, 18, 54, - -1000, -1000, 54, 95, 21, -1000, 54, 54, 78, 20, - 120, 15, 12, 89, -1000, 54, 146, 43, 120, -1000, - 132, -1000, -1000, 108, 54, 19, 39, -4, -1000, 131, - 1, 126, -1000, 89, -1000, 63, -1000, 149, -1000, -1000, - -1000, -1000, -1000, 39, 39, -1000, -1000, 8, -1, -1000, - 150, 34, -1000, -3, -1000, -1000, -1000, -1000, -1000, -4, - 29, 29, -1000, -10, -4, -15, -1000, -1000, 151, -1000, - -1000, -1000, -1000, -1000, 39, -4, 52, 149, 38, -4, - -4, -4, -4, 5, -1000, -1000, -4, -18, 54, -1000, - -1000, -41, -1000, -1000, -4, -1000, -1000, 34, 34, 34, - -19, 34, -1000, -25, -1000, -30, -1000, -1000, 34, -1000, - -4, -1000, 54, 71, 34, -1000, 54, -16, -1000, 54, - 90, -36, -1000, 85, -1000, 92, 92, -1000, 113, -1000, - -1000, 156, -1000, -1000, -1000, -1000, + 93, -1000, -1000, -1000, -1000, 40, 58, 63, -1000, -1000, + -1000, -1000, -1000, 40, 131, -1000, 40, 40, 22, 40, + -1000, -1000, 40, 101, 6, -1000, 40, 40, 77, 11, + 116, 9, -2, 84, -1000, 40, 149, 33, 116, -1000, + 123, -1000, -1000, 105, 40, 16, 32, -7, -1000, 122, + -6, 117, -1000, 84, -1000, 83, -1000, 148, -1000, -1000, + -1000, -1000, -1000, 32, 32, -1000, -1000, 5, -4, -1000, + 151, 27, -1000, -13, -1000, -1000, -1000, -1000, -1000, -7, + 20, 20, -1000, -18, -7, -19, -1000, -1000, 154, -1000, + -1000, -1000, -1000, -1000, 32, -7, 46, 148, 51, -7, + -7, -7, -7, 2, -1000, -1000, -7, -21, 40, -1000, + -1000, -45, -1000, -1000, -7, -1000, -1000, 27, 27, 27, + -22, 27, -1000, -28, -1000, -33, -1000, -1000, 27, -1000, + -7, -1000, 40, 89, 27, -1000, 40, -43, 145, 40, + 129, -1000, -39, -1000, 143, -1000, 97, -1000, -1000, 76, + 91, 91, -1000, 120, -1000, -1000, 158, -1000, -1000, -1000, + -1000, } var yyPgo = [...]int{ - 0, 181, 180, 179, 178, 0, 11, 8, 12, 2, - 154, 3, 177, 176, 175, 115, 7, 16, 174, 113, - 173, 172, 170, 4, 169, 99, 168, 9, 167, 1, - 166, 165, 164, 162, 5, 161, + 0, 186, 185, 184, 183, 0, 11, 8, 12, 2, + 155, 3, 182, 181, 180, 138, 7, 16, 179, 113, + 178, 177, 176, 4, 175, 100, 174, 25, 173, 1, + 171, 170, 169, 168, 5, 166, 165, 163, } var yyR1 = [...]int{ @@ -213,58 +223,62 @@ var yyR1 = [...]int{ 24, 14, 14, 15, 18, 18, 18, 18, 22, 22, 23, 23, 23, 21, 21, 20, 20, 16, 16, 33, 17, 29, 29, 29, 29, 29, 30, 30, 31, 31, - 32, 32, 34, 34, 34, 34, 34, 34, 34, 34, - 34, 34, 34, 35, 35, 35, 2, 3, 4, + 36, 36, 37, 37, 32, 32, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 35, 35, 35, + 2, 3, 4, } var yyR2 = [...]int{ 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 1, 2, 2, 1, 1, 3, 3, 1, 1, 3, 4, 1, 1, 2, 2, 2, 2, 0, 1, - 2, 5, 4, 9, 0, 2, 0, 3, 4, 0, + 2, 5, 4, 11, 0, 2, 0, 3, 4, 0, 1, 1, 3, 3, 0, 1, 4, 6, 0, 2, 0, 1, 1, 0, 2, 0, 1, 1, 3, 1, 3, 2, 2, 1, 1, 2, 3, 3, 0, 2, - 0, 2, 1, 4, 1, 1, 1, 1, 1, 3, - 3, 3, 3, 0, 1, 3, 4, 8, 10, + 0, 1, 0, 2, 0, 2, 1, 4, 1, 1, + 1, 1, 1, 3, 3, 3, 3, 0, 1, 3, + 4, 8, 10, } var yyChk = [...]int{ - -1000, -1, -2, -3, -4, 34, 11, -13, -10, -9, - -5, 41, 43, 36, -20, 37, 49, 16, -5, 19, - -10, -5, 50, -5, -14, -15, -5, 27, 49, -28, - -18, -5, -5, -19, -15, 10, 49, 51, -26, -25, - 29, 37, 26, 25, 9, 12, 50, 50, -27, 29, - 37, 15, -5, -19, -21, 40, -25, 21, 26, -5, - -7, -6, 45, 47, 48, 41, 42, -7, -16, -17, - -33, -34, 26, -5, -7, -8, 42, 41, 43, 50, - 47, 48, 46, 21, 50, 21, -27, 33, -23, 6, - 14, -7, -7, 51, 49, 49, 51, -22, 9, 44, - 48, 47, 50, -34, -8, -8, 50, -16, 50, -24, - 7, -7, -17, -32, 39, -23, -6, -34, -34, -34, - -35, -34, 51, -16, 51, -11, -9, 51, -34, 51, - 49, 51, 49, 51, -34, -9, 30, -5, -12, 50, - -31, -11, -30, 27, 51, 13, 38, -29, 35, 8, - 32, 24, -29, 26, 12, 4, + -1000, -1, -2, -3, -4, 37, 11, -13, -10, -9, + -5, 44, 46, 39, -20, 40, 52, 18, -5, 21, + -10, -5, 53, -5, -14, -15, -5, 30, 52, -28, + -18, -5, -5, -19, -15, 10, 52, 54, -26, -25, + 32, 40, 29, 28, 9, 12, 53, 53, -27, 32, + 40, 17, -5, -19, -21, 43, -25, 24, 29, -5, + -7, -6, 48, 50, 51, 44, 45, -7, -16, -17, + -33, -34, 29, -5, -7, -8, 45, 44, 46, 53, + 50, 51, 49, 24, 53, 24, -27, 36, -23, 6, + 16, -7, -7, 54, 52, 52, 54, -22, 9, 47, + 51, 50, 53, -34, -8, -8, 53, -16, 53, -24, + 7, -7, -17, -32, 42, -23, -6, -34, -34, -34, + -35, -34, 54, -16, 54, -11, -9, 54, -34, 54, + 52, 54, 52, 54, -34, -9, 33, -5, -12, 53, + -36, 13, -11, -37, 22, 54, -31, 14, -30, 30, + 15, 41, -29, 38, 8, 35, 27, -29, 29, 12, + 4, } var yyDef = [...]int{ 0, -2, 1, 2, 3, 0, 55, 0, 19, 18, 14, 6, 7, 0, 0, 56, 0, 0, 0, 0, - 20, 86, 0, 0, 36, 41, 44, 0, 34, 0, + 20, 90, 0, 0, 36, 41, 44, 0, 34, 0, 28, 45, 0, 0, 42, 0, 34, 53, 43, 29, 0, 22, 23, 0, 0, 0, 0, 0, 37, 0, - 0, 0, 35, 0, 87, 0, 30, 50, 24, 25, + 0, 0, 35, 0, 91, 0, 30, 50, 24, 25, 26, 27, 8, 0, 0, 4, 5, 0, 0, 57, - 48, 59, 72, 0, 74, 75, 76, -2, -2, 0, + 48, 59, 76, 0, 78, 79, 80, -2, -2, 0, 0, 0, 11, 0, 0, 0, 38, 54, 39, 51, - 52, 9, 10, 46, 0, 0, 70, 50, 0, 0, - 0, 0, 83, 0, 12, 13, 0, 0, 0, 21, - 40, 0, 58, 88, 0, 60, 49, 79, 80, 81, - 0, 84, 82, 0, 32, 0, 15, 47, 71, 73, - 0, 31, 0, 0, 85, 16, 0, 0, 68, 0, - 33, 0, 69, 0, 17, 0, 0, 66, 0, 63, - 64, 0, 67, 61, 62, 65, + 52, 9, 10, 46, 0, 0, 74, 50, 0, 0, + 0, 0, 87, 0, 12, 13, 0, 0, 0, 21, + 40, 0, 58, 92, 0, 60, 49, 83, 84, 85, + 0, 88, 86, 0, 32, 0, 15, 47, 75, 77, + 0, 31, 0, 0, 89, 16, 0, 0, 70, 0, + 72, 71, 0, 68, 0, 17, 33, 73, 69, 0, + 0, 0, 66, 0, 63, 64, 0, 67, 61, 62, + 65, } var yyTok1 = [...]int{ @@ -272,7 +286,7 @@ var yyTok1 = [...]int{ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, - 50, 51, 3, 48, 49, 47, + 53, 54, 3, 51, 52, 50, } var yyTok2 = [...]int{ @@ -280,7 +294,7 @@ var yyTok2 = [...]int{ 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 43, 44, 45, 46, + 42, 43, 44, 45, 46, 47, 48, 49, } var yyTok3 = [...]int{ 0, @@ -625,503 +639,529 @@ yydefault: case 4: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:117 +//line parser.go.y:122 { yyVAL.literal = yyDollar[1].identifier } case 5: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:120 +//line parser.go.y:125 { yyVAL.literal = yyDollar[1].identifier } case 6: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:125 +//line parser.go.y:130 { yyVAL.identifier = yyDollar[1].identifier } case 7: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:128 +//line parser.go.y:133 { yyVAL.identifier = yyDollar[1].identifier } case 8: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:133 +//line parser.go.y:138 { yyVAL.signedNumber = yyDollar[1].signedNumber } case 9: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:136 +//line parser.go.y:141 { yyVAL.signedNumber = -yyDollar[2].signedNumber } case 10: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:139 +//line parser.go.y:144 { yyVAL.signedNumber = yyDollar[2].signedNumber } case 11: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:144 +//line parser.go.y:149 { yyVAL.float = yyDollar[1].float } case 12: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:147 +//line parser.go.y:152 { yyVAL.float = -yyDollar[2].float } case 13: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:150 +//line parser.go.y:155 { yyVAL.float = yyDollar[2].float } case 14: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:155 +//line parser.go.y:160 { yyVAL.columnName = yyDollar[1].identifier } case 15: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:160 +//line parser.go.y:165 { yyVAL.columnNameList = []string{yyDollar[1].columnName} } case 16: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:163 +//line parser.go.y:168 { yyVAL.columnNameList = append(yyDollar[1].columnNameList, yyDollar[3].columnName) } case 17: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:168 +//line parser.go.y:173 { yyVAL.columnNameList = yyDollar[2].columnNameList } case 18: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:173 +//line parser.go.y:178 { yyVAL.columnName = yyDollar[1].columnName } case 19: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:178 +//line parser.go.y:183 { yyVAL.columnNameList = []string{yyDollar[1].columnName} } case 20: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:181 +//line parser.go.y:186 { yyVAL.columnNameList = append(yyDollar[1].columnNameList, yyDollar[3].columnName) } case 21: yyDollar = yyS[yypt-4 : yypt+1] - //line parser.go.y:187 +//line parser.go.y:192 { yyVAL.columnConstraint = ccPrimaryKey{yyDollar[3].sortOrder, yyDollar[4].bool} } case 22: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:190 +//line parser.go.y:195 { yyVAL.columnConstraint = ccUnique(true) } case 23: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:193 +//line parser.go.y:198 { yyVAL.columnConstraint = ccNull(true) } case 24: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:196 +//line parser.go.y:201 { yyVAL.columnConstraint = ccNull(false) } case 25: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:199 +//line parser.go.y:204 { yyVAL.columnConstraint = ccCollate(yyDollar[2].identifier) } case 26: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:202 +//line parser.go.y:207 { yyVAL.columnConstraint = ccDefault(yyDollar[2].signedNumber) } case 27: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:205 +//line parser.go.y:210 { yyVAL.columnConstraint = ccDefault(yyDollar[2].literal) } case 28: yyDollar = yyS[yypt-0 : yypt+1] - //line parser.go.y:210 +//line parser.go.y:215 { yyVAL.columnConstraintList = nil } case 29: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:213 +//line parser.go.y:218 { yyVAL.columnConstraintList = []columnConstraint{yyDollar[1].columnConstraint} } case 30: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:216 +//line parser.go.y:221 { yyVAL.columnConstraintList = append(yyDollar[1].columnConstraintList, yyDollar[2].columnConstraint) } case 31: yyDollar = yyS[yypt-5 : yypt+1] - //line parser.go.y:221 +//line parser.go.y:226 { yyVAL.tableConstraint = TablePrimaryKey{yyDollar[4].indexedColumnList} } case 32: yyDollar = yyS[yypt-4 : yypt+1] - //line parser.go.y:224 +//line parser.go.y:229 { yyVAL.tableConstraint = TableUnique{yyDollar[3].indexedColumnList} } case 33: - yyDollar = yyS[yypt-9 : yypt+1] - //line parser.go.y:227 + yyDollar = yyS[yypt-11 : yypt+1] +//line parser.go.y:232 { yyVAL.tableConstraint = TableForeignKey{ - Columns: yyDollar[4].columnNameList, - ForeignTable: yyDollar[7].identifier, - ForeignColumns: yyDollar[8].columnNameList, - Triggers: yyDollar[9].triggerList, + Columns: yyDollar[4].columnNameList, + ForeignTable: yyDollar[7].identifier, + ForeignColumns: yyDollar[8].columnNameList, + Deferrable: yyDollar[9].bool, + InitiallyDeferred: yyDollar[10].bool, + Triggers: yyDollar[11].triggerList, } } case 34: yyDollar = yyS[yypt-0 : yypt+1] - //line parser.go.y:237 +//line parser.go.y:244 { } case 35: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:238 +//line parser.go.y:245 { } case 36: yyDollar = yyS[yypt-0 : yypt+1] - //line parser.go.y:242 +//line parser.go.y:249 { } case 37: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:243 +//line parser.go.y:250 { yyVAL.tableConstraintList = []TableConstraint{yyDollar[3].tableConstraint} } case 38: yyDollar = yyS[yypt-4 : yypt+1] - //line parser.go.y:246 +//line parser.go.y:253 { yyVAL.tableConstraintList = append(yyDollar[1].tableConstraintList, yyDollar[4].tableConstraint) } case 39: yyDollar = yyS[yypt-0 : yypt+1] - //line parser.go.y:252 +//line parser.go.y:259 { } case 40: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:253 +//line parser.go.y:260 { yyVAL.bool = true } case 41: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:258 +//line parser.go.y:265 { yyVAL.columnDefList = []ColumnDef{yyDollar[1].columnDef} } case 42: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:261 +//line parser.go.y:268 { yyVAL.columnDefList = append(yyDollar[1].columnDefList, yyDollar[3].columnDef) } case 43: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:266 +//line parser.go.y:273 { yyVAL.columnDef = makeColumnDef(yyDollar[1].identifier, yyDollar[2].name, yyDollar[3].columnConstraintList) } case 44: yyDollar = yyS[yypt-0 : yypt+1] - //line parser.go.y:271 +//line parser.go.y:278 { yyVAL.name = "" } case 45: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:274 +//line parser.go.y:281 { yyVAL.name = yyDollar[1].identifier } case 46: yyDollar = yyS[yypt-4 : yypt+1] - //line parser.go.y:277 +//line parser.go.y:284 { yyVAL.name = yyDollar[1].identifier } case 47: yyDollar = yyS[yypt-6 : yypt+1] - //line parser.go.y:280 +//line parser.go.y:287 { yyVAL.name = yyDollar[1].identifier } case 48: yyDollar = yyS[yypt-0 : yypt+1] - //line parser.go.y:285 +//line parser.go.y:292 { } case 49: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:286 +//line parser.go.y:293 { yyVAL.collate = yyDollar[2].literal } case 50: yyDollar = yyS[yypt-0 : yypt+1] - //line parser.go.y:291 +//line parser.go.y:298 { yyVAL.sortOrder = Asc } case 51: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:294 +//line parser.go.y:301 { yyVAL.sortOrder = Asc } case 52: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:297 +//line parser.go.y:304 { yyVAL.sortOrder = Desc } case 53: yyDollar = yyS[yypt-0 : yypt+1] - //line parser.go.y:302 +//line parser.go.y:309 { yyVAL.withoutRowid = false } case 54: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:305 +//line parser.go.y:312 { yyVAL.withoutRowid = true } case 55: yyDollar = yyS[yypt-0 : yypt+1] - //line parser.go.y:310 +//line parser.go.y:317 { yyVAL.unique = false } case 56: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:313 +//line parser.go.y:320 { yyVAL.unique = true } case 57: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:318 +//line parser.go.y:325 { yyVAL.indexedColumnList = []IndexedColumn{yyDollar[1].indexedColumn} } case 58: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:321 +//line parser.go.y:328 { yyVAL.indexedColumnList = append(yyDollar[1].indexedColumnList, yyDollar[3].indexedColumn) } case 59: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:326 +//line parser.go.y:333 { yyVAL.expr = yyDollar[1].expr } case 60: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:331 +//line parser.go.y:338 { yyVAL.indexedColumn = newIndexColumn(yyDollar[1].expr, yyDollar[2].collate, yyDollar[3].sortOrder) } case 61: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:336 +//line parser.go.y:343 { yyVAL.triggerAction = ActionSetNull } case 62: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:339 +//line parser.go.y:346 { yyVAL.triggerAction = ActionSetDefault } case 63: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:342 +//line parser.go.y:349 { yyVAL.triggerAction = ActionCascade } case 64: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:345 +//line parser.go.y:352 { yyVAL.triggerAction = ActionRestrict } case 65: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:348 +//line parser.go.y:355 { yyVAL.triggerAction = ActionNoAction } case 66: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:353 +//line parser.go.y:360 { yyVAL.trigger = TriggerOnDelete(yyDollar[3].triggerAction) } case 67: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:356 +//line parser.go.y:363 { yyVAL.trigger = TriggerOnUpdate(yyDollar[3].triggerAction) } case 68: yyDollar = yyS[yypt-0 : yypt+1] - //line parser.go.y:361 +//line parser.go.y:368 { } case 69: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:362 +//line parser.go.y:369 { yyVAL.triggerList = append(yyDollar[1].triggerList, yyDollar[2].trigger) } case 70: yyDollar = yyS[yypt-0 : yypt+1] - //line parser.go.y:367 +//line parser.go.y:374 { + yyVAL.bool = false } case 71: + yyDollar = yyS[yypt-1 : yypt+1] +//line parser.go.y:377 + { + yyVAL.bool = true + } + case 72: + yyDollar = yyS[yypt-0 : yypt+1] +//line parser.go.y:382 + { + yyVAL.bool = false + } + case 73: yyDollar = yyS[yypt-2 : yypt+1] - //line parser.go.y:368 +//line parser.go.y:384 + { + yyVAL.bool = true + } + case 74: + yyDollar = yyS[yypt-0 : yypt+1] +//line parser.go.y:389 + { + } + case 75: + yyDollar = yyS[yypt-2 : yypt+1] +//line parser.go.y:390 { yyVAL.where = yyDollar[2].expr } - case 72: + case 76: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:373 +//line parser.go.y:395 { yyVAL.expr = nil } - case 73: + case 77: yyDollar = yyS[yypt-4 : yypt+1] - //line parser.go.y:376 +//line parser.go.y:398 { yyVAL.expr = ExFunction{yyDollar[1].identifier, yyDollar[3].exprList} } - case 74: + case 78: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:379 +//line parser.go.y:401 { yyVAL.expr = yyDollar[1].signedNumber } - case 75: + case 79: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:382 +//line parser.go.y:404 { yyVAL.expr = yyDollar[1].float } - case 76: + case 80: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:385 +//line parser.go.y:407 { yyVAL.expr = yyDollar[1].identifier } - case 77: + case 81: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:388 +//line parser.go.y:410 { yyVAL.expr = ExColumn(yyDollar[1].identifier) } - case 78: + case 82: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:391 +//line parser.go.y:413 { yyVAL.expr = ExColumn(yyDollar[1].identifier) } - case 79: + case 83: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:394 +//line parser.go.y:416 { yyVAL.expr = ExBinaryOp{yyDollar[2].identifier, yyDollar[1].expr, yyDollar[3].expr} } - case 80: + case 84: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:397 +//line parser.go.y:419 { yyVAL.expr = ExBinaryOp{"+", yyDollar[1].expr, yyDollar[3].expr} } - case 81: + case 85: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:400 +//line parser.go.y:422 { yyVAL.expr = ExBinaryOp{"-", yyDollar[1].expr, yyDollar[3].expr} } - case 82: + case 86: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:403 +//line parser.go.y:425 { yyVAL.expr = yyDollar[2].expr } - case 83: + case 87: yyDollar = yyS[yypt-0 : yypt+1] - //line parser.go.y:408 +//line parser.go.y:430 { yyVAL.exprList = nil } - case 84: + case 88: yyDollar = yyS[yypt-1 : yypt+1] - //line parser.go.y:411 +//line parser.go.y:433 { yyVAL.exprList = []Expression{yyDollar[1].expr} } - case 85: + case 89: yyDollar = yyS[yypt-3 : yypt+1] - //line parser.go.y:414 +//line parser.go.y:436 { yyVAL.exprList = append(yyDollar[1].exprList, yyDollar[3].expr) } - case 86: + case 90: yyDollar = yyS[yypt-4 : yypt+1] - //line parser.go.y:419 +//line parser.go.y:441 { yylex.(*lexer).result = SelectStmt{Columns: yyDollar[2].columnNameList, Table: yyDollar[4].identifier} } - case 87: + case 91: yyDollar = yyS[yypt-8 : yypt+1] - //line parser.go.y:424 +//line parser.go.y:446 { yylex.(*lexer).result = CreateTableStmt{ Table: yyDollar[3].identifier, @@ -1130,9 +1170,9 @@ yydefault: WithoutRowid: yyDollar[8].withoutRowid, } } - case 88: + case 92: yyDollar = yyS[yypt-10 : yypt+1] - //line parser.go.y:434 +//line parser.go.y:456 { yylex.(*lexer).result = CreateIndexStmt{ Index: yyDollar[4].identifier, diff --git a/sql/parser.go.y b/sql/parser.go.y index 5789e60..34eeefd 100644 --- a/sql/parser.go.y +++ b/sql/parser.go.y @@ -63,6 +63,8 @@ package sql %type indexedColumnExpr %type expr %type exprList +%type deferrable +%type initiallyDeferred %token ACTION %token AND @@ -73,6 +75,8 @@ package sql %token CONSTRAINT %token CREATE %token DEFAULT +%token DEFERRABLE +%token DEFERRED %token DELETE %token DESC %token FOREIGN @@ -80,6 +84,7 @@ package sql %token GLOB %token IN %token INDEX +%token INITIALLY %token IS %token KEY %token LIKE @@ -224,12 +229,14 @@ tableConstraint: UNIQUE '(' indexedColumnList ')' { $$ = TableUnique{$3} } | - FOREIGN KEY '(' columnNameList ')' REFERENCES identifier optColumnNameList triggerList { + FOREIGN KEY '(' columnNameList ')' REFERENCES identifier optColumnNameList deferrable initiallyDeferred triggerList { $$ = TableForeignKey{ Columns: $4, ForeignTable: $7, ForeignColumns: $8, - Triggers: $9, + Deferrable: $9, + InitiallyDeferred: $10, + Triggers: $11, } } @@ -363,6 +370,22 @@ triggerList: $$ = append($1, $2) } +deferrable: + { + $$ = false + } | + DEFERRABLE { + $$ = true + } + +initiallyDeferred: + { + $$ = false + } | + INITIALLY DEFERRED { + $$ = true + } + where: { } | WHERE expr { diff --git a/sql/sql.go b/sql/sql.go index 6f8bfe3..79dc389 100644 --- a/sql/sql.go +++ b/sql/sql.go @@ -100,10 +100,12 @@ type TableUnique struct { IndexedColumns []IndexedColumn } type TableForeignKey struct { - Columns []string - ForeignTable string - ForeignColumns []string - Triggers []Trigger + Columns []string + ForeignTable string + ForeignColumns []string + Deferrable bool + InitiallyDeferred bool + Triggers []Trigger } type Trigger interface{} type TriggerOnDelete TriggerAction diff --git a/sql/tokenizer.go b/sql/tokenizer.go index 229a50e..5a9a813 100644 --- a/sql/tokenizer.go +++ b/sql/tokenizer.go @@ -48,6 +48,9 @@ var ( "UPDATE": UPDATE, "WHERE": WHERE, "WITHOUT": WITHOUT, + "DEFERRABLE": DEFERRABLE, + "INITIALLY": INITIALLY, + "DEFERRED": DEFERRED, } operators = map[string]struct{}{ "||": struct{}{},