From 03ef762f83d73cdbadfb57d0dcfd2fcc1a28f266 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?zhangliang3=20=5B=E5=BC=A0=E8=89=AF=5D?= Date: Tue, 29 Nov 2016 09:31:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D#278,=20set=20autocommit?= =?UTF-8?q?=E6=94=AF=E6=8C=81ON=EF=BC=8COFF=EF=BC=8C"ON",=20"OFF"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/hack/version.go | 4 +- proxy/server/conn_set.go | 19 +- sqlparser/sql.go | 415 ++++++++++++++++++++------------------- sqlparser/sql.y | 6 +- 4 files changed, 229 insertions(+), 215 deletions(-) diff --git a/core/hack/version.go b/core/hack/version.go index 3dc904b1..bd297d1d 100644 --- a/core/hack/version.go +++ b/core/hack/version.go @@ -1,6 +1,6 @@ package hack const ( - Version = "2016-11-20 09:29:56 +0800 @c9b0909" - Compile = "2016-11-24 19:35:53 +0800 by go version go1.7.3 darwin/amd64" + Version = "2016-11-26 11:13:45 +0800 @7b5c49e" + Compile = "2016-11-26 11:25:54 +0800 by go version go1.7.1 linux/amd64" ) diff --git a/proxy/server/conn_set.go b/proxy/server/conn_set.go index 7eee990f..dc87ebac 100644 --- a/proxy/server/conn_set.go +++ b/proxy/server/conn_set.go @@ -76,12 +76,17 @@ func (c *ClientConn) handleSet(stmt *sqlparser.Set, sql string) (err error) { } func (c *ClientConn) handleSetAutoCommit(val sqlparser.ValExpr) error { - value, ok := val.(sqlparser.NumVal) - if !ok { - return fmt.Errorf("set autocommit error") + flag := sqlparser.String(val) + flag = strings.Trim(flag, "'`\"") + // autocommit允许为 0, 1, ON, OFF, "ON", "OFF", 不允许"0", "1" + if flag == `0` || flag == `1` { + _, ok := val.(sqlparser.NumVal) + if !ok { + return fmt.Errorf("set autocommit error") + } } - switch value[0] { - case '1': + switch strings.ToUpper(flag) { + case `1`, `ON`: c.status |= mysql.SERVER_STATUS_AUTOCOMMIT if c.status&mysql.SERVER_STATUS_IN_TRANS > 0 { c.status &= ^mysql.SERVER_STATUS_IN_TRANS @@ -95,10 +100,10 @@ func (c *ClientConn) handleSetAutoCommit(val sqlparser.ValExpr) error { co.Close() } c.txConns = make(map[*backend.Node]*backend.BackendConn) - case '0': + case `0`, `OFF`: c.status &= ^mysql.SERVER_STATUS_AUTOCOMMIT default: - return fmt.Errorf("invalid autocommit flag %s", value) + return fmt.Errorf("invalid autocommit flag %s", flag) } return c.writeOK(nil) diff --git a/sqlparser/sql.go b/sqlparser/sql.go index 0a38ce02..1c02d4a6 100644 --- a/sqlparser/sql.go +++ b/sqlparser/sql.go @@ -271,135 +271,134 @@ var yyExca = [...]int{ -2, 0, } -const yyNprod = 213 +const yyNprod = 214 const yyPrivate = 57344 var yyTokenNames []string var yyStates []string -const yyLast = 644 +const yyLast = 637 var yyAct = [...]int{ - 106, 103, 306, 342, 181, 375, 71, 134, 262, 336, - 97, 114, 143, 179, 221, 182, 3, 257, 193, 93, - 73, 92, 89, 384, 58, 203, 278, 279, 280, 281, - 282, 104, 283, 284, 61, 35, 36, 37, 38, 85, - 384, 156, 155, 384, 150, 75, 74, 78, 80, 51, - 63, 82, 150, 150, 250, 86, 219, 45, 50, 47, - 51, 270, 137, 48, 53, 54, 55, 69, 353, 352, - 351, 324, 326, 79, 81, 52, 60, 56, 76, 98, - 133, 333, 168, 169, 170, 165, 127, 386, 141, 328, - 136, 75, 147, 248, 165, 124, 152, 166, 167, 168, - 169, 170, 165, 251, 385, 145, 289, 383, 332, 154, - 130, 178, 180, 142, 209, 183, 298, 296, 249, 184, - 218, 187, 325, 91, 75, 74, 75, 74, 62, 207, - 192, 199, 210, 389, 190, 72, 59, 235, 258, 200, - 301, 132, 197, 198, 129, 258, 195, 191, 155, 213, - 234, 233, 156, 155, 227, 199, 238, 84, 335, 156, - 155, 225, 348, 337, 98, 214, 229, 230, 266, 140, - 226, 231, 350, 228, 236, 237, 217, 240, 241, 242, - 243, 244, 245, 246, 247, 349, 322, 321, 318, 316, - 232, 239, 125, 319, 317, 320, 206, 208, 205, 98, - 98, 194, 194, 337, 267, 264, 125, 253, 255, 250, - 265, 261, 268, 87, 259, 359, 75, 74, 149, 273, - 75, 274, 272, 35, 36, 37, 38, 271, 121, 49, - 145, 224, 369, 276, 125, 225, 223, 368, 288, 275, - 254, 367, 109, 113, 62, 260, 119, 128, 291, 292, - 215, 150, 90, 96, 110, 111, 112, 90, 101, 117, - 188, 75, 74, 186, 295, 290, 185, 304, 98, 302, - 305, 68, 303, 18, 300, 145, 297, 90, 100, 76, - 120, 163, 166, 167, 168, 169, 170, 165, 225, 225, - 287, 314, 315, 329, 153, 381, 115, 116, 94, 224, - 327, 310, 286, 309, 223, 311, 62, 331, 339, 382, - 370, 212, 211, 60, 338, 334, 148, 344, 138, 135, - 131, 340, 343, 113, 83, 118, 119, 123, 252, 356, - 126, 18, 122, 76, 110, 111, 112, 88, 128, 117, - 294, 201, 139, 66, 354, 64, 307, 347, 308, 355, - 144, 263, 365, 346, 363, 313, 194, 364, 70, 366, - 120, 197, 388, 373, 379, 18, 374, 40, 376, 376, - 376, 371, 372, 343, 377, 378, 115, 116, 17, 16, - 75, 74, 15, 109, 113, 390, 387, 119, 39, 14, - 391, 13, 392, 12, 96, 110, 111, 112, 18, 101, - 117, 202, 46, 269, 204, 118, 77, 146, 41, 42, - 43, 44, 380, 109, 113, 360, 341, 119, 345, 100, - 57, 120, 312, 299, 76, 110, 111, 112, 189, 101, - 117, 256, 108, 105, 107, 216, 102, 115, 116, 94, - 157, 99, 323, 109, 113, 222, 18, 119, 277, 100, - 220, 120, 95, 285, 76, 110, 111, 112, 151, 101, - 117, 65, 113, 34, 67, 119, 118, 115, 116, 11, - 10, 9, 76, 110, 111, 112, 8, 128, 117, 100, - 7, 120, 6, 5, 4, 2, 18, 19, 20, 21, - 1, 0, 113, 0, 0, 119, 118, 115, 116, 120, - 330, 0, 76, 110, 111, 112, 357, 128, 117, 0, - 22, 0, 0, 0, 0, 115, 116, 164, 163, 166, - 167, 168, 169, 170, 165, 0, 118, 0, 0, 120, - 0, 0, 33, 0, 0, 0, 164, 163, 166, 167, - 168, 169, 170, 165, 118, 115, 116, 0, 164, 163, - 166, 167, 168, 169, 170, 165, 358, 361, 362, 0, - 0, 0, 0, 0, 27, 28, 0, 29, 30, 196, - 31, 32, 0, 0, 118, 23, 24, 26, 25, 159, - 161, 0, 0, 0, 0, 171, 172, 173, 174, 175, - 176, 177, 162, 160, 158, 164, 163, 166, 167, 168, - 169, 170, 165, 293, 0, 0, 0, 164, 163, 166, - 167, 168, 169, 170, 165, 0, 0, 0, 0, 0, - 164, 163, 166, 167, 168, 169, 170, 165, 164, 163, - 166, 167, 168, 169, 170, 165, 278, 279, 280, 281, - 282, 0, 283, 284, + 106, 103, 307, 343, 181, 376, 71, 263, 337, 258, + 114, 97, 222, 179, 134, 182, 3, 104, 143, 193, + 385, 92, 89, 73, 156, 155, 385, 58, 113, 385, + 150, 119, 204, 85, 61, 93, 325, 327, 76, 110, + 111, 112, 78, 128, 117, 75, 74, 150, 80, 51, + 63, 82, 271, 150, 251, 86, 50, 220, 51, 137, + 199, 35, 36, 37, 38, 120, 45, 81, 47, 52, + 69, 354, 48, 53, 54, 55, 249, 60, 353, 98, + 133, 115, 116, 76, 387, 352, 127, 326, 141, 79, + 386, 75, 147, 384, 333, 56, 152, 136, 124, 334, + 279, 280, 281, 282, 283, 145, 284, 285, 290, 154, + 118, 299, 178, 180, 130, 183, 142, 297, 250, 184, + 187, 219, 91, 165, 75, 74, 75, 74, 62, 252, + 192, 200, 390, 259, 190, 302, 132, 59, 236, 129, + 72, 259, 197, 198, 156, 155, 201, 156, 155, 195, + 191, 235, 234, 336, 228, 200, 214, 84, 155, 358, + 226, 125, 218, 329, 98, 215, 349, 230, 231, 239, + 351, 232, 338, 229, 237, 238, 233, 241, 242, 243, + 244, 245, 246, 247, 248, 338, 227, 267, 140, 164, + 163, 166, 167, 168, 169, 170, 165, 319, 317, 98, + 98, 210, 320, 318, 240, 268, 265, 254, 256, 359, + 266, 350, 262, 87, 260, 323, 208, 75, 74, 211, + 269, 75, 275, 273, 163, 166, 167, 168, 169, 170, + 165, 145, 322, 321, 272, 226, 125, 289, 370, 251, + 360, 276, 255, 274, 109, 113, 194, 369, 119, 292, + 293, 368, 291, 128, 194, 96, 110, 111, 112, 225, + 101, 117, 75, 74, 224, 296, 188, 301, 305, 98, + 306, 303, 168, 169, 170, 165, 145, 298, 277, 304, + 100, 186, 120, 207, 209, 206, 125, 149, 226, 226, + 315, 316, 312, 35, 36, 37, 38, 185, 115, 116, + 94, 166, 167, 168, 169, 170, 165, 49, 332, 340, + 18, 261, 216, 90, 339, 121, 335, 18, 90, 90, + 150, 288, 341, 344, 62, 345, 113, 118, 153, 119, + 253, 76, 382, 287, 330, 328, 76, 110, 111, 112, + 62, 128, 117, 225, 311, 355, 383, 123, 224, 68, + 356, 310, 213, 366, 364, 212, 60, 148, 138, 365, + 135, 367, 197, 120, 374, 131, 83, 375, 371, 377, + 377, 377, 372, 373, 344, 378, 379, 357, 122, 115, + 116, 75, 74, 18, 109, 113, 391, 388, 119, 295, + 88, 392, 202, 393, 139, 96, 110, 111, 112, 18, + 101, 117, 144, 279, 280, 281, 282, 283, 118, 284, + 285, 66, 64, 308, 109, 113, 348, 309, 119, 264, + 100, 347, 120, 314, 194, 76, 110, 111, 112, 70, + 101, 117, 389, 380, 18, 40, 17, 16, 115, 116, + 94, 15, 14, 13, 109, 113, 12, 203, 119, 46, + 100, 270, 120, 205, 77, 76, 110, 111, 112, 146, + 101, 117, 381, 113, 361, 342, 119, 118, 115, 116, + 126, 346, 313, 76, 110, 111, 112, 300, 128, 117, + 100, 189, 120, 257, 108, 105, 107, 18, 19, 20, + 21, 217, 102, 113, 157, 99, 119, 118, 115, 116, + 120, 362, 363, 76, 110, 111, 112, 324, 128, 117, + 223, 22, 278, 221, 95, 286, 115, 116, 164, 163, + 166, 167, 168, 169, 170, 165, 151, 118, 65, 34, + 120, 67, 11, 33, 10, 9, 8, 7, 6, 196, + 5, 39, 4, 2, 1, 118, 115, 116, 0, 0, + 0, 164, 163, 166, 167, 168, 169, 170, 165, 0, + 0, 41, 42, 43, 44, 27, 28, 0, 29, 30, + 0, 31, 32, 57, 0, 118, 23, 24, 26, 25, + 159, 161, 0, 0, 0, 0, 171, 172, 173, 174, + 175, 176, 177, 162, 160, 158, 164, 163, 166, 167, + 168, 169, 170, 165, 331, 0, 0, 0, 0, 0, + 0, 0, 294, 164, 163, 166, 167, 168, 169, 170, + 165, 164, 163, 166, 167, 168, 169, 170, 165, 164, + 163, 166, 167, 168, 169, 170, 165, } var yyPact = [...]int{ - 481, -1000, -1000, 185, -1000, -1000, -1000, -1000, -1000, -1000, + 482, -1000, -1000, 255, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -41, -42, -23, -34, -1000, -8, -1000, - -1000, -1000, 45, 213, 360, 328, -1000, -1000, -1000, 325, - -1000, -53, 282, 349, 47, -56, -26, 213, -1000, -24, - 213, -1000, 293, -64, 213, -64, -1000, 312, 241, -1000, - 43, -1000, -1000, -1000, -1000, 363, -1000, 193, 307, 298, - 282, 164, 302, -1000, 82, -1000, 30, 289, 85, 213, - -1000, 288, -1000, -39, 287, 322, 116, 213, 282, 326, - 248, 285, 209, -1000, -1000, 275, 29, 105, 523, -1000, - 423, 393, -1000, -1000, -1000, 471, 230, 227, -1000, 224, + -1000, -1000, -1000, -32, -44, -29, -25, -1000, 10, -1000, + -1000, -1000, 46, 293, 429, 395, -1000, -1000, -1000, 393, + -1000, -53, 325, 420, 52, -61, -10, 293, -1000, -31, + 293, -1000, 335, -70, 293, -70, -1000, 365, 277, -1000, + 42, -1000, -1000, -1000, -1000, 364, -1000, 280, 353, 318, + 325, 194, 442, -1000, 77, -1000, 34, 334, 80, 293, + -1000, 329, -1000, -42, 327, 374, 135, 293, 325, 378, + 300, 326, 278, -1000, -1000, 309, 29, 90, 524, -1000, + 424, 394, -1000, -1000, -1000, 472, 261, 245, -1000, 230, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, - 471, -1000, 282, 248, 346, 248, -1000, 476, 441, 471, - 213, -1000, 321, -80, -1000, 101, -1000, 281, -1000, -1000, - 280, -1000, 221, -1000, 211, 185, 14, -1000, -1000, 200, - 363, -1000, -1000, 213, 97, 423, 423, 471, 211, 80, - 471, 471, 135, 471, 471, 471, 471, 471, 471, 471, - 471, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 523, - -13, 12, -3, 523, -1000, 222, 363, -1000, 360, 86, - 556, 216, 192, 338, 423, -1000, 471, 556, 556, -1000, - -1000, -1000, 115, 213, -1000, -40, -1000, -1000, -1000, -1000, - -1000, -1000, -1000, -1000, 326, 248, 177, -1000, -1000, 248, - 191, 593, 271, 268, 26, -1000, -1000, -1000, -1000, -1000, - 93, 556, -1000, 211, 471, 471, 556, 548, -1000, 319, - 23, 208, -1000, 6, 6, 15, 15, 15, -1000, -1000, - 471, -1000, -1000, 11, 363, 10, 79, -1000, 423, 326, - 248, 338, 331, 334, 105, 556, 272, -1000, -1000, 270, - -1000, -1000, 164, 211, -1000, 344, 200, 200, -1000, -1000, - 146, 145, 152, 144, 143, 20, -1000, 269, -17, 262, - -1000, 556, 445, 471, -1000, 556, -1000, 2, -1000, -1, - -1000, 471, 98, 110, 150, 331, -1000, 471, 471, -1000, - -1000, -1000, 341, 333, 593, 109, -1000, 142, -1000, 129, - -1000, -1000, -1000, -1000, -29, -30, -31, -1000, -1000, -1000, - 471, 556, -1000, -1000, 556, 471, -1000, 303, -1000, -1000, - 464, 173, -1000, 535, -1000, 338, 423, 471, 423, -1000, - -1000, 205, 201, 196, 556, 556, 283, 471, 471, 471, - -1000, -1000, -1000, 331, 105, 167, 105, 213, 213, 213, - 357, 556, 556, -1000, 279, 1, -1000, -2, -19, 248, - -1000, 355, 62, -1000, 213, -1000, -1000, 164, -1000, 213, - -1000, 213, -1000, + 472, -1000, 325, 300, 414, 300, -1000, 446, 305, 7, + 293, -1000, 372, -73, -1000, 188, -1000, 324, -1000, -1000, + 321, -1000, 283, -1000, 217, 255, 15, -1000, -1000, 228, + 364, -1000, -1000, 293, 97, 424, 424, 472, 217, 81, + 472, 472, 148, 472, 472, 472, 472, 472, 472, 472, + 472, -1000, -1000, -1000, -1000, -1000, -1000, -1000, -1000, 524, + -30, 12, 23, 524, -1000, 224, 364, -1000, 429, 82, + 541, 282, 244, 406, 424, -1000, 472, 541, 541, -1000, + -1000, -1000, -1000, 134, 293, -1000, -49, -1000, -1000, -1000, + -1000, -1000, -1000, -1000, -1000, 378, 300, 201, -1000, -1000, + 300, 236, 360, 302, 312, 28, -1000, -1000, -1000, -1000, + -1000, 103, 541, -1000, 217, 472, 472, 541, 557, -1000, + 368, 227, 151, -1000, 196, 196, 44, 44, 44, -1000, + -1000, 472, -1000, -1000, 11, 364, 5, 74, -1000, 424, + 378, 300, 406, 398, 403, 90, 541, 320, -1000, -1000, + 313, -1000, -1000, 194, 217, -1000, 412, 228, 228, -1000, + -1000, 155, 154, 190, 189, 172, -15, -1000, 304, 57, + 303, -1000, 541, 549, 472, -1000, 541, -1000, -12, -1000, + 17, -1000, 472, 93, 132, 119, 398, -1000, 472, 472, + -1000, -1000, -1000, 409, 402, 360, 113, -1000, 168, -1000, + 127, -1000, -1000, -1000, -1000, -14, -21, -28, -1000, -1000, + -1000, 472, 541, -1000, -1000, 541, 472, -1000, 351, -1000, + -1000, 117, 198, -1000, 479, -1000, 406, 424, 472, 424, + -1000, -1000, 215, 211, 202, 541, 541, 341, 472, 472, + 472, -1000, -1000, -1000, 398, 90, 197, 90, 293, 293, + 293, 426, 541, 541, -1000, 316, -13, -1000, -16, -22, + 300, -1000, 425, 61, -1000, 293, -1000, -1000, 194, -1000, + 293, -1000, 293, -1000, } var yyPgo = [...]int{ - 0, 490, 485, 15, 484, 483, 482, 480, 476, 471, - 470, 469, 388, 464, 463, 461, 229, 21, 19, 458, - 453, 452, 450, 14, 448, 445, 24, 442, 5, 18, - 10, 441, 440, 12, 436, 13, 31, 4, 435, 434, - 11, 433, 1, 432, 431, 17, 428, 423, 422, 418, - 8, 416, 3, 415, 2, 412, 22, 407, 9, 6, - 20, 157, 406, 404, 403, 402, 401, 0, 7, 393, - 391, 389, 382, 379, 378, 367, + 0, 544, 543, 15, 542, 540, 538, 537, 536, 535, + 534, 532, 541, 531, 529, 528, 307, 21, 35, 526, + 515, 514, 513, 12, 512, 510, 27, 507, 5, 19, + 11, 495, 494, 18, 492, 13, 17, 4, 491, 486, + 10, 485, 1, 484, 483, 9, 481, 477, 472, 471, + 7, 465, 3, 464, 2, 462, 22, 459, 8, 6, + 23, 157, 454, 453, 451, 449, 447, 0, 14, 446, + 443, 442, 441, 437, 436, 435, } var yyR1 = [...]int{ @@ -422,9 +421,9 @@ var yyR1 = [...]int{ 42, 42, 34, 34, 34, 34, 48, 48, 49, 49, 50, 50, 51, 51, 52, 53, 53, 53, 54, 54, 54, 54, 55, 55, 55, 56, 56, 57, 57, 58, - 58, 59, 59, 60, 61, 61, 62, 62, 16, 16, - 63, 63, 63, 63, 63, 64, 64, 65, 65, 66, - 66, 67, 68, + 58, 59, 59, 60, 60, 61, 61, 62, 62, 16, + 16, 63, 63, 63, 63, 63, 64, 64, 65, 65, + 66, 66, 67, 68, } var yyR2 = [...]int{ @@ -447,9 +446,9 @@ var yyR2 = [...]int{ 1, 3, 1, 1, 1, 1, 0, 3, 0, 2, 0, 3, 1, 3, 2, 0, 1, 1, 0, 2, 4, 4, 0, 2, 4, 0, 3, 1, 3, 0, - 5, 1, 3, 3, 0, 2, 0, 3, 0, 1, - 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, - 2, 1, 0, + 5, 1, 3, 3, 3, 0, 2, 0, 3, 0, + 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, + 0, 2, 1, 0, } var yyChk = [...]int{ @@ -472,70 +471,70 @@ var yyChk = [...]int{ 70, 57, 69, 73, 72, 79, 74, 75, 76, 77, 78, 62, 63, 64, 65, 66, 67, 68, -30, -35, -30, -37, -3, -35, -35, 36, 36, -40, 36, -46, - -35, -26, -59, -29, 10, -60, 93, -35, -35, -67, - -68, 20, -66, 105, -63, 97, 95, 28, 96, 13, - 31, 31, 31, -68, -56, 29, -38, -36, 106, 42, - -22, -23, -25, 36, 31, -40, -18, -67, 76, -30, - -30, -35, -36, 71, 70, 57, -35, -35, 21, 56, - -35, -35, -35, -35, -35, -35, -35, -35, 106, 106, - 42, 106, 106, -17, 18, -17, -44, -45, 59, -56, - 29, -29, -50, 13, -30, -35, 53, -67, -68, -64, - 101, -33, -59, 42, -42, -29, 42, -24, 43, 44, - 45, 46, 47, 49, 50, -20, 31, 19, -23, 80, - -36, -35, -35, 55, 21, -35, 106, -17, 106, -47, - -45, 61, -30, -33, -59, -50, -54, 15, 14, 31, - 31, -36, -48, 11, -23, -23, 43, 48, 43, 48, - 43, 43, 43, -27, 51, 102, 52, 31, 106, 31, - 55, -35, 106, 82, -35, 60, -58, 53, -58, -54, - -35, -51, -52, -35, -68, -49, 12, 14, 53, 43, - 43, 99, 99, 99, -35, -35, 26, 42, 92, 42, - -53, 22, 23, -50, -30, -37, -30, 36, 36, 36, - 27, -35, -35, -52, -54, -28, -67, -28, -28, 7, - -55, 16, 30, 106, 42, 106, 106, -59, 7, 71, - -67, -67, -67, + -35, -26, -59, -29, 10, -60, 93, -35, -35, 53, + -67, -68, 20, -66, 105, -63, 97, 95, 28, 96, + 13, 31, 31, 31, -68, -56, 29, -38, -36, 106, + 42, -22, -23, -25, 36, 31, -40, -18, -67, 76, + -30, -30, -35, -36, 71, 70, 57, -35, -35, 21, + 56, -35, -35, -35, -35, -35, -35, -35, -35, 106, + 106, 42, 106, 106, -17, 18, -17, -44, -45, 59, + -56, 29, -29, -50, 13, -30, -35, 53, -67, -68, + -64, 101, -33, -59, 42, -42, -29, 42, -24, 43, + 44, 45, 46, 47, 49, 50, -20, 31, 19, -23, + 80, -36, -35, -35, 55, 21, -35, 106, -17, 106, + -47, -45, 61, -30, -33, -59, -50, -54, 15, 14, + 31, 31, -36, -48, 11, -23, -23, 43, 48, 43, + 48, 43, 43, 43, -27, 51, 102, 52, 31, 106, + 31, 55, -35, 106, 82, -35, 60, -58, 53, -58, + -54, -35, -51, -52, -35, -68, -49, 12, 14, 53, + 43, 43, 99, 99, 99, -35, -35, 26, 42, 92, + 42, -53, 22, 23, -50, -30, -37, -30, 36, 36, + 36, 27, -35, -35, -52, -54, -28, -67, -28, -28, + 7, -55, 16, 30, 106, 42, 106, 106, -59, 7, + 71, -67, -67, -67, } var yyDef = [...]int{ 0, -2, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 47, 47, - 47, 47, 47, 207, 198, 0, 0, 30, 0, 32, + 47, 47, 47, 208, 199, 0, 0, 30, 0, 32, 33, 47, 0, 0, 0, 51, 53, 54, 55, 56, - 49, 198, 0, 0, 0, 196, 0, 0, 208, 0, - 0, 199, 0, 194, 0, 194, 31, 0, 185, 35, - 89, 36, 211, 19, 52, 0, 57, 48, 0, 0, - 0, 26, 0, 191, 0, 160, 211, 0, 0, 0, - 212, 0, 212, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 17, 58, 60, 65, 211, 63, 64, 99, + 49, 199, 0, 0, 0, 197, 0, 0, 209, 0, + 0, 200, 0, 195, 0, 195, 31, 0, 185, 35, + 89, 36, 212, 19, 52, 0, 57, 48, 0, 0, + 0, 26, 0, 191, 0, 160, 212, 0, 0, 0, + 213, 0, 213, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 17, 58, 60, 65, 212, 63, 64, 99, 0, 0, 130, 131, 132, 0, 160, 0, 146, 0, 162, 163, 164, 165, 126, 149, 150, 151, 147, 148, 153, 50, 0, 0, 97, 0, 27, 28, 0, 0, - 0, 212, 0, 209, 39, 0, 42, 0, 44, 195, - 0, 212, 185, 34, 0, 122, 0, 187, 90, 0, + 0, 213, 0, 210, 39, 0, 42, 0, 44, 196, + 0, 213, 185, 34, 0, 122, 0, 187, 90, 0, 0, 61, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 114, 115, 116, 117, 118, 119, 120, 102, 0, 0, 0, 0, 128, 141, 0, 0, 113, 0, 0, - 154, 185, 97, 170, 0, 192, 0, 128, 193, 161, - 37, 197, 0, 0, 212, 205, 200, 201, 202, 203, - 204, 43, 45, 46, 0, 0, 121, 123, 186, 0, - 97, 68, 74, 0, 86, 88, 59, 67, 62, 100, - 101, 104, 105, 0, 0, 0, 107, 0, 111, 0, - 133, 134, 135, 136, 137, 138, 139, 140, 103, 125, - 0, 127, 142, 0, 0, 0, 158, 155, 0, 0, - 0, 170, 178, 0, 98, 29, 0, 210, 40, 0, - 206, 22, 23, 0, 188, 166, 0, 0, 77, 78, - 0, 0, 0, 0, 0, 91, 75, 0, 0, 0, - 106, 108, 0, 0, 112, 129, 143, 0, 145, 0, - 156, 0, 0, 189, 189, 178, 25, 0, 0, 212, - 41, 124, 168, 0, 69, 72, 79, 0, 81, 0, - 83, 84, 85, 70, 0, 0, 0, 76, 71, 87, - 0, 109, 144, 152, 159, 0, 20, 0, 21, 24, - 179, 171, 172, 175, 38, 170, 0, 0, 0, 80, - 82, 0, 0, 0, 110, 157, 0, 0, 0, 0, - 174, 176, 177, 178, 169, 167, 73, 0, 0, 0, - 0, 180, 181, 173, 182, 0, 95, 0, 0, 0, - 18, 0, 0, 92, 0, 93, 94, 190, 183, 0, - 96, 0, 184, + 154, 185, 97, 170, 0, 192, 0, 128, 193, 194, + 161, 37, 198, 0, 0, 213, 206, 201, 202, 203, + 204, 205, 43, 45, 46, 0, 0, 121, 123, 186, + 0, 97, 68, 74, 0, 86, 88, 59, 67, 62, + 100, 101, 104, 105, 0, 0, 0, 107, 0, 111, + 0, 133, 134, 135, 136, 137, 138, 139, 140, 103, + 125, 0, 127, 142, 0, 0, 0, 158, 155, 0, + 0, 0, 170, 178, 0, 98, 29, 0, 211, 40, + 0, 207, 22, 23, 0, 188, 166, 0, 0, 77, + 78, 0, 0, 0, 0, 0, 91, 75, 0, 0, + 0, 106, 108, 0, 0, 112, 129, 143, 0, 145, + 0, 156, 0, 0, 189, 189, 178, 25, 0, 0, + 213, 41, 124, 168, 0, 69, 72, 79, 0, 81, + 0, 83, 84, 85, 70, 0, 0, 0, 76, 71, + 87, 0, 109, 144, 152, 159, 0, 20, 0, 21, + 24, 179, 171, 172, 175, 38, 170, 0, 0, 0, + 80, 82, 0, 0, 0, 110, 157, 0, 0, 0, + 0, 174, 176, 177, 178, 169, 167, 73, 0, 0, + 0, 0, 180, 181, 173, 182, 0, 95, 0, 0, + 0, 18, 0, 0, 92, 0, 93, 94, 190, 183, + 0, 96, 0, 184, } var yyTok1 = [...]int{ @@ -2020,116 +2019,122 @@ yydefault: yyVAL.updateExpr = &UpdateExpr{Name: yyDollar[1].colName, Expr: yyDollar[3].valExpr} } case 194: - yyDollar = yyS[yypt-0 : yypt+1] - //line ./sqlparser/sql.y:1075 + yyDollar = yyS[yypt-3 : yypt+1] + //line ./sqlparser/sql.y:1074 { - yyVAL.empty = struct{}{} + yyVAL.updateExpr = &UpdateExpr{Name: yyDollar[1].colName, Expr: StrVal("ON")} } case 195: - yyDollar = yyS[yypt-2 : yypt+1] - //line ./sqlparser/sql.y:1077 + yyDollar = yyS[yypt-0 : yypt+1] + //line ./sqlparser/sql.y:1079 { yyVAL.empty = struct{}{} } case 196: - yyDollar = yyS[yypt-0 : yypt+1] - //line ./sqlparser/sql.y:1080 + yyDollar = yyS[yypt-2 : yypt+1] + //line ./sqlparser/sql.y:1081 { yyVAL.empty = struct{}{} } case 197: - yyDollar = yyS[yypt-3 : yypt+1] - //line ./sqlparser/sql.y:1082 + yyDollar = yyS[yypt-0 : yypt+1] + //line ./sqlparser/sql.y:1084 { yyVAL.empty = struct{}{} } case 198: - yyDollar = yyS[yypt-0 : yypt+1] - //line ./sqlparser/sql.y:1085 + yyDollar = yyS[yypt-3 : yypt+1] + //line ./sqlparser/sql.y:1086 { - yyVAL.str = "" + yyVAL.empty = struct{}{} } case 199: - yyDollar = yyS[yypt-1 : yypt+1] - //line ./sqlparser/sql.y:1087 + yyDollar = yyS[yypt-0 : yypt+1] + //line ./sqlparser/sql.y:1089 { - yyVAL.str = AST_IGNORE + yyVAL.str = "" } case 200: yyDollar = yyS[yypt-1 : yypt+1] //line ./sqlparser/sql.y:1091 { - yyVAL.empty = struct{}{} + yyVAL.str = AST_IGNORE } case 201: yyDollar = yyS[yypt-1 : yypt+1] - //line ./sqlparser/sql.y:1093 + //line ./sqlparser/sql.y:1095 { yyVAL.empty = struct{}{} } case 202: yyDollar = yyS[yypt-1 : yypt+1] - //line ./sqlparser/sql.y:1095 + //line ./sqlparser/sql.y:1097 { yyVAL.empty = struct{}{} } case 203: yyDollar = yyS[yypt-1 : yypt+1] - //line ./sqlparser/sql.y:1097 + //line ./sqlparser/sql.y:1099 { yyVAL.empty = struct{}{} } case 204: yyDollar = yyS[yypt-1 : yypt+1] - //line ./sqlparser/sql.y:1099 + //line ./sqlparser/sql.y:1101 { yyVAL.empty = struct{}{} } case 205: - yyDollar = yyS[yypt-0 : yypt+1] - //line ./sqlparser/sql.y:1102 + yyDollar = yyS[yypt-1 : yypt+1] + //line ./sqlparser/sql.y:1103 { yyVAL.empty = struct{}{} } case 206: - yyDollar = yyS[yypt-1 : yypt+1] - //line ./sqlparser/sql.y:1104 + yyDollar = yyS[yypt-0 : yypt+1] + //line ./sqlparser/sql.y:1106 { yyVAL.empty = struct{}{} } case 207: - yyDollar = yyS[yypt-0 : yypt+1] - //line ./sqlparser/sql.y:1107 + yyDollar = yyS[yypt-1 : yypt+1] + //line ./sqlparser/sql.y:1108 { yyVAL.empty = struct{}{} } case 208: - yyDollar = yyS[yypt-1 : yypt+1] - //line ./sqlparser/sql.y:1109 + yyDollar = yyS[yypt-0 : yypt+1] + //line ./sqlparser/sql.y:1111 { yyVAL.empty = struct{}{} } case 209: - yyDollar = yyS[yypt-0 : yypt+1] - //line ./sqlparser/sql.y:1112 + yyDollar = yyS[yypt-1 : yypt+1] + //line ./sqlparser/sql.y:1113 { yyVAL.empty = struct{}{} } case 210: - yyDollar = yyS[yypt-2 : yypt+1] - //line ./sqlparser/sql.y:1114 + yyDollar = yyS[yypt-0 : yypt+1] + //line ./sqlparser/sql.y:1116 { yyVAL.empty = struct{}{} } case 211: - yyDollar = yyS[yypt-1 : yypt+1] + yyDollar = yyS[yypt-2 : yypt+1] //line ./sqlparser/sql.y:1118 { - yyVAL.bytes = bytes.ToLower(yyDollar[1].bytes) + yyVAL.empty = struct{}{} } case 212: + yyDollar = yyS[yypt-1 : yypt+1] + //line ./sqlparser/sql.y:1122 + { + yyVAL.bytes = bytes.ToLower(yyDollar[1].bytes) + } + case 213: yyDollar = yyS[yypt-0 : yypt+1] - //line ./sqlparser/sql.y:1123 + //line ./sqlparser/sql.y:1127 { ForceEOF(yylex) } diff --git a/sqlparser/sql.y b/sqlparser/sql.y index 1c4535f9..01037783 100644 --- a/sqlparser/sql.y +++ b/sqlparser/sql.y @@ -1068,7 +1068,11 @@ update_list: update_expression: column_name '=' value_expression { - $$ = &UpdateExpr{Name: $1, Expr: $3} + $$ = &UpdateExpr{Name: $1, Expr: $3} + } +| column_name '=' ON + { + $$ = &UpdateExpr{Name: $1, Expr: StrVal("ON")} } exists_opt: