diff --git a/lerna.json b/lerna.json index fa16c61b1d..29b87c8333 100644 --- a/lerna.json +++ b/lerna.json @@ -2,9 +2,7 @@ "version": "1.0.0-alpha.14", "npmClient": "yarn", "useWorkspaces": true, - "npmClientArgs": [ - "--ignore-engines" - ], + "npmClientArgs": ["--ignore-engines"], "command": { "version": { "forcePublish": true, diff --git a/packages/core/client/src/collection-manager/templates/components/sql-collection/FieldsConfigure.tsx b/packages/core/client/src/collection-manager/templates/components/sql-collection/FieldsConfigure.tsx index 5a2ad441a8..0935adfdf1 100644 --- a/packages/core/client/src/collection-manager/templates/components/sql-collection/FieldsConfigure.tsx +++ b/packages/core/client/src/collection-manager/templates/components/sql-collection/FieldsConfigure.tsx @@ -136,6 +136,7 @@ export const FieldsConfigure = observer( Object.entries(sourceFields || {}).forEach(([col, val]: [string, any]) => fieldsMp.set(col, { name: col, + type: 'string', // default ...val, uiSchema: { title: col, @@ -217,7 +218,7 @@ export const FieldsConfigure = observer( placeholder={t('Select field source')} onChange={(value: string[]) => { let sourceField = sourceFields[value?.[1]]; - if (!sourceField) { + if (!sourceField?.interface) { sourceField = getCollectionField(value?.join('.') || ''); } handleFieldChange( diff --git a/packages/core/database/package.json b/packages/core/database/package.json index f2d0cd0585..fdfe7760fc 100644 --- a/packages/core/database/package.json +++ b/packages/core/database/package.json @@ -6,6 +6,7 @@ "types": "./lib/index.d.ts", "license": "AGPL-3.0", "dependencies": { + "node-sql-parser": "^4.18.0", "@nocobase/logger": "1.0.0-alpha.14", "@nocobase/utils": "1.0.0-alpha.14", "async-mutex": "^0.3.2", diff --git a/packages/core/database/src/database.ts b/packages/core/database/src/database.ts index e0ed142de0..c7f6457238 100644 --- a/packages/core/database/src/database.ts +++ b/packages/core/database/src/database.ts @@ -54,7 +54,6 @@ import QueryInterface from './query-interface/query-interface'; import buildQueryInterface from './query-interface/query-interface-builder'; import { RelationRepository } from './relation-repository/relation-repository'; import { Repository } from './repository'; -import { SqlCollection } from './sql-collection/sql-collection'; import { AfterDefineCollectionListener, BeforeDefineCollectionListener, @@ -1011,20 +1010,6 @@ export class Database extends EventEmitter implements AsyncEmitter { return; }, }); - - this.collectionFactory.registerCollectionType(SqlCollection, { - condition: (options) => { - return options.sql; - }, - - async onSync() { - return; - }, - - async onDump(dumper, collection: Collection) { - return; - }, - }); } } diff --git a/packages/core/database/src/index.ts b/packages/core/database/src/index.ts index c26b6fbfb0..810981a835 100644 --- a/packages/core/database/src/index.ts +++ b/packages/core/database/src/index.ts @@ -50,5 +50,5 @@ export { snakeCase } from './utils'; export * from './value-parsers'; export * from './view-collection'; export * from './view/view-inference'; -export * from './sql-collection'; export * from './helpers'; +export { default as sqlParser, SQLParserTypes } from './sql-parser'; diff --git a/packages/core/database/src/query-interface/postgres-query-interface.ts b/packages/core/database/src/query-interface/postgres-query-interface.ts index 57f3204fbf..eda08b0cd7 100644 --- a/packages/core/database/src/query-interface/postgres-query-interface.ts +++ b/packages/core/database/src/query-interface/postgres-query-interface.ts @@ -9,7 +9,7 @@ import lodash from 'lodash'; import { Collection } from '../collection'; -import sqlParser from '../sql-parser/postgres'; +import sqlParser from '../sql-parser'; import QueryInterface, { TableInfo } from './query-interface'; import { Transaction } from 'sequelize'; @@ -124,7 +124,9 @@ export default class PostgresQueryInterface extends QueryInterface { } parseSQL(sql: string): any { - return sqlParser.parse(sql); + return sqlParser.parse(sql, { + database: 'Postgresql', + }); } async viewColumnUsage(options): Promise<{ diff --git a/packages/core/database/src/sql-parser/index.js b/packages/core/database/src/sql-parser/index.js deleted file mode 100644 index 943df2b139..0000000000 --- a/packages/core/database/src/sql-parser/index.js +++ /dev/null @@ -1,10707 +0,0 @@ -/** - * This file is part of the NocoBase (R) project. - * Copyright (c) 2020-2024 NocoBase Co., Ltd. - * Authors: NocoBase Team. - * - * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. - * For more information, please refer to: https://www.nocobase.com/agreement. - */ - -// Generated by Peggy 3.0.2. -// -// https://peggyjs.org/ - -"use strict"; - -function peg$subclass(child, parent) { - function C() { this.constructor = child; } - C.prototype = parent.prototype; - child.prototype = new C(); -} - -function peg$SyntaxError(message, expected, found, location) { - var self = Error.call(this, message); - // istanbul ignore next Check is a necessary evil to support older environments - if (Object.setPrototypeOf) { - Object.setPrototypeOf(self, peg$SyntaxError.prototype); - } - self.expected = expected; - self.found = found; - self.location = location; - self.name = "SyntaxError"; - return self; -} - -peg$subclass(peg$SyntaxError, Error); - -function peg$padEnd(str, targetLength, padString) { - padString = padString || " "; - if (str.length > targetLength) { return str; } - targetLength -= str.length; - padString += padString.repeat(targetLength); - return str + padString.slice(0, targetLength); -} - -peg$SyntaxError.prototype.format = function(sources) { - var str = "Error: " + this.message; - if (this.location) { - var src = null; - var k; - for (k = 0; k < sources.length; k++) { - if (sources[k].source === this.location.source) { - src = sources[k].text.split(/\r\n|\n|\r/g); - break; - } - } - var s = this.location.start; - var offset_s = (this.location.source && (typeof this.location.source.offset === "function")) - ? this.location.source.offset(s) - : s; - var loc = this.location.source + ":" + offset_s.line + ":" + offset_s.column; - if (src) { - var e = this.location.end; - var filler = peg$padEnd("", offset_s.line.toString().length, ' '); - var line = src[s.line - 1]; - var last = s.line === e.line ? e.column : line.length + 1; - var hatLen = (last - s.column) || 1; - str += "\n --> " + loc + "\n" - + filler + " |\n" - + offset_s.line + " | " + line + "\n" - + filler + " | " + peg$padEnd("", s.column - 1, ' ') - + peg$padEnd("", hatLen, "^"); - } else { - str += "\n at " + loc; - } - } - return str; -}; - -peg$SyntaxError.buildMessage = function(expected, found) { - var DESCRIBE_EXPECTATION_FNS = { - literal: function(expectation) { - return "\"" + literalEscape(expectation.text) + "\""; - }, - - class: function(expectation) { - var escapedParts = expectation.parts.map(function(part) { - return Array.isArray(part) - ? classEscape(part[0]) + "-" + classEscape(part[1]) - : classEscape(part); - }); - - return "[" + (expectation.inverted ? "^" : "") + escapedParts.join("") + "]"; - }, - - any: function() { - return "any character"; - }, - - end: function() { - return "end of input"; - }, - - other: function(expectation) { - return expectation.description; - } - }; - - function hex(ch) { - return ch.charCodeAt(0).toString(16).toUpperCase(); - } - - function literalEscape(s) { - return s - .replace(/\\/g, "\\\\") - .replace(/"/g, "\\\"") - .replace(/\0/g, "\\0") - .replace(/\t/g, "\\t") - .replace(/\n/g, "\\n") - .replace(/\r/g, "\\r") - .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); - } - - function classEscape(s) { - return s - .replace(/\\/g, "\\\\") - .replace(/\]/g, "\\]") - .replace(/\^/g, "\\^") - .replace(/-/g, "\\-") - .replace(/\0/g, "\\0") - .replace(/\t/g, "\\t") - .replace(/\n/g, "\\n") - .replace(/\r/g, "\\r") - .replace(/[\x00-\x0F]/g, function(ch) { return "\\x0" + hex(ch); }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function(ch) { return "\\x" + hex(ch); }); - } - - function describeExpectation(expectation) { - return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); - } - - function describeExpected(expected) { - var descriptions = expected.map(describeExpectation); - var i, j; - - descriptions.sort(); - - if (descriptions.length > 0) { - for (i = 1, j = 1; i < descriptions.length; i++) { - if (descriptions[i - 1] !== descriptions[i]) { - descriptions[j] = descriptions[i]; - j++; - } - } - descriptions.length = j; - } - - switch (descriptions.length) { - case 1: - return descriptions[0]; - - case 2: - return descriptions[0] + " or " + descriptions[1]; - - default: - return descriptions.slice(0, -1).join(", ") - + ", or " - + descriptions[descriptions.length - 1]; - } - } - - function describeFound(found) { - return found ? "\"" + literalEscape(found) + "\"" : "end of input"; - } - - return "Expected " + describeExpected(expected) + " but " + describeFound(found) + " found."; -}; - -function peg$parse(input, options) { - options = options !== undefined ? options : {}; - - var peg$FAILED = {}; - var peg$source = options.grammarSource; - - var peg$startRuleFunctions = { start: peg$parsestart }; - var peg$startRuleFunction = peg$parsestart; - - var peg$c0 = "("; - var peg$c1 = ")"; - var peg$c2 = "="; - var peg$c3 = "!"; - var peg$c4 = ">="; - var peg$c5 = ">"; - var peg$c6 = "<="; - var peg$c7 = "<>"; - var peg$c8 = "<"; - var peg$c9 = "!="; - var peg$c10 = "+"; - var peg$c11 = "-"; - var peg$c12 = "*"; - var peg$c13 = "/"; - var peg$c14 = "%"; - var peg$c15 = "\""; - var peg$c16 = "'"; - var peg$c17 = "`"; - var peg$c18 = ":"; - var peg$c19 = "\\'"; - var peg$c20 = "\\\""; - var peg$c21 = "\\\\"; - var peg$c22 = "\\/"; - var peg$c23 = "\\b"; - var peg$c24 = "\\f"; - var peg$c25 = "\\n"; - var peg$c26 = "\\r"; - var peg$c27 = "\\t"; - var peg$c28 = "\\u"; - var peg$c29 = "."; - var peg$c30 = "null"; - var peg$c31 = "true"; - var peg$c32 = "false"; - var peg$c33 = "show"; - var peg$c34 = "drop"; - var peg$c35 = "select"; - var peg$c36 = "update"; - var peg$c37 = "create"; - var peg$c38 = "delete"; - var peg$c39 = "insert"; - var peg$c40 = "RECURSIVE"; - var peg$c41 = "replace"; - var peg$c42 = "explain"; - var peg$c43 = "into"; - var peg$c44 = "from"; - var peg$c45 = "set"; - var peg$c46 = "as"; - var peg$c47 = "table"; - var peg$c48 = "on"; - var peg$c49 = "left"; - var peg$c50 = "right"; - var peg$c51 = "full"; - var peg$c52 = "inner"; - var peg$c53 = "join"; - var peg$c54 = "outer"; - var peg$c55 = "union"; - var peg$c56 = "values"; - var peg$c57 = "using"; - var peg$c58 = "where"; - var peg$c59 = "with"; - var peg$c60 = "group"; - var peg$c61 = "by"; - var peg$c62 = "order"; - var peg$c63 = "having"; - var peg$c64 = "limit"; - var peg$c65 = "asc"; - var peg$c66 = "desc"; - var peg$c67 = "all"; - var peg$c68 = "distinct"; - var peg$c69 = "between"; - var peg$c70 = "in"; - var peg$c71 = "is"; - var peg$c72 = "like"; - var peg$c73 = "exists"; - var peg$c74 = "not"; - var peg$c75 = "and"; - var peg$c76 = "or"; - var peg$c77 = "count"; - var peg$c78 = "max"; - var peg$c79 = "min"; - var peg$c80 = "sum"; - var peg$c81 = "avg"; - var peg$c82 = "case"; - var peg$c83 = "when"; - var peg$c84 = "then"; - var peg$c85 = "else"; - var peg$c86 = "end"; - var peg$c87 = "cast"; - var peg$c88 = "char"; - var peg$c89 = "varchar"; - var peg$c90 = "numeric"; - var peg$c91 = "decimal"; - var peg$c92 = "signed"; - var peg$c93 = "unsigned"; - var peg$c94 = "int"; - var peg$c95 = "integer"; - var peg$c96 = "json"; - var peg$c97 = "smallint"; - var peg$c98 = "date"; - var peg$c99 = "time"; - var peg$c100 = "timestamp"; - var peg$c101 = "user"; - var peg$c102 = "current_date"; - var peg$c103 = "adddate"; - var peg$c104 = "interval"; - var peg$c105 = "year"; - var peg$c106 = "month"; - var peg$c107 = "day"; - var peg$c108 = "hour"; - var peg$c109 = "minute"; - var peg$c110 = "second"; - var peg$c111 = "current_time"; - var peg$c112 = "current_timestamp"; - var peg$c113 = "current_user"; - var peg$c114 = "session_user"; - var peg$c115 = "system_user"; - var peg$c116 = "$"; - var peg$c117 = "return"; - var peg$c118 = ":="; - var peg$c119 = "dual"; - var peg$c120 = "sql_calc_found_rows"; - var peg$c121 = "sql_cache"; - var peg$c122 = "sql_no_cache"; - var peg$c123 = "sql_small_result"; - var peg$c124 = "sql_big_result"; - var peg$c125 = "sql_buffer_result"; - var peg$c126 = ","; - var peg$c127 = "["; - var peg$c128 = "]"; - var peg$c129 = ";"; - var peg$c130 = "/*"; - var peg$c131 = "*/"; - var peg$c132 = "--"; - - var peg$r0 = /^[^"]/; - var peg$r1 = /^[^']/; - var peg$r2 = /^[^`]/; - var peg$r3 = /^[A-Za-z_]/; - var peg$r4 = /^[A-Za-z0-9_]/; - var peg$r5 = /^[A-Za-z0-9_:]/; - var peg$r6 = /^[^"\\\0-\x1F\x7F]/; - var peg$r7 = /^[^'\\\0-\x1F\x7F]/; - var peg$r8 = /^[\n\r]/; - var peg$r9 = /^[0-9]/; - var peg$r10 = /^[1-9]/; - var peg$r11 = /^[0-9a-fA-F]/; - var peg$r12 = /^[eE]/; - var peg$r13 = /^[+\-]/; - var peg$r14 = /^[ \t\n\r]/; - - var peg$e0 = peg$literalExpectation("(", false); - var peg$e1 = peg$literalExpectation(")", false); - var peg$e2 = peg$literalExpectation("=", false); - var peg$e3 = peg$literalExpectation("!", false); - var peg$e4 = peg$literalExpectation(">=", false); - var peg$e5 = peg$literalExpectation(">", false); - var peg$e6 = peg$literalExpectation("<=", false); - var peg$e7 = peg$literalExpectation("<>", false); - var peg$e8 = peg$literalExpectation("<", false); - var peg$e9 = peg$literalExpectation("!=", false); - var peg$e10 = peg$literalExpectation("+", false); - var peg$e11 = peg$literalExpectation("-", false); - var peg$e12 = peg$literalExpectation("*", false); - var peg$e13 = peg$literalExpectation("/", false); - var peg$e14 = peg$literalExpectation("%", false); - var peg$e15 = peg$literalExpectation("\"", false); - var peg$e16 = peg$classExpectation(["\""], true, false); - var peg$e17 = peg$literalExpectation("'", false); - var peg$e18 = peg$classExpectation(["'"], true, false); - var peg$e19 = peg$literalExpectation("`", false); - var peg$e20 = peg$classExpectation(["`"], true, false); - var peg$e21 = peg$classExpectation([["A", "Z"], ["a", "z"], "_"], false, false); - var peg$e22 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_"], false, false); - var peg$e23 = peg$classExpectation([["A", "Z"], ["a", "z"], ["0", "9"], "_", ":"], false, false); - var peg$e24 = peg$literalExpectation(":", false); - var peg$e25 = peg$classExpectation(["\"", "\\", ["\0", "\x1F"], "\x7F"], true, false); - var peg$e26 = peg$classExpectation(["'", "\\", ["\0", "\x1F"], "\x7F"], true, false); - var peg$e27 = peg$literalExpectation("\\'", false); - var peg$e28 = peg$literalExpectation("\\\"", false); - var peg$e29 = peg$literalExpectation("\\\\", false); - var peg$e30 = peg$literalExpectation("\\/", false); - var peg$e31 = peg$literalExpectation("\\b", false); - var peg$e32 = peg$literalExpectation("\\f", false); - var peg$e33 = peg$literalExpectation("\\n", false); - var peg$e34 = peg$literalExpectation("\\r", false); - var peg$e35 = peg$literalExpectation("\\t", false); - var peg$e36 = peg$literalExpectation("\\u", false); - var peg$e37 = peg$classExpectation(["\n", "\r"], false, false); - var peg$e38 = peg$literalExpectation(".", false); - var peg$e39 = peg$classExpectation([["0", "9"]], false, false); - var peg$e40 = peg$classExpectation([["1", "9"]], false, false); - var peg$e41 = peg$classExpectation([["0", "9"], ["a", "f"], ["A", "F"]], false, false); - var peg$e42 = peg$classExpectation(["e", "E"], false, false); - var peg$e43 = peg$classExpectation(["+", "-"], false, false); - var peg$e44 = peg$literalExpectation("NULL", true); - var peg$e45 = peg$literalExpectation("TRUE", true); - var peg$e46 = peg$literalExpectation("FALSE", true); - var peg$e47 = peg$literalExpectation("SHOW", true); - var peg$e48 = peg$literalExpectation("DROP", true); - var peg$e49 = peg$literalExpectation("SELECT", true); - var peg$e50 = peg$literalExpectation("UPDATE", true); - var peg$e51 = peg$literalExpectation("CREATE", true); - var peg$e52 = peg$literalExpectation("DELETE", true); - var peg$e53 = peg$literalExpectation("INSERT", true); - var peg$e54 = peg$literalExpectation("RECURSIVE", false); - var peg$e55 = peg$literalExpectation("REPLACE", true); - var peg$e56 = peg$literalExpectation("EXPLAIN", true); - var peg$e57 = peg$literalExpectation("INTO", true); - var peg$e58 = peg$literalExpectation("FROM", true); - var peg$e59 = peg$literalExpectation("SET", true); - var peg$e60 = peg$literalExpectation("AS", true); - var peg$e61 = peg$literalExpectation("TABLE", true); - var peg$e62 = peg$literalExpectation("ON", true); - var peg$e63 = peg$literalExpectation("LEFT", true); - var peg$e64 = peg$literalExpectation("RIGHT", true); - var peg$e65 = peg$literalExpectation("FULL", true); - var peg$e66 = peg$literalExpectation("INNER", true); - var peg$e67 = peg$literalExpectation("JOIN", true); - var peg$e68 = peg$literalExpectation("OUTER", true); - var peg$e69 = peg$literalExpectation("UNION", true); - var peg$e70 = peg$literalExpectation("VALUES", true); - var peg$e71 = peg$literalExpectation("USING", true); - var peg$e72 = peg$literalExpectation("WHERE", true); - var peg$e73 = peg$literalExpectation("WITH", true); - var peg$e74 = peg$literalExpectation("GROUP", true); - var peg$e75 = peg$literalExpectation("BY", true); - var peg$e76 = peg$literalExpectation("ORDER", true); - var peg$e77 = peg$literalExpectation("HAVING", true); - var peg$e78 = peg$literalExpectation("LIMIT", true); - var peg$e79 = peg$literalExpectation("ASC", true); - var peg$e80 = peg$literalExpectation("DESC", true); - var peg$e81 = peg$literalExpectation("ALL", true); - var peg$e82 = peg$literalExpectation("DISTINCT", true); - var peg$e83 = peg$literalExpectation("BETWEEN", true); - var peg$e84 = peg$literalExpectation("IN", true); - var peg$e85 = peg$literalExpectation("IS", true); - var peg$e86 = peg$literalExpectation("LIKE", true); - var peg$e87 = peg$literalExpectation("EXISTS", true); - var peg$e88 = peg$literalExpectation("NOT", true); - var peg$e89 = peg$literalExpectation("AND", true); - var peg$e90 = peg$literalExpectation("OR", true); - var peg$e91 = peg$literalExpectation("COUNT", true); - var peg$e92 = peg$literalExpectation("MAX", true); - var peg$e93 = peg$literalExpectation("MIN", true); - var peg$e94 = peg$literalExpectation("SUM", true); - var peg$e95 = peg$literalExpectation("AVG", true); - var peg$e96 = peg$literalExpectation("CASE", true); - var peg$e97 = peg$literalExpectation("WHEN", true); - var peg$e98 = peg$literalExpectation("THEN", true); - var peg$e99 = peg$literalExpectation("ELSE", true); - var peg$e100 = peg$literalExpectation("END", true); - var peg$e101 = peg$literalExpectation("CAST", true); - var peg$e102 = peg$literalExpectation("CHAR", true); - var peg$e103 = peg$literalExpectation("VARCHAR", true); - var peg$e104 = peg$literalExpectation("NUMERIC", true); - var peg$e105 = peg$literalExpectation("DECIMAL", true); - var peg$e106 = peg$literalExpectation("SIGNED", true); - var peg$e107 = peg$literalExpectation("UNSIGNED", true); - var peg$e108 = peg$literalExpectation("INT", true); - var peg$e109 = peg$literalExpectation("INTEGER", true); - var peg$e110 = peg$literalExpectation("JSON", true); - var peg$e111 = peg$literalExpectation("SMALLINT", true); - var peg$e112 = peg$literalExpectation("DATE", true); - var peg$e113 = peg$literalExpectation("TIME", true); - var peg$e114 = peg$literalExpectation("TIMESTAMP", true); - var peg$e115 = peg$literalExpectation("USER", true); - var peg$e116 = peg$literalExpectation("CURRENT_DATE", true); - var peg$e117 = peg$literalExpectation("ADDDATE", true); - var peg$e118 = peg$literalExpectation("INTERVAL", true); - var peg$e119 = peg$literalExpectation("YEAR", true); - var peg$e120 = peg$literalExpectation("MONTH", true); - var peg$e121 = peg$literalExpectation("DAY", true); - var peg$e122 = peg$literalExpectation("HOUR", true); - var peg$e123 = peg$literalExpectation("MINUTE", true); - var peg$e124 = peg$literalExpectation("SECOND", true); - var peg$e125 = peg$literalExpectation("CURRENT_TIME", true); - var peg$e126 = peg$literalExpectation("CURRENT_TIMESTAMP", true); - var peg$e127 = peg$literalExpectation("CURRENT_USER", true); - var peg$e128 = peg$literalExpectation("SESSION_USER", true); - var peg$e129 = peg$literalExpectation("SYSTEM_USER", true); - var peg$e130 = peg$literalExpectation("$", false); - var peg$e131 = peg$literalExpectation("return", true); - var peg$e132 = peg$literalExpectation(":=", false); - var peg$e133 = peg$literalExpectation("DUAL", true); - var peg$e134 = peg$literalExpectation("SQL_CALC_FOUND_ROWS", true); - var peg$e135 = peg$literalExpectation("SQL_CACHE", true); - var peg$e136 = peg$literalExpectation("SQL_NO_CACHE", true); - var peg$e137 = peg$literalExpectation("SQL_SMALL_RESULT", true); - var peg$e138 = peg$literalExpectation("SQL_BIG_RESULT", true); - var peg$e139 = peg$literalExpectation("SQL_BUFFER_RESULT", true); - var peg$e140 = peg$literalExpectation(",", false); - var peg$e141 = peg$literalExpectation("[", false); - var peg$e142 = peg$literalExpectation("]", false); - var peg$e143 = peg$literalExpectation(";", false); - var peg$e144 = peg$literalExpectation("/*", false); - var peg$e145 = peg$literalExpectation("*/", false); - var peg$e146 = peg$literalExpectation("--", false); - var peg$e147 = peg$anyExpectation(); - var peg$e148 = peg$classExpectation([" ", "\t", "\n", "\r"], false, false); - - var peg$f0 = function(head, tail) { - const cur = [head && head.ast || head]; - for (let i = 0; i < tail.length; i++) { - if(!tail[i][3] || tail[i][3].length === 0) continue; - cur.push(tail[i][3] && tail[i][3].ast || tail[i][3]); - } - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: cur - } - }; - var peg$f1 = function(head, tail) { - let cur = head; - for (let i = 0; i < tail.length; i++) { - cur._next = tail[i][3]; - cur = cur._next - } - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: head - } - }; - var peg$f2 = function(s) { - return s[2]; - }; - var peg$f3 = function(head, tail) { - return createList(head, tail); - }; - var peg$f4 = function(cte) { - cte.recursive = true; - return [cte] - }; - var peg$f5 = function(name, columns, stmt) { - return { name, stmt, columns }; - }; - var peg$f6 = function(head, tail) { - return createList(head, tail); - }; - var peg$f7 = function(cte, opts, d, c, f, w, g, h, o, l) { - if(f) f.forEach(info => info.table && tableList.add(`select::${info.db}::${info.table}`)); - return { - with: cte, - type: 'select', - options: opts, - distinct: d, - columns: c, - from: f, - where: w, - groupby: g, - having: h, - orderby: o, - limit: l - }; - }; - var peg$f8 = function(head, tail) { - const opts = [head]; - for (let i = 0, l = tail.length; i < l; ++i) { - opts.push(tail[i][1]); - } - return opts; - }; - var peg$f9 = function(option) { return option; }; - var peg$f10 = function() { - columnList.add('select::null::(.*)'); - return '*'; - }; - var peg$f11 = function(head, tail) { - return createList(head, tail); - }; - var peg$f12 = function(tbl) { - columnList.add(`select::${tbl}::(.*)`); - return { - expr: { - type: 'column_ref', - table: tbl, - column: '*' - }, - as: null - }; - }; - var peg$f13 = function(e, alias) { - return { expr: e, as: alias }; - }; - var peg$f14 = function(i) { return i; }; - var peg$f15 = function(i) { return i; }; - var peg$f16 = function(l) { return l; }; - var peg$f17 = function(head, tail) { - tail.unshift(head); - return tail; - }; - var peg$f18 = function(t) { return t; }; - var peg$f19 = function(t) { return t; }; - var peg$f20 = function(op, t, head, tail) { - t.join = op; - t.using = createList(head, tail); - return t; - }; - var peg$f21 = function(op, t, expr) { - t.join = op; - t.on = expr; - return t; - }; - var peg$f22 = function(op, stmt, alias, expr) { - stmt.parentheses = true; - return { - expr: stmt, - as: alias, - join: op, - on: expr - }; - }; - var peg$f23 = function() { - return { - type: 'dual' - }; - }; - var peg$f24 = function(t, alias) { - if (t.type === 'var') { - t.as = alias; - return t; - } else { - return { - db: t.db, - table: t.table, - as: alias - }; - } - }; - var peg$f25 = function(stmt, alias) { - stmt.parentheses = true; - return { - expr: stmt, - as: alias - }; - }; - var peg$f26 = function() { return 'LEFT JOIN'; }; - var peg$f27 = function() { return 'RIGHT JOIN'; }; - var peg$f28 = function() { return 'FULL JOIN'; }; - var peg$f29 = function() { return 'INNER JOIN'; }; - var peg$f30 = function(dt, tail) { - const obj = { db: null, table: dt }; - if (tail !== null) { - obj.db = dt; - obj.table = tail[3]; - } - return obj; - }; - var peg$f31 = function(v) { - v.db = null; - v.table = v.name; - return v; - }; - var peg$f32 = function(e) { return e; }; - var peg$f33 = function(e) { return e; }; - var peg$f34 = function(l) { return l; }; - var peg$f35 = function(head, tail) { - return createList(head, tail); - }; - var peg$f36 = function(e) { return e; }; - var peg$f37 = function(l) { return l; }; - var peg$f38 = function(head, tail) { - return createList(head, tail); - }; - var peg$f39 = function(e, d) { - const obj = { expr: e, type: 'ASC' }; - if (d === 'DESC') obj.type = 'DESC'; - return obj; - }; - var peg$f40 = function(i1, tail) { - const res = [i1]; - if (tail === null) res.unshift({ type: 'number', value: 0 }); - else res.push(tail[2]); - return res; - }; - var peg$f41 = function(t, l, w) { - if(t.table) tableList.add(`update::${t.db}::${t.table}`); - if(l) l.forEach(col => columnList.add(`update::${t.table}::${col.column}`)); - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: { - type: 'update', - db: t.db, - table: t.table, - set: l, - where: w - } - }; - }; - var peg$f42 = function(t, f, w) { - if(f) f.forEach(info => { - info.table && tableList.add(`delete::${info.db}::${info.table}`); - columnList.add(`delete::${info.table}::(.*)`); - }); - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: { - type: 'delete', - tables: t, - from: f, - where: w - } - }; - }; - var peg$f43 = function(head, tail) { - return createList(head, tail); - }; - var peg$f44 = function(tbl, c, v) { - return { column: c, value: v, table: tbl && tbl[0] }; - }; - var peg$f45 = function(ri, t, c, v) { - if (t.table) tableList.add(`insert::${t.db}::${t.table}`); - if (c) c.forEach(c => columnList.add(`insert::${t.table}::${c}`)); - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: { - type: ri, - db: t.db, - table: t.table, - columns: c, - values: v - } - }; - }; - var peg$f46 = function(ri, t, v) { - if (t.table) tableList.add(`insert::${t.db}::${t.table}`); - columnList.add(`insert::${t.table}::(.*)`); - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: { - type: ri, - db: t.db, - table: t.table, - columns: null, - values: v - } - }; - }; - var peg$f47 = function() { return 'insert'; }; - var peg$f48 = function() { return 'replace'; }; - var peg$f49 = function(l) { return l; }; - var peg$f50 = function(head, tail) { - return createList(head, tail); - }; - var peg$f51 = function(l) { - return l; - }; - var peg$f52 = function(head, tail) { - const el = { type: 'expr_list' }; - el.value = createList(head, tail); - return el; - }; - var peg$f53 = function(n, u) { - return { - type: 'interval', - value: [n, u] - } - }; - var peg$f54 = function(expr, condition_list, otherwise) { - if (otherwise) condition_list.push(otherwise); - return { - type: 'case', - expr: expr || null, - args: condition_list - }; - }; - var peg$f55 = function(condition, result) { - return { - type: 'when', - cond: condition, - result: result - }; - }; - var peg$f56 = function(result) { - return { type: 'else', result: result }; - }; - var peg$f57 = function(head, tail) { - return createBinaryExprChain(head, tail); - }; - var peg$f58 = function(head, tail) { - return createBinaryExprChain(head, tail); - }; - var peg$f59 = function(expr) { - return createUnaryExpr('NOT', expr); - }; - var peg$f60 = function(left, rh) { - if (rh === null) return left; - else if (rh.type === 'arithmetic') return createBinaryExprChain(left, rh.tail); - else return createBinaryExpr(rh.op, left, rh.right); - }; - var peg$f61 = function(op, stmt) { - stmt.parentheses = true; - return createUnaryExpr(op, stmt); - }; - var peg$f62 = function(nk) { return nk[0] + ' ' + nk[2]; }; - var peg$f63 = function(l) { - return { type: 'arithmetic', tail: l }; - }; - var peg$f64 = function(right) { - return { op: 'IS', right: right }; - }; - var peg$f65 = function(right) { - return { op: 'IS NOT', right: right }; - }; - var peg$f66 = function(op, begin, end) { - return { - op: op, - right: { - type: 'expr_list', - value: [begin, end] - } - }; - }; - var peg$f67 = function(nk) { return nk[0] + ' ' + nk[2]; }; - var peg$f68 = function(nk) { return nk[0] + ' ' + nk[2]; }; - var peg$f69 = function(nk) { return nk[0] + ' ' + nk[2]; }; - var peg$f70 = function(op, right) { - return { op: op, right: right }; - }; - var peg$f71 = function(op, l) { - return { op: op, right: l }; - }; - var peg$f72 = function(op, e) { - return { op: op, right: e }; - }; - var peg$f73 = function(head, tail) { - return createBinaryExprChain(head, tail); - }; - var peg$f74 = function(head, tail) { - return createBinaryExprChain(head, tail) - }; - var peg$f75 = function(e) { - e.parentheses = true; - return e; - }; - var peg$f76 = function(list) { - list.parentheses = true; - return list; - }; - var peg$f77 = function(tbl, col) { - columnList.add(`select::${tbl}::${col}`); - return { - type: 'column_ref', - table: tbl, - column: col - }; - }; - var peg$f78 = function(col) { - columnList.add(`select::null::${col}`); - return { - type: 'column_ref', - table: null, - column: col - }; - }; - var peg$f79 = function(head, tail) { - return createList(head, tail); - }; - var peg$f80 = function(name) { return reservedMap[name.toUpperCase()] === true; }; - var peg$f81 = function(name) { - return name; - }; - var peg$f82 = function(name) { - return name; - }; - var peg$f83 = function(name) { - if (reservedMap[name.toUpperCase()] === true) throw new Error("Error: "+ JSON.stringify(name)+" is a reserved word, can not as alias clause"); - return false - }; - var peg$f84 = function(name) { - return name; - }; - var peg$f85 = function(name) { - return name; - }; - var peg$f86 = function(chars) { return chars.join(''); }; - var peg$f87 = function(chars) { return chars.join(''); }; - var peg$f88 = function(chars) { return chars.join(''); }; - var peg$f89 = function(name) { return reservedMap[name.toUpperCase()] === true; }; - var peg$f90 = function(name) { return name; }; - var peg$f91 = function(start, parts) { return start + parts.join(''); }; - var peg$f92 = function(start, parts) { return start + parts.join(''); }; - var peg$f93 = function(l) { - return { type: 'param', value: l[1] }; - }; - var peg$f94 = function(name, e) { - return { - type: 'aggr_func', - name: name, - args: { - expr: e - } - }; - }; - var peg$f95 = function(name, arg) { - return { - type: 'aggr_func', - name: name, - args: arg - }; - }; - var peg$f96 = function(e) { return { expr: e }; }; - var peg$f97 = function(d, c) { return { distinct: d, expr: c }; }; - var peg$f98 = function() { return { type: 'star', value: '*' }; }; - var peg$f99 = function(name, l) { - return { - type: 'function', - name: name, - args: l ? l: { type: 'expr_list', value: [] } - }; - }; - var peg$f100 = function(name) { - return { - type: 'function', - name: name, - args: { type: 'expr_list', value: [] } - }; - }; - var peg$f101 = function(e, t) { - return { - type: 'cast', - expr: e, - target: t - }; - }; - var peg$f102 = function(e, precision) { - return { - type: 'cast', - expr: e, - target: { - dataType: 'DECIMAL(' + precision + ')' - } - }; - }; - var peg$f103 = function(e, precision, scale) { - return { - type: 'cast', - expr: e, - target: { - dataType: 'DECIMAL(' + precision + ', ' + scale + ')' - } - }; - }; - var peg$f104 = function(e, s, t) { /* MySQL cast to un-/signed integer */ - return { - type: 'cast', - expr: e, - target: { - dataType: s + (t ? ' ' + t: '') - } - }; - }; - var peg$f105 = function(head, tail) { - return createList(head, tail); - }; - var peg$f106 = function() { - return { type: 'null', value: null }; - }; - var peg$f107 = function() { - return { type: 'bool', value: true }; - }; - var peg$f108 = function() { - return { type: 'bool', value: false }; - }; - var peg$f109 = function(ca) { - return { - type: 'string', - value: ca[1].join('') - }; - }; - var peg$f110 = function(ca) { - return { - type: 'string', - value: ca[1].join('') - }; - }; - var peg$f111 = function(type, ca) { - return { - type: type.toLowerCase(), - value: ca[1].join('') - }; - }; - var peg$f112 = function() { return "'"; }; - var peg$f113 = function() { return '"'; }; - var peg$f114 = function() { return "\\"; }; - var peg$f115 = function() { return "/"; }; - var peg$f116 = function() { return "\b"; }; - var peg$f117 = function() { return "\f"; }; - var peg$f118 = function() { return "\n"; }; - var peg$f119 = function() { return "\r"; }; - var peg$f120 = function() { return "\t"; }; - var peg$f121 = function(h1, h2, h3, h4) { - return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4)); - }; - var peg$f122 = function(n) { - return { type: 'number', value: n }; - }; - var peg$f123 = function(int_, frac, exp) { return parseFloat(int_ + frac + exp); }; - var peg$f124 = function(int_, frac) { return parseFloat(int_ + frac); }; - var peg$f125 = function(int_, exp) { return parseFloat(int_ + exp); }; - var peg$f126 = function(int_) { return parseFloat(int_); }; - var peg$f127 = function(digit19, digits) { return digit19 + digits; }; - var peg$f128 = function(op, digit19, digits) { return "-" + digit19 + digits; }; - var peg$f129 = function(op, digit) { return "-" + digit; }; - var peg$f130 = function(digits) { return "." + digits; }; - var peg$f131 = function(e, digits) { return e + digits; }; - var peg$f132 = function(digits) { return digits.join(""); }; - var peg$f133 = function(e, sign) { return e + (sign !== null ? sign: ''); }; - var peg$f134 = function() { return 'ASC'; }; - var peg$f135 = function() { return 'DESC'; }; - var peg$f136 = function() { return 'ALL'; }; - var peg$f137 = function() { return 'DISTINCT';}; - var peg$f138 = function() { return 'BETWEEN'; }; - var peg$f139 = function() { return 'IN'; }; - var peg$f140 = function() { return 'IS'; }; - var peg$f141 = function() { return 'LIKE'; }; - var peg$f142 = function() { return 'EXISTS'; }; - var peg$f143 = function() { return 'NOT'; }; - var peg$f144 = function() { return 'AND'; }; - var peg$f145 = function() { return 'OR'; }; - var peg$f146 = function() { return 'COUNT'; }; - var peg$f147 = function() { return 'MAX'; }; - var peg$f148 = function() { return 'MIN'; }; - var peg$f149 = function() { return 'SUM'; }; - var peg$f150 = function() { return 'AVG'; }; - var peg$f151 = function() { return 'CHAR'; }; - var peg$f152 = function() { return 'VARCHAR';}; - var peg$f153 = function() { return 'NUMERIC'; }; - var peg$f154 = function() { return 'DECIMAL'; }; - var peg$f155 = function() { return 'SIGNED'; }; - var peg$f156 = function() { return 'UNSIGNED'; }; - var peg$f157 = function() { return 'INT'; }; - var peg$f158 = function() { return 'INTEGER'; }; - var peg$f159 = function() { return 'JSON'; }; - var peg$f160 = function() { return 'SMALLINT'; }; - var peg$f161 = function() { return 'DATE'; }; - var peg$f162 = function() { return 'TIME'; }; - var peg$f163 = function() { return 'TIMESTAMP'; }; - var peg$f164 = function() { return 'USER'; }; - var peg$f165 = function() { return 'CURRENT_DATE'; }; - var peg$f166 = function() { return 'ADDDATE'; }; - var peg$f167 = function() { return 'INTERVAL'; }; - var peg$f168 = function() { return 'YEAR'; }; - var peg$f169 = function() { return 'MONTH'; }; - var peg$f170 = function() { return 'DAY'; }; - var peg$f171 = function() { return 'HOUR'; }; - var peg$f172 = function() { return 'MINUTE'; }; - var peg$f173 = function() { return 'SECOND'; }; - var peg$f174 = function() { return 'CURRENT_TIME'; }; - var peg$f175 = function() { return 'CURRENT_TIMESTAMP'; }; - var peg$f176 = function() { return 'CURRENT_USER'; }; - var peg$f177 = function() { return 'SESSION_USER'; }; - var peg$f178 = function() { return 'SYSTEM_USER'; }; - var peg$f179 = function() { varList = []; return true; }; - var peg$f180 = function(s) { - return { stmt: s, vars: varList }; - }; - var peg$f181 = function(va, e) { - return { - type: 'assign', - left: va, - right: e - }; - }; - var peg$f182 = function(e) { - return { type: 'return', expr: e }; - }; - var peg$f183 = function(head, tail) { - return createBinaryExprChain(head, tail); - }; - var peg$f184 = function(head, tail) { - return createBinaryExprChain(head, tail); - }; - var peg$f185 = function(lt, op, rt, expr) { - return { - type: 'join', - ltable: lt, - rtable: rt, - op: op, - on: expr - }; - }; - var peg$f186 = function(e) { - e.parentheses = true; - return e; - }; - var peg$f187 = function(name, l) { - //compatible with original func_call - return { - type: 'function', - name: name, - args: { - type: 'expr_list', - value: l - } - }; - }; - var peg$f188 = function(head, tail) { - return createList(head, tail); - }; - var peg$f189 = function(l) { - return { type: 'array', value: l }; - }; - var peg$f190 = function(name, m) { - //push for analysis - varList.push(name); - return { - type: 'var', - name: name, - members: m - }; - }; - var peg$f191 = function(l) { - const s = []; - for (let i = 0; i < l.length; i++) { - s.push(l[i][1]); - } - return s; - }; - var peg$f192 = function(t, l) { - return { dataType: t, length: parseInt(l.join(''), 10) }; - }; - var peg$f193 = function(t) { return { dataType: t }; }; - var peg$f194 = function(t) { return { dataType: t }; }; - var peg$f195 = function(t) { return { dataType: t }; }; - var peg$f196 = function(t) { return { dataType: t }; }; - var peg$f197 = function(t) { return { dataType: t }; }; - var peg$currPos = 0; - var peg$savedPos = 0; - var peg$posDetailsCache = [{ line: 1, column: 1 }]; - var peg$maxFailPos = 0; - var peg$maxFailExpected = []; - var peg$silentFails = 0; - - var peg$result; - - if ("startRule" in options) { - if (!(options.startRule in peg$startRuleFunctions)) { - throw new Error("Can't start parsing from rule \"" + options.startRule + "\"."); - } - - peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; - } - - function text() { - return input.substring(peg$savedPos, peg$currPos); - } - - function offset() { - return peg$savedPos; - } - - function range() { - return { - source: peg$source, - start: peg$savedPos, - end: peg$currPos - }; - } - - function location() { - return peg$computeLocation(peg$savedPos, peg$currPos); - } - - function expected(description, location) { - location = location !== undefined - ? location - : peg$computeLocation(peg$savedPos, peg$currPos); - - throw peg$buildStructuredError( - [peg$otherExpectation(description)], - input.substring(peg$savedPos, peg$currPos), - location - ); - } - - function error(message, location) { - location = location !== undefined - ? location - : peg$computeLocation(peg$savedPos, peg$currPos); - - throw peg$buildSimpleError(message, location); - } - - function peg$literalExpectation(text, ignoreCase) { - return { type: "literal", text: text, ignoreCase: ignoreCase }; - } - - function peg$classExpectation(parts, inverted, ignoreCase) { - return { type: "class", parts: parts, inverted: inverted, ignoreCase: ignoreCase }; - } - - function peg$anyExpectation() { - return { type: "any" }; - } - - function peg$endExpectation() { - return { type: "end" }; - } - - function peg$otherExpectation(description) { - return { type: "other", description: description }; - } - - function peg$computePosDetails(pos) { - var details = peg$posDetailsCache[pos]; - var p; - - if (details) { - return details; - } else { - p = pos - 1; - while (!peg$posDetailsCache[p]) { - p--; - } - - details = peg$posDetailsCache[p]; - details = { - line: details.line, - column: details.column - }; - - while (p < pos) { - if (input.charCodeAt(p) === 10) { - details.line++; - details.column = 1; - } else { - details.column++; - } - - p++; - } - - peg$posDetailsCache[pos] = details; - - return details; - } - } - - function peg$computeLocation(startPos, endPos, offset) { - var startPosDetails = peg$computePosDetails(startPos); - var endPosDetails = peg$computePosDetails(endPos); - - var res = { - source: peg$source, - start: { - offset: startPos, - line: startPosDetails.line, - column: startPosDetails.column - }, - end: { - offset: endPos, - line: endPosDetails.line, - column: endPosDetails.column - } - }; - if (offset && peg$source && (typeof peg$source.offset === "function")) { - res.start = peg$source.offset(res.start); - res.end = peg$source.offset(res.end); - } - return res; - } - - function peg$fail(expected) { - if (peg$currPos < peg$maxFailPos) { return; } - - if (peg$currPos > peg$maxFailPos) { - peg$maxFailPos = peg$currPos; - peg$maxFailExpected = []; - } - - peg$maxFailExpected.push(expected); - } - - function peg$buildSimpleError(message, location) { - return new peg$SyntaxError(message, null, null, location); - } - - function peg$buildStructuredError(expected, found, location) { - return new peg$SyntaxError( - peg$SyntaxError.buildMessage(expected, found), - expected, - found, - location - ); - } - - function peg$parsestart() { - var s0; - - s0 = peg$parsemultiple_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parsecrud_stmt(); - } - - return s0; - } - - function peg$parsecrud_stmt() { - var s0; - - s0 = peg$parseunion_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parseupdate_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parsereplace_insert_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parseinsert_no_columns_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parsedelete_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parseproc_stmts(); - } - } - } - } - } - - return s0; - } - - function peg$parsemultiple_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsecrud_stmt(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseSEMICOLON(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecrud_stmt(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseSEMICOLON(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecrud_stmt(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f0(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseunion_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseselect_stmt(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseKW_UNION(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseselect_stmt(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseKW_UNION(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseselect_stmt(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f1(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseselect_stmt() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$parseselect_stmt_nake(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 40) { - s2 = peg$c0; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e0); } - } - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseselect_stmt(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (input.charCodeAt(peg$currPos) === 41) { - s6 = peg$c1; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e1); } - } - if (s6 !== peg$FAILED) { - s2 = [s2, s3, s4, s5, s6]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f2(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parsewith_clause() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseKW_WITH(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecte_definition(); - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$currPos; - s6 = peg$parse__(); - s7 = peg$parseCOMMA(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsecte_definition(); - if (s9 !== peg$FAILED) { - s6 = [s6, s7, s8, s9]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$currPos; - s6 = peg$parse__(); - s7 = peg$parseCOMMA(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsecte_definition(); - if (s9 !== peg$FAILED) { - s6 = [s6, s7, s8, s9]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f3(s3, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parse__(); - s2 = peg$parseKW_WITH(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseKW_RECURSIVE(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parsecte_definition(); - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f4(s6); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsecte_definition() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - s1 = peg$parseident_name(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecte_column_definition(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseKW_AS(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseLPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseunion_stmt(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseRPAREN(); - if (s11 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f5(s1, s3, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecte_column_definition() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecolumn(); - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$currPos; - s6 = peg$parse__(); - s7 = peg$parseCOMMA(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsecolumn(); - if (s9 !== peg$FAILED) { - s6 = [s6, s7, s8, s9]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$currPos; - s6 = peg$parse__(); - s7 = peg$parseCOMMA(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsecolumn(); - if (s9 !== peg$FAILED) { - s6 = [s6, s7, s8, s9]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } - s5 = peg$parse__(); - s6 = peg$parseRPAREN(); - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f6(s3, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseselect_stmt_nake() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20, s21; - - s0 = peg$currPos; - s1 = peg$parsewith_clause(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseKW_SELECT(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseoption_clause(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseKW_DISTINCT(); - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parsecolumn_clause(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parsefrom_clause(); - if (s11 === peg$FAILED) { - s11 = null; - } - s12 = peg$parse__(); - s13 = peg$parsewhere_clause(); - if (s13 === peg$FAILED) { - s13 = null; - } - s14 = peg$parse__(); - s15 = peg$parsegroup_by_clause(); - if (s15 === peg$FAILED) { - s15 = null; - } - s16 = peg$parse__(); - s17 = peg$parsehaving_clause(); - if (s17 === peg$FAILED) { - s17 = null; - } - s18 = peg$parse__(); - s19 = peg$parseorder_by_clause(); - if (s19 === peg$FAILED) { - s19 = null; - } - s20 = peg$parse__(); - s21 = peg$parselimit_clause(); - if (s21 === peg$FAILED) { - s21 = null; - } - peg$savedPos = s0; - s0 = peg$f7(s1, s5, s7, s9, s11, s13, s15, s17, s19, s21); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseoption_clause() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsequery_option(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsequery_option(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsequery_option(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f8(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsequery_option() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseOPT_SQL_CALC_FOUND_ROWS(); - if (s1 === peg$FAILED) { - s1 = peg$parseOPT_SQL_CACHE(); - if (s1 === peg$FAILED) { - s1 = peg$parseOPT_SQL_NO_CACHE(); - } - if (s1 === peg$FAILED) { - s1 = peg$parseOPT_SQL_BIG_RESULT(); - if (s1 === peg$FAILED) { - s1 = peg$parseOPT_SQL_SMALL_RESULT(); - if (s1 === peg$FAILED) { - s1 = peg$parseOPT_SQL_BUFFER_RESULT(); - } - } - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f9(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsecolumn_clause() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_ALL(); - if (s1 === peg$FAILED) { - s1 = peg$currPos; - s2 = peg$parseSTAR(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - s4 = peg$parseident_start(); - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = undefined; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 === peg$FAILED) { - s1 = peg$parseSTAR(); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f10(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsecolumn_list_item(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn_list_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn_list_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f11(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsecolumn_list_item() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseDOT(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseSTAR(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f12(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseexpr(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsealias_clause(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f13(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsealias_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_AS(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsealias_ident(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f14(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_AS(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseident(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f15(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsefrom_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_FROM(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsetable_ref_list(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f16(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetable_ref_list() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsetable_base(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsetable_ref(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsetable_ref(); - } - peg$savedPos = s0; - s0 = peg$f17(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetable_ref() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parse__(); - s2 = peg$parseCOMMA(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parsetable_base(); - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f18(s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parse__(); - s2 = peg$parsetable_join(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f19(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsetable_join() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15; - - s0 = peg$currPos; - s1 = peg$parsejoin_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsetable_base(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseKW_USING(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseLPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseident_name(); - if (s9 !== peg$FAILED) { - s10 = []; - s11 = peg$currPos; - s12 = peg$parse__(); - s13 = peg$parseCOMMA(); - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - s15 = peg$parseident_name(); - if (s15 !== peg$FAILED) { - s12 = [s12, s13, s14, s15]; - s11 = s12; - } else { - peg$currPos = s11; - s11 = peg$FAILED; - } - } else { - peg$currPos = s11; - s11 = peg$FAILED; - } - while (s11 !== peg$FAILED) { - s10.push(s11); - s11 = peg$currPos; - s12 = peg$parse__(); - s13 = peg$parseCOMMA(); - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - s15 = peg$parseident_name(); - if (s15 !== peg$FAILED) { - s12 = [s12, s13, s14, s15]; - s11 = s12; - } else { - peg$currPos = s11; - s11 = peg$FAILED; - } - } else { - peg$currPos = s11; - s11 = peg$FAILED; - } - } - s11 = peg$parse__(); - s12 = peg$parseRPAREN(); - if (s12 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f20(s1, s3, s9, s10); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsejoin_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsetable_base(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseon_clause(); - if (s5 === peg$FAILED) { - s5 = null; - } - peg$savedPos = s0; - s0 = peg$f21(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsejoin_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseunion_stmt(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsealias_clause(); - if (s9 === peg$FAILED) { - s9 = null; - } - s10 = peg$parse__(); - s11 = peg$parseon_clause(); - if (s11 === peg$FAILED) { - s11 = null; - } - peg$savedPos = s0; - s0 = peg$f22(s1, s5, s9, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - - return s0; - } - - function peg$parsetable_base() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_DUAL(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f23(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsetable_name(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsealias_clause(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f24(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseunion_stmt(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsealias_clause(); - if (s7 === peg$FAILED) { - s7 = null; - } - peg$savedPos = s0; - s0 = peg$f25(s3, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - - return s0; - } - - function peg$parsejoin_op() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_LEFT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_OUTER(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseKW_JOIN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f26(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_RIGHT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_OUTER(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseKW_JOIN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f27(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_FULL(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_OUTER(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseKW_JOIN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f28(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_INNER(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parseKW_JOIN(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f29(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - - return s0; - } - - function peg$parsetable_name() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$parse__(); - s4 = peg$parseDOT(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parseident(); - if (s6 !== peg$FAILED) { - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 === peg$FAILED) { - s2 = null; - } - peg$savedPos = s0; - s0 = peg$f30(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsevar_decl(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f31(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parseon_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_ON(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseexpr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f32(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsewhere_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_WHERE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseexpr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f33(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsegroup_by_clause() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_GROUP(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_BY(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsecolumn_ref_list(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f34(s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecolumn_ref_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsecolumn_ref(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn_ref(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn_ref(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f35(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsehaving_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_HAVING(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseexpr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f36(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseorder_by_clause() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_ORDER(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_BY(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseorder_by_list(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f37(s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseorder_by_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseorder_by_element(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseorder_by_element(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseorder_by_element(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f38(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseorder_by_element() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseexpr(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_DESC(); - if (s3 === peg$FAILED) { - s3 = peg$parseKW_ASC(); - } - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f39(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsenumber_or_param() { - var s0; - - s0 = peg$parseliteral_numeric(); - if (s0 === peg$FAILED) { - s0 = peg$parseparam(); - } - - return s0; - } - - function peg$parselimit_clause() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - s1 = peg$parseKW_LIMIT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsenumber_or_param(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$currPos; - s6 = peg$parseCOMMA(); - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - s8 = peg$parsenumber_or_param(); - if (s8 !== peg$FAILED) { - s6 = [s6, s7, s8]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - if (s5 === peg$FAILED) { - s5 = null; - } - peg$savedPos = s0; - s0 = peg$f40(s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseupdate_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseKW_UPDATE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsetable_name(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseKW_SET(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseset_list(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsewhere_clause(); - if (s9 === peg$FAILED) { - s9 = null; - } - peg$savedPos = s0; - s0 = peg$f41(s3, s7, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsedelete_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_DELETE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsetable_ref_list(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parsefrom_clause(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsewhere_clause(); - if (s7 === peg$FAILED) { - s7 = null; - } - peg$savedPos = s0; - s0 = peg$f42(s3, s5, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseset_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseset_item(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseset_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseset_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f43(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseset_item() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseident(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseDOT(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parsecolumn_name(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (input.charCodeAt(peg$currPos) === 61) { - s5 = peg$c2; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e2); } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseadditive_expr(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f44(s1, s3, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsereplace_insert_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; - - s0 = peg$currPos; - s1 = peg$parsereplace_insert(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_INTO(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsetable_name(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseLPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsecolumn_list(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseRPAREN(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - s13 = peg$parsevalue_clause(); - if (s13 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f45(s1, s5, s9, s13); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseinsert_no_columns_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsereplace_insert(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_INTO(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsetable_name(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsevalue_clause(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f46(s1, s5, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsereplace_insert() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_INSERT(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f47(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_REPLACE(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f48(); - } - s0 = s1; - } - - return s0; - } - - function peg$parsevalue_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_VALUES(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsevalue_list(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f49(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsevalue_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsevalue_item(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsevalue_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsevalue_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f50(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsevalue_item() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseexpr_list(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f51(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexpr_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseexpr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseexpr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseexpr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f52(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseinterval_expr() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_INTERVAL(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsenumber(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseinterval_unit(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f53(s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecase_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - s1 = peg$parseKW_CASE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseexpr(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = []; - s6 = peg$parsecase_when_then(); - if (s6 !== peg$FAILED) { - while (s6 !== peg$FAILED) { - s5.push(s6); - s6 = peg$parsecase_when_then(); - } - } else { - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecase_else(); - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parseKW_END(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseKW_CASE(); - if (s11 === peg$FAILED) { - s11 = null; - } - peg$savedPos = s0; - s0 = peg$f54(s3, s5, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecase_when_then() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - s1 = peg$parseKW_WHEN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseexpr(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseKW_THEN(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseexpr(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - peg$savedPos = s0; - s0 = peg$f55(s3, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecase_else() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_ELSE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseexpr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f56(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexpr() { - var s0; - - s0 = peg$parseor_expr(); - if (s0 === peg$FAILED) { - s0 = peg$parseselect_stmt(); - } - - return s0; - } - - function peg$parseor_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseand_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseKW_OR(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseand_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseKW_OR(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseand_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f57(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseand_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsenot_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseKW_AND(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsenot_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseKW_AND(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsenot_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f58(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsenot_expr() { - var s0, s1, s2, s3, s4; - - s0 = peg$parsecomparison_expr(); - if (s0 === peg$FAILED) { - s0 = peg$parseexists_expr(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_NOT(); - if (s1 === peg$FAILED) { - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 33) { - s2 = peg$c3; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e3); } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s4 = peg$c2; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e2); } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = undefined; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsenot_expr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f59(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - - return s0; - } - - function peg$parsecomparison_expr() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseadditive_expr(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecomparison_op_right(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f60(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexists_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseexists_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseunion_stmt(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f61(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexists_op() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_NOT(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseKW_EXISTS(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f62(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parseKW_EXISTS(); - } - - return s0; - } - - function peg$parsecomparison_op_right() { - var s0; - - s0 = peg$parsearithmetic_op_right(); - if (s0 === peg$FAILED) { - s0 = peg$parsein_op_right(); - if (s0 === peg$FAILED) { - s0 = peg$parsebetween_op_right(); - if (s0 === peg$FAILED) { - s0 = peg$parseis_op_right(); - if (s0 === peg$FAILED) { - s0 = peg$parselike_op_right(); - } - } - } - } - - return s0; - } - - function peg$parsearithmetic_op_right() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = []; - s2 = peg$currPos; - s3 = peg$parse__(); - s4 = peg$parsearithmetic_comparison_operator(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parseadditive_expr(); - if (s6 !== peg$FAILED) { - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$currPos; - s3 = peg$parse__(); - s4 = peg$parsearithmetic_comparison_operator(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parseadditive_expr(); - if (s6 !== peg$FAILED) { - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f63(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsearithmetic_comparison_operator() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c4) { - s0 = peg$c4; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e4); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 62) { - s0 = peg$c5; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e5); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c6) { - s0 = peg$c6; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e6); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c7) { - s0 = peg$c7; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e7); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 60) { - s0 = peg$c8; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e8); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 61) { - s0 = peg$c2; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e2); } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c9) { - s0 = peg$c9; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e9); } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parseis_op_right() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parseKW_IS(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseadditive_expr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f64(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_IS(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseKW_NOT(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseadditive_expr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f65(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsebetween_op_right() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsebetween_or_not_between_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseadditive_expr(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseKW_AND(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseadditive_expr(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f66(s1, s3, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsebetween_or_not_between_op() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_NOT(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseKW_BETWEEN(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f67(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parseKW_BETWEEN(); - } - - return s0; - } - - function peg$parselike_op() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_NOT(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseKW_LIKE(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f68(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parseKW_LIKE(); - } - - return s0; - } - - function peg$parsein_op() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_NOT(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseKW_IN(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f69(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parseKW_IN(); - } - - return s0; - } - - function peg$parselike_op_right() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parselike_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecomparison_expr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f70(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsein_op_right() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsein_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr_list(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f71(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsein_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsevar_decl(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f72(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parseadditive_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsemultiplicative_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseadditive_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsemultiplicative_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseadditive_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsemultiplicative_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f73(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseadditive_operator() { - var s0; - - if (input.charCodeAt(peg$currPos) === 43) { - s0 = peg$c10; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e10); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 45) { - s0 = peg$c11; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e11); } - } - } - - return s0; - } - - function peg$parsemultiplicative_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseprimary(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsemultiplicative_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseprimary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsemultiplicative_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseprimary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f74(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsemultiplicative_operator() { - var s0; - - if (input.charCodeAt(peg$currPos) === 42) { - s0 = peg$c12; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e12); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 47) { - s0 = peg$c13; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e13); } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 37) { - s0 = peg$c14; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e14); } - } - } - } - - return s0; - } - - function peg$parseprimary() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$parseliteral(); - if (s0 === peg$FAILED) { - s0 = peg$parsecast_expr(); - if (s0 === peg$FAILED) { - s0 = peg$parseaggr_func(); - if (s0 === peg$FAILED) { - s0 = peg$parsefunc_call(); - if (s0 === peg$FAILED) { - s0 = peg$parsecase_expr(); - if (s0 === peg$FAILED) { - s0 = peg$parseinterval_expr(); - if (s0 === peg$FAILED) { - s0 = peg$parsecolumn_ref(); - if (s0 === peg$FAILED) { - s0 = peg$parseparam(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseexpr(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f75(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseexpr_list(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f76(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$parsevar_decl(); - } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parsecolumn_ref() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseDOT(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsecolumn(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f77(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsecolumn(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f78(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parsecolumn_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsecolumn(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f79(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseident() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parseident_name(); - if (s1 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s2 = peg$f80(s1); - if (s2) { - s2 = peg$FAILED; - } else { - s2 = undefined; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f81(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsequoted_ident(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f82(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parsealias_ident() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parseident_name(); - if (s1 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s2 = peg$f83(s1); - if (s2) { - s2 = peg$FAILED; - } else { - s2 = undefined; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f84(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsequoted_ident(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f85(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parsequoted_ident() { - var s0; - - s0 = peg$parsedouble_quoted_ident(); - if (s0 === peg$FAILED) { - s0 = peg$parsesingle_quoted_ident(); - if (s0 === peg$FAILED) { - s0 = peg$parsebackticks_quoted_ident(); - } - } - - return s0; - } - - function peg$parsedouble_quoted_ident() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { - s1 = peg$c15; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e15); } - } - if (s1 !== peg$FAILED) { - s2 = []; - if (peg$r0.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e16); } - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - if (peg$r0.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e16); } - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 34) { - s3 = peg$c15; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e15); } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f86(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsesingle_quoted_ident() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { - s1 = peg$c16; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } - } - if (s1 !== peg$FAILED) { - s2 = []; - if (peg$r1.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e18); } - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - if (peg$r1.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e18); } - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 39) { - s3 = peg$c16; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f87(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsebackticks_quoted_ident() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 96) { - s1 = peg$c17; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e19); } - } - if (s1 !== peg$FAILED) { - s2 = []; - if (peg$r2.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e20); } - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - if (peg$r2.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e20); } - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 96) { - s3 = peg$c17; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e19); } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f88(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecolumn() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parsecolumn_name(); - if (s1 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s2 = peg$f89(s1); - if (s2) { - s2 = peg$FAILED; - } else { - s2 = undefined; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f90(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$parsequoted_ident(); - } - - return s0; - } - - function peg$parsecolumn_name() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseident_start(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsecolumn_part(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsecolumn_part(); - } - peg$savedPos = s0; - s0 = peg$f91(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseident_name() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseident_start(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parseident_part(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parseident_part(); - } - peg$savedPos = s0; - s0 = peg$f92(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseident_start() { - var s0; - - if (peg$r3.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e21); } - } - - return s0; - } - - function peg$parseident_part() { - var s0; - - if (peg$r4.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e22); } - } - - return s0; - } - - function peg$parsecolumn_part() { - var s0; - - if (peg$r5.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e23); } - } - - return s0; - } - - function peg$parseparam() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 58) { - s2 = peg$c18; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e24); } - } - if (s2 !== peg$FAILED) { - s3 = peg$parseident_name(); - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f93(s1); - } - s0 = s1; - - return s0; - } - - function peg$parseaggr_func() { - var s0; - - s0 = peg$parseaggr_fun_count(); - if (s0 === peg$FAILED) { - s0 = peg$parseaggr_fun_smma(); - } - - return s0; - } - - function peg$parseaggr_fun_smma() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_SUM_MAX_MIN_AVG(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseadditive_expr(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f94(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SUM_MAX_MIN_AVG() { - var s0; - - s0 = peg$parseKW_SUM(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_MAX(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_MIN(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_AVG(); - } - } - } - - return s0; - } - - function peg$parseaggr_fun_count() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_COUNT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsecount_arg(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f95(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecount_arg() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsestar_expr(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f96(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_DISTINCT(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parsecolumn_ref(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f97(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsestar_expr() { - var s0, s1; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 42) { - s1 = peg$c12; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e12); } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f98(); - } - s0 = s1; - - return s0; - } - - function peg$parsefunc_call() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr_list(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f99(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsescalar_func(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$parse__(); - s4 = peg$parseLPAREN(); - if (s4 !== peg$FAILED) { - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 === peg$FAILED) { - s2 = null; - } - peg$savedPos = s0; - s0 = peg$f100(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsescalar_func() { - var s0; - - s0 = peg$parseKW_CURRENT_DATE(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_CURRENT_TIME(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_CURRENT_TIMESTAMP(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_CURRENT_USER(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_USER(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_SESSION_USER(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_SYSTEM_USER(); - } - } - } - } - } - } - - return s0; - } - - function peg$parsecast_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20, s21; - - s0 = peg$currPos; - s1 = peg$parseKW_CAST(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseKW_AS(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsedata_type(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseRPAREN(); - if (s11 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f101(s5, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_CAST(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseKW_AS(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseKW_DECIMAL(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseLPAREN(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - s13 = peg$parseint(); - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - s15 = peg$parseRPAREN(); - if (s15 !== peg$FAILED) { - s16 = peg$parse__(); - s17 = peg$parseRPAREN(); - if (s17 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f102(s5, s13); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_CAST(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseKW_AS(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseKW_DECIMAL(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseLPAREN(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - s13 = peg$parseint(); - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - s15 = peg$parseCOMMA(); - if (s15 !== peg$FAILED) { - s16 = peg$parse__(); - s17 = peg$parseint(); - if (s17 !== peg$FAILED) { - s18 = peg$parse__(); - s19 = peg$parseRPAREN(); - if (s19 !== peg$FAILED) { - s20 = peg$parse__(); - s21 = peg$parseRPAREN(); - if (s21 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f103(s5, s13, s17); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_CAST(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseKW_AS(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsesignedness(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseKW_INTEGER(); - if (s11 === peg$FAILED) { - s11 = null; - } - s12 = peg$parse__(); - s13 = peg$parseRPAREN(); - if (s13 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f104(s5, s9, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - - return s0; - } - - function peg$parsesignedness() { - var s0; - - s0 = peg$parseKW_SIGNED(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_UNSIGNED(); - } - - return s0; - } - - function peg$parseliteral() { - var s0; - - s0 = peg$parseliteral_string(); - if (s0 === peg$FAILED) { - s0 = peg$parseliteral_numeric(); - if (s0 === peg$FAILED) { - s0 = peg$parseliteral_bool(); - if (s0 === peg$FAILED) { - s0 = peg$parseliteral_null(); - if (s0 === peg$FAILED) { - s0 = peg$parseliteral_datetime(); - } - } - } - } - - return s0; - } - - function peg$parseliteral_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseliteral(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseliteral(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseliteral(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f105(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseliteral_null() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_NULL(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f106(); - } - s0 = s1; - - return s0; - } - - function peg$parseliteral_bool() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_TRUE(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f107(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_FALSE(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f108(); - } - s0 = s1; - } - - return s0; - } - - function peg$parseliteral_string() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { - s2 = peg$c16; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } - } - if (s2 !== peg$FAILED) { - s3 = []; - s4 = peg$parsesingle_char(); - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parsesingle_char(); - } - if (input.charCodeAt(peg$currPos) === 39) { - s4 = peg$c16; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } - } - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f109(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { - s2 = peg$c15; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e15); } - } - if (s2 !== peg$FAILED) { - s3 = []; - s4 = peg$parsesingle_quote_char(); - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parsesingle_quote_char(); - } - if (input.charCodeAt(peg$currPos) === 34) { - s4 = peg$c15; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e15); } - } - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f110(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parseliteral_datetime() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parseKW_TIME(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DATE(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_TIMESTAMP(); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { - s4 = peg$c16; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } - } - if (s4 !== peg$FAILED) { - s5 = []; - s6 = peg$parsesingle_char(); - while (s6 !== peg$FAILED) { - s5.push(s6); - s6 = peg$parsesingle_char(); - } - if (input.charCodeAt(peg$currPos) === 39) { - s6 = peg$c16; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e17); } - } - if (s6 !== peg$FAILED) { - s4 = [s4, s5, s6]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f111(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsesingle_quote_char() { - var s0; - - if (peg$r6.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e25); } - } - if (s0 === peg$FAILED) { - s0 = peg$parseescape_char(); - } - - return s0; - } - - function peg$parsesingle_char() { - var s0; - - if (peg$r7.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e26); } - } - if (s0 === peg$FAILED) { - s0 = peg$parseescape_char(); - } - - return s0; - } - - function peg$parseescape_char() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c19) { - s1 = peg$c19; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e27); } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f112(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c20) { - s1 = peg$c20; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e28); } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f113(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c21) { - s1 = peg$c21; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e29); } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f114(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c22) { - s1 = peg$c22; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e30); } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f115(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c23) { - s1 = peg$c23; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e31); } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f116(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c24) { - s1 = peg$c24; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e32); } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f117(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c25) { - s1 = peg$c25; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e33); } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f118(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c26) { - s1 = peg$c26; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e34); } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f119(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c27) { - s1 = peg$c27; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e35); } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f120(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c28) { - s1 = peg$c28; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e36); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsehexDigit(); - if (s2 !== peg$FAILED) { - s3 = peg$parsehexDigit(); - if (s3 !== peg$FAILED) { - s4 = peg$parsehexDigit(); - if (s4 !== peg$FAILED) { - s5 = peg$parsehexDigit(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f121(s2, s3, s4, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parseline_terminator() { - var s0; - - if (peg$r8.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e37); } - } - - return s0; - } - - function peg$parseliteral_numeric() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parsenumber(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f122(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsenumber() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parseint(); - if (s1 !== peg$FAILED) { - s2 = peg$parsefrac(); - if (s2 !== peg$FAILED) { - s3 = peg$parseexp(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - peg$savedPos = s0; - s0 = peg$f123(s1, s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseint(); - if (s1 !== peg$FAILED) { - s2 = peg$parsefrac(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - peg$savedPos = s0; - s0 = peg$f124(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseint(); - if (s1 !== peg$FAILED) { - s2 = peg$parseexp(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - peg$savedPos = s0; - s0 = peg$f125(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseint(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - peg$savedPos = s0; - s0 = peg$f126(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - - return s0; - } - - function peg$parseint() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsedigit19(); - if (s1 !== peg$FAILED) { - s2 = peg$parsedigits(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f127(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$parsedigit(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 45) { - s1 = peg$c11; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e11); } - } - if (s1 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 43) { - s1 = peg$c10; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e10); } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsedigit19(); - if (s2 !== peg$FAILED) { - s3 = peg$parsedigits(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f128(s1, s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 45) { - s1 = peg$c11; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e11); } - } - if (s1 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 43) { - s1 = peg$c10; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e10); } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsedigit(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f129(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - - return s0; - } - - function peg$parsefrac() { - var s0, s1, s2; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 46) { - s1 = peg$c29; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e38); } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsedigits(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f130(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexp() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parsee(); - if (s1 !== peg$FAILED) { - s2 = peg$parsedigits(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f131(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsedigits() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = []; - s2 = peg$parsedigit(); - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$parsedigit(); - } - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f132(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsedigit() { - var s0; - - if (peg$r9.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e39); } - } - - return s0; - } - - function peg$parsedigit19() { - var s0; - - if (peg$r10.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e40); } - } - - return s0; - } - - function peg$parsehexDigit() { - var s0; - - if (peg$r11.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e41); } - } - - return s0; - } - - function peg$parsee() { - var s0, s1, s2; - - s0 = peg$currPos; - if (peg$r12.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e42); } - } - if (s1 !== peg$FAILED) { - if (peg$r13.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e43); } - } - if (s2 === peg$FAILED) { - s2 = null; - } - peg$savedPos = s0; - s0 = peg$f133(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_NULL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c30) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e44); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TRUE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c31) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e45); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_FALSE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c32) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e46); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SHOW() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c33) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e47); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DROP() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c34) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e48); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SELECT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c35) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e49); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UPDATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c36) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e50); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CREATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c37) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e51); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DELETE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c38) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e52); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_INSERT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c39) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e53); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_RECURSIVE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9) === peg$c40) { - s1 = peg$c40; - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e54); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REPLACE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c41) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e55); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_EXPLAIN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c42) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e56); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_INTO() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c43) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e57); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_FROM() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c44) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e58); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SET() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c45) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e59); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_AS() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c46) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e60); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TABLE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c47) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e61); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ON() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c48) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e62); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_LEFT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c49) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e63); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_RIGHT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c50) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e64); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_FULL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c51) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e65); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_INNER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c52) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e66); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_JOIN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c53) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e67); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_OUTER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c54) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e68); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNION() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c55) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e69); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_VALUES() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c56) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e70); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_USING() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c57) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e71); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_WHERE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c58) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e72); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_WITH() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c59) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e73); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_GROUP() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c60) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e74); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_BY() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c61) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e75); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ORDER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c62) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e76); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_HAVING() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c63) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e77); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_LIMIT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c64) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e78); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ASC() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c65) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e79); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f134(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DESC() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c66) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e80); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f135(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ALL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c67) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e81); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f136(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DISTINCT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c68) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e82); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f137(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_BETWEEN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c69) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e83); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f138(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_IN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c70) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e84); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f139(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_IS() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c71) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e85); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f140(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_LIKE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c72) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e86); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f141(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_EXISTS() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c73) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e87); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f142(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_NOT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c74) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e88); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f143(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_AND() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c75) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e89); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f144(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_OR() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c76) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e90); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f145(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_COUNT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c77) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e91); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f146(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_MAX() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c78) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e92); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f147(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_MIN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c79) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e93); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f148(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SUM() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c80) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e94); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f149(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_AVG() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c81) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e95); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f150(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CASE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c82) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e96); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_WHEN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c83) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e97); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_THEN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c84) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e98); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ELSE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c85) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e99); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_END() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c86) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e100); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CAST() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c87) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e101); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CHAR() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c88) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e102); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f151(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_VARCHAR() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c89) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e103); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f152(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_NUMERIC() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c90) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e104); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f153(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DECIMAL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c91) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e105); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f154(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SIGNED() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c92) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e106); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f155(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNSIGNED() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c93) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e107); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f156(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_INT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c94) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e108); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f157(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_INTEGER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c95) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e109); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f158(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_JSON() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c96) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e110); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f159(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SMALLINT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c97) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e111); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f160(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c98) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e112); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f161(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TIME() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c99) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e113); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f162(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TIMESTAMP() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c100) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e114); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f163(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_USER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c101) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e115); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f164(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CURRENT_DATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c102) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e116); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f165(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ADD_DATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c103) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e117); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f166(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_INTERVAL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c104) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e118); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f167(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNIT_YEAR() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c105) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e119); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f168(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNIT_MONTH() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c106) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e120); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f169(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNIT_DAY() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c107) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e121); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f170(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNIT_HOUR() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c108) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e122); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f171(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNIT_MINUTE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c109) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e123); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f172(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNIT_SECOND() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c110) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e124); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f173(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CURRENT_TIME() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c111) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e125); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f174(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CURRENT_TIMESTAMP() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 17).toLowerCase() === peg$c112) { - s1 = input.substr(peg$currPos, 17); - peg$currPos += 17; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e126); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f175(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CURRENT_USER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c113) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e127); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f176(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SESSION_USER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c114) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e128); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f177(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SYSTEM_USER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 11).toLowerCase() === peg$c115) { - s1 = input.substr(peg$currPos, 11); - peg$currPos += 11; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e129); } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f178(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_VAR_PRE() { - var s0; - - if (input.charCodeAt(peg$currPos) === 36) { - s0 = peg$c116; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e130); } - } - - return s0; - } - - function peg$parseKW_RETURN() { - var s0; - - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c117) { - s0 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e131); } - } - - return s0; - } - - function peg$parseKW_ASSIGN() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c118) { - s0 = peg$c118; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e132); } - } - - return s0; - } - - function peg$parseKW_DUAL() { - var s0; - - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c119) { - s0 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e133); } - } - - return s0; - } - - function peg$parseOPT_SQL_CALC_FOUND_ROWS() { - var s0; - - if (input.substr(peg$currPos, 19).toLowerCase() === peg$c120) { - s0 = input.substr(peg$currPos, 19); - peg$currPos += 19; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e134); } - } - - return s0; - } - - function peg$parseOPT_SQL_CACHE() { - var s0; - - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c121) { - s0 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e135); } - } - - return s0; - } - - function peg$parseOPT_SQL_NO_CACHE() { - var s0; - - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c122) { - s0 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e136); } - } - - return s0; - } - - function peg$parseOPT_SQL_SMALL_RESULT() { - var s0; - - if (input.substr(peg$currPos, 16).toLowerCase() === peg$c123) { - s0 = input.substr(peg$currPos, 16); - peg$currPos += 16; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e137); } - } - - return s0; - } - - function peg$parseOPT_SQL_BIG_RESULT() { - var s0; - - if (input.substr(peg$currPos, 14).toLowerCase() === peg$c124) { - s0 = input.substr(peg$currPos, 14); - peg$currPos += 14; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e138); } - } - - return s0; - } - - function peg$parseOPT_SQL_BUFFER_RESULT() { - var s0; - - if (input.substr(peg$currPos, 17).toLowerCase() === peg$c125) { - s0 = input.substr(peg$currPos, 17); - peg$currPos += 17; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e139); } - } - - return s0; - } - - function peg$parseDOT() { - var s0; - - if (input.charCodeAt(peg$currPos) === 46) { - s0 = peg$c29; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e38); } - } - - return s0; - } - - function peg$parseCOMMA() { - var s0; - - if (input.charCodeAt(peg$currPos) === 44) { - s0 = peg$c126; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e140); } - } - - return s0; - } - - function peg$parseSTAR() { - var s0; - - if (input.charCodeAt(peg$currPos) === 42) { - s0 = peg$c12; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e12); } - } - - return s0; - } - - function peg$parseLPAREN() { - var s0; - - if (input.charCodeAt(peg$currPos) === 40) { - s0 = peg$c0; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e0); } - } - - return s0; - } - - function peg$parseRPAREN() { - var s0; - - if (input.charCodeAt(peg$currPos) === 41) { - s0 = peg$c1; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e1); } - } - - return s0; - } - - function peg$parseLBRAKE() { - var s0; - - if (input.charCodeAt(peg$currPos) === 91) { - s0 = peg$c127; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e141); } - } - - return s0; - } - - function peg$parseRBRAKE() { - var s0; - - if (input.charCodeAt(peg$currPos) === 93) { - s0 = peg$c128; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e142); } - } - - return s0; - } - - function peg$parseSEMICOLON() { - var s0; - - if (input.charCodeAt(peg$currPos) === 59) { - s0 = peg$c129; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e143); } - } - - return s0; - } - - function peg$parse__() { - var s0, s1; - - s0 = []; - s1 = peg$parsewhitespace(); - if (s1 === peg$FAILED) { - s1 = peg$parsecomment(); - } - while (s1 !== peg$FAILED) { - s0.push(s1); - s1 = peg$parsewhitespace(); - if (s1 === peg$FAILED) { - s1 = peg$parsecomment(); - } - } - - return s0; - } - - function peg$parsecomment() { - var s0; - - s0 = peg$parseblock_comment(); - if (s0 === peg$FAILED) { - s0 = peg$parseline_comment(); - } - - return s0; - } - - function peg$parseblock_comment() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c130) { - s1 = peg$c130; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e144); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - if (input.substr(peg$currPos, 2) === peg$c131) { - s5 = peg$c131; - peg$currPos += 2; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e145); } - } - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = undefined; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - s5 = peg$parsechar(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - if (input.substr(peg$currPos, 2) === peg$c131) { - s5 = peg$c131; - peg$currPos += 2; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e145); } - } - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = undefined; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - s5 = peg$parsechar(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - if (input.substr(peg$currPos, 2) === peg$c131) { - s3 = peg$c131; - peg$currPos += 2; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e145); } - } - if (s3 !== peg$FAILED) { - s1 = [s1, s2, s3]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseline_comment() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c132) { - s1 = peg$c132; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e146); } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parseEOL(); - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = undefined; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - s5 = peg$parsechar(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parseEOL(); - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = undefined; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - s5 = peg$parsechar(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsechar() { - var s0; - - if (input.length > peg$currPos) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e147); } - } - - return s0; - } - - function peg$parseinterval_unit() { - var s0; - - s0 = peg$parseKW_UNIT_YEAR(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_UNIT_MONTH(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_UNIT_DAY(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_UNIT_HOUR(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_UNIT_MINUTE(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_UNIT_SECOND(); - } - } - } - } - } - - return s0; - } - - function peg$parsewhitespace() { - var s0; - - if (peg$r14.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e148); } - } - - return s0; - } - - function peg$parseEOL() { - var s0, s1; - - s0 = peg$parseEOF(); - if (s0 === peg$FAILED) { - s0 = []; - if (peg$r8.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e37); } - } - if (s1 !== peg$FAILED) { - while (s1 !== peg$FAILED) { - s0.push(s1); - if (peg$r8.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e37); } - } - } - } else { - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parseEOF() { - var s0, s1; - - s0 = peg$currPos; - peg$silentFails++; - if (input.length > peg$currPos) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e147); } - } - peg$silentFails--; - if (s1 === peg$FAILED) { - s0 = undefined; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseproc_stmts() { - var s0, s1; - - s0 = []; - s1 = peg$parseproc_stmt(); - while (s1 !== peg$FAILED) { - s0.push(s1); - s1 = peg$parseproc_stmt(); - } - - return s0; - } - - function peg$parseproc_stmt() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - peg$savedPos = peg$currPos; - s1 = peg$f179(); - if (s1) { - s1 = undefined; - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseassign_stmt(); - if (s3 === peg$FAILED) { - s3 = peg$parsereturn_stmt(); - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f180(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseassign_stmt() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsevar_decl(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ASSIGN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseproc_expr(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f181(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsereturn_stmt() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_RETURN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseproc_expr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f182(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseproc_expr() { - var s0; - - s0 = peg$parseselect_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parseproc_join(); - if (s0 === peg$FAILED) { - s0 = peg$parseproc_additive_expr(); - if (s0 === peg$FAILED) { - s0 = peg$parseproc_array(); - } - } - } - - return s0; - } - - function peg$parseproc_additive_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseproc_multiplicative_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseadditive_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseproc_multiplicative_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseadditive_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseproc_multiplicative_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f183(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseproc_multiplicative_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseproc_primary(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsemultiplicative_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseproc_primary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsemultiplicative_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseproc_primary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f184(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseproc_join() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsevar_decl(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsejoin_op(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsevar_decl(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseon_clause(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f185(s1, s3, s5, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseproc_primary() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$parseliteral(); - if (s0 === peg$FAILED) { - s0 = peg$parsevar_decl(); - if (s0 === peg$FAILED) { - s0 = peg$parseproc_func_call(); - if (s0 === peg$FAILED) { - s0 = peg$parseparam(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseproc_additive_expr(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f186(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - } - - return s0; - } - - function peg$parseproc_func_call() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseproc_primary_list(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f187(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseproc_primary_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseproc_primary(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseproc_primary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseproc_primary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f188(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseproc_array() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseLBRAKE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseproc_primary_list(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRBRAKE(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f189(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsevar_decl() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_VAR_PRE(); - if (s1 !== peg$FAILED) { - s2 = peg$parseident_name(); - if (s2 !== peg$FAILED) { - s3 = peg$parsemem_chain(); - peg$savedPos = s0; - s0 = peg$f190(s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsemem_chain() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = []; - s2 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 46) { - s3 = peg$c29; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e38); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parseident_name(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 46) { - s3 = peg$c29; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e38); } - } - if (s3 !== peg$FAILED) { - s4 = peg$parseident_name(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } - peg$savedPos = s0; - s1 = peg$f191(s1); - s0 = s1; - - return s0; - } - - function peg$parsedata_type() { - var s0; - - s0 = peg$parsecharacter_string_type(); - if (s0 === peg$FAILED) { - s0 = peg$parsenumeric_type(); - if (s0 === peg$FAILED) { - s0 = peg$parsedatetime_type(); - if (s0 === peg$FAILED) { - s0 = peg$parsejson_type(); - } - } - } - - return s0; - } - - function peg$parsecharacter_string_type() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - s1 = peg$parseKW_CHAR(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_VARCHAR(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = []; - if (peg$r9.test(input.charAt(peg$currPos))) { - s6 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e39); } - } - if (s6 !== peg$FAILED) { - while (s6 !== peg$FAILED) { - s5.push(s6); - if (peg$r9.test(input.charAt(peg$currPos))) { - s6 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { peg$fail(peg$e39); } - } - } - } else { - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - peg$savedPos = s0; - s0 = peg$f192(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_CHAR(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f193(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_VARCHAR(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f194(s1); - } - s0 = s1; - } - } - - return s0; - } - - function peg$parsenumeric_type() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_NUMERIC(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DECIMAL(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_INT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_INTEGER(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_SMALLINT(); - } - } - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f195(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsedatetime_type() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_DATE(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_TIME(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_TIMESTAMP(); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f196(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsejson_type() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_JSON(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f197(s1); - } - s0 = s1; - - return s0; - } - - - const reservedMap = { - 'ALL': true, - 'AND': true, - 'AS': true, - 'ASC': true, - - 'BETWEEN': true, - 'BY': true, - - 'CASE': true, - 'CREATE': true, - 'CONTAINS': true, - 'CURRENT_DATE': true, - 'CURRENT_TIME': true, - 'CURRENT_TIMESTAMP': true, - 'CURRENT_USER': true, - - 'DELETE': true, - 'DESC': true, - 'DISTINCT': true, - 'DROP': true, - - 'ELSE': true, - 'END': true, - 'EXISTS': true, - 'EXPLAIN': true, - - 'FALSE': true, - 'FROM': true, - 'FULL': true, - - 'GROUP': true, - - 'HAVING': true, - - 'IN': true, - 'INDEX': true, - 'INNER': true, - 'INSERT': true, - 'INTO': true, - 'IS': true, - - 'JOIN': true, - 'JSON': true, - - 'LEFT': true, - 'LIKE': true, - 'LIMIT': true, - - 'NOT': true, - 'NULL': true, - - 'ON': true, - 'OR': true, - 'ORDER': true, - 'OUTER': true, - - 'RECURSIVE': true, - 'REPLACE': true, - 'RIGHT': true, - - 'SELECT': true, - 'SESSION_USER': true, - 'SET': true, - 'SHOW': true, - 'STATUS': true, // reserved (MySQL) - 'SYSTEM_USER': true, - - 'TABLE': true, - 'THEN': true, - 'TRUE': true, - 'TYPE': true, // reserved (MySQL) - - 'UNION': true, - 'UPDATE': true, - 'USER': true, - 'USING': true, - - 'VALUES': true, - - 'WITH': true, - 'WHEN': true, - 'WHERE': true - }; - - function createUnaryExpr(op, e) { - return { - type: 'unary_expr', - operator: op, - expr: e - }; - } - - function createBinaryExpr(op, left, right) { - return { - type: 'binary_expr', - operator: op, - left: left, - right: right - }; - } - - function createList(head, tail) { - const result = [head]; - for (let i = 0; i < tail.length; i++) { - result.push(tail[i][3]); - } - return result; - } - - function createBinaryExprChain(head, tail) { - let result = head; - for (let i = 0; i < tail.length; i++) { - result = createBinaryExpr(tail[i][1], result, tail[i][3]); - } - return result; - } - - const cmpPrefixMap = { - '+': true, - '-': true, - '*': true, - '/': true, - '>': true, - '<': true, - '!': true, - '=': true, - - //between - 'B': true, - 'b': true, - //for is or in - 'I': true, - 'i': true, - //for like - 'L': true, - 'l': true, - //for not - 'N': true, - 'n': true - }; - - // used for dependency analysis - let varList = []; - - const tableList = new Set(); - const columnList = new Set(); - - peg$result = peg$startRuleFunction(); - - if (peg$result !== peg$FAILED && peg$currPos === input.length) { - return peg$result; - } else { - if (peg$result !== peg$FAILED && peg$currPos < input.length) { - peg$fail(peg$endExpectation()); - } - - throw peg$buildStructuredError( - peg$maxFailExpected, - peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, - peg$maxFailPos < input.length - ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) - : peg$computeLocation(peg$maxFailPos, peg$maxFailPos) - ); - } -} - -module.exports = { - SyntaxError: peg$SyntaxError, - parse: peg$parse -}; diff --git a/packages/core/database/src/sql-parser/index.ts b/packages/core/database/src/sql-parser/index.ts new file mode 100644 index 0000000000..24862a2748 --- /dev/null +++ b/packages/core/database/src/sql-parser/index.ts @@ -0,0 +1,14 @@ +/** + * This file is part of the NocoBase (R) project. + * Copyright (c) 2020-2024 NocoBase Co., Ltd. + * Authors: NocoBase Team. + * + * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. + * For more information, please refer to: https://www.nocobase.com/agreement. + */ + +import { Parser } from 'node-sql-parser'; +import type * as SQLParserTypes from 'node-sql-parser'; + +export default new Parser(); +export type { SQLParserTypes }; diff --git a/packages/core/database/src/sql-parser/postgres.js b/packages/core/database/src/sql-parser/postgres.js deleted file mode 100644 index 4049fb4367..0000000000 --- a/packages/core/database/src/sql-parser/postgres.js +++ /dev/null @@ -1,27654 +0,0 @@ -/** - * This file is part of the NocoBase (R) project. - * Copyright (c) 2020-2024 NocoBase Co., Ltd. - * Authors: NocoBase Team. - * - * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. - * For more information, please refer to: https://www.nocobase.com/agreement. - */ - -// Generated by Peggy 3.0.2. -// -// https://peggyjs.org/ - -'use strict'; - -function peg$subclass(child, parent) { - function C() { - this.constructor = child; - } - C.prototype = parent.prototype; - child.prototype = new C(); -} - -function peg$SyntaxError(message, expected, found, location) { - var self = Error.call(this, message); - // istanbul ignore next Check is a necessary evil to support older environments - if (Object.setPrototypeOf) { - Object.setPrototypeOf(self, peg$SyntaxError.prototype); - } - self.expected = expected; - self.found = found; - self.location = location; - self.name = 'SyntaxError'; - return self; -} - -peg$subclass(peg$SyntaxError, Error); - -function peg$padEnd(str, targetLength, padString) { - padString = padString || ' '; - if (str.length > targetLength) { - return str; - } - targetLength -= str.length; - padString += padString.repeat(targetLength); - return str + padString.slice(0, targetLength); -} - -peg$SyntaxError.prototype.format = function (sources) { - var str = 'Error: ' + this.message; - if (this.location) { - var src = null; - var k; - for (k = 0; k < sources.length; k++) { - if (sources[k].source === this.location.source) { - src = sources[k].text.split(/\r\n|\n|\r/g); - break; - } - } - var s = this.location.start; - var offset_s = - this.location.source && typeof this.location.source.offset === 'function' ? this.location.source.offset(s) : s; - var loc = this.location.source + ':' + offset_s.line + ':' + offset_s.column; - if (src) { - var e = this.location.end; - var filler = peg$padEnd('', offset_s.line.toString().length, ' '); - var line = src[s.line - 1]; - var last = s.line === e.line ? e.column : line.length + 1; - var hatLen = last - s.column || 1; - str += - '\n --> ' + - loc + - '\n' + - filler + - ' |\n' + - offset_s.line + - ' | ' + - line + - '\n' + - filler + - ' | ' + - peg$padEnd('', s.column - 1, ' ') + - peg$padEnd('', hatLen, '^'); - } else { - str += '\n at ' + loc; - } - } - return str; -}; - -peg$SyntaxError.buildMessage = function (expected, found) { - var DESCRIBE_EXPECTATION_FNS = { - literal: function (expectation) { - return '"' + literalEscape(expectation.text) + '"'; - }, - - class: function (expectation) { - var escapedParts = expectation.parts.map(function (part) { - return Array.isArray(part) ? classEscape(part[0]) + '-' + classEscape(part[1]) : classEscape(part); - }); - - return '[' + (expectation.inverted ? '^' : '') + escapedParts.join('') + ']'; - }, - - any: function () { - return 'any character'; - }, - - end: function () { - return 'end of input'; - }, - - other: function (expectation) { - return expectation.description; - }, - }; - - function hex(ch) { - return ch.charCodeAt(0).toString(16).toUpperCase(); - } - - function literalEscape(s) { - return s - .replace(/\\/g, '\\\\') - .replace(/"/g, '\\"') - .replace(/\0/g, '\\0') - .replace(/\t/g, '\\t') - .replace(/\n/g, '\\n') - .replace(/\r/g, '\\r') - .replace(/[\x00-\x0F]/g, function (ch) { - return '\\x0' + hex(ch); - }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { - return '\\x' + hex(ch); - }); - } - - function classEscape(s) { - return s - .replace(/\\/g, '\\\\') - .replace(/\]/g, '\\]') - .replace(/\^/g, '\\^') - .replace(/-/g, '\\-') - .replace(/\0/g, '\\0') - .replace(/\t/g, '\\t') - .replace(/\n/g, '\\n') - .replace(/\r/g, '\\r') - .replace(/[\x00-\x0F]/g, function (ch) { - return '\\x0' + hex(ch); - }) - .replace(/[\x10-\x1F\x7F-\x9F]/g, function (ch) { - return '\\x' + hex(ch); - }); - } - - function describeExpectation(expectation) { - return DESCRIBE_EXPECTATION_FNS[expectation.type](expectation); - } - - function describeExpected(expected) { - var descriptions = expected.map(describeExpectation); - var i, j; - - descriptions.sort(); - - if (descriptions.length > 0) { - for (i = 1, j = 1; i < descriptions.length; i++) { - if (descriptions[i - 1] !== descriptions[i]) { - descriptions[j] = descriptions[i]; - j++; - } - } - descriptions.length = j; - } - - switch (descriptions.length) { - case 1: - return descriptions[0]; - - case 2: - return descriptions[0] + ' or ' + descriptions[1]; - - default: - return descriptions.slice(0, -1).join(', ') + ', or ' + descriptions[descriptions.length - 1]; - } - } - - function describeFound(found) { - return found ? '"' + literalEscape(found) + '"' : 'end of input'; - } - - return 'Expected ' + describeExpected(expected) + ' but ' + describeFound(found) + ' found.'; -}; - -function peg$parse(input, options) { - options = options !== undefined ? options : {}; - - var peg$FAILED = {}; - var peg$source = options.grammarSource; - - var peg$startRuleFunctions = { start: peg$parsestart }; - var peg$startRuleFunction = peg$parsestart; - - var peg$c0 = 'if'; - var peg$c1 = 'extension'; - var peg$c2 = 'schema'; - var peg$c3 = 'version'; - var peg$c4 = 'increment'; - var peg$c5 = 'minvalue'; - var peg$c6 = 'no'; - var peg$c7 = 'maxvalue'; - var peg$c8 = 'start'; - var peg$c9 = 'cache'; - var peg$c10 = 'cycle'; - var peg$c11 = 'owned'; - var peg$c12 = 'none'; - var peg$c13 = 'nulls'; - var peg$c14 = 'first'; - var peg$c15 = 'last'; - var peg$c16 = 'auto_increment'; - var peg$c17 = 'unique'; - var peg$c18 = 'key'; - var peg$c19 = 'primary'; - var peg$c20 = 'column_format'; - var peg$c21 = 'fixed'; - var peg$c22 = 'dynamic'; - var peg$c23 = 'default'; - var peg$c24 = 'storage'; - var peg$c25 = 'disk'; - var peg$c26 = 'memory'; - var peg$c27 = 'cascade'; - var peg$c28 = 'restrict'; - var peg$c29 = 'algorithm'; - var peg$c30 = 'instant'; - var peg$c31 = 'inplace'; - var peg$c32 = 'copy'; - var peg$c33 = 'lock'; - var peg$c34 = 'shared'; - var peg$c35 = 'exclusive'; - var peg$c36 = 'primary key'; - var peg$c37 = 'foreign key'; - var peg$c38 = 'match full'; - var peg$c39 = 'match partial'; - var peg$c40 = 'match simple'; - var peg$c41 = 'set null'; - var peg$c42 = 'no action'; - var peg$c43 = 'set default'; - var peg$c44 = 'trigger'; - var peg$c45 = 'before'; - var peg$c46 = 'after'; - var peg$c47 = 'instead of'; - var peg$c48 = 'on'; - var peg$c49 = 'execute'; - var peg$c50 = 'procedure'; - var peg$c51 = 'of'; - var peg$c52 = 'not'; - var peg$c53 = 'deferrable'; - var peg$c54 = 'initially immediate'; - var peg$c55 = 'initially deferred'; - var peg$c56 = 'for'; - var peg$c57 = 'each'; - var peg$c58 = 'row'; - var peg$c59 = 'statement'; - var peg$c60 = 'character'; - var peg$c61 = 'set'; - var peg$c62 = 'charset'; - var peg$c63 = 'collate'; - var peg$c64 = 'avg_row_length'; - var peg$c65 = 'key_block_size'; - var peg$c66 = 'max_rows'; - var peg$c67 = 'min_rows'; - var peg$c68 = 'stats_sample_pages'; - var peg$c69 = 'connection'; - var peg$c70 = 'compression'; - var peg$c71 = "'"; - var peg$c72 = 'zlib'; - var peg$c73 = 'lz4'; - var peg$c74 = 'engine'; - var peg$c75 = 'in'; - var peg$c76 = 'access share'; - var peg$c77 = 'row share'; - var peg$c78 = 'row exclusive'; - var peg$c79 = 'share update exclusive'; - var peg$c80 = 'share row exclusive'; - var peg$c81 = 'access exclusive'; - var peg$c82 = 'share'; - var peg$c83 = 'mode'; - var peg$c84 = 'nowait'; - var peg$c85 = 'tables'; - var peg$c86 = 'prepare'; - var peg$c87 = ';'; - var peg$c88 = '('; - var peg$c89 = ')'; - var peg$c90 = '"'; - var peg$c91 = 'outfile'; - var peg$c92 = 'dumpfile'; - var peg$c93 = 'btree'; - var peg$c94 = 'hash'; - var peg$c95 = 'gist'; - var peg$c96 = 'gin'; - var peg$c97 = 'with'; - var peg$c98 = 'parser'; - var peg$c99 = 'visible'; - var peg$c100 = 'invisible'; - var peg$c101 = 'lateral'; - var peg$c102 = 'tablesample'; - var peg$c103 = 'repeatable'; - var peg$c104 = 'cross'; - var peg$c105 = 'following'; - var peg$c106 = 'preceding'; - var peg$c107 = 'current'; - var peg$c108 = 'unbounded'; - var peg$c109 = '='; - var peg$c110 = 'conflict'; - var peg$c111 = '!'; - var peg$c112 = '>='; - var peg$c113 = '>'; - var peg$c114 = '<='; - var peg$c115 = '<>'; - var peg$c116 = '<'; - var peg$c117 = '!='; - var peg$c118 = 'similar'; - var peg$c119 = 'escape'; - var peg$c120 = '@>'; - var peg$c121 = '<@'; - var peg$c122 = '?'; - var peg$c123 = '?|'; - var peg$c124 = '?&'; - var peg$c125 = '#-'; - var peg$c126 = '+'; - var peg$c127 = '-'; - var peg$c128 = '*'; - var peg$c129 = '/'; - var peg$c130 = '%'; - var peg$c131 = '||'; - var peg$c132 = '$'; - var peg$c133 = 'e'; - var peg$c134 = '`'; - var peg$c135 = ':'; - var peg$c136 = 'over'; - var peg$c137 = 'filter'; - var peg$c138 = 'first_value'; - var peg$c139 = 'last_value'; - var peg$c140 = 'row_number'; - var peg$c141 = 'dense_rank'; - var peg$c142 = 'rank'; - var peg$c143 = 'lag'; - var peg$c144 = 'lead'; - var peg$c145 = 'nth_value'; - var peg$c146 = 'ignore'; - var peg$c147 = 'respect'; - var peg$c148 = 'percentile_cont'; - var peg$c149 = 'percentile_disc'; - var peg$c150 = 'within'; - var peg$c151 = 'separator'; - var peg$c152 = 'both'; - var peg$c153 = 'leading'; - var peg$c154 = 'trailing'; - var peg$c155 = 'trim'; - var peg$c156 = 'now'; - var peg$c157 = 'at'; - var peg$c158 = 'zone'; - var peg$c159 = 'century'; - var peg$c160 = 'day'; - var peg$c161 = 'date'; - var peg$c162 = 'decade'; - var peg$c163 = 'dow'; - var peg$c164 = 'doy'; - var peg$c165 = 'epoch'; - var peg$c166 = 'hour'; - var peg$c167 = 'isodow'; - var peg$c168 = 'isoyear'; - var peg$c169 = 'microseconds'; - var peg$c170 = 'millennium'; - var peg$c171 = 'milliseconds'; - var peg$c172 = 'minute'; - var peg$c173 = 'month'; - var peg$c174 = 'quarter'; - var peg$c175 = 'second'; - var peg$c176 = 'timezone'; - var peg$c177 = 'timezone_hour'; - var peg$c178 = 'timezone_minute'; - var peg$c179 = 'week'; - var peg$c180 = 'year'; - var peg$c181 = 'ntile'; - var peg$c182 = "\\'"; - var peg$c183 = '\\"'; - var peg$c184 = '\\\\'; - var peg$c185 = '\\/'; - var peg$c186 = '\\b'; - var peg$c187 = '\\f'; - var peg$c188 = '\\n'; - var peg$c189 = '\\r'; - var peg$c190 = '\\t'; - var peg$c191 = '\\u'; - var peg$c192 = '\\'; - var peg$c193 = "''"; - var peg$c194 = '.'; - var peg$c195 = 'null'; - var peg$c196 = 'not null'; - var peg$c197 = 'true'; - var peg$c198 = 'to'; - var peg$c199 = 'false'; - var peg$c200 = 'show'; - var peg$c201 = 'drop'; - var peg$c202 = 'use'; - var peg$c203 = 'alter'; - var peg$c204 = 'select'; - var peg$c205 = 'update'; - var peg$c206 = 'create'; - var peg$c207 = 'temporary'; - var peg$c208 = 'temp'; - var peg$c209 = 'delete'; - var peg$c210 = 'insert'; - var peg$c211 = 'RECURSIVE'; - var peg$c212 = 'replace'; - var peg$c213 = 'returning'; - var peg$c214 = 'rename'; - var peg$c215 = 'explain'; - var peg$c216 = 'partition'; - var peg$c217 = 'into'; - var peg$c218 = 'from'; - var peg$c219 = 'as'; - var peg$c220 = 'table'; - var peg$c221 = 'database'; - var peg$c222 = 'scheme'; - var peg$c223 = 'sequence'; - var peg$c224 = 'tablespace'; - var peg$c225 = 'deallocate'; - var peg$c226 = 'left'; - var peg$c227 = 'right'; - var peg$c228 = 'full'; - var peg$c229 = 'inner'; - var peg$c230 = 'join'; - var peg$c231 = 'outer'; - var peg$c232 = 'union'; - var peg$c233 = 'values'; - var peg$c234 = 'using'; - var peg$c235 = 'where'; - var peg$c236 = 'group'; - var peg$c237 = 'by'; - var peg$c238 = 'order'; - var peg$c239 = 'having'; - var peg$c240 = 'window'; - var peg$c241 = 'limit'; - var peg$c242 = 'offset'; - var peg$c243 = 'asc'; - var peg$c244 = 'desc'; - var peg$c245 = 'all'; - var peg$c246 = 'distinct'; - var peg$c247 = 'between'; - var peg$c248 = 'is'; - var peg$c249 = 'like'; - var peg$c250 = 'ilike'; - var peg$c251 = 'exists'; - var peg$c252 = 'and'; - var peg$c253 = 'or'; - var peg$c254 = 'array'; - var peg$c255 = 'array_agg'; - var peg$c256 = 'count'; - var peg$c257 = 'group_concat'; - var peg$c258 = 'max'; - var peg$c259 = 'min'; - var peg$c260 = 'sum'; - var peg$c261 = 'avg'; - var peg$c262 = 'extract'; - var peg$c263 = 'call'; - var peg$c264 = 'case'; - var peg$c265 = 'when'; - var peg$c266 = 'then'; - var peg$c267 = 'else'; - var peg$c268 = 'end'; - var peg$c269 = 'cast'; - var peg$c270 = 'bool'; - var peg$c271 = 'boolean'; - var peg$c272 = 'char'; - var peg$c273 = 'varchar'; - var peg$c274 = 'numeric'; - var peg$c275 = 'decimal'; - var peg$c276 = 'signed'; - var peg$c277 = 'unsigned'; - var peg$c278 = 'int'; - var peg$c279 = 'zerofill'; - var peg$c280 = 'integer'; - var peg$c281 = 'json'; - var peg$c282 = 'jsonb'; - var peg$c283 = 'geometry'; - var peg$c284 = 'smallint'; - var peg$c285 = 'serial'; - var peg$c286 = 'tinyint'; - var peg$c287 = 'tinytext'; - var peg$c288 = 'text'; - var peg$c289 = 'mediumtext'; - var peg$c290 = 'longtext'; - var peg$c291 = 'bigint'; - var peg$c292 = 'enum'; - var peg$c293 = 'float'; - var peg$c294 = 'double'; - var peg$c295 = 'bigserial'; - var peg$c296 = 'real'; - var peg$c297 = 'datetime'; - var peg$c298 = 'rows'; - var peg$c299 = 'time'; - var peg$c300 = 'timestamp'; - var peg$c301 = 'truncate'; - var peg$c302 = 'user'; - var peg$c303 = 'uuid'; - var peg$c304 = 'oid'; - var peg$c305 = 'regclass'; - var peg$c306 = 'regcollation'; - var peg$c307 = 'regconfig'; - var peg$c308 = 'regdictionary'; - var peg$c309 = 'regnamespace'; - var peg$c310 = 'regoper'; - var peg$c311 = 'regoperator'; - var peg$c312 = 'regproc'; - var peg$c313 = 'regprocedure'; - var peg$c314 = 'regrole'; - var peg$c315 = 'regtype'; - var peg$c316 = 'current_date'; - var peg$c317 = 'adddate'; - var peg$c318 = 'interval'; - var peg$c319 = 'current_time'; - var peg$c320 = 'current_timestamp'; - var peg$c321 = 'current_user'; - var peg$c322 = 'session_user'; - var peg$c323 = 'system_user'; - var peg$c324 = 'global'; - var peg$c325 = 'session'; - var peg$c326 = 'local'; - var peg$c327 = 'persist'; - var peg$c328 = 'persist_only'; - var peg$c329 = '@'; - var peg$c330 = '@@'; - var peg$c331 = '$$'; - var peg$c332 = 'return'; - var peg$c333 = ':='; - var peg$c334 = '::'; - var peg$c335 = 'dual'; - var peg$c336 = 'add'; - var peg$c337 = 'column'; - var peg$c338 = 'index'; - var peg$c339 = 'fulltext'; - var peg$c340 = 'spatial'; - var peg$c341 = 'comment'; - var peg$c342 = 'constraint'; - var peg$c343 = 'concurrently'; - var peg$c344 = 'references'; - var peg$c345 = 'sql_calc_found_rows'; - var peg$c346 = 'sql_cache'; - var peg$c347 = 'sql_no_cache'; - var peg$c348 = 'sql_small_result'; - var peg$c349 = 'sql_big_result'; - var peg$c350 = 'sql_buffer_result'; - var peg$c351 = ','; - var peg$c352 = '['; - var peg$c353 = ']'; - var peg$c354 = '->'; - var peg$c355 = '->>'; - var peg$c356 = '#>'; - var peg$c357 = '#>>'; - var peg$c358 = '&&'; - var peg$c359 = '/*'; - var peg$c360 = '*/'; - var peg$c361 = '--'; - var peg$c362 = '#'; - var peg$c363 = 'bytea'; - var peg$c364 = 'without'; - - var peg$r0 = /^[^"]/; - var peg$r1 = /^[^']/; - var peg$r2 = /^[^`]/; - var peg$r3 = /^[A-Za-z_]/; - var peg$r4 = /^[A-Za-z0-9_\-]/; - var peg$r5 = /^[A-Za-z0-9_]/; - var peg$r6 = /^[\n]/; - var peg$r7 = /^[^"\\\0-\x1F\x7F]/; - var peg$r8 = /^[^'\\]/; - var peg$r9 = /^[\n\r]/; - var peg$r10 = /^[0-9]/; - var peg$r11 = /^[0-9a-fA-F]/; - var peg$r12 = /^[eE]/; - var peg$r13 = /^[+\-]/; - var peg$r14 = /^[ \t\n\r]/; - var peg$r15 = /^[^$]/; - - var peg$e0 = peg$literalExpectation('IF', true); - var peg$e1 = peg$literalExpectation('EXTENSION', true); - var peg$e2 = peg$literalExpectation('SCHEMA', true); - var peg$e3 = peg$literalExpectation('VERSION', true); - var peg$e4 = peg$literalExpectation('INCREMENT', true); - var peg$e5 = peg$literalExpectation('MINVALUE', true); - var peg$e6 = peg$literalExpectation('NO', true); - var peg$e7 = peg$literalExpectation('MAXVALUE', true); - var peg$e8 = peg$literalExpectation('START', true); - var peg$e9 = peg$literalExpectation('CACHE', true); - var peg$e10 = peg$literalExpectation('CYCLE', true); - var peg$e11 = peg$literalExpectation('OWNED', true); - var peg$e12 = peg$literalExpectation('NONE', true); - var peg$e13 = peg$literalExpectation('NULLS', true); - var peg$e14 = peg$literalExpectation('FIRST', true); - var peg$e15 = peg$literalExpectation('LAST', true); - var peg$e16 = peg$literalExpectation('AUTO_INCREMENT', true); - var peg$e17 = peg$literalExpectation('UNIQUE', true); - var peg$e18 = peg$literalExpectation('KEY', true); - var peg$e19 = peg$literalExpectation('PRIMARY', true); - var peg$e20 = peg$literalExpectation('COLUMN_FORMAT', true); - var peg$e21 = peg$literalExpectation('FIXED', true); - var peg$e22 = peg$literalExpectation('DYNAMIC', true); - var peg$e23 = peg$literalExpectation('DEFAULT', true); - var peg$e24 = peg$literalExpectation('STORAGE', true); - var peg$e25 = peg$literalExpectation('DISK', true); - var peg$e26 = peg$literalExpectation('MEMORY', true); - var peg$e27 = peg$literalExpectation('CASCADE', true); - var peg$e28 = peg$literalExpectation('RESTRICT', true); - var peg$e29 = peg$literalExpectation('ALGORITHM', true); - var peg$e30 = peg$literalExpectation('INSTANT', true); - var peg$e31 = peg$literalExpectation('INPLACE', true); - var peg$e32 = peg$literalExpectation('COPY', true); - var peg$e33 = peg$literalExpectation('LOCK', true); - var peg$e34 = peg$literalExpectation('SHARED', true); - var peg$e35 = peg$literalExpectation('EXCLUSIVE', true); - var peg$e36 = peg$literalExpectation('PRIMARY KEY', true); - var peg$e37 = peg$literalExpectation('FOREIGN KEY', true); - var peg$e38 = peg$literalExpectation('MATCH FULL', true); - var peg$e39 = peg$literalExpectation('MATCH PARTIAL', true); - var peg$e40 = peg$literalExpectation('MATCH SIMPLE', true); - var peg$e41 = peg$literalExpectation('SET NULL', true); - var peg$e42 = peg$literalExpectation('NO ACTION', true); - var peg$e43 = peg$literalExpectation('SET DEFAULT', true); - var peg$e44 = peg$literalExpectation('TRIGGER', true); - var peg$e45 = peg$literalExpectation('BEFORE', true); - var peg$e46 = peg$literalExpectation('AFTER', true); - var peg$e47 = peg$literalExpectation('INSTEAD OF', true); - var peg$e48 = peg$literalExpectation('ON', true); - var peg$e49 = peg$literalExpectation('EXECUTE', true); - var peg$e50 = peg$literalExpectation('PROCEDURE', true); - var peg$e51 = peg$literalExpectation('OF', true); - var peg$e52 = peg$literalExpectation('NOT', true); - var peg$e53 = peg$literalExpectation('DEFERRABLE', true); - var peg$e54 = peg$literalExpectation('INITIALLY IMMEDIATE', true); - var peg$e55 = peg$literalExpectation('INITIALLY DEFERRED', true); - var peg$e56 = peg$literalExpectation('FOR', true); - var peg$e57 = peg$literalExpectation('EACH', true); - var peg$e58 = peg$literalExpectation('ROW', true); - var peg$e59 = peg$literalExpectation('STATEMENT', true); - var peg$e60 = peg$literalExpectation('CHARACTER', true); - var peg$e61 = peg$literalExpectation('SET', true); - var peg$e62 = peg$literalExpectation('CHARSET', true); - var peg$e63 = peg$literalExpectation('COLLATE', true); - var peg$e64 = peg$literalExpectation('AVG_ROW_LENGTH', true); - var peg$e65 = peg$literalExpectation('KEY_BLOCK_SIZE', true); - var peg$e66 = peg$literalExpectation('MAX_ROWS', true); - var peg$e67 = peg$literalExpectation('MIN_ROWS', true); - var peg$e68 = peg$literalExpectation('STATS_SAMPLE_PAGES', true); - var peg$e69 = peg$literalExpectation('CONNECTION', true); - var peg$e70 = peg$literalExpectation('COMPRESSION', true); - var peg$e71 = peg$literalExpectation("'", false); - var peg$e72 = peg$literalExpectation('ZLIB', true); - var peg$e73 = peg$literalExpectation('LZ4', true); - var peg$e74 = peg$literalExpectation('ENGINE', true); - var peg$e75 = peg$literalExpectation('IN', true); - var peg$e76 = peg$literalExpectation('ACCESS SHARE', true); - var peg$e77 = peg$literalExpectation('ROW SHARE', true); - var peg$e78 = peg$literalExpectation('ROW EXCLUSIVE', true); - var peg$e79 = peg$literalExpectation('SHARE UPDATE EXCLUSIVE', true); - var peg$e80 = peg$literalExpectation('SHARE ROW EXCLUSIVE', true); - var peg$e81 = peg$literalExpectation('ACCESS EXCLUSIVE', true); - var peg$e82 = peg$literalExpectation('SHARE', true); - var peg$e83 = peg$literalExpectation('MODE', true); - var peg$e84 = peg$literalExpectation('NOWAIT', true); - var peg$e85 = peg$literalExpectation('TABLES', true); - var peg$e86 = peg$literalExpectation('PREPARE', true); - var peg$e87 = peg$literalExpectation(';', false); - var peg$e88 = peg$literalExpectation('(', false); - var peg$e89 = peg$literalExpectation(')', false); - var peg$e90 = peg$literalExpectation('"', false); - var peg$e91 = peg$literalExpectation('OUTFILE', true); - var peg$e92 = peg$literalExpectation('DUMPFILE', true); - var peg$e93 = peg$literalExpectation('BTREE', true); - var peg$e94 = peg$literalExpectation('HASH', true); - var peg$e95 = peg$literalExpectation('GIST', true); - var peg$e96 = peg$literalExpectation('GIN', true); - var peg$e97 = peg$literalExpectation('WITH', true); - var peg$e98 = peg$literalExpectation('PARSER', true); - var peg$e99 = peg$literalExpectation('VISIBLE', true); - var peg$e100 = peg$literalExpectation('INVISIBLE', true); - var peg$e101 = peg$literalExpectation('LATERAL', true); - var peg$e102 = peg$literalExpectation('TABLESAMPLE', true); - var peg$e103 = peg$literalExpectation('REPEATABLE', true); - var peg$e104 = peg$literalExpectation('CROSS', true); - var peg$e105 = peg$literalExpectation('FOLLOWING', true); - var peg$e106 = peg$literalExpectation('PRECEDING', true); - var peg$e107 = peg$literalExpectation('CURRENT', true); - var peg$e108 = peg$literalExpectation('UNBOUNDED', true); - var peg$e109 = peg$literalExpectation('=', false); - var peg$e110 = peg$literalExpectation('CONFLICT', true); - var peg$e111 = peg$literalExpectation('!', false); - var peg$e112 = peg$literalExpectation('>=', false); - var peg$e113 = peg$literalExpectation('>', false); - var peg$e114 = peg$literalExpectation('<=', false); - var peg$e115 = peg$literalExpectation('<>', false); - var peg$e116 = peg$literalExpectation('<', false); - var peg$e117 = peg$literalExpectation('!=', false); - var peg$e118 = peg$literalExpectation('SIMILAR', true); - var peg$e119 = peg$literalExpectation('ESCAPE', true); - var peg$e120 = peg$literalExpectation('@>', false); - var peg$e121 = peg$literalExpectation('<@', false); - var peg$e122 = peg$literalExpectation('?', false); - var peg$e123 = peg$literalExpectation('?|', false); - var peg$e124 = peg$literalExpectation('?&', false); - var peg$e125 = peg$literalExpectation('#-', false); - var peg$e126 = peg$literalExpectation('+', false); - var peg$e127 = peg$literalExpectation('-', false); - var peg$e128 = peg$literalExpectation('*', false); - var peg$e129 = peg$literalExpectation('/', false); - var peg$e130 = peg$literalExpectation('%', false); - var peg$e131 = peg$literalExpectation('||', false); - var peg$e132 = peg$literalExpectation('$', false); - var peg$e133 = peg$literalExpectation('E', true); - var peg$e134 = peg$classExpectation(['"'], true, false); - var peg$e135 = peg$classExpectation(["'"], true, false); - var peg$e136 = peg$literalExpectation('`', false); - var peg$e137 = peg$classExpectation(['`'], true, false); - var peg$e138 = peg$classExpectation([['A', 'Z'], ['a', 'z'], '_'], false, false); - var peg$e139 = peg$classExpectation([['A', 'Z'], ['a', 'z'], ['0', '9'], '_', '-'], false, false); - var peg$e140 = peg$classExpectation([['A', 'Z'], ['a', 'z'], ['0', '9'], '_'], false, false); - var peg$e141 = peg$literalExpectation(':', false); - var peg$e142 = peg$literalExpectation('OVER', true); - var peg$e143 = peg$literalExpectation('FILTER', true); - var peg$e144 = peg$literalExpectation('FIRST_VALUE', true); - var peg$e145 = peg$literalExpectation('LAST_VALUE', true); - var peg$e146 = peg$literalExpectation('ROW_NUMBER', true); - var peg$e147 = peg$literalExpectation('DENSE_RANK', true); - var peg$e148 = peg$literalExpectation('RANK', true); - var peg$e149 = peg$literalExpectation('LAG', true); - var peg$e150 = peg$literalExpectation('LEAD', true); - var peg$e151 = peg$literalExpectation('NTH_VALUE', true); - var peg$e152 = peg$literalExpectation('IGNORE', true); - var peg$e153 = peg$literalExpectation('RESPECT', true); - var peg$e154 = peg$literalExpectation('percentile_cont', true); - var peg$e155 = peg$literalExpectation('percentile_disc', true); - var peg$e156 = peg$literalExpectation('within', true); - var peg$e157 = peg$literalExpectation('mode', true); - var peg$e158 = peg$literalExpectation('SEPARATOR', true); - var peg$e159 = peg$literalExpectation('BOTH', true); - var peg$e160 = peg$literalExpectation('LEADING', true); - var peg$e161 = peg$literalExpectation('TRAILING', true); - var peg$e162 = peg$literalExpectation('trim', true); - var peg$e163 = peg$literalExpectation('now', true); - var peg$e164 = peg$literalExpectation('at', true); - var peg$e165 = peg$literalExpectation('zone', true); - var peg$e166 = peg$literalExpectation('CENTURY', true); - var peg$e167 = peg$literalExpectation('DAY', true); - var peg$e168 = peg$literalExpectation('DATE', true); - var peg$e169 = peg$literalExpectation('DECADE', true); - var peg$e170 = peg$literalExpectation('DOW', true); - var peg$e171 = peg$literalExpectation('DOY', true); - var peg$e172 = peg$literalExpectation('EPOCH', true); - var peg$e173 = peg$literalExpectation('HOUR', true); - var peg$e174 = peg$literalExpectation('ISODOW', true); - var peg$e175 = peg$literalExpectation('ISOYEAR', true); - var peg$e176 = peg$literalExpectation('MICROSECONDS', true); - var peg$e177 = peg$literalExpectation('MILLENNIUM', true); - var peg$e178 = peg$literalExpectation('MILLISECONDS', true); - var peg$e179 = peg$literalExpectation('MINUTE', true); - var peg$e180 = peg$literalExpectation('MONTH', true); - var peg$e181 = peg$literalExpectation('QUARTER', true); - var peg$e182 = peg$literalExpectation('SECOND', true); - var peg$e183 = peg$literalExpectation('TIMEZONE', true); - var peg$e184 = peg$literalExpectation('TIMEZONE_HOUR', true); - var peg$e185 = peg$literalExpectation('TIMEZONE_MINUTE', true); - var peg$e186 = peg$literalExpectation('WEEK', true); - var peg$e187 = peg$literalExpectation('YEAR', true); - var peg$e188 = peg$literalExpectation('NTILE', true); - var peg$e189 = peg$classExpectation(['\n'], false, false); - var peg$e190 = peg$classExpectation(['"', '\\', ['\0', '\x1F'], '\x7F'], true, false); - var peg$e191 = peg$classExpectation(["'", '\\'], true, false); - var peg$e192 = peg$literalExpectation("\\'", false); - var peg$e193 = peg$literalExpectation('\\"', false); - var peg$e194 = peg$literalExpectation('\\\\', false); - var peg$e195 = peg$literalExpectation('\\/', false); - var peg$e196 = peg$literalExpectation('\\b', false); - var peg$e197 = peg$literalExpectation('\\f', false); - var peg$e198 = peg$literalExpectation('\\n', false); - var peg$e199 = peg$literalExpectation('\\r', false); - var peg$e200 = peg$literalExpectation('\\t', false); - var peg$e201 = peg$literalExpectation('\\u', false); - var peg$e202 = peg$literalExpectation('\\', false); - var peg$e203 = peg$literalExpectation("''", false); - var peg$e204 = peg$classExpectation(['\n', '\r'], false, false); - var peg$e205 = peg$literalExpectation('.', false); - var peg$e206 = peg$classExpectation([['0', '9']], false, false); - var peg$e207 = peg$classExpectation( - [ - ['0', '9'], - ['a', 'f'], - ['A', 'F'], - ], - false, - false, - ); - var peg$e208 = peg$classExpectation(['e', 'E'], false, false); - var peg$e209 = peg$classExpectation(['+', '-'], false, false); - var peg$e210 = peg$literalExpectation('NULL', true); - var peg$e211 = peg$literalExpectation('NOT NULL', true); - var peg$e212 = peg$literalExpectation('TRUE', true); - var peg$e213 = peg$literalExpectation('TO', true); - var peg$e214 = peg$literalExpectation('FALSE', true); - var peg$e215 = peg$literalExpectation('SHOW', true); - var peg$e216 = peg$literalExpectation('DROP', true); - var peg$e217 = peg$literalExpectation('USE', true); - var peg$e218 = peg$literalExpectation('ALTER', true); - var peg$e219 = peg$literalExpectation('SELECT', true); - var peg$e220 = peg$literalExpectation('UPDATE', true); - var peg$e221 = peg$literalExpectation('CREATE', true); - var peg$e222 = peg$literalExpectation('TEMPORARY', true); - var peg$e223 = peg$literalExpectation('TEMP', true); - var peg$e224 = peg$literalExpectation('DELETE', true); - var peg$e225 = peg$literalExpectation('INSERT', true); - var peg$e226 = peg$literalExpectation('RECURSIVE', false); - var peg$e227 = peg$literalExpectation('REPLACE', true); - var peg$e228 = peg$literalExpectation('RETURNING', true); - var peg$e229 = peg$literalExpectation('RENAME', true); - var peg$e230 = peg$literalExpectation('EXPLAIN', true); - var peg$e231 = peg$literalExpectation('PARTITION', true); - var peg$e232 = peg$literalExpectation('INTO', true); - var peg$e233 = peg$literalExpectation('FROM', true); - var peg$e234 = peg$literalExpectation('AS', true); - var peg$e235 = peg$literalExpectation('TABLE', true); - var peg$e236 = peg$literalExpectation('DATABASE', true); - var peg$e237 = peg$literalExpectation('SCHEME', true); - var peg$e238 = peg$literalExpectation('SEQUENCE', true); - var peg$e239 = peg$literalExpectation('TABLESPACE', true); - var peg$e240 = peg$literalExpectation('DEALLOCATE', true); - var peg$e241 = peg$literalExpectation('LEFT', true); - var peg$e242 = peg$literalExpectation('RIGHT', true); - var peg$e243 = peg$literalExpectation('FULL', true); - var peg$e244 = peg$literalExpectation('INNER', true); - var peg$e245 = peg$literalExpectation('JOIN', true); - var peg$e246 = peg$literalExpectation('OUTER', true); - var peg$e247 = peg$literalExpectation('UNION', true); - var peg$e248 = peg$literalExpectation('VALUES', true); - var peg$e249 = peg$literalExpectation('USING', true); - var peg$e250 = peg$literalExpectation('WHERE', true); - var peg$e251 = peg$literalExpectation('GROUP', true); - var peg$e252 = peg$literalExpectation('BY', true); - var peg$e253 = peg$literalExpectation('ORDER', true); - var peg$e254 = peg$literalExpectation('HAVING', true); - var peg$e255 = peg$literalExpectation('WINDOW', true); - var peg$e256 = peg$literalExpectation('LIMIT', true); - var peg$e257 = peg$literalExpectation('OFFSET', true); - var peg$e258 = peg$literalExpectation('ASC', true); - var peg$e259 = peg$literalExpectation('DESC', true); - var peg$e260 = peg$literalExpectation('ALL', true); - var peg$e261 = peg$literalExpectation('DISTINCT', true); - var peg$e262 = peg$literalExpectation('BETWEEN', true); - var peg$e263 = peg$literalExpectation('IS', true); - var peg$e264 = peg$literalExpectation('LIKE', true); - var peg$e265 = peg$literalExpectation('ILIKE', true); - var peg$e266 = peg$literalExpectation('EXISTS', true); - var peg$e267 = peg$literalExpectation('AND', true); - var peg$e268 = peg$literalExpectation('OR', true); - var peg$e269 = peg$literalExpectation('ARRAY', true); - var peg$e270 = peg$literalExpectation('ARRAY_AGG', true); - var peg$e271 = peg$literalExpectation('COUNT', true); - var peg$e272 = peg$literalExpectation('GROUP_CONCAT', true); - var peg$e273 = peg$literalExpectation('MAX', true); - var peg$e274 = peg$literalExpectation('MIN', true); - var peg$e275 = peg$literalExpectation('SUM', true); - var peg$e276 = peg$literalExpectation('AVG', true); - var peg$e277 = peg$literalExpectation('EXTRACT', true); - var peg$e278 = peg$literalExpectation('CALL', true); - var peg$e279 = peg$literalExpectation('CASE', true); - var peg$e280 = peg$literalExpectation('WHEN', true); - var peg$e281 = peg$literalExpectation('THEN', true); - var peg$e282 = peg$literalExpectation('ELSE', true); - var peg$e283 = peg$literalExpectation('END', true); - var peg$e284 = peg$literalExpectation('CAST', true); - var peg$e285 = peg$literalExpectation('BOOL', true); - var peg$e286 = peg$literalExpectation('BOOLEAN', true); - var peg$e287 = peg$literalExpectation('CHAR', true); - var peg$e288 = peg$literalExpectation('VARCHAR', true); - var peg$e289 = peg$literalExpectation('NUMERIC', true); - var peg$e290 = peg$literalExpectation('DECIMAL', true); - var peg$e291 = peg$literalExpectation('SIGNED', true); - var peg$e292 = peg$literalExpectation('UNSIGNED', true); - var peg$e293 = peg$literalExpectation('INT', true); - var peg$e294 = peg$literalExpectation('ZEROFILL', true); - var peg$e295 = peg$literalExpectation('INTEGER', true); - var peg$e296 = peg$literalExpectation('JSON', true); - var peg$e297 = peg$literalExpectation('JSONB', true); - var peg$e298 = peg$literalExpectation('GEOMETRY', true); - var peg$e299 = peg$literalExpectation('SMALLINT', true); - var peg$e300 = peg$literalExpectation('SERIAL', true); - var peg$e301 = peg$literalExpectation('TINYINT', true); - var peg$e302 = peg$literalExpectation('TINYTEXT', true); - var peg$e303 = peg$literalExpectation('TEXT', true); - var peg$e304 = peg$literalExpectation('MEDIUMTEXT', true); - var peg$e305 = peg$literalExpectation('LONGTEXT', true); - var peg$e306 = peg$literalExpectation('BIGINT', true); - var peg$e307 = peg$literalExpectation('ENUM', true); - var peg$e308 = peg$literalExpectation('FLOAT', true); - var peg$e309 = peg$literalExpectation('DOUBLE', true); - var peg$e310 = peg$literalExpectation('BIGSERIAL', true); - var peg$e311 = peg$literalExpectation('REAL', true); - var peg$e312 = peg$literalExpectation('DATETIME', true); - var peg$e313 = peg$literalExpectation('ROWS', true); - var peg$e314 = peg$literalExpectation('TIME', true); - var peg$e315 = peg$literalExpectation('TIMESTAMP', true); - var peg$e316 = peg$literalExpectation('TRUNCATE', true); - var peg$e317 = peg$literalExpectation('USER', true); - var peg$e318 = peg$literalExpectation('UUID', true); - var peg$e319 = peg$literalExpectation('OID', true); - var peg$e320 = peg$literalExpectation('REGCLASS', true); - var peg$e321 = peg$literalExpectation('REGCOLLATION', true); - var peg$e322 = peg$literalExpectation('REGCONFIG', true); - var peg$e323 = peg$literalExpectation('REGDICTIONARY', true); - var peg$e324 = peg$literalExpectation('REGNAMESPACE', true); - var peg$e325 = peg$literalExpectation('REGOPER', true); - var peg$e326 = peg$literalExpectation('REGOPERATOR', true); - var peg$e327 = peg$literalExpectation('REGPROC', true); - var peg$e328 = peg$literalExpectation('REGPROCEDURE', true); - var peg$e329 = peg$literalExpectation('REGROLE', true); - var peg$e330 = peg$literalExpectation('REGTYPE', true); - var peg$e331 = peg$literalExpectation('CURRENT_DATE', true); - var peg$e332 = peg$literalExpectation('ADDDATE', true); - var peg$e333 = peg$literalExpectation('INTERVAL', true); - var peg$e334 = peg$literalExpectation('CURRENT_TIME', true); - var peg$e335 = peg$literalExpectation('CURRENT_TIMESTAMP', true); - var peg$e336 = peg$literalExpectation('CURRENT_USER', true); - var peg$e337 = peg$literalExpectation('SESSION_USER', true); - var peg$e338 = peg$literalExpectation('SYSTEM_USER', true); - var peg$e339 = peg$literalExpectation('GLOBAL', true); - var peg$e340 = peg$literalExpectation('SESSION', true); - var peg$e341 = peg$literalExpectation('LOCAL', true); - var peg$e342 = peg$literalExpectation('PERSIST', true); - var peg$e343 = peg$literalExpectation('PERSIST_ONLY', true); - var peg$e344 = peg$literalExpectation('@', false); - var peg$e345 = peg$literalExpectation('@@', false); - var peg$e346 = peg$literalExpectation('$$', false); - var peg$e347 = peg$literalExpectation('return', true); - var peg$e348 = peg$literalExpectation(':=', false); - var peg$e349 = peg$literalExpectation('::', false); - var peg$e350 = peg$literalExpectation('DUAL', true); - var peg$e351 = peg$literalExpectation('ADD', true); - var peg$e352 = peg$literalExpectation('COLUMN', true); - var peg$e353 = peg$literalExpectation('INDEX', true); - var peg$e354 = peg$literalExpectation('FULLTEXT', true); - var peg$e355 = peg$literalExpectation('SPATIAL', true); - var peg$e356 = peg$literalExpectation('COMMENT', true); - var peg$e357 = peg$literalExpectation('CONSTRAINT', true); - var peg$e358 = peg$literalExpectation('CONCURRENTLY', true); - var peg$e359 = peg$literalExpectation('REFERENCES', true); - var peg$e360 = peg$literalExpectation('SQL_CALC_FOUND_ROWS', true); - var peg$e361 = peg$literalExpectation('SQL_CACHE', true); - var peg$e362 = peg$literalExpectation('SQL_NO_CACHE', true); - var peg$e363 = peg$literalExpectation('SQL_SMALL_RESULT', true); - var peg$e364 = peg$literalExpectation('SQL_BIG_RESULT', true); - var peg$e365 = peg$literalExpectation('SQL_BUFFER_RESULT', true); - var peg$e366 = peg$literalExpectation(',', false); - var peg$e367 = peg$literalExpectation('[', false); - var peg$e368 = peg$literalExpectation(']', false); - var peg$e369 = peg$literalExpectation('->', false); - var peg$e370 = peg$literalExpectation('->>', false); - var peg$e371 = peg$literalExpectation('#>', false); - var peg$e372 = peg$literalExpectation('#>>', false); - var peg$e373 = peg$literalExpectation('&&', false); - var peg$e374 = peg$literalExpectation('/*', false); - var peg$e375 = peg$literalExpectation('*/', false); - var peg$e376 = peg$literalExpectation('--', false); - var peg$e377 = peg$literalExpectation('#', false); - var peg$e378 = peg$anyExpectation(); - var peg$e379 = peg$classExpectation([' ', '\t', '\n', '\r'], false, false); - var peg$e380 = peg$classExpectation(['$'], true, false); - var peg$e381 = peg$literalExpectation('bytea', true); - var peg$e382 = peg$literalExpectation('WITHOUT', true); - var peg$e383 = peg$literalExpectation('ZONE', true); - - var peg$f0 = function (n) { - // => multiple_stmt | cmd_stmt | crud_stmt - return n; - }; - var peg$f1 = function (head, tail) { - /* - // is in reality: { tableList: any[]; columnList: any[]; ast: T; } - export type AstStatement = T; - => AstStatement */ - const cur = [(head && head.ast) || head]; - for (let i = 0; i < tail.length; i++) { - if (!tail[i][3] || tail[i][3].length === 0) continue; - cur.push((tail[i][3] && tail[i][3].ast) || tail[i][3]); - } - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: cur, - }; - }; - var peg$f2 = function (a) { - // => 'union' | 'union all' - return a ? 'union all' : 'union'; - }; - var peg$f3 = function (head, tail, ob, l) { - /* export interface union_stmt_node extends select_stmt_node { - _next: union_stmt_node; - set_op: 'union' | 'union all'; - } - => AstStatement - */ - let cur = head; - for (let i = 0; i < tail.length; i++) { - cur._next = tail[i][3]; - cur.set_op = tail[i][1]; - cur = cur._next; - } - if (ob) head._orderby = ob; - if (l && l.value && l.value.length > 0) head._limit = l; - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: head, - }; - }; - var peg$f4 = function () { - // => 'IF NOT EXISTS' - return 'IF NOT EXISTS'; - }; - var peg$f5 = function (a, e, ife, n, w, s, v, f) { - /* - export type nameOrLiteral = literal_string | { type: 'same', value: string; }; - => { - type: 'create'; - keyword: 'extension'; - if_not_exists?: 'if not exists'; - extension: nameOrLiteral; - with: 'with'; - schema: nameOrLiteral; - version: nameOrLiteral; - from: nameOrLiteral; - } - */ - return { - type: 'create', - keyword: e.toLowerCase(), - if_not_exists: ife, - extension: commonStrToLiteral(n), - with: w && w[0].toLowerCase(), - schema: commonStrToLiteral(s && s[2].toLowerCase()), // <== wont that be a bug ? - version: commonStrToLiteral(v && v[2]), - from: commonStrToLiteral(f && f[2]), - }; - }; - var peg$f6 = function (head, tail) { - // => create_option_character_set[] - return createList(head, tail, 1); - }; - var peg$f7 = function (a, k, ife, t, c) { - /* - export type create_db_stmt = { - type: 'create', - keyword: 'database', - if_not_exists?: 'if not exists', - database: string, - create_definition?: create_db_definition - } - => AstStatement - */ - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: a[0].toLowerCase(), - keyword: 'database', - if_not_exists: ife, - database: t, - create_definitions: c, - }, - }; - }; - var peg$f8 = function (a, tp, ife, t, c, to, ir, as, qe) { - /* - export type create_table_stmt_node = create_table_stmt_node_simple | create_table_stmt_node_like; - export interface create_table_stmt_node_base { - type: 'create'; - keyword: 'table'; - temporary?: 'temporary'; - if_not_exists?: 'if not exists'; - table: table_ref_list; - } - export interface create_table_stmt_node_simple extends create_table_stmt_node_base{ - ignore_replace?: 'ignore' | 'replace'; - as?: 'as'; - query_expr?: union_stmt_node; - create_definition?: create_table_definition; - table_options?: table_options; - } - => AstStatement - */ - if (t) t.forEach((tt) => tableList.add(`create::${tt.db}::${tt.table}`)); - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: a[0].toLowerCase(), - keyword: 'table', - temporary: tp && tp.toLowerCase(), - if_not_exists: ife, - table: t, - ignore_replace: ir && ir[0].toLowerCase(), - as: as && as[0].toLowerCase(), - query_expr: qe && qe.ast, - create_definitions: c, - table_options: to, - }, - }; - }; - var peg$f9 = function (a, tp, ife, t, lt) { - /* - - export interface create_table_stmt_node_like extends create_table_stmt_node_base{ - like: create_like_table; - } - => AstStatement; - */ - if (t) t.forEach((tt) => tableList.add(`create::${tt.db}::${tt.table}`)); - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: a[0].toLowerCase(), - keyword: 'table', - temporary: tp && tp.toLowerCase(), - if_not_exists: ife, - table: t, - like: lt, - }, - }; - }; - var peg$f10 = function (a, tp, ife, t, as, c) { - /* - export type create_sequence_stmt = { - type: 'create', - keyword: 'sequence', - temporary?: 'temporary' | 'temp', - if_not_exists?: 'if not exists', - table: table_ref_list, - create_definition?: create_sequence_definition_list - } - => AstStatement - */ - t.as = as && as[2]; - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: a[0].toLowerCase(), - keyword: 'sequence', - temporary: tp && tp.toLowerCase(), - if_not_exists: ife, - sequence: [t], - create_definitions: c, - }, - }; - }; - var peg$f11 = function (k, b, n) { - /* - export type sequence_definition = { "resource": "sequence", prefix?: string,value: literal | column_ref } - => sequence_definition - */ - return { - resource: 'sequence', - prefix: b ? `${k.toLowerCase()} by` : k.toLowerCase(), - value: n, - }; - }; - var peg$f12 = function (k, n) { - // => sequence_definition - return { - resource: 'sequence', - prefix: k.toLowerCase(), - value: n, - }; - }; - var peg$f13 = function () { - // => sequence_definition - return { - resource: 'sequence', - value: { - type: 'origin', - value: 'no minvalue', - }, - }; - }; - var peg$f14 = function (k, n) { - // => sequence_definition - return { - resource: 'sequence', - prefix: k.toLowerCase(), - value: n, - }; - }; - var peg$f15 = function () { - // => sequence_definition - return { - resource: 'sequence', - value: { - type: 'origin', - value: 'no maxvalue', - }, - }; - }; - var peg$f16 = function (k, w, n) { - // => sequence_definition - return { - resource: 'sequence', - prefix: w ? `${k.toLowerCase()} with` : k.toLowerCase(), - value: n, - }; - }; - var peg$f17 = function (k, n) { - // => sequence_definition - return { - resource: 'sequence', - prefix: k.toLowerCase(), - value: n, - }; - }; - var peg$f18 = function (n) { - // => sequence_definition - return { - resource: 'sequence', - value: { - type: 'origin', - value: n ? 'no cycle' : 'cycle', - }, - }; - }; - var peg$f19 = function () { - // => sequence_definition - return { - resource: 'sequence', - prefix: 'owned by', - value: { - type: 'origin', - value: 'none', - }, - }; - }; - var peg$f20 = function (n, col) { - // => sequence_definition - return { - resource: 'sequence', - prefix: 'owned by', - value: col, - }; - }; - var peg$f21 = function (head, tail) { - // => create_sequence_definition[] - return createList(head, tail, 1); - }; - var peg$f22 = function (a, kw, t, co, n, on, ta, um, cols, wr, ts, w) { - /* - export interface create_index_stmt_node { - type: 'create'; - index_type?: 'unique'; - keyword: 'index'; - concurrently?: 'concurrently'; - index: string; - on_kw: string; - table: table_name; - index_using?: index_type; - index_columns: column_order[]; - with?: index_option[]; - with_before_where: true; - tablespace?: {type: 'origin'; value: string; } - where?: where_clause; - } - => AstStatement - */ - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: a[0].toLowerCase(), - index_type: kw && kw.toLowerCase(), - keyword: t.toLowerCase(), - concurrently: co && co.toLowerCase(), - index: n, - on_kw: on[0].toLowerCase(), - table: ta, - index_using: um, - index_columns: cols, - with: wr && wr[4], - with_before_where: true, - tablespace: ts && { type: 'origin', value: ts[2] }, - where: w, - }, - }; - }; - var peg$f23 = function (head, tail) { - // => column_order[] - return createList(head, tail); - }; - var peg$f24 = function (c, ca, op, o, nf) { - /* - => { - collate: collate_expr; - opclass: ident; - order: 'asc' | 'desc'; - nulls: 'nulls last' | 'nulls first'; - } - */ - return { - ...c, - collate: ca, - opclass: op, - order_by: o && o.toLowerCase(), - nulls: nf && `${nf[0].toLowerCase()} ${nf[2].toLowerCase()}`, - }; - }; - var peg$f25 = function (t) { - // => { type: 'like'; table: table_ref_list; } - return { - type: 'like', - table: t, - }; - }; - var peg$f26 = function (e) { - // => create_like_table_simple & { parentheses?: boolean; } - e.parentheses = true; - return e; - }; - var peg$f27 = function (head, tail) { - // => create_definition[] - return createList(head, tail); - }; - var peg$f28 = function (a) { - // => { auto_increment: 'auto_increment'; } - return { auto_increment: a.toLowerCase() }; - }; - var peg$f29 = function (u) { - // => { unique_or_primary: 'unique' | 'primary key'; } - const unique_or_primary = []; - if (u) unique_or_primary.push(u[0], u[2]); - return { - unique_or_primary: unique_or_primary - .filter((v) => v) - .join(' ') - .toLowerCase(''), - }; - }; - var peg$f30 = function (co) { - // => { comment: keyword_comment; } - return { comment: co }; - }; - var peg$f31 = function (ca) { - // => { collate: collate_expr; } - return { collate: ca }; - }; - var peg$f32 = function (cf) { - // => { column_format: column_format; } - return { column_format: cf }; - }; - var peg$f33 = function (s) { - // => { storage: storage } - return { storage: s }; - }; - var peg$f34 = function (re) { - // => { reference_definition: reference_definition; } - return { reference_definition: re }; - }; - var peg$f35 = function (t, s, v) { - // => { character_set: collate_expr } - return { character_set: { type: t, value: v, symbol: s } }; - }; - var peg$f36 = function (head, tail) { - /* - => { - nullable?: column_constraint['nullable']; - default_val?: column_constraint['default_val']; - auto_increment?: 'auto_increment'; - unique_or_primary?: 'unique' | 'primary key'; - comment?: keyword_comment; - collate?: collate_expr; - column_format?: column_format; - storage?: storage; - reference_definition?: reference_definition; - } - */ - let opt = head; - for (let i = 0; i < tail.length; i++) { - opt = { ...opt, ...tail[i][1] }; - } - return opt; - }; - var peg$f37 = function (c, d, cdo) { - /* - => { - column: column_ref; - definition: data_type; - nullable: column_constraint['nullable']; - default_val: column_constraint['default_val']; - auto_increment?: 'auto_increment'; - unique_or_primary?: 'unique' | 'primary key'; - comment?: keyword_comment; - collate?: collate_expr; - column_format?: column_format; - storage?: storage; - reference_definition?: reference_definition; - resource: 'column'; - } - */ - columnList.add(`create::${c.table}::${c.column}`); - return { - column: c, - definition: d, - resource: 'column', - ...(cdo || {}), - }; - }; - var peg$f38 = function (n, df) { - // => { nullable: literal_null | literal_not_null; default_val: default_expr; } - if (n && !n.value) n.value = 'null'; - return { - default_val: df, - nullable: n, - }; - }; - var peg$f39 = function (df, n) { - // => { nullable: literal_null | literal_not_null; default_val: default_expr; } - if (n && !n.value) n.value = 'null'; - return { - default_val: df, - nullable: n, - }; - }; - var peg$f40 = function (s, ca) { - // => { type: 'collate'; symbol: '=' | null; value: ident; } - return { - type: 'collate', - symbol: s, - value: ca, - }; - }; - var peg$f41 = function (k, f) { - // => { type: 'column_format'; value: 'fixed' | 'dynamic' | 'default'; } - return { - type: 'column_format', - value: f.toLowerCase(), - }; - }; - var peg$f42 = function (k, s) { - // => { type: 'storage'; value: 'disk' | 'memory' } - return { - type: 'storage', - value: s.toLowerCase(), - }; - }; - var peg$f43 = function (ce) { - // => { type: 'default'; value: literal | expr; } - return { - type: 'default', - value: ce, - }; - }; - var peg$f44 = function (head, tail) { - // => (ALTER_ALGORITHM | ALTER_LOCK)[] - return createList(head, tail, 1); - }; - var peg$f45 = function (a, r, t) { - /* - export interface drop_stmt_node { - type: 'drop'; - keyword: 'table'; - name: table_ref_list; - } - => AstStatement - */ - if (t) t.forEach((tt) => tableList.add(`${a}::${tt.db}::${tt.table}`)); - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: a.toLowerCase(), - keyword: r.toLowerCase(), - name: t, - }, - }; - }; - var peg$f46 = function (a, r, cu, ie, i, op) { - /* - export interface drop_index_stmt_node { - type: 'drop'; - prefix?: 'CONCURRENTLY'; - keyword: string; - name: column_ref; - options?: 'cascade' | 'restrict'; - } - => AstStatement - */ - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: a.toLowerCase(), - keyword: r.toLowerCase(), - prefix: cu, - name: i, - options: op && [{ type: 'origin', value: op }], - }, - }; - }; - var peg$f47 = function (a, kw, t) { - /* - export interface truncate_stmt_node { - type: 'trucate'; - keyword: 'table'; - name: table_ref_list; - } - => AstStatement - */ - if (t) t.forEach((tt) => tableList.add(`${a}::${tt.db}::${tt.table}`)); - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: a.toLowerCase(), - keyword: (kw && kw.toLowerCase()) || 'table', - name: t, - }, - }; - }; - var peg$f48 = function (d) { - /* - export interface use_stmt_node { - type: 'use'; - db: ident; - } - => AstStatement - */ - tableList.add(`use::${d}::null`); - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: 'use', - db: d, - }, - }; - }; - var peg$f49 = function (t, e) { - /* - export interface alter_table_stmt_node { - type: 'alter'; - table: table_ref_list; - expr: alter_action_list; - } - => AstStatement - */ - if (t && t.length > 0) t.forEach((table) => tableList.add(`alter::${table.db}::${table.table}`)); - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: 'alter', - table: t, - expr: e, - }, - }; - }; - var peg$f50 = function (head, tail) { - // => alter_action[] - return createList(head, tail); - }; - var peg$f51 = function (kc, cd) { - /* - => { - action: 'add'; - keyword: KW_COLUMN; - resource: 'column'; - type: 'alter'; - } & create_column_definition; - */ - return { - action: 'add', - ...cd, - keyword: kc, - resource: 'column', - type: 'alter', - }; - }; - var peg$f52 = function (kc, c) { - /* => { - action: 'drop'; - collumn: column_ref; - keyword: KW_COLUMN; - resource: 'column'; - type: 'alter'; - } */ - return { - action: 'drop', - column: c, - keyword: kc, - resource: 'column', - type: 'alter', - }; - }; - var peg$f53 = function (c) { - /* => { - action: 'add'; - create_definitions: create_db_definition; - resource: 'constraint'; - type: 'alter'; - } */ - return { - action: 'add', - create_definitions: c, - resource: 'constraint', - type: 'alter', - }; - }; - var peg$f54 = function (id) { - /* => { - action: 'add'; - type: 'alter'; - } & create_index_definition */ - return { - action: 'add', - type: 'alter', - ...id, - }; - }; - var peg$f55 = function (kw, tn) { - /* => { - action: 'rename'; - type: 'alter'; - resource: 'table'; - keyword?: 'to' | 'as'; - table: ident; - } */ - return { - action: 'rename', - type: 'alter', - resource: 'table', - keyword: kw && kw[0].toLowerCase(), - table: tn, - }; - }; - var peg$f56 = function (s, val) { - /* => { - type: 'alter'; - keyword: 'algorithm'; - resource: 'algorithm'; - symbol?: '='; - algorithm: 'DEFAULT' | 'INSTANT' | 'INPLACE' | 'COPY'; - }*/ - return { - type: 'alter', - keyword: 'algorithm', - resource: 'algorithm', - symbol: s, - algorithm: val, - }; - }; - var peg$f57 = function (s, val) { - /* => { - type: 'alter'; - keyword: 'lock'; - resource: 'lock'; - symbol?: '='; - lock: 'DEFAULT' | 'NONE' | 'SHARED' | 'EXCLUSIVE'; - }*/ - return { - type: 'alter', - keyword: 'lock', - resource: 'lock', - symbol: s, - lock: val, - }; - }; - var peg$f58 = function (kc, c, t, de, id) { - /* => { - index: column; - definition: cte_column_definition; - keyword: 'index' | 'key'; - index_type?: index_type; - resource: 'index'; - index_options?: index_options; - }*/ - return { - index: c, - definition: de, - keyword: kc.toLowerCase(), - index_type: t, - resource: 'index', - index_options: id, - }; - }; - var peg$f59 = function (p, kc, c, de, id) { - /* => { - index: column; - definition: cte_column_definition; - keyword: 'fulltext' | 'spatial' | 'fulltext key' | 'spatial key' | 'fulltext index' | 'spatial index'; - index_options?: index_options; - resource: 'index'; - }*/ - return { - index: c, - definition: de, - keyword: (kc && `${p.toLowerCase()} ${kc.toLowerCase()}`) || p.toLowerCase(), - index_options: id, - resource: 'index', - }; - }; - var peg$f60 = function (kc, c) { - // => { keyword: 'constraint'; constraint: ident; } - return { - keyword: kc.toLowerCase(), - constraint: c, - }; - }; - var peg$f61 = function (kc, p, t, de, id) { - /* => { - constraint?: constraint_name['constraint']; - definition: cte_column_definition; - constraint_type: 'primary key'; - index_type?: index_type; - resource: 'constraint'; - index_options?: index_options; - }*/ - return { - constraint: kc && kc.constraint, - definition: de, - constraint_type: p.toLowerCase(), - keyword: kc && kc.keyword, - index_type: t, - resource: 'constraint', - index_options: id, - }; - }; - var peg$f62 = function (kc, u, p, i, t, de, id) { - /* => { - constraint?: constraint_name['constraint']; - definition: cte_column_definition; - constraint_type: 'unique key' | 'unique' | 'unique index'; - index_type?: index_type; - resource: 'constraint'; - index_options?: index_options; - }*/ - return { - constraint: kc && kc.constraint, - definition: de, - constraint_type: (p && `${u.toLowerCase()} ${p.toLowerCase()}`) || u.toLowerCase(), - keyword: kc && kc.keyword, - index_type: t, - index: i, - resource: 'constraint', - index_options: id, - }; - }; - var peg$f63 = function (kc, p, i, de, id) { - /* => { - constraint?: constraint_name['constraint']; - definition: cte_column_definition; - constraint_type: 'FOREIGN KEY'; - keyword: constraint_name['keyword']; - index?: column; - resource: 'constraint'; - reference_definition?: reference_definition; - }*/ - return { - constraint: kc && kc.constraint, - definition: de, - constraint_type: p, - keyword: kc && kc.keyword, - index: i, - resource: 'constraint', - reference_definition: id, - }; - }; - var peg$f64 = function (kc, t, de, m, od, ou) { - /* => { - definition: cte_column_definition; - table: table_ref_list; - keyword: 'references'; - match: 'match full' | 'match partial' | 'match simple'; - on_action: [on_reference?]; - }*/ - return { - definition: de, - table: [t], - keyword: kc.toLowerCase(), - match: m && m.toLowerCase(), - on_action: [od, ou].filter((v) => v), - }; - }; - var peg$f65 = function (oa) { - /* => { - on_action: [on_reference]; - } - */ - return { - on_action: [oa], - }; - }; - var peg$f66 = function (kw, ro) { - // => { type: 'on delete' | 'on update'; value: reference_option; } - return { - type: `on ${kw[0].toLowerCase()}`, - value: ro, - }; - }; - var peg$f67 = function (kc) { - // => 'restrict' | 'cascade' | 'set null' | 'no action' | 'set default' - return kc.toLowerCase(); - }; - var peg$f68 = function (kw, kc, t, c, p, te, on, tn, fr, de, fe, tw, fc, fct) { - /* - => { - type: 'create'; - constraint: string; - location: 'before' | 'after' | 'instead of'; - events: trigger_event_list; - table: table_name; - from?: table_name; - deferrable?: trigger_deferrable; - for_each?: trigger_for_row; - when?: trigger_when; - execute: { - keyword: 'execute procedure'; - expr: proc_func_call; - }; - constraint_type: 'trigger'; - keyword: 'trigger'; - constraint_kw: 'constraint'; - resource: 'constraint'; - } - */ - return { - type: 'create', - constraint: c, - location: p && p.toLowerCase(), - events: te, - table: tn, - from: fr && fr[2], - deferrable: de, - for_each: fe, - when: tw, - execute: { - keyword: 'execute procedure', - expr: fct, - }, - constraint_type: t && t.toLowerCase(), - keyword: t && t.toLowerCase(), - constraint_kw: kc && kc.toLowerCase(), - resource: 'constraint', - }; - }; - var peg$f69 = function (kw) { - // => { keyword: 'insert' | 'delete' | 'truncate' } - const keyword = Array.isArray(kw) ? kw[0].toLowerCase() : kw.toLowerCase(); - return { - keyword, - }; - }; - var peg$f70 = function (kw, a) { - // => { keyword: 'update'; args?: { keyword: 'of', columns: column_ref_list; }} - return { - keyword: kw && kw[0] && kw[0].toLowerCase(), - args: (a && { keyword: a[0], columns: a[2] }) || null, - }; - }; - var peg$f71 = function (head, tail) { - // => trigger_event[]; - return createList(head, tail); - }; - var peg$f72 = function (kw, args) { - // => { keyword: 'deferrable' | 'not deferrable'; args: 'initially immediate' | 'initially deferred' } - return { - keyword: kw && kw[0] ? `${kw[0].toLowerCase()} deferrable` : 'deferrable', - args: args && args.toLowerCase(), - }; - }; - var peg$f73 = function (kw, e, ob) { - // => { keyword: 'for' | 'for each'; args: 'row' | 'statement' } - return { - keyword: e ? `${kw.toLowerCase()} ${e.toLowerCase()}` : kw.toLowerCase(), - args: ob.toLowerCase(), - }; - }; - var peg$f74 = function (condition) { - // => { type: 'when'; cond: expr; parentheses: true; } - return { - type: 'when', - cond: condition, - parentheses: true, - }; - }; - var peg$f75 = function (head, tail) { - // => table_option[] - return createList(head, tail); - }; - var peg$f76 = function () { - // => string - return 'CHARACTER SET'; - }; - var peg$f77 = function (kw, t, s, v) { - /* => { - keyword: 'character set' | 'charset' | 'collate' | 'default character set' | 'default charset' | 'default collate'; - symbol: '='; - value: ident_name; - } */ - return { - keyword: (kw && `${kw[0].toLowerCase()} ${t.toLowerCase()}`) || t.toLowerCase(), - symbol: s, - value: v, - }; - }; - var peg$f78 = function (kw, s, v) { - /* => { - keyword: 'auto_increment' | 'avg_row_length' | 'key_block_size' | 'max_rows' | 'min_rows' | 'stats_sample_pages'; - symbol: '='; - value: number; // <== literal_numeric['value'] - } */ - return { - keyword: kw.toLowerCase(), - symbol: s, - value: v.value, - }; - }; - var peg$f79 = function (kw, s, c) { - // => { keyword: 'connection' | 'comment'; symbol: '='; value: string; } - return { - keyword: kw.toLowerCase(), - symbol: s, - value: `'${c.value}'`, - }; - }; - var peg$f80 = function (kw, s, v) { - // => { keyword: 'compression'; symbol: '='; value: "'ZLIB'" | "'LZ4'" | "'NONE'" } - return { - keyword: kw.toLowerCase(), - symbol: s, - value: v.join('').toUpperCase(), - }; - }; - var peg$f81 = function (kw, s, c) { - // => { keyword: 'engine'; symbol: '='; value: string; } - return { - keyword: kw.toLowerCase(), - symbol: s, - value: c.toUpperCase(), - }; - }; - var peg$f82 = function (fsid) { - // => create_fulltext_spatial_index_definition & { action: 'add'; type: 'alter' } - return { - action: 'add', - type: 'alter', - ...fsid, - }; - }; - var peg$f83 = function (t) { - /* - export interface rename_stmt_node { - type: 'rename'; - table: table_to_list; - } - => AstStatement - */ - t.forEach((tg) => tg.forEach((dt) => dt.table && tableList.add(`rename::${dt.db}::${dt.table}`))); - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: 'rename', - table: t, - }, - }; - }; - var peg$f84 = function (kw, a) { - /* - export interface set_stmt_node { - type: 'set'; - expr: assign_stmt & { keyword?: 'GLOBAL' | 'SESSION' | 'LOCAL' | 'PERSIST' | 'PERSIST_ONLY'; }; - } - => AstStatement - */ - a.keyword = kw; - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: 'set', - expr: a, - }, - }; - }; - var peg$f85 = function (m) { - // => { mode: string; } - return { - mode: `in ${m.toLowerCase()} mode`, - }; - }; - var peg$f86 = function (k, t, lm, nw) { - /* - export interface lock_stmt_node { - type: 'lock'; - keyword: 'lock'; - tables: [[table_base], ...{table: table_ref}[]]; // see table_ref_list - lock_mode?: lock_mode; - nowait?: 'NOWAIT'; - } - => AstStatement - */ - - if (t) t.forEach((tt) => tableList.add(`lock::${tt.db}::${tt.table}`)); - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: 'lock', - keyword: k && k.toLowerCase(), - tables: t.map((table) => ({ table })), - lock_mode: lm, - nowait: nw, - }, - }; - }; - var peg$f87 = function (e) { - /* - export interface call_stmt_node { - type: 'call'; - expr: proc_func_call; - } - => AstStatement - */ - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: 'call', - expr: e, - }, - }; - }; - var peg$f88 = function () { - return { - /* - export interface show_stmt_node { - type: 'show'; - keyword: 'tables' | 'var'; - var?: without_prefix_var_decl; - } - => AstStatement - */ - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: 'show', - keyword: 'tables', - }, - }; - }; - var peg$f89 = function (c) { - return { - // => AstStatement - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: 'show', - keyword: 'var', - var: c, - }, - }; - }; - var peg$f90 = function (p, i) { - return { - /* - export interface deallocate_stmt_node { - type: 'deallocate'; - keyword: 'PREPARE' | undefined; - expr: { type: 'default', value: string } - } - => AstStatement - */ - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: 'deallocate', - keyword: p, - expr: { type: 'default', value: i }, - }, - }; - }; - var peg$f91 = function () { - // => { type: 'select'; } - return { - type: 'select', - }; - }; - var peg$f92 = function (s) { - /* - export interface select_stmt_node extends select_stmt_nake { - parentheses_symbol: true; - } - => select_stmt_node - */ - return { - ...s[2], - parentheses_symbol: true, - }; - }; - var peg$f93 = function (head, tail) { - // => cte_definition[] - return createList(head, tail); - }; - var peg$f94 = function (cte) { - // => [cte_definition & {recursive: true; }] - cte.recursive = true; - return [cte]; - }; - var peg$f95 = function (name, columns, stmt) { - // => { name: { type: 'default'; value: string; }; stmt: crud_stmt; columns?: cte_column_definition; } - if (typeof name === 'string') name = { type: 'default', value: name }; - return { name, stmt: stmt.ast, columns }; - }; - var peg$f96 = function (l) { - // => column_ref_list - return l; - }; - var peg$f97 = function (d, o, c) { - // => {type: string; columns: column_ref_list;} - console.lo; - return { - type: `${d} ON`, - columns: c, - }; - }; - var peg$f98 = function (d) { - // => { type: string | undefined; } - return { - type: d, - }; - }; - var peg$f99 = function (cte, opts, d, c, ci, f, fi, w, g, h, o, l, win, li) { - /* => { - with?: with_clause; - type: 'select'; - options?: option_clause; - distinct?: {type: string; columns?: column_list; }; - columns: column_clause; - from?: from_clause; - into?: into_clause; - where?: where_clause; - groupby?: group_by_clause; - having?: having_clause; - orderby?: order_by_clause; - limit?: limit_clause; - window?: window_clause; - }*/ - if ((ci && fi) || (ci && li) || (fi && li) || (ci && fi && li)) { - throw new Error('A given SQL statement can contain at most one INTO clause'); - } - if (f) f.forEach((info) => info.table && tableList.add(`select::${info.db}::${info.table}`)); - return { - with: cte, - type: 'select', - options: opts, - distinct: d, - columns: c, - into: { - ...(ci || fi || li || {}), - position: (ci && 'column') || (fi && 'from') || (li && 'end'), - }, - from: f, - where: w, - groupby: g, - having: h, - orderby: o, - limit: l, - window: win, - }; - }; - var peg$f100 = function (head, tail) { - // => query_option[] - const opts = [head]; - for (let i = 0, l = tail.length; i < l; ++i) { - opts.push(tail[i][1]); - } - return opts; - }; - var peg$f101 = function (option) { - // => 'SQL_CALC_FOUND_ROWS'| 'SQL_CACHE'| 'SQL_NO_CACHE'| 'SQL_BIG_RESULT'| 'SQL_SMALL_RESULT'| 'SQL_BUFFER_RESULT' - return option; - }; - var peg$f102 = function (head, tail) { - // => 'ALL' | '*' | column_list_item[] - columnList.add('select::null::(.*)'); - if (tail && tail.length > 0) { - head[0] = { - expr: { - type: 'column_ref', - table: null, - column: '*', - }, - as: null, - }; - return createList(head[0], tail); - } - return head[0]; - }; - var peg$f103 = function (head, tail) { - // => column_list_item[] - return createList(head, tail); - }; - var peg$f104 = function (n) { - // => { brackets: boolean, number: number } - return { - brackets: true, - number: n, - }; - }; - var peg$f105 = function (e, a) { - // => (expr || binary_expr) & { array_index: array_index } - if (a) e.array_index = a; - return e; - }; - var peg$f106 = function (e, a) { - // => (_expr || binary_expr) & { array_index: array_index } - if (a) e.array_index = a; - return e; - }; - var peg$f107 = function (p, t, s) { - // => data_type & { quoted?: string } - if ((p && !s) || (!p && s)) throw new Error('double quoted not match'); - if (p && s) t.quoted = '"'; - return t; - }; - var peg$f108 = function (c) { - // => { expr: expr; as: null; } - return { expr: c, as: null }; - }; - var peg$f109 = function (e, s, t, tail, alias) { - // => { type: 'cast'; expr: expr; symbol: '::'; target: cast_data_type; as?: null; } - return { - as: alias, - type: 'cast', - expr: e, - symbol: '::', - target: t, - tail: tail && tail[0] && { operator: tail[0][1], expr: tail[0][3] }, - }; - }; - var peg$f110 = function (tbl, pro) { - // => { expr: column_ref; as: null; } - const mid = pro && pro[0]; - let schema; - if (mid) { - schema = tbl; - tbl = mid; - } - columnList.add(`select::${tbl}::(.*)`); - const column = '*'; - return { - expr: { - type: 'column_ref', - table: tbl, - schema, - column, - }, - as: null, - }; - }; - var peg$f111 = function (tbl) { - // => { expr: column_ref; as: null; } - const table = (tbl && tbl[0]) || null; - columnList.add(`select::${table}::(.*)`); - return { - expr: { - type: 'column_ref', - table: table, - column: '*', - }, - as: null, - }; - }; - var peg$f112 = function (c, d) { - if (d) return true; - }; - var peg$f113 = function (c, d, alias) { - // => { type: 'expr'; expr: expr; as?: alias_clause; } - columnList.add(`select::null::${c}`); - return { type: 'expr', expr: { type: 'column_ref', table: null, column: c }, as: alias }; - }; - var peg$f114 = function (e, alias) { - // => { type: 'expr'; expr: expr; as?: alias_clause; } - return { type: 'expr', expr: e, as: alias }; - }; - var peg$f115 = function (i) { - /*=>alias_ident*/ return i; - }; - var peg$f116 = function (i) { - /*=>alias_ident*/ return i; - }; - var peg$f117 = function (i) { - /*=>ident*/ return i; - }; - var peg$f118 = function (v) { - // => { keyword: 'var'; type: 'into'; expr: var_decl_list; } - return { - keyword: 'var', - type: 'into', - expr: v, - }; - }; - var peg$f119 = function (k, f) { - // => { keyword: 'var'; type: 'into'; expr: literal_string | ident; } - return { - keyword: k, - type: 'into', - expr: f, - }; - }; - var peg$f120 = function (l) { - /*=>table_ref_list*/ return l; - }; - var peg$f121 = function (head, tail) { - // => table_to_item[] - return createList(head, tail); - }; - var peg$f122 = function (head, tail) { - // => table_name[] - return [head, tail]; - }; - var peg$f123 = function (t) { - // => { keyword: 'using'; type: 'btree' | 'hash' | 'gist' | 'gin' } - return { - keyword: 'using', - type: t.toLowerCase(), - }; - }; - var peg$f124 = function (head, tail) { - // => index_option[] - return createList(head, tail); - }; - var peg$f125 = function (head, tail) { - // => index_option[] - const result = [head]; - for (let i = 0; i < tail.length; i++) { - result.push(tail[i][1]); - } - return result; - }; - var peg$f126 = function (k, e, kbs) { - // => { type: 'key_block_size'; symbol: '='; expr: number; } - return { - type: k.toLowerCase(), - symbol: e, - expr: kbs, - }; - }; - var peg$f127 = function (k, e, kbs) { - // => { type: ident_name; symbol: '='; expr: number | {type: 'origin'; value: ident; }; } - return { - type: k.toLowerCase(), - symbol: e, - expr: (typeof kbs === 'string' && { type: 'origin', value: kbs }) || kbs, - }; - }; - var peg$f128 = function (pn) { - // => { type: 'with parser'; expr: ident_name } - return { - type: 'with parser', - expr: pn, - }; - }; - var peg$f129 = function (k) { - // => { type: 'visible'; expr: 'visible' } | { type: 'invisible'; expr: 'invisible' } - return { - type: k.toLowerCase(), - expr: k.toLowerCase(), - }; - }; - var peg$f130 = function (head, tail) { - // => [table_base, ...table_ref[]] - tail.unshift(head); - tail.forEach((tableInfo) => { - const { table, as } = tableInfo; - tableAlias[table] = table; - if (as) tableAlias[as] = table; - refreshColumnList(columnList); - }); - return tail; - }; - var peg$f131 = function (t) { - /* => table_base */ return t; - }; - var peg$f132 = function (t) { - /* => table_join */ return t; - }; - var peg$f133 = function (op, t, head, tail) { - // => table_base & {join: join_op; using: ident_name[]; } - t.join = op; - t.using = createList(head, tail); - return t; - }; - var peg$f134 = function (op, t, expr) { - // => table_base & {join: join_op; on?: on_clause; } - t.join = op; - t.on = expr; - return t; - }; - var peg$f135 = function (op, stmt, alias, expr) { - /* => { - expr: (union_stmt || table_ref_list) & { parentheses: true; }; - as?: alias_clause; - join: join_op; - on?: on_clause; - }*/ - if (Array.isArray(stmt)) stmt = { type: 'tables', expr: stmt }; - stmt.parentheses = true; - return { - expr: stmt, - as: alias, - join: op, - on: expr, - }; - }; - var peg$f136 = function () { - // => { type: 'dual' } - return { - type: 'dual', - }; - }; - var peg$f137 = function (stmt, alias) { - // => { expr: value_clause; as?: alias_clause; } - return { - expr: { type: 'values', values: stmt }, - as: alias, - }; - }; - var peg$f138 = function (l, stmt, alias) { - // => { prefix?: string; expr: union_stmt | value_clause; as?: alias_clause; } - if (Array.isArray(stmt)) stmt = { type: 'values', values: stmt }; - stmt.parentheses = true; - return { - prefix: l, - expr: stmt, - as: alias, - }; - }; - var peg$f139 = function (l, stmt, alias) { - // => { prefix?: string; expr: table_ref_list; as?: alias_clause; } - stmt = { type: 'tables', expr: stmt, parentheses: true }; - return { - prefix: l, - expr: stmt, - as: alias, - }; - }; - var peg$f140 = function (l, e, alias) { - // => { prefix?: string; type: 'expr'; expr: expr; as?: alias_clause; } - return { prefix: l, type: 'expr', expr: e, as: alias }; - }; - var peg$f141 = function (t, f, re, alias) { - // => table_name & { expr: expr, repeatable: literal_numeric; as?: alias_clause;} - return { - ...t, - as: alias, - tablesample: { - expr: f, - repeatable: re && re[4], - }, - }; - }; - var peg$f142 = function (t, alias) { - // => table_name & { as?: alias_clause; } - if (t.type === 'var') { - t.as = alias; - return t; - } else { - return { - ...t, - as: alias, - }; - } - }; - var peg$f143 = function () { - /* => 'LEFT JOIN' */ return 'LEFT JOIN'; - }; - var peg$f144 = function () { - /* => 'RIGHT JOIN' */ return 'RIGHT JOIN'; - }; - var peg$f145 = function () { - /* => 'FULL JOIN' */ return 'FULL JOIN'; - }; - var peg$f146 = function () { - /* => 'CROSS JOIN' */ return 'CROSS JOIN'; - }; - var peg$f147 = function () { - /* => 'INNER JOIN' */ return 'INNER JOIN'; - }; - var peg$f148 = function (dt, schema, tail) { - // => { db?: ident; schema?: ident, table: ident | '*'; } - const obj = { db: null, table: dt }; - if (tail !== null) { - obj.db = dt; - obj.schema = schema[3]; - obj.table = tail[3]; - } - return obj; - }; - var peg$f149 = function (dt) { - // => IGNORE - tableList.add(`select::${dt}::(.*)`); - return { - db: dt, - table: '*', - }; - }; - var peg$f150 = function (dt, tail) { - // => IGNORE - const obj = { db: null, table: dt }; - if (tail !== null) { - obj.db = dt; - obj.table = tail[3]; - } - return obj; - }; - var peg$f151 = function (v) { - // => IGNORE - v.db = null; - v.table = v.name; - return v; - }; - var peg$f152 = function (e) { - /* => or_and_where_expr */ return e; - }; - var peg$f153 = function (e) { - /* => binary_expr */ return e; - }; - var peg$f154 = function (e) { - /* => expr_list['value'] */ return e.value; - }; - var peg$f155 = function (head, tail) { - // => column_ref[] - return createList(head, tail); - }; - var peg$f156 = function (e) { - /* => expr */ return e; - }; - var peg$f157 = function (l) { - // => { keyword: 'window'; type: 'window', expr: named_window_expr_list; } - return { - keyword: 'window', - type: 'window', - expr: l, - }; - }; - var peg$f158 = function (head, tail) { - // => named_window_expr[] - return createList(head, tail); - }; - var peg$f159 = function (nw, anw) { - // => { name: ident_name; as_window_specification: as_window_specification; } - return { - name: nw, - as_window_specification: anw, - }; - }; - var peg$f160 = function (ws) { - // => { window_specification: window_specification; parentheses: boolean } - return { - window_specification: ws || {}, - parentheses: true, - }; - }; - var peg$f161 = function (bc, l, w) { - // => { name: null; partitionby: partition_by_clause; orderby: order_by_clause; window_frame_clause: string | null; } - return { - name: null, - partitionby: bc, - orderby: l, - window_frame_clause: w, - }; - }; - var peg$f162 = function (bc, l) { - // => { name: null; partitionby: partition_by_clause; orderby: order_by_clause; window_frame_clause: null } - return { - name: null, - partitionby: bc, - orderby: l, - window_frame_clause: null, - }; - }; - var peg$f163 = function (kw, s) { - // => string - return `rows ${s.value}`; - }; - var peg$f164 = function (p, f) { - // => string - return `rows between ${p.value} and ${f.value}`; - }; - var peg$f165 = function (s) { - // => string - s.value += ' FOLLOWING'; - return s; - }; - var peg$f166 = function (s) { - // => string - s.value += ' PRECEDING'; - return s; - }; - var peg$f167 = function () { - // => { type: 'single_quote_string'; value: string } - return { type: 'single_quote_string', value: 'current row' }; - }; - var peg$f168 = function (s) { - // => literal_string - return { type: 'single_quote_string', value: s.toUpperCase() }; - }; - var peg$f169 = function (bc) { - /* => column_clause */ return bc; - }; - var peg$f170 = function (l) { - /* => order_by_list */ return l; - }; - var peg$f171 = function (head, tail) { - // => order_by_element[] - return createList(head, tail); - }; - var peg$f172 = function (e, d, nl) { - // => { expr: expr; type: 'ASC' | 'DESC'; nulls: 'NULLS FIRST' | 'NULLS LAST' | undefined } - const obj = { expr: e, type: 'ASC' }; - if (d === 'DESC') obj.type = 'DESC'; - obj.nulls = nl && `${nl[0]} ${nl[2] ? nl[2] : obj.type === 'ASC' ? 'LAST' : 'FIRST'}`; - return obj; - }; - var peg$f173 = function (l, tail) { - // => { separator: 'offset' | ''; value: [number_or_param | { type: 'origin', value: 'all' }, number_or_param?] } - const res = []; - if (l) res.push(typeof l[2] === 'string' ? { type: 'origin', value: 'all' } : l[2]); - if (tail) res.push(tail[2]); - return { - seperator: (tail && tail[0] && tail[0].toLowerCase()) || '', - value: res, - }; - }; - var peg$f174 = function (cte, t, l, f, w, r) { - /* export interface update_stmt_node { - with?: with_clause; - type: 'update'; - table: table_ref_list; - set: set_list; - from?: from_clause; - where?: where_clause; - returning?: returning_stmt; - } - => AstStatement - */ - const dbObj = {}; - if (t) - t.forEach((tableInfo) => { - const { db, as, table, join } = tableInfo; - const action = join ? 'select' : 'update'; - if (db) dbObj[table] = db; - if (table) tableList.add(`${action}::${db}::${table}`); - }); - if (l) { - l.forEach((col) => { - if (col.table) { - const table = queryTableAlias(col.table); - tableList.add(`update::${dbObj[table] || null}::${table}`); - } - columnList.add(`update::${col.table}::${col.column}`); - }); - } - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - with: cte, - type: 'update', - table: t, - set: l, - from: f, - where: w, - returning: r, - }, - }; - }; - var peg$f175 = function (t, f, w) { - /* - export interface table_ref_addition extends table_name { - addition: true; - as?: alias_clause; - } - export interface delete_stmt_node { - type: 'delete'; - table?: table_ref_list | [table_ref_addition]; - where?: where_clause; - } - => AstStatement - */ - if (f) - f.forEach((tableInfo) => { - const { db, as, table, join } = tableInfo; - const action = join ? 'select' : 'delete'; - if (table) tableList.add(`${action}::${db}::${table}`); - if (!join) columnList.add(`delete::${table}::(.*)`); - }); - if (t === null && f.length === 1) { - const tableInfo = f[0]; - t = [ - { - db: tableInfo.db, - table: tableInfo.table, - as: tableInfo.as, - addition: true, - }, - ]; - } - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: 'delete', - table: t, - from: f, - where: w, - }, - }; - }; - var peg$f176 = function (head, tail) { - // => set_item[] - return createList(head, tail); - }; - var peg$f177 = function (tbl, c, v) { - // => { column: ident; value: additive_expr; table?: ident;} - return { column: c, value: v, table: tbl && tbl[0] }; - }; - var peg$f178 = function (tbl, c, v) { - // => { column: ident; value: column_ref; table?: ident; keyword: 'values' } - return { column: c, value: v, table: tbl && tbl[0], keyword: 'values' }; - }; - var peg$f179 = function (k, c) { - // => { type: 'returning'; columns: column_clause | select_stmt; } - return { - type: (k && k.toLowerCase()) || 'returning', - columns: (c === '*' && [{ type: 'expr', expr: { type: 'column_ref', table: null, column: '*' }, as: null }]) || c, - }; - }; - var peg$f180 = function (head, tail) { - // => ident_name[] - return createList(head, tail); - }; - var peg$f181 = function (v) { - // => value_item - return v; - }; - var peg$f182 = function (ri, t, p, c, v, r) { - /* - export interface replace_insert_stmt_node { - type: 'insert' | 'replace'; - table?: [table_name]; - columns: column_list; - values: insert_value_clause; - partition?: insert_partition; - returning?: returning_stmt; - } - => AstStatement - */ - if (t) { - tableList.add(`insert::${t.db}::${t.table}`); - t.as = null; - } - if (c) { - let table = (t && t.table) || null; - if (Array.isArray(v)) { - v.forEach((row, idx) => { - if (row.value.length != c.length) { - throw new Error(`Error: column count doesn't match value count at row ${idx + 1}`); - } - }); - } - c.forEach((c) => columnList.add(`insert::${table}::${c}`)); - } - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: ri, - table: [t], - columns: c, - values: v, - partition: p, - returning: r, - }, - }; - }; - var peg$f183 = function (ri, ig, it, t, p, v, r) { - // => AstStatement - if (t) { - tableList.add(`insert::${t.db}::${t.table}`); - columnList.add(`insert::${t.table}::(.*)`); - t.as = null; - } - const prefix = [ig, it] - .filter((v) => v) - .map((v) => v[0] && v[0].toLowerCase()) - .join(' '); - return { - tableList: Array.from(tableList), - columnList: columnListTableAlias(columnList), - ast: { - type: ri, - table: [t], - columns: null, - values: v, - partition: p, - prefix, - returning: r, - }, - }; - }; - var peg$f184 = function () { - /* => 'insert' */ return 'insert'; - }; - var peg$f185 = function () { - /* => 'replace' */ return 'replace'; - }; - var peg$f186 = function (l) { - /* => value_list */ return l; - }; - var peg$f187 = function (head, tail) { - // => value_item[] - return createList(head, tail); - }; - var peg$f188 = function (l) { - // => expr_list - return l; - }; - var peg$f189 = function (head, tail) { - // => { type: 'expr_list'; value: expr_item[] } - const el = { type: 'expr_list' }; - el.value = createList(head, tail); - return el; - }; - var peg$f190 = function (e, u) { - // => { type: 'interval', expr: expr; unit: interval_unit; } - return { - type: 'interval', - expr: e, - unit: u.toLowerCase(), - }; - }; - var peg$f191 = function (e) { - // => { type: 'interval', expr: expr; unit: interval_unit; } - return { - type: 'interval', - expr: e, - unit: '', - }; - }; - var peg$f192 = function (condition_list, otherwise) { - /* => { - type: 'case'; - expr: null; - // nb: Only the last element is a case_else - args: (case_when_then | case_else)[]; - } */ - if (otherwise) condition_list.push(otherwise); - return { - type: 'case', - expr: null, - args: condition_list, - }; - }; - var peg$f193 = function (expr, condition_list, otherwise) { - /* => { - type: 'case'; - expr: expr; - // nb: Only the last element is a case_else - args: (case_when_then | case_else)[]; - } */ - if (otherwise) condition_list.push(otherwise); - return { - type: 'case', - expr: expr, - args: condition_list, - }; - }; - var peg$f194 = function (head, tail) { - // => case_when_then[] - return createList(head, tail, 1); - }; - var peg$f195 = function (condition, result) { - // => { type: 'when'; cond: binary_expr; result: expr; } - return { - type: 'when', - cond: condition, - result: result, - }; - }; - var peg$f196 = function (result) { - // => { type: 'else'; condition?: never; result: expr; } - return { type: 'else', result: result }; - }; - var peg$f197 = function (head, tail, rh) { - /* - export type BINARY_OPERATORS = LOGIC_OPERATOR | 'OR' | 'AND' | multiplicative_operator | additive_operator - | arithmetic_comparison_operator - | 'IN' | 'NOT IN' - | 'BETWEEN' | 'NOT BETWEEN' - | 'IS' | 'IS NOT' - | 'LIKE' - | '@>' | '<@' | OPERATOR_CONCATENATION | DOUBLE_WELL_ARROW | WELL_ARROW | '?' | '?|' | '?&' | '#-' - export interface binary_expr { - type: 'binary_expr', - operator: BINARY_OPERATORS, - left: expr, - right: expr - } - => binary_expr - */ - const logicExpr = createBinaryExprChain(head, tail); - if (rh === null) return logicExpr; - else if (rh.type === 'arithmetic') return createBinaryExprChain(logicExpr, rh.tail); - else return createBinaryExpr(rh.op, logicExpr, rh.right); - }; - var peg$f198 = function (op, tail) { - /* - export type UNARY_OPERATORS = '+' | '-' | 'EXISTS' | 'NOT EXISTS' | 'NULL' - => { - type: 'unary_expr', - operator: UNARY_OPERATORS, - expr: expr; - parentheses?: boolean; - } */ - return createUnaryExpr(op, tail[0][1]); - }; - var peg$f199 = function (head, tail) { - // => binary_expr - const len = tail.length; - let result = tail[len - 1][3]; - for (let i = len - 1; i >= 0; i--) { - const left = i === 0 ? head : tail[i - 1][3]; - result = createBinaryExpr(tail[i][1], left, result); - } - return result; - }; - var peg$f200 = function (head, tail) { - // => binary_expr | { type: 'expr_list'; value: expr[] } - const len = tail.length; - let result = head; - let seperator = ''; - for (let i = 0; i < len; ++i) { - if (tail[i][1] === ',') { - seperator = ','; - if (!Array.isArray(result)) result = [result]; - result.push(tail[i][3]); - } else { - result = createBinaryExpr(tail[i][1], result, tail[i][3]); - } - } - if (seperator === ',') { - const el = { type: 'expr_list' }; - el.value = result; - return el; - } - return result; - }; - var peg$f201 = function (head, tail) { - // => binary_expr - return createBinaryExprChain(head, tail); - }; - var peg$f202 = function (head, tail) { - // => binary_expr - return createBinaryExprChain(head, tail); - }; - var peg$f203 = function (expr) { - // => unary_expr - return createUnaryExpr('NOT', expr); - }; - var peg$f204 = function (left, rh) { - // => binary_expr - if (rh === null) return left; - else if (rh.type === 'arithmetic') return createBinaryExprChain(left, rh.tail); - else return createBinaryExpr(rh.op, left, rh.right); - }; - var peg$f205 = function (op, stmt) { - // => unary_expr - stmt.parentheses = true; - return createUnaryExpr(op, stmt); - }; - var peg$f206 = function (nk) { - /* => 'NOT EXISTS' */ return nk[0] + ' ' + nk[2]; - }; - var peg$f207 = function (l) { - // => { type: 'arithmetic'; tail: any } - return { type: 'arithmetic', tail: l }; - }; - var peg$f208 = function (right) { - // => { op: 'IS'; right: additive_expr; } - return { op: 'IS', right: right }; - }; - var peg$f209 = function (right) { - // => { type: 'origin'; value: string; } - const { db, table } = right.pop(); - const tableName = table === '*' ? '*' : `"${table}"`; - let tableStr = db ? `"${db}".${tableName}` : tableName; - return { - op: 'IS', - right: { - type: 'default', - value: `DISTINCT FROM ${tableStr}`, - }, - }; - }; - var peg$f210 = function (right) { - // => { type: 'IS NOT'; right: additive_expr; } - return { op: 'IS NOT', right: right }; - }; - var peg$f211 = function (op, begin, end) { - // => { op: 'BETWEEN' | 'NOT BETWEEN'; right: { type: 'expr_list'; value: [expr, expr] } } - return { - op: op, - right: { - type: 'expr_list', - value: [begin, end], - }, - }; - }; - var peg$f212 = function (nk) { - /* => 'NOT BETWEEN' */ return nk[0] + ' ' + nk[2]; - }; - var peg$f213 = function (nk) { - /* => 'LIKE' */ return nk[0] + ' ' + nk[2]; - }; - var peg$f214 = function () { - // => 'SIMILAR TO' - return 'SIMILAR TO'; - }; - var peg$f215 = function () { - // => 'NOT SIMILAR TO' - return 'NOT SIMILAR TO'; - }; - var peg$f216 = function (kw, c) { - // => { type: 'ESCAPE'; value: literal_string } - return { - type: 'ESCAPE', - value: c, - }; - }; - var peg$f217 = function (nk) { - /* => 'NOT IN' */ return nk[0] + ' ' + nk[2]; - }; - var peg$f218 = function (op, right, es) { - // => { op: like_op; right: (literal | comparison_expr) & { escape?: escape_op }; } - if (es) right.escape = es; - return { op: op, right: right }; - }; - var peg$f219 = function (op, l) { - // => {op: in_op; right: expr_list | var_decl | literal_string; } - return { op: op, right: l }; - }; - var peg$f220 = function (op, e) { - // => IGNORE - return { op: op, right: e }; - }; - var peg$f221 = function (s, c) { - // => { op: string; right: expr } - return { - op: s, - right: (c && c.expr) || c, - }; - }; - var peg$f222 = function (head, tail) { - // => binary_expr - return createBinaryExprChain(head, tail); - }; - var peg$f223 = function (head, tail) { - // => binary_expr - return createBinaryExprChain(head, tail); - }; - var peg$f224 = function (c, a) { - // => column_ref - c.array_index = a; - return c; - }; - var peg$f225 = function (list) { - // => or_and_where_expr - list.parentheses = true; - return list; - }; - var peg$f226 = function (p, n) { - // => { type: 'origin'; value: string; } - return { - type: 'origin', - value: `$<${n.value}>`, - }; - }; - var peg$f227 = function (n) { - // => { type: 'origin'; value: string; } - return { - type: 'origin', - value: `E'${n.join('')}'`, - }; - }; - var peg$f228 = function (tbl) { - // => IGNORE - const table = (tbl && tbl[0]) || null; - columnList.add(`select::${table}::(.*)`); - return { - type: 'column_ref', - table: table, - column: '*', - }; - }; - var peg$f229 = function (tbl, col, a) { - // => IGNORE - const tableName = (tbl && tbl[0]) || null; - columnList.add(`select::${tableName}::${col}`); - return { - type: 'column_ref', - table: tableName, - column: col, - arrows: a.map((item) => item[0]), - properties: a.map((item) => item[2]), - }; - }; - var peg$f230 = function (schema, tbl, col) { - /* => { - type: 'column_ref'; - schema: string; - table: string; - column: column | '*'; - arrows?: ('->>' | '->')[]; - property?: (literal_string | literal_numeric)[]; - } */ - columnList.add(`select::${schema}.${tbl[3]}::${col[3]}`); - return { - type: 'column_ref', - schema: schema, - table: tbl[3], - column: col[3], - }; - }; - var peg$f231 = function (tbl, col) { - /* => { - type: 'column_ref'; - table: ident; - column: column | '*'; - arrows?: ('->>' | '->')[]; - property?: (literal_string | literal_numeric)[]; - } */ - columnList.add(`select::${tbl}::${col}`); - return { - type: 'column_ref', - table: tbl, - column: col, - }; - }; - var peg$f232 = function (col) { - // => IGNORE - columnList.add(`select::null::${col}`); - return { - type: 'column_ref', - table: null, - column: col, - }; - }; - var peg$f233 = function (head, tail) { - // => column[] - return createList(head, tail); - }; - var peg$f234 = function (name) { - return reservedMap[name.toUpperCase()] === true; - }; - var peg$f235 = function (name) { - // => ident_name - return name; - }; - var peg$f236 = function (name) { - // => indent_name - return name; - }; - var peg$f237 = function (name) { - return reservedMap[name.toUpperCase()] === true; - }; - var peg$f238 = function (name, c) { - // => string - return `${name}(${c.join(', ')})`; - }; - var peg$f239 = function (name) { - return reservedMap[name.toUpperCase()] === true; - }; - var peg$f240 = function (name) { - // => string - return name; - }; - var peg$f241 = function (name) { - // => IGNORE - return name; - }; - var peg$f242 = function (chars) { - /* => string */ return chars.join(''); - }; - var peg$f243 = function (chars) { - /* => string */ return chars.join(''); - }; - var peg$f244 = function (chars) { - /* => string */ return chars.join(''); - }; - var peg$f245 = function (name) { - return reservedMap[name.toUpperCase()] === true; - }; - var peg$f246 = function (name) { - /* => string */ return name; - }; - var peg$f247 = function (start, parts) { - /* => string */ return start + parts.join(''); - }; - var peg$f248 = function (start, parts) { - // => string - return start + parts.join(''); - }; - var peg$f249 = function (l) { - // => { type: 'param'; value: ident_name } - return { type: 'param', value: l[1] }; - }; - var peg$f250 = function (kw, l) { - // => { type: 'on update'; keyword: string; parentheses: boolean; expr: expr } - return { - type: 'on update', - keyword: kw, - parentheses: true, - expr: l, - }; - }; - var peg$f251 = function (kw) { - // => { type: 'on update'; keyword: string; } - return { - type: 'on update', - keyword: kw, - }; - }; - var peg$f252 = function (aws) { - // => { type: 'windows'; as_window_specification: as_window_specification } - return { - type: 'window', - as_window_specification: aws, - }; - }; - var peg$f253 = function (bc, l) { - // => { partitionby: partition_by_clause; orderby: order_by_clause } - return { - partitionby: bc, - orderby: l, - }; - }; - var peg$f254 = function (wc) { - // => { keyword: 'filter'; parentheses: true, where: where_clause } - return { - keyword: 'filter', - parentheses: true, - where: wc, - }; - }; - var peg$f255 = function (e, f) { - // => { type: 'aggr_func'; name: string; args: { expr: additive_expr } | count_arg; over: over_partition; filter?: aggr_filter; } - if (f) e.filter = f; - return e; - }; - var peg$f256 = function (name, over) { - // => { type: 'window_func'; name: string; over: over_partition } - return { - type: 'window_func', - name: name, - over: over, - }; - }; - var peg$f257 = function (name, l, cn, over) { - // => { type: 'window_func'; name: string; args: expr_list; consider_nulls: null | string; over: over_partition } - return { - type: 'window_func', - name: name, - args: l, - over: over, - consider_nulls: cn, - }; - }; - var peg$f258 = function (name, l, cn, over) { - // => window_fun_laglead - return { - type: 'window_func', - name: name, - args: { - type: 'expr_list', - value: [l], - }, - over: over, - consider_nulls: cn, - }; - }; - var peg$f259 = function (v) { - // => string - return v.toUpperCase() + ' NULLS'; - }; - var peg$f260 = function (name, e, bc) { - // => { type: 'aggr_func'; name: 'SUM' | 'MAX' | 'MIN' | 'AVG'; args: { expr: additive_expr }; over: over_partition } - return { - type: 'aggr_func', - name: name, - args: { - expr: e, - }, - over: bc, - }; - }; - var peg$f261 = function (name, arg, bc) { - // => { type: 'aggr_func'; name: 'COUNT' | 'GROUP_CONCAT'; args:count_arg; over: over_partition } - return { - type: 'aggr_func', - name: name, - args: arg, - over: bc, - }; - }; - var peg$f262 = function (name, arg, or, bc) { - // => { type: 'aggr_func'; name: 'PERCENTILE_CONT' | 'PERCENTILE_DISC'; args: literal_numeric / literal_array; within_group_orderby: order_by_clause; over?: over_partition } - return { - type: 'aggr_func', - name: name.toUpperCase(), - args: { - expr: arg, - }, - within_group_orderby: or, - over: bc, - }; - }; - var peg$f263 = function (name, or, bc) { - // => { type: 'aggr_func'; name: 'MODE'; args: literal_numeric / literal_array; within_group_orderby: order_by_clause; over?: over_partition } - return { - type: 'aggr_func', - name: name.toUpperCase(), - args: { expr: {} }, - within_group_orderby: or, - over: bc, - }; - }; - var peg$f264 = function (kw, s) { - // => { keyword: string | null; value: literal_string; } - return { - keyword: kw, - value: s, - }; - }; - var peg$f265 = function (d, c, or, s) { - /* => { distinct: 'DISTINCT'; expr: expr; orderby?: order_by_clause; parentheses: boolean; separator?: concat_separator; } */ return { - distinct: d, - expr: c, - orderby: or, - parentheses: true, - separator: s, - }; - }; - var peg$f266 = function (d, c, or, s) { - /* => { distinct: 'DISTINCT'; expr: expr; orderby?: order_by_clause; parentheses: boolean; separator?: concat_separator; } */ return { - distinct: d, - expr: c, - orderby: or, - parentheses: false, - separator: s, - }; - }; - var peg$f267 = function (e) { - /* => { expr: star_expr } */ return { expr: e }; - }; - var peg$f268 = function (pre, name, arg, o) { - // => { type: 'aggr_func'; args:count_arg; name: 'ARRAY_AGG'; orderby?: order_by_clause } - return { - type: 'aggr_func', - name: pre ? `${pre[0]}.${name}` : name, - args: arg, - orderby: o, - }; - }; - var peg$f269 = function () { - /* => { type: 'star'; value: '*' } */ return { type: 'star', value: '*' }; - }; - var peg$f270 = function (p, rm, k) { - // => expr_list - let value = []; - if (p) value.push({ type: 'origin', value: p }); - if (rm) value.push(rm); - value.push({ type: 'origin', value: 'from' }); - return { - type: 'expr_list', - value, - }; - }; - var peg$f271 = function (tr, s) { - // => { type: 'function'; name: string; args: expr_list; } - let args = tr || { type: 'expr_list', value: [] }; - args.value.push(s); - return { - type: 'function', - name: 'TRIM', - args, - }; - }; - var peg$f272 = function (name, l, z) { - // => { type: 'function'; name: string; args: expr_list; suffix: literal_string; } - z.prefix = 'at time zone'; - return { - type: 'function', - name: name, - args: l ? l : { type: 'expr_list', value: [] }, - suffix: z, - }; - }; - var peg$f273 = function (name, l, bc) { - // => { type: 'function'; name: string; args: expr_list; over?: over_partition; } - return { - type: 'function', - name: name, - args: l ? l : { type: 'expr_list', value: [] }, - over: bc, - }; - }; - var peg$f274 = function (name, l) { - // => { type: 'function'; name: string; args: expr_list; } - if (l && l.type !== 'expr_list') l = { type: 'expr_list', value: [l] }; - return { - type: 'function', - name: name, - args: l ? l : { type: 'expr_list', value: [] }, - }; - }; - var peg$f275 = function (f, up) { - // => { type: 'function'; name: string; over?: on_update_current_timestamp; } - return { - type: 'function', - name: f, - over: up, - }; - }; - var peg$f276 = function (f) { - // => 'string' - return f; - }; - var peg$f277 = function (kw, f, t, s) { - // => { type: 'extract'; args: { field: extract_filed; cast_type: 'TIMESTAMP' | 'INTERVAL' | 'TIME'; source: expr; }} - return { - type: kw.toLowerCase(), - args: { - field: f, - cast_type: t, - source: s, - }, - }; - }; - var peg$f278 = function (kw, f, s) { - // => { type: 'extract'; args: { field: extract_filed; source: expr; }} - return { - type: kw.toLowerCase(), - args: { - field: f, - source: s, - }, - }; - }; - var peg$f279 = function (e, s, t, alias) { - /* => { - as?: alias_clause, - type: 'cast'; - expr: literal | aggr_func | func_call | case_expr | interval_expr | column_ref | param - | expr; - symbol: '::' | 'as', - keyword: 'cast'; - target: data_type; - } - */ - e.parentheses = true; - return { - as: alias, - type: 'cast', - keyword: 'cast', - expr: e, - symbol: '::', - target: t, - }; - }; - var peg$f280 = function (e, s, t, alias) { - /* => { - as?: alias_clause, - type: 'cast'; - expr: literal | aggr_func | func_call | case_expr | interval_expr | column_ref | param - | expr; - symbol: '::' | 'as', - keyword: 'cast'; - target: data_type; - } - */ - return { - as: alias, - type: 'cast', - keyword: 'cast', - expr: e, - symbol: '::', - target: t, - }; - }; - var peg$f281 = function (c, e, t) { - // => IGNORE - return { - type: 'cast', - keyword: c.toLowerCase(), - expr: e, - symbol: 'as', - target: t, - }; - }; - var peg$f282 = function (c, e, precision) { - // => IGNORE - return { - type: 'cast', - keyword: c.toLowerCase(), - expr: e, - symbol: 'as', - target: { - dataType: 'DECIMAL(' + precision + ')', - }, - }; - }; - var peg$f283 = function (c, e, precision, scale) { - // => IGNORE - return { - type: 'cast', - keyword: c.toLowerCase(), - expr: e, - symbol: 'as', - target: { - dataType: 'DECIMAL(' + precision + ', ' + scale + ')', - }, - }; - }; - var peg$f284 = function (c, e, s, t) { - /* MySQL cast to un-/signed integer */ - // => IGNORE - return { - type: 'cast', - keyword: c.toLowerCase(), - expr: e, - symbol: 'as', - target: { - dataType: s + (t ? ' ' + t : ''), - }, - }; - }; - var peg$f285 = function (s, c) { - /* - => { - expr_list: expr_list | {type: 'origin', value: ident }, - type: string, - keyword: string, - brackets: boolean - } - */ - return { - expr_list: c || { type: 'origin', value: '' }, - type: 'array', - keyword: 'array', - brackets: true, - }; - }; - var peg$f286 = function (head, tail) { - // => literal[] - return createList(head, tail); - }; - var peg$f287 = function () { - // => { type: 'null'; value: null } - return { type: 'null', value: null }; - }; - var peg$f288 = function () { - // => { type: 'not null'; value: 'not null' } - return { - type: 'not null', - value: 'not null', - }; - }; - var peg$f289 = function () { - // => { type: 'bool', value: true } - return { type: 'bool', value: true }; - }; - var peg$f290 = function () { - //=> { type: 'bool', value: false } - return { type: 'bool', value: false }; - }; - var peg$f291 = function (ca, fs) { - // => { type: 'single_quote_string'; value: string; } - return { - type: 'single_quote_string', - value: `${ca[1].join('')}${fs[1].join('')}`, - }; - }; - var peg$f292 = function (ca) { - // => { type: 'single_quote_string'; value: string; } - return { - type: 'single_quote_string', - value: ca[1].join(''), - }; - }; - var peg$f293 = function (ca) { - // => { type: 'string'; value: string; } - return { - type: 'double_quote_string', - value: ca[1].join(''), - }; - }; - var peg$f294 = function (type, ca) { - // => { type: 'TIME' | 'DATE' | 'TIMESTAMP' | 'DATETIME', value: string } - return { - type: type.toLowerCase(), - value: ca[1].join(''), - }; - }; - var peg$f295 = function (type, ca) { - // => { type: 'TIME' | 'DATE' | 'TIMESTAMP' | 'DATETIME', value: string } - return { - type: type.toLowerCase(), - value: ca[1].join(''), - }; - }; - var peg$f296 = function () { - return "\\'"; - }; - var peg$f297 = function () { - return '\\"'; - }; - var peg$f298 = function () { - return '\\\\'; - }; - var peg$f299 = function () { - return '\\/'; - }; - var peg$f300 = function () { - return '\b'; - }; - var peg$f301 = function () { - return '\f'; - }; - var peg$f302 = function () { - return '\n'; - }; - var peg$f303 = function () { - return '\r'; - }; - var peg$f304 = function () { - return '\t'; - }; - var peg$f305 = function (h1, h2, h3, h4) { - return String.fromCharCode(parseInt('0x' + h1 + h2 + h3 + h4)); - }; - var peg$f306 = function () { - return '\\'; - }; - var peg$f307 = function () { - return "''"; - }; - var peg$f308 = function (n) { - // => number | { type: 'bigint'; value: string; } - if (n && n.type === 'bigint') return n; - return { type: 'number', value: n }; - }; - var peg$f309 = function (int_, frac, exp) { - const numStr = (int_ || '') + frac + exp; - return { - type: 'bigint', - value: numStr, - }; - }; - var peg$f310 = function (int_, frac) { - // => IGNORE - const numStr = (int_ || '') + frac; - if (int_ && isBigInt(int_)) - return { - type: 'bigint', - value: numStr, - }; - return parseFloat(numStr); - }; - var peg$f311 = function (int_, exp) { - // => IGNORE - const numStr = int_ + exp; - return { - type: 'bigint', - value: numStr, - }; - }; - var peg$f312 = function (int_) { - // => IGNORE - if (isBigInt(int_)) - return { - type: 'bigint', - value: int_, - }; - return parseFloat(int_); - }; - var peg$f313 = function (op, digits) { - return op + digits; - }; - var peg$f314 = function (op, digit) { - return op + digit; - }; - var peg$f315 = function (digits) { - return '.' + digits; - }; - var peg$f316 = function (e, digits) { - return e + digits; - }; - var peg$f317 = function (digits) { - return digits.join(''); - }; - var peg$f318 = function (e, sign) { - return e + (sign !== null ? sign : ''); - }; - var peg$f319 = function () { - return 'DROP'; - }; - var peg$f320 = function () { - return 'TEMPORARY'; - }; - var peg$f321 = function () { - return 'TEMP'; - }; - var peg$f322 = function () { - return 'RETURNING'; - }; - var peg$f323 = function () { - return 'PARTITION'; - }; - var peg$f324 = function () { - return 'TABLE'; - }; - var peg$f325 = function () { - return 'DATABASE'; - }; - var peg$f326 = function () { - return 'SCHEME'; - }; - var peg$f327 = function () { - return 'SEQUENCE'; - }; - var peg$f328 = function () { - return 'TABLESPACE'; - }; - var peg$f329 = function () { - return 'COLLATE'; - }; - var peg$f330 = function () { - return 'DEALLOCATE'; - }; - var peg$f331 = function () { - return 'OFFSET'; - }; - var peg$f332 = function () { - return 'ASC'; - }; - var peg$f333 = function () { - return 'DESC'; - }; - var peg$f334 = function () { - return 'ALL'; - }; - var peg$f335 = function () { - return 'DISTINCT'; - }; - var peg$f336 = function () { - return 'BETWEEN'; - }; - var peg$f337 = function () { - return 'IN'; - }; - var peg$f338 = function () { - return 'IS'; - }; - var peg$f339 = function () { - return 'LIKE'; - }; - var peg$f340 = function () { - return 'ILIKE'; - }; - var peg$f341 = function () { - /* => 'EXISTS' */ return 'EXISTS'; - }; - var peg$f342 = function () { - return 'NOT'; - }; - var peg$f343 = function () { - return 'AND'; - }; - var peg$f344 = function () { - return 'OR'; - }; - var peg$f345 = function () { - return 'ARRAY'; - }; - var peg$f346 = function () { - return 'ARRAY_AGG'; - }; - var peg$f347 = function () { - return 'COUNT'; - }; - var peg$f348 = function () { - return 'GROUP_CONCAT'; - }; - var peg$f349 = function () { - return 'MAX'; - }; - var peg$f350 = function () { - return 'MIN'; - }; - var peg$f351 = function () { - return 'SUM'; - }; - var peg$f352 = function () { - return 'AVG'; - }; - var peg$f353 = function () { - return 'EXTRACT'; - }; - var peg$f354 = function () { - return 'CALL'; - }; - var peg$f355 = function () { - return 'CAST'; - }; - var peg$f356 = function () { - return 'BOOL'; - }; - var peg$f357 = function () { - return 'BOOLEAN'; - }; - var peg$f358 = function () { - return 'CHAR'; - }; - var peg$f359 = function () { - return 'CHARACTER'; - }; - var peg$f360 = function () { - return 'VARCHAR'; - }; - var peg$f361 = function () { - return 'NUMERIC'; - }; - var peg$f362 = function () { - return 'DECIMAL'; - }; - var peg$f363 = function () { - return 'SIGNED'; - }; - var peg$f364 = function () { - return 'UNSIGNED'; - }; - var peg$f365 = function () { - return 'INT'; - }; - var peg$f366 = function () { - return 'ZEROFILL'; - }; - var peg$f367 = function () { - return 'INTEGER'; - }; - var peg$f368 = function () { - return 'JSON'; - }; - var peg$f369 = function () { - return 'JSONB'; - }; - var peg$f370 = function () { - return 'GEOMETRY'; - }; - var peg$f371 = function () { - return 'SMALLINT'; - }; - var peg$f372 = function () { - return 'SERIAL'; - }; - var peg$f373 = function () { - return 'TINYINT'; - }; - var peg$f374 = function () { - return 'TINYTEXT'; - }; - var peg$f375 = function () { - return 'TEXT'; - }; - var peg$f376 = function () { - return 'MEDIUMTEXT'; - }; - var peg$f377 = function () { - return 'LONGTEXT'; - }; - var peg$f378 = function () { - return 'BIGINT'; - }; - var peg$f379 = function () { - return 'ENUM'; - }; - var peg$f380 = function () { - return 'FLOAT'; - }; - var peg$f381 = function () { - return 'DOUBLE'; - }; - var peg$f382 = function () { - return 'BIGSERIAL'; - }; - var peg$f383 = function () { - return 'REAL'; - }; - var peg$f384 = function () { - return 'DATE'; - }; - var peg$f385 = function () { - return 'DATETIME'; - }; - var peg$f386 = function () { - return 'ROWS'; - }; - var peg$f387 = function () { - return 'TIME'; - }; - var peg$f388 = function () { - return 'TIMESTAMP'; - }; - var peg$f389 = function () { - return 'TRUNCATE'; - }; - var peg$f390 = function () { - return 'USER'; - }; - var peg$f391 = function () { - return 'UUID'; - }; - var peg$f392 = function () { - return 'OID'; - }; - var peg$f393 = function () { - return 'REGCLASS'; - }; - var peg$f394 = function () { - return 'REGCOLLATION'; - }; - var peg$f395 = function () { - return 'REGCONFIG'; - }; - var peg$f396 = function () { - return 'REGDICTIONARY'; - }; - var peg$f397 = function () { - return 'REGNAMESPACE'; - }; - var peg$f398 = function () { - return 'REGOPER'; - }; - var peg$f399 = function () { - return 'REGOPERATOR'; - }; - var peg$f400 = function () { - return 'REGPROC'; - }; - var peg$f401 = function () { - return 'REGPROCEDURE'; - }; - var peg$f402 = function () { - return 'REGROLE'; - }; - var peg$f403 = function () { - return 'REGTYPE'; - }; - var peg$f404 = function () { - return 'CURRENT_DATE'; - }; - var peg$f405 = function () { - return 'ADDDATE'; - }; - var peg$f406 = function () { - return 'INTERVAL'; - }; - var peg$f407 = function () { - return 'YEAR'; - }; - var peg$f408 = function () { - return 'MONTH'; - }; - var peg$f409 = function () { - return 'DAY'; - }; - var peg$f410 = function () { - return 'HOUR'; - }; - var peg$f411 = function () { - return 'MINUTE'; - }; - var peg$f412 = function () { - return 'SECOND'; - }; - var peg$f413 = function () { - return 'CURRENT_TIME'; - }; - var peg$f414 = function () { - return 'CURRENT_TIMESTAMP'; - }; - var peg$f415 = function () { - return 'CURRENT_USER'; - }; - var peg$f416 = function () { - return 'SESSION_USER'; - }; - var peg$f417 = function () { - return 'SYSTEM_USER'; - }; - var peg$f418 = function () { - return 'GLOBAL'; - }; - var peg$f419 = function () { - return 'SESSION'; - }; - var peg$f420 = function () { - return 'LOCAL'; - }; - var peg$f421 = function () { - return 'PERSIST'; - }; - var peg$f422 = function () { - return 'PERSIST_ONLY'; - }; - var peg$f423 = function () { - return 'ADD'; - }; - var peg$f424 = function () { - return 'COLUMN'; - }; - var peg$f425 = function () { - return 'INDEX'; - }; - var peg$f426 = function () { - return 'KEY'; - }; - var peg$f427 = function () { - return 'FULLTEXT'; - }; - var peg$f428 = function () { - return 'SPATIAL'; - }; - var peg$f429 = function () { - return 'UNIQUE'; - }; - var peg$f430 = function () { - return 'KEY_BLOCK_SIZE'; - }; - var peg$f431 = function () { - return 'COMMENT'; - }; - var peg$f432 = function () { - return 'CONSTRAINT'; - }; - var peg$f433 = function () { - return 'CONCURRENTLY'; - }; - var peg$f434 = function () { - return 'REFERENCES'; - }; - var peg$f435 = function (k, s, c) { - // => { type: 'comment'; keyword: 'comment'; symbol: '='; value: literal_string; } - return { - type: k.toLowerCase(), - keyword: k.toLowerCase(), - symbol: s, - value: c, - }; - }; - var peg$f436 = function () { - varList = []; - return true; - }; - var peg$f437 = function (s) { - // => { type: 'proc'; stmt: assign_stmt | return_stmt; vars: any } - return { type: 'proc', stmt: s, vars: varList }; - }; - var peg$f438 = function (va, s, e) { - // => { type: 'assign'; left: var_decl | without_prefix_var_decl; symbol: ':=' | '='; right: proc_expr; } - return { - type: 'assign', - left: va, - symbol: s, - right: e, - }; - }; - var peg$f439 = function (e) { - // => { type: 'return'; expr: proc_expr; } - return { type: 'return', expr: e }; - }; - var peg$f440 = function (head, tail) { - // => binary_expr - return createBinaryExprChain(head, tail); - }; - var peg$f441 = function (head, tail) { - // => binary_expr - return createBinaryExprChain(head, tail); - }; - var peg$f442 = function (lt, op, rt, expr) { - // => { type: 'join'; ltable: var_decl; rtable: var_decl; op: join_op; expr: on_clause; } - return { - type: 'join', - ltable: lt, - rtable: rt, - op: op, - on: expr, - }; - }; - var peg$f443 = function (e) { - // => proc_additive_expr & { parentheses: true; } - e.parentheses = true; - return e; - }; - var peg$f444 = function (dt, tail) { - // => string - let name = dt; - if (tail !== null) { - name = `${dt}.${tail[3]}`; - } - return name; - }; - var peg$f445 = function (name, l) { - // => { type: 'function'; name: string; args: null | { type: expr_list; value: proc_primary_list; }} - //compatible with original func_call - return { - type: 'function', - name: name, - args: { - type: 'expr_list', - value: l, - }, - }; - }; - var peg$f446 = function (name) { - // => IGNORE - return { - type: 'function', - name: name, - args: null, - }; - }; - var peg$f447 = function (head, tail) { - // => proc_primary[] - return createList(head, tail); - }; - var peg$f448 = function (l) { - // => { type: 'array'; value: proc_primary_list } - return { type: 'array', value: l }; - }; - var peg$f449 = function (head, tail) { - // => var_decl[] - return createList(head, tail); - }; - var peg$f450 = function (p, d, s) { - // => { type: 'var'; name: string; prefix: string; suffix: string; }; - return { - type: 'var', - name: d.join(''), - prefix: '$$', - suffix: '$$', - }; - }; - var peg$f451 = function (f, d, s) { - if (f !== s) return true; - }; - var peg$f452 = function (f, d, s) { - // => { type: 'var'; name: string; prefix: string; suffix: string; }; - return { - type: 'var', - name: d.join(''), - prefix: `$${f}$`, - suffix: `$${s}$`, - }; - }; - var peg$f453 = function (p, d) { - // => without_prefix_var_decl & { type: 'var'; prefix: string; }; - // push for analysis - return { - type: 'var', - ...d, - prefix: p, - }; - }; - var peg$f454 = function (p, name, m, s) { - // => { type: 'var'; prefix: string; name: ident_name; members: mem_chain; quoted: string | null } - //push for analysis - if ((p && !s) || (!p && s)) throw new Error('double quoted not match'); - varList.push(name); - return { - type: 'var', - name: name, - members: m, - quoted: p && s ? '"' : null, - prefix: null, - }; - }; - var peg$f455 = function (n) { - // => { type: 'var'; prefix: null; name: number; members: []; quoted: null } - return { - type: 'var', - name: n.value, - members: [], - quoted: null, - prefix: null, - }; - }; - var peg$f456 = function (l) { - // => ident_name[]; - const s = []; - for (let i = 0; i < l.length; i++) { - s.push(l[i][1]); - } - return s; - }; - var peg$f457 = function (t) { - /* => data_type */ - return { ...t, array: 'two' }; - }; - var peg$f458 = function (t) { - /* => data_type */ - return { ...t, array: 'one' }; - }; - var peg$f459 = function (t) { - /* => data_type */ return { dataType: t }; - }; - var peg$f460 = function () { - /* => data_type */ return { dataType: 'BYTEA' }; - }; - var peg$f461 = function (t, l) { - // => data_type - return { dataType: t, length: parseInt(l.join(''), 10) }; - }; - var peg$f462 = function (t) { - /* => data_type */ return { dataType: t }; - }; - var peg$f463 = function (t) { - /* => data_type */ return { dataType: t }; - }; - var peg$f464 = function (un, ze) { - // => any[]; - const result = []; - if (un) result.push(un); - if (ze) result.push(ze); - return result; - }; - var peg$f465 = function (t, l, r, s) { - /* => data_type */ return { - dataType: t, - length: parseInt(l.join(''), 10), - scale: r && parseInt(r[2].join(''), 10), - parentheses: true, - suffix: s, - }; - }; - var peg$f466 = function (t, l, s) { - /* => data_type */ return { dataType: t, length: parseInt(l.join(''), 10), suffix: s }; - }; - var peg$f467 = function (t, s) { - /* => data_type */ return { dataType: t, suffix: s }; - }; - var peg$f468 = function (t) { - /* => data_type */ return { dataType: t }; - }; - var peg$f469 = function (w) { - // => string[]; - return [w.toUpperCase(), 'TIME', 'ZONE']; - }; - var peg$f470 = function (t, l, tz) { - /* => data_type */ return { dataType: t, length: parseInt(l.join(''), 10), parentheses: true, suffix: tz }; - }; - var peg$f471 = function (t, tz) { - /* => data_type */ return { dataType: t, suffix: tz }; - }; - var peg$f472 = function (t, l) { - /* => data_type */ return { dataType: t, length: parseInt(l.join(''), 10), parentheses: true }; - }; - var peg$f473 = function (t) { - /* => data_type */ return { dataType: t }; - }; - var peg$f474 = function (t, e) { - /* => data_type */ - e.parentheses = true; - return { - dataType: t, - expr: e, - }; - }; - var peg$f475 = function (t) { - /* => data_type */ return { dataType: t }; - }; - var peg$f476 = function (t) { - /* => data_type */ return { dataType: t }; - }; - var peg$f477 = function (t) { - /* => data_type */ return { dataType: t }; - }; - var peg$f478 = function (t) { - /* => data_type */ return { dataType: `${t}[]` }; - }; - var peg$f479 = function (t) { - /* => data_type */ return { dataType: t }; - }; - var peg$f480 = function (t) { - /* => data_type */ return { dataType: t }; - }; - var peg$currPos = 0; - var peg$savedPos = 0; - var peg$posDetailsCache = [{ line: 1, column: 1 }]; - var peg$maxFailPos = 0; - var peg$maxFailExpected = []; - var peg$silentFails = 0; - - var peg$result; - - if ('startRule' in options) { - if (!(options.startRule in peg$startRuleFunctions)) { - throw new Error('Can\'t start parsing from rule "' + options.startRule + '".'); - } - - peg$startRuleFunction = peg$startRuleFunctions[options.startRule]; - } - - function text() { - return input.substring(peg$savedPos, peg$currPos); - } - - function offset() { - return peg$savedPos; - } - - function range() { - return { - source: peg$source, - start: peg$savedPos, - end: peg$currPos, - }; - } - - function location() { - return peg$computeLocation(peg$savedPos, peg$currPos); - } - - function expected(description, location) { - location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos); - - throw peg$buildStructuredError( - [peg$otherExpectation(description)], - input.substring(peg$savedPos, peg$currPos), - location, - ); - } - - function error(message, location) { - location = location !== undefined ? location : peg$computeLocation(peg$savedPos, peg$currPos); - - throw peg$buildSimpleError(message, location); - } - - function peg$literalExpectation(text, ignoreCase) { - return { type: 'literal', text: text, ignoreCase: ignoreCase }; - } - - function peg$classExpectation(parts, inverted, ignoreCase) { - return { type: 'class', parts: parts, inverted: inverted, ignoreCase: ignoreCase }; - } - - function peg$anyExpectation() { - return { type: 'any' }; - } - - function peg$endExpectation() { - return { type: 'end' }; - } - - function peg$otherExpectation(description) { - return { type: 'other', description: description }; - } - - function peg$computePosDetails(pos) { - var details = peg$posDetailsCache[pos]; - var p; - - if (details) { - return details; - } else { - p = pos - 1; - while (!peg$posDetailsCache[p]) { - p--; - } - - details = peg$posDetailsCache[p]; - details = { - line: details.line, - column: details.column, - }; - - while (p < pos) { - if (input.charCodeAt(p) === 10) { - details.line++; - details.column = 1; - } else { - details.column++; - } - - p++; - } - - peg$posDetailsCache[pos] = details; - - return details; - } - } - - function peg$computeLocation(startPos, endPos, offset) { - var startPosDetails = peg$computePosDetails(startPos); - var endPosDetails = peg$computePosDetails(endPos); - - var res = { - source: peg$source, - start: { - offset: startPos, - line: startPosDetails.line, - column: startPosDetails.column, - }, - end: { - offset: endPos, - line: endPosDetails.line, - column: endPosDetails.column, - }, - }; - if (offset && peg$source && typeof peg$source.offset === 'function') { - res.start = peg$source.offset(res.start); - res.end = peg$source.offset(res.end); - } - return res; - } - - function peg$fail(expected) { - if (peg$currPos < peg$maxFailPos) { - return; - } - - if (peg$currPos > peg$maxFailPos) { - peg$maxFailPos = peg$currPos; - peg$maxFailExpected = []; - } - - peg$maxFailExpected.push(expected); - } - - function peg$buildSimpleError(message, location) { - return new peg$SyntaxError(message, null, null, location); - } - - function peg$buildStructuredError(expected, found, location) { - return new peg$SyntaxError(peg$SyntaxError.buildMessage(expected, found), expected, found, location); - } - - function peg$parsestart() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parse__(); - s2 = peg$parsemultiple_stmt(); - if (s2 === peg$FAILED) { - s2 = peg$parsecmd_stmt(); - if (s2 === peg$FAILED) { - s2 = peg$parsecrud_stmt(); - } - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f0(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecmd_stmt() { - var s0; - - s0 = peg$parsedrop_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parsecreate_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parsetruncate_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parserename_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parsecall_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parseuse_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parsealter_table_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parseset_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parselock_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parseshow_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parsedeallocate_stmt(); - } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parsecreate_stmt() { - var s0; - - s0 = peg$parsecreate_table_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parsecreate_constraint_trigger(); - if (s0 === peg$FAILED) { - s0 = peg$parsecreate_extension_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parsecreate_index_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parsecreate_sequence(); - if (s0 === peg$FAILED) { - s0 = peg$parsecreate_db_stmt(); - } - } - } - } - } - - return s0; - } - - function peg$parsecrud_stmt() { - var s0; - - s0 = peg$parseunion_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parseupdate_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parsereplace_insert_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parseinsert_no_columns_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parsedelete_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parsecmd_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parseproc_stmts(); - } - } - } - } - } - } - - return s0; - } - - function peg$parsemultiple_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsecrud_stmt(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseSEMICOLON(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecrud_stmt(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseSEMICOLON(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecrud_stmt(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f1(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseset_op() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_UNION(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ALL(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f2(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseunion_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseselect_stmt(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseset_op(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseselect_stmt(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseset_op(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseselect_stmt(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - s3 = peg$parse__(); - s4 = peg$parseorder_by_clause(); - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parse__(); - s6 = peg$parselimit_clause(); - peg$savedPos = s0; - s0 = peg$f3(s1, s2, s4, s6); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseif_not_exists_stmt() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c0) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e0); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_NOT(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseKW_EXISTS(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f4(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_extension_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18; - - s0 = peg$currPos; - s1 = peg$parseKW_CREATE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c1) { - s3 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e1); - } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseif_not_exists_stmt(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseident_name(); - if (s7 === peg$FAILED) { - s7 = peg$parseliteral_string(); - } - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseKW_WITH(); - if (s9 === peg$FAILED) { - s9 = null; - } - s10 = peg$parse__(); - s11 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c2) { - s12 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s12 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e2); - } - } - if (s12 !== peg$FAILED) { - s13 = peg$parse__(); - s14 = peg$parseident_name(); - if (s14 !== peg$FAILED) { - s12 = [s12, s13, s14]; - s11 = s12; - } else { - peg$currPos = s11; - s11 = peg$FAILED; - } - } else { - peg$currPos = s11; - s11 = peg$FAILED; - } - if (s11 === peg$FAILED) { - s11 = peg$parseliteral_string(); - } - if (s11 === peg$FAILED) { - s11 = null; - } - s12 = peg$parse__(); - s13 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c3) { - s14 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s14 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e3); - } - } - if (s14 !== peg$FAILED) { - s15 = peg$parse__(); - s16 = peg$parseident_name(); - if (s16 === peg$FAILED) { - s16 = peg$parseliteral_string(); - } - if (s16 !== peg$FAILED) { - s14 = [s14, s15, s16]; - s13 = s14; - } else { - peg$currPos = s13; - s13 = peg$FAILED; - } - } else { - peg$currPos = s13; - s13 = peg$FAILED; - } - if (s13 === peg$FAILED) { - s13 = null; - } - s14 = peg$parse__(); - s15 = peg$currPos; - s16 = peg$parseKW_FROM(); - if (s16 !== peg$FAILED) { - s17 = peg$parse__(); - s18 = peg$parseident_name(); - if (s18 === peg$FAILED) { - s18 = peg$parseliteral_string(); - } - if (s18 !== peg$FAILED) { - s16 = [s16, s17, s18]; - s15 = s16; - } else { - peg$currPos = s15; - s15 = peg$FAILED; - } - } else { - peg$currPos = s15; - s15 = peg$FAILED; - } - if (s15 === peg$FAILED) { - s15 = null; - } - peg$savedPos = s0; - s0 = peg$f5(s1, s3, s5, s7, s9, s11, s13, s15); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_db_definition() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsecreate_option_character_set(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsecreate_option_character_set(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsecreate_option_character_set(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f6(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_db_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseKW_CREATE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_DATABASE(); - if (s3 === peg$FAILED) { - s3 = peg$parseKW_SCHEME(); - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseif_not_exists_stmt(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseident_name(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsecreate_db_definition(); - if (s9 === peg$FAILED) { - s9 = null; - } - peg$savedPos = s0; - s0 = peg$f7(s1, s3, s5, s7, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_table_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19; - - s0 = peg$currPos; - s1 = peg$parseKW_CREATE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_TEMPORARY(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseKW_TABLE(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseif_not_exists_stmt(); - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parsetable_ref_list(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parsecreate_table_definition(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - s13 = peg$parsetable_options(); - if (s13 === peg$FAILED) { - s13 = null; - } - s14 = peg$parse__(); - s15 = peg$parseKW_IGNORE(); - if (s15 === peg$FAILED) { - s15 = peg$parseKW_REPLACE(); - } - if (s15 === peg$FAILED) { - s15 = null; - } - s16 = peg$parse__(); - s17 = peg$parseKW_AS(); - if (s17 === peg$FAILED) { - s17 = null; - } - s18 = peg$parse__(); - s19 = peg$parseunion_stmt(); - if (s19 === peg$FAILED) { - s19 = null; - } - peg$savedPos = s0; - s0 = peg$f8(s1, s3, s7, s9, s11, s13, s15, s17, s19); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_CREATE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_TEMPORARY(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseKW_TABLE(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseif_not_exists_stmt(); - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parsetable_ref_list(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parsecreate_like_table(); - if (s11 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f9(s1, s3, s7, s9, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsecreate_sequence() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14; - - s0 = peg$currPos; - s1 = peg$parseKW_CREATE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_TEMPORARY(); - if (s3 === peg$FAILED) { - s3 = peg$parseKW_TEMP(); - } - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseKW_SEQUENCE(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseif_not_exists_stmt(); - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parsetable_name(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$currPos; - s12 = peg$parseKW_AS(); - if (s12 !== peg$FAILED) { - s13 = peg$parse__(); - s14 = peg$parsealias_ident(); - if (s14 !== peg$FAILED) { - s12 = [s12, s13, s14]; - s11 = s12; - } else { - peg$currPos = s11; - s11 = peg$FAILED; - } - } else { - peg$currPos = s11; - s11 = peg$FAILED; - } - if (s11 === peg$FAILED) { - s11 = null; - } - s12 = peg$parse__(); - s13 = peg$parsecreate_sequence_definition_list(); - if (s13 === peg$FAILED) { - s13 = null; - } - peg$savedPos = s0; - s0 = peg$f10(s1, s3, s7, s9, s11, s13); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsesequence_definition_increment() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c4) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e4); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_BY(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseliteral_numeric(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f11(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsesequence_definition_minval() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c5) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e5); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseliteral_numeric(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f12(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c6) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e6); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c5) { - s3 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e5); - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f13(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsesequence_definition_maxval() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c7) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e7); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseliteral_numeric(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f14(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c6) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e6); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c7) { - s3 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e7); - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f15(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsesequence_definition_start() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c8) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e8); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_WITH(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseliteral_numeric(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f16(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsesequence_definition_cache() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c9) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e9); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseliteral_numeric(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f17(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsesequence_definition_cycle() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c6) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e6); - } - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c10) { - s3 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e10); - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f18(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsesequence_definition_owned() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c11) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e11); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_BY(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c12) { - s5 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e12); - } - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f19(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c11) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e11); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_BY(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsecolumn_ref(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f20(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsecreate_sequence_definition() { - var s0; - - s0 = peg$parsesequence_definition_increment(); - if (s0 === peg$FAILED) { - s0 = peg$parsesequence_definition_minval(); - if (s0 === peg$FAILED) { - s0 = peg$parsesequence_definition_maxval(); - if (s0 === peg$FAILED) { - s0 = peg$parsesequence_definition_start(); - if (s0 === peg$FAILED) { - s0 = peg$parsesequence_definition_cache(); - if (s0 === peg$FAILED) { - s0 = peg$parsesequence_definition_cycle(); - if (s0 === peg$FAILED) { - s0 = peg$parsesequence_definition_owned(); - } - } - } - } - } - } - - return s0; - } - - function peg$parsecreate_sequence_definition_list() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsecreate_sequence_definition(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsecreate_sequence_definition(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsecreate_sequence_definition(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f21(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_index_stmt() { - var s0, - s1, - s2, - s3, - s4, - s5, - s6, - s7, - s8, - s9, - s10, - s11, - s12, - s13, - s14, - s15, - s16, - s17, - s18, - s19, - s20, - s21, - s22, - s23, - s24, - s25, - s26, - s27, - s28, - s29, - s30; - - s0 = peg$currPos; - s1 = peg$parseKW_CREATE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_UNIQUE(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseKW_INDEX(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseKW_CONCURRENTLY(); - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parseident(); - if (s9 === peg$FAILED) { - s9 = null; - } - s10 = peg$parse__(); - s11 = peg$parseKW_ON(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - s13 = peg$parsetable_name(); - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - s15 = peg$parseindex_type(); - if (s15 === peg$FAILED) { - s15 = null; - } - s16 = peg$parse__(); - s17 = peg$parseLPAREN(); - if (s17 !== peg$FAILED) { - s18 = peg$parse__(); - s19 = peg$parsecolumn_order_list(); - if (s19 !== peg$FAILED) { - s20 = peg$parse__(); - s21 = peg$parseRPAREN(); - if (s21 !== peg$FAILED) { - s22 = peg$parse__(); - s23 = peg$currPos; - s24 = peg$parseKW_WITH(); - if (s24 !== peg$FAILED) { - s25 = peg$parse__(); - s26 = peg$parseLPAREN(); - if (s26 !== peg$FAILED) { - s27 = peg$parse__(); - s28 = peg$parseindex_options_list(); - if (s28 !== peg$FAILED) { - s29 = peg$parse__(); - s30 = peg$parseRPAREN(); - if (s30 !== peg$FAILED) { - s24 = [s24, s25, s26, s27, s28, s29, s30]; - s23 = s24; - } else { - peg$currPos = s23; - s23 = peg$FAILED; - } - } else { - peg$currPos = s23; - s23 = peg$FAILED; - } - } else { - peg$currPos = s23; - s23 = peg$FAILED; - } - } else { - peg$currPos = s23; - s23 = peg$FAILED; - } - if (s23 === peg$FAILED) { - s23 = null; - } - s24 = peg$parse__(); - s25 = peg$currPos; - s26 = peg$parseKW_TABLESPACE(); - if (s26 !== peg$FAILED) { - s27 = peg$parse__(); - s28 = peg$parseident_name(); - if (s28 !== peg$FAILED) { - s26 = [s26, s27, s28]; - s25 = s26; - } else { - peg$currPos = s25; - s25 = peg$FAILED; - } - } else { - peg$currPos = s25; - s25 = peg$FAILED; - } - if (s25 === peg$FAILED) { - s25 = null; - } - s26 = peg$parse__(); - s27 = peg$parsewhere_clause(); - if (s27 === peg$FAILED) { - s27 = null; - } - s28 = peg$parse__(); - peg$savedPos = s0; - s0 = peg$f22(s1, s3, s5, s7, s9, s11, s13, s15, s19, s23, s25, s27); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecolumn_order_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsecolumn_order(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn_order(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn_order(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f23(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecolumn_order() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12; - - s0 = peg$currPos; - s1 = peg$parseexpr(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecollate_expr(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseident(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseKW_ASC(); - if (s7 === peg$FAILED) { - s7 = peg$parseKW_DESC(); - } - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c13) { - s10 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s10 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e13); - } - } - if (s10 !== peg$FAILED) { - s11 = peg$parse__(); - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c14) { - s12 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s12 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e14); - } - } - if (s12 === peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c15) { - s12 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s12 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e15); - } - } - } - if (s12 !== peg$FAILED) { - s10 = [s10, s11, s12]; - s9 = s10; - } else { - peg$currPos = s9; - s9 = peg$FAILED; - } - } else { - peg$currPos = s9; - s9 = peg$FAILED; - } - if (s9 === peg$FAILED) { - s9 = null; - } - peg$savedPos = s0; - s0 = peg$f24(s1, s3, s5, s7, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_like_table_simple() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_LIKE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsetable_ref_list(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f25(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_like_table() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$parsecreate_like_table_simple(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecreate_like_table(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f26(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsecreate_table_definition() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecreate_definition(); - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$currPos; - s6 = peg$parse__(); - s7 = peg$parseCOMMA(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsecreate_definition(); - if (s9 !== peg$FAILED) { - s6 = [s6, s7, s8, s9]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$currPos; - s6 = peg$parse__(); - s7 = peg$parseCOMMA(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsecreate_definition(); - if (s9 !== peg$FAILED) { - s6 = [s6, s7, s8, s9]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } - s5 = peg$parse__(); - s6 = peg$parseRPAREN(); - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f27(s3, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_definition() { - var s0; - - s0 = peg$parsecreate_column_definition(); - if (s0 === peg$FAILED) { - s0 = peg$parsecreate_index_definition(); - if (s0 === peg$FAILED) { - s0 = peg$parsecreate_fulltext_spatial_index_definition(); - if (s0 === peg$FAILED) { - s0 = peg$parsecreate_constraint_definition(); - } - } - } - - return s0; - } - - function peg$parsecolumn_definition_opt() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$parsecolumn_constraint(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 14).toLowerCase() === peg$c16) { - s1 = input.substr(peg$currPos, 14); - peg$currPos += 14; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e16); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f28(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c17) { - s2 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e17); - } - } - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c18) { - s4 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e18); - } - } - if (s4 === peg$FAILED) { - s4 = null; - } - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 === peg$FAILED) { - s1 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c19) { - s2 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e19); - } - } - if (s2 === peg$FAILED) { - s2 = null; - } - s3 = peg$parse__(); - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c18) { - s4 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e18); - } - } - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f29(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsekeyword_comment(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f30(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsecollate_expr(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f31(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsecolumn_format(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f32(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsestorage(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f33(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsereference_definition(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f34(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsecreate_option_character_set_kw(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ASSIGIN_EQUAL(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseident_name(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f35(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parsecolumn_definition_opt_list() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsecolumn_definition_opt(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = []; - s4 = peg$currPos; - s5 = peg$parse__(); - s6 = peg$parsecolumn_definition_opt(); - if (s6 !== peg$FAILED) { - s5 = [s5, s6]; - s4 = s5; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$currPos; - s5 = peg$parse__(); - s6 = peg$parsecolumn_definition_opt(); - if (s6 !== peg$FAILED) { - s5 = [s5, s6]; - s4 = s5; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f36(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_column_definition() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsecolumn_ref(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsedata_type(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsecolumn_definition_opt_list(); - if (s5 === peg$FAILED) { - s5 = null; - } - peg$savedPos = s0; - s0 = peg$f37(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecolumn_constraint() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseliteral_not_null(); - if (s1 === peg$FAILED) { - s1 = peg$parseliteral_null(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsedefault_expr(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f38(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsedefault_expr(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseliteral_not_null(); - if (s3 === peg$FAILED) { - s3 = peg$parseliteral_null(); - } - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f39(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsecollate_expr() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_COLLATE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ASSIGIN_EQUAL(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseident(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f40(s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecolumn_format() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 13).toLowerCase() === peg$c20) { - s1 = input.substr(peg$currPos, 13); - peg$currPos += 13; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e20); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c21) { - s3 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e21); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c22) { - s3 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e22); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c23) { - s3 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e23); - } - } - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f41(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsestorage() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c24) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e24); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c25) { - s3 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e25); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c26) { - s3 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e26); - } - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f42(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsedefault_expr() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_DEFAULT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseliteral(); - if (s3 === peg$FAILED) { - s3 = peg$parseexpr(); - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f43(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsedrop_index_opt() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseALTER_ALGORITHM(); - if (s1 === peg$FAILED) { - s1 = peg$parseALTER_LOCK(); - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseALTER_ALGORITHM(); - if (s5 === peg$FAILED) { - s5 = peg$parseALTER_LOCK(); - } - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseALTER_ALGORITHM(); - if (s5 === peg$FAILED) { - s5 = peg$parseALTER_LOCK(); - } - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f44(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsedrop_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - s1 = peg$parseKW_DROP(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_TABLE(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsetable_ref_list(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f45(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_DROP(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_INDEX(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseKW_CONCURRENTLY(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c0) { - s8 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e0); - } - } - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - s10 = peg$parseKW_EXISTS(); - if (s10 !== peg$FAILED) { - s8 = [s8, s9, s10]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parsecolumn_ref(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c27) { - s11 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s11 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e27); - } - } - if (s11 === peg$FAILED) { - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c28) { - s11 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s11 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e28); - } - } - } - if (s11 === peg$FAILED) { - s11 = null; - } - peg$savedPos = s0; - s0 = peg$f46(s1, s3, s5, s7, s9, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsetruncate_stmt() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_TRUNCATE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_TABLE(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parsetable_ref_list(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f47(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseuse_stmt() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_USE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseident(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f48(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsealter_table_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_ALTER(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_TABLE(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsetable_ref_list(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsealter_action_list(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f49(s5, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsealter_action_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsealter_action(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsealter_action(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsealter_action(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f50(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsealter_action() { - var s0; - - s0 = peg$parseALTER_ADD_COLUMN(); - if (s0 === peg$FAILED) { - s0 = peg$parseALTER_ADD_CONSTRAINT(); - if (s0 === peg$FAILED) { - s0 = peg$parseALTER_DROP_COLUMN(); - if (s0 === peg$FAILED) { - s0 = peg$parseALTER_ADD_INDEX_OR_KEY(); - if (s0 === peg$FAILED) { - s0 = peg$parseALTER_ADD_FULLETXT_SPARITAL_INDEX(); - if (s0 === peg$FAILED) { - s0 = peg$parseALTER_RENAME_TABLE(); - if (s0 === peg$FAILED) { - s0 = peg$parseALTER_ALGORITHM(); - if (s0 === peg$FAILED) { - s0 = peg$parseALTER_LOCK(); - } - } - } - } - } - } - } - - return s0; - } - - function peg$parseALTER_ADD_COLUMN() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_ADD(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_COLUMN(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parsecreate_column_definition(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f51(s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseALTER_DROP_COLUMN() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_DROP(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_COLUMN(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parsecolumn_ref(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f52(s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseALTER_ADD_CONSTRAINT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_ADD(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecreate_constraint_definition(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f53(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseALTER_ADD_INDEX_OR_KEY() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_ADD(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecreate_index_definition(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f54(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseALTER_RENAME_TABLE() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_RENAME(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_TO(); - if (s3 === peg$FAILED) { - s3 = peg$parseKW_AS(); - } - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseident(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f55(s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseALTER_ALGORITHM() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c29) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e29); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ASSIGIN_EQUAL(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c23) { - s5 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e23); - } - } - if (s5 === peg$FAILED) { - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c30) { - s5 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e30); - } - } - if (s5 === peg$FAILED) { - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c31) { - s5 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e31); - } - } - if (s5 === peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c32) { - s5 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e32); - } - } - } - } - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f56(s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseALTER_LOCK() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c33) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e33); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ASSIGIN_EQUAL(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c23) { - s5 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e23); - } - } - if (s5 === peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c12) { - s5 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e12); - } - } - if (s5 === peg$FAILED) { - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c34) { - s5 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e34); - } - } - if (s5 === peg$FAILED) { - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c35) { - s5 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e35); - } - } - } - } - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f57(s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_index_definition() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10; - - s0 = peg$currPos; - s1 = peg$parseKW_INDEX(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_KEY(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecolumn(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseindex_type(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parsecte_column_definition(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseindex_options(); - if (s9 === peg$FAILED) { - s9 = null; - } - s10 = peg$parse__(); - peg$savedPos = s0; - s0 = peg$f58(s1, s3, s5, s7, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_fulltext_spatial_index_definition() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10; - - s0 = peg$currPos; - s1 = peg$parseKW_FULLTEXT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_SPATIAL(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_INDEX(); - if (s3 === peg$FAILED) { - s3 = peg$parseKW_KEY(); - } - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parsecolumn(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parsecte_column_definition(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseindex_options(); - if (s9 === peg$FAILED) { - s9 = null; - } - s10 = peg$parse__(); - peg$savedPos = s0; - s0 = peg$f59(s1, s3, s5, s7, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_constraint_definition() { - var s0; - - s0 = peg$parsecreate_constraint_primary(); - if (s0 === peg$FAILED) { - s0 = peg$parsecreate_constraint_unique(); - if (s0 === peg$FAILED) { - s0 = peg$parsecreate_constraint_foreign(); - } - } - - return s0; - } - - function peg$parseconstraint_name() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_CONSTRAINT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseident(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f60(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_constraint_primary() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseconstraint_name(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - if (input.substr(peg$currPos, 11).toLowerCase() === peg$c36) { - s3 = input.substr(peg$currPos, 11); - peg$currPos += 11; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e36); - } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseindex_type(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parsecte_column_definition(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseindex_options(); - if (s9 === peg$FAILED) { - s9 = null; - } - peg$savedPos = s0; - s0 = peg$f61(s1, s3, s5, s7, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_constraint_unique() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; - - s0 = peg$currPos; - s1 = peg$parseconstraint_name(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseKW_UNIQUE(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseKW_INDEX(); - if (s5 === peg$FAILED) { - s5 = peg$parseKW_KEY(); - } - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parsecolumn(); - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parseindex_type(); - if (s9 === peg$FAILED) { - s9 = null; - } - s10 = peg$parse__(); - s11 = peg$parsecte_column_definition(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - s13 = peg$parseindex_options(); - if (s13 === peg$FAILED) { - s13 = null; - } - peg$savedPos = s0; - s0 = peg$f62(s1, s3, s5, s7, s9, s11, s13); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_constraint_foreign() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseconstraint_name(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - if (input.substr(peg$currPos, 11).toLowerCase() === peg$c37) { - s3 = input.substr(peg$currPos, 11); - peg$currPos += 11; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e37); - } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsecolumn(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parsecte_column_definition(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsereference_definition(); - if (s9 === peg$FAILED) { - s9 = null; - } - peg$savedPos = s0; - s0 = peg$f63(s1, s3, s5, s7, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsereference_definition() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - s1 = peg$parseKW_REFERENCES(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsetable_name(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsecte_column_definition(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c38) { - s7 = input.substr(peg$currPos, 10); - peg$currPos += 10; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e38); - } - } - if (s7 === peg$FAILED) { - if (input.substr(peg$currPos, 13).toLowerCase() === peg$c39) { - s7 = input.substr(peg$currPos, 13); - peg$currPos += 13; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e39); - } - } - if (s7 === peg$FAILED) { - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c40) { - s7 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e40); - } - } - } - } - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parseon_reference(); - if (s9 === peg$FAILED) { - s9 = null; - } - s10 = peg$parse__(); - s11 = peg$parseon_reference(); - if (s11 === peg$FAILED) { - s11 = null; - } - peg$savedPos = s0; - s0 = peg$f64(s1, s3, s5, s7, s9, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseon_reference(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f65(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parseon_reference() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_ON(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_DELETE(); - if (s3 === peg$FAILED) { - s3 = peg$parseKW_UPDATE(); - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsereference_option(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f66(s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsereference_option() { - var s0, s1; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c28) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e28); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c27) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e27); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c41) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e41); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c42) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e42); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 11).toLowerCase() === peg$c43) { - s1 = input.substr(peg$currPos, 11); - peg$currPos += 11; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e43); - } - } - } - } - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f67(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsecreate_constraint_trigger() { - var s0, - s1, - s2, - s3, - s4, - s5, - s6, - s7, - s8, - s9, - s10, - s11, - s12, - s13, - s14, - s15, - s16, - s17, - s18, - s19, - s20, - s21, - s22, - s23, - s24, - s25, - s26, - s27, - s28, - s29; - - s0 = peg$currPos; - s1 = peg$parseKW_CREATE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_CONSTRAINT(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c44) { - s5 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e44); - } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseident_name(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c45) { - s9 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e45); - } - } - if (s9 === peg$FAILED) { - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c46) { - s9 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e46); - } - } - if (s9 === peg$FAILED) { - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c47) { - s9 = input.substr(peg$currPos, 10); - peg$currPos += 10; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e47); - } - } - } - } - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parsetrigger_event_list(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c48) { - s13 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s13 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e48); - } - } - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - s15 = peg$parsetable_name(); - if (s15 !== peg$FAILED) { - s16 = peg$parse__(); - s17 = peg$currPos; - s18 = peg$parseKW_FROM(); - if (s18 !== peg$FAILED) { - s19 = peg$parse__(); - s20 = peg$parsetable_name(); - if (s20 !== peg$FAILED) { - s18 = [s18, s19, s20]; - s17 = s18; - } else { - peg$currPos = s17; - s17 = peg$FAILED; - } - } else { - peg$currPos = s17; - s17 = peg$FAILED; - } - if (s17 === peg$FAILED) { - s17 = null; - } - s18 = peg$parse__(); - s19 = peg$parsetrigger_deferrable(); - if (s19 === peg$FAILED) { - s19 = null; - } - s20 = peg$parse__(); - s21 = peg$parsetrigger_for_row(); - if (s21 === peg$FAILED) { - s21 = null; - } - s22 = peg$parse__(); - s23 = peg$parsetrigger_when(); - if (s23 === peg$FAILED) { - s23 = null; - } - s24 = peg$parse__(); - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c49) { - s25 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s25 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e49); - } - } - if (s25 !== peg$FAILED) { - s26 = peg$parse__(); - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c50) { - s27 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s27 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e50); - } - } - if (s27 !== peg$FAILED) { - s28 = peg$parse__(); - s29 = peg$parseproc_func_call(); - if (s29 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f68(s1, s3, s5, s7, s9, s11, s13, s15, s17, s19, s21, s23, s25, s29); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetrigger_event() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parseKW_INSERT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DELETE(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_TRUNCATE(); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f69(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_UPDATE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c51) { - s4 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e51); - } - } - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parsecolumn_ref_list(); - if (s6 !== peg$FAILED) { - s4 = [s4, s5, s6]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f70(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsetrigger_event_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsetrigger_event(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseKW_OR(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsetrigger_event(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseKW_OR(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsetrigger_event(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f71(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetrigger_deferrable() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c52) { - s2 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e52); - } - } - if (s2 === peg$FAILED) { - s2 = null; - } - s3 = peg$parse__(); - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c53) { - s4 = input.substr(peg$currPos, 10); - peg$currPos += 10; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e53); - } - } - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 19).toLowerCase() === peg$c54) { - s3 = input.substr(peg$currPos, 19); - peg$currPos += 19; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e54); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 18).toLowerCase() === peg$c55) { - s3 = input.substr(peg$currPos, 18); - peg$currPos += 18; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e55); - } - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f72(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetrigger_for_row() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c56) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e56); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c57) { - s3 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e57); - } - } - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c58) { - s5 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e58); - } - } - if (s5 === peg$FAILED) { - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c59) { - s5 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e59); - } - } - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f73(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetrigger_when() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_WHEN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f74(s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetable_options() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsetable_option(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parsetable_option(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parsetable_option(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f75(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_option_character_set_kw() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c60) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e60); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c61) { - s3 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e61); - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f76(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecreate_option_character_set() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_DEFAULT(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parsecreate_option_character_set_kw(); - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c62) { - s3 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e62); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c63) { - s3 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e63); - } - } - } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseKW_ASSIGIN_EQUAL(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseident_name(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f77(s1, s3, s5, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetable_option() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 14).toLowerCase() === peg$c16) { - s1 = input.substr(peg$currPos, 14); - peg$currPos += 14; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e16); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 14).toLowerCase() === peg$c64) { - s1 = input.substr(peg$currPos, 14); - peg$currPos += 14; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e64); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 14).toLowerCase() === peg$c65) { - s1 = input.substr(peg$currPos, 14); - peg$currPos += 14; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e65); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c66) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e66); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c67) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e67); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 18).toLowerCase() === peg$c68) { - s1 = input.substr(peg$currPos, 18); - peg$currPos += 18; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e68); - } - } - } - } - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ASSIGIN_EQUAL(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseliteral_numeric(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f78(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$parsecreate_option_character_set(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_COMMENT(); - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c69) { - s1 = input.substr(peg$currPos, 10); - peg$currPos += 10; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e69); - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ASSIGIN_EQUAL(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseliteral_string(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f79(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 11).toLowerCase() === peg$c70) { - s1 = input.substr(peg$currPos, 11); - peg$currPos += 11; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e70); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ASSIGIN_EQUAL(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { - s6 = peg$c71; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e71); - } - } - if (s6 !== peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c72) { - s7 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e72); - } - } - if (s7 === peg$FAILED) { - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c73) { - s7 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e73); - } - } - if (s7 === peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c12) { - s7 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e12); - } - } - } - } - if (s7 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 39) { - s8 = peg$c71; - peg$currPos++; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e71); - } - } - if (s8 !== peg$FAILED) { - s6 = [s6, s7, s8]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f80(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c74) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e74); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ASSIGIN_EQUAL(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseident_name(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f81(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - } - - return s0; - } - - function peg$parseALTER_ADD_FULLETXT_SPARITAL_INDEX() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_ADD(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecreate_fulltext_spatial_index_definition(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f82(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parserename_stmt() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_RENAME(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_TABLE(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsetable_to_list(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f83(s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseset_stmt() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_SET(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_GLOBAL(); - if (s3 === peg$FAILED) { - s3 = peg$parseKW_SESSION(); - if (s3 === peg$FAILED) { - s3 = peg$parseKW_LOCAL(); - if (s3 === peg$FAILED) { - s3 = peg$parseKW_PERSIST(); - if (s3 === peg$FAILED) { - s3 = peg$parseKW_PERSIST_ONLY(); - } - } - } - } - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseassign_stmt(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f84(s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parselock_mode() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c75) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e75); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c76) { - s3 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e76); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c77) { - s3 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e77); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 13).toLowerCase() === peg$c78) { - s3 = input.substr(peg$currPos, 13); - peg$currPos += 13; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e78); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 22).toLowerCase() === peg$c79) { - s3 = input.substr(peg$currPos, 22); - peg$currPos += 22; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e79); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 19).toLowerCase() === peg$c80) { - s3 = input.substr(peg$currPos, 19); - peg$currPos += 19; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e80); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c35) { - s3 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e35); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 16).toLowerCase() === peg$c81) { - s3 = input.substr(peg$currPos, 16); - peg$currPos += 16; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e81); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c82) { - s3 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e82); - } - } - } - } - } - } - } - } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c83) { - s5 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e83); - } - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f85(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parselock_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseKW_LOCK(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_TABLE(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parsetable_ref_list(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parselock_mode(); - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c84) { - s9 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e84); - } - } - if (s9 === peg$FAILED) { - s9 = null; - } - peg$savedPos = s0; - s0 = peg$f86(s3, s5, s7, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecall_stmt() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_CALL(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseproc_func_call(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f87(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseshow_stmt() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_SHOW(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c85) { - s3 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e85); - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f88(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_SHOW(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsewithout_prefix_var_decl(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f89(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsedeallocate_stmt() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_DEALLOCATE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c86) { - s3 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e86); - } - } - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseident_name(); - if (s5 === peg$FAILED) { - s5 = peg$parseKW_ALL(); - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f90(s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseselect_stmt() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parseKW_SELECT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.charCodeAt(peg$currPos) === 59) { - s3 = peg$c87; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e87); - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f91(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$parseselect_stmt_nake(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 40) { - s2 = peg$c88; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e88); - } - } - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseselect_stmt(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - if (input.charCodeAt(peg$currPos) === 41) { - s6 = peg$c89; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e89); - } - } - if (s6 !== peg$FAILED) { - s2 = [s2, s3, s4, s5, s6]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f92(s1); - } - s0 = s1; - } - } - - return s0; - } - - function peg$parsewith_clause() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseKW_WITH(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecte_definition(); - if (s3 !== peg$FAILED) { - s4 = []; - s5 = peg$currPos; - s6 = peg$parse__(); - s7 = peg$parseCOMMA(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsecte_definition(); - if (s9 !== peg$FAILED) { - s6 = [s6, s7, s8, s9]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$currPos; - s6 = peg$parse__(); - s7 = peg$parseCOMMA(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsecte_definition(); - if (s9 !== peg$FAILED) { - s6 = [s6, s7, s8, s9]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f93(s3, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parse__(); - s2 = peg$parseKW_WITH(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseKW_RECURSIVE(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parsecte_definition(); - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f94(s6); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsecte_definition() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - s1 = peg$parseliteral_string(); - if (s1 === peg$FAILED) { - s1 = peg$parseident_name(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecte_column_definition(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseKW_AS(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseLPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsecrud_stmt(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseRPAREN(); - if (s11 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f95(s1, s3, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecte_column_definition() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecolumn_ref_list(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f96(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsedistinct_on() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseKW_DISTINCT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ON(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseLPAREN(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn_ref_list(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseRPAREN(); - if (s9 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f97(s1, s3, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_DISTINCT(); - if (s1 === peg$FAILED) { - s1 = null; - } - peg$savedPos = s0; - s1 = peg$f98(s1); - s0 = s1; - } - - return s0; - } - - function peg$parseselect_stmt_nake() { - var s0, - s1, - s2, - s3, - s4, - s5, - s6, - s7, - s8, - s9, - s10, - s11, - s12, - s13, - s14, - s15, - s16, - s17, - s18, - s19, - s20, - s21, - s22, - s23, - s24, - s25, - s26, - s27, - s28, - s29, - s30; - - s0 = peg$currPos; - s1 = peg$parse__(); - s2 = peg$parsewith_clause(); - if (s2 === peg$FAILED) { - s2 = null; - } - s3 = peg$parse__(); - s4 = peg$parseKW_SELECT(); - if (s4 !== peg$FAILED) { - s5 = peg$parse___(); - if (s5 !== peg$FAILED) { - s6 = peg$parseoption_clause(); - if (s6 === peg$FAILED) { - s6 = null; - } - s7 = peg$parse__(); - s8 = peg$parsedistinct_on(); - if (s8 === peg$FAILED) { - s8 = null; - } - s9 = peg$parse__(); - s10 = peg$parsecolumn_clause(); - if (s10 !== peg$FAILED) { - s11 = peg$parse__(); - s12 = peg$parseinto_clause(); - if (s12 === peg$FAILED) { - s12 = null; - } - s13 = peg$parse__(); - s14 = peg$parsefrom_clause(); - if (s14 === peg$FAILED) { - s14 = null; - } - s15 = peg$parse__(); - s16 = peg$parseinto_clause(); - if (s16 === peg$FAILED) { - s16 = null; - } - s17 = peg$parse__(); - s18 = peg$parsewhere_clause(); - if (s18 === peg$FAILED) { - s18 = null; - } - s19 = peg$parse__(); - s20 = peg$parsegroup_by_clause(); - if (s20 === peg$FAILED) { - s20 = null; - } - s21 = peg$parse__(); - s22 = peg$parsehaving_clause(); - if (s22 === peg$FAILED) { - s22 = null; - } - s23 = peg$parse__(); - s24 = peg$parseorder_by_clause(); - if (s24 === peg$FAILED) { - s24 = null; - } - s25 = peg$parse__(); - s26 = peg$parselimit_clause(); - s27 = peg$parse__(); - s28 = peg$parsewindow_clause(); - if (s28 === peg$FAILED) { - s28 = null; - } - s29 = peg$parse__(); - s30 = peg$parseinto_clause(); - if (s30 === peg$FAILED) { - s30 = null; - } - peg$savedPos = s0; - s0 = peg$f99(s2, s6, s8, s10, s12, s14, s16, s18, s20, s22, s24, s26, s28, s30); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseoption_clause() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsequery_option(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsequery_option(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsequery_option(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f100(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsequery_option() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseOPT_SQL_CALC_FOUND_ROWS(); - if (s1 === peg$FAILED) { - s1 = peg$parseOPT_SQL_CACHE(); - if (s1 === peg$FAILED) { - s1 = peg$parseOPT_SQL_NO_CACHE(); - } - if (s1 === peg$FAILED) { - s1 = peg$parseOPT_SQL_BIG_RESULT(); - if (s1 === peg$FAILED) { - s1 = peg$parseOPT_SQL_SMALL_RESULT(); - if (s1 === peg$FAILED) { - s1 = peg$parseOPT_SQL_BUFFER_RESULT(); - } - } - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f101(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsecolumn_clause() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_ALL(); - if (s1 === peg$FAILED) { - s1 = peg$currPos; - s2 = peg$parseSTAR(); - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - s4 = peg$parseident_start(); - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = undefined; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 === peg$FAILED) { - s1 = peg$parseSTAR(); - } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn_list_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn_list_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f102(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsecolumn_list_item(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn_list_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn_list_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f103(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsearray_index() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseLBRAKE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsenumber(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRBRAKE(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f104(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexpr_item() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsebinary_column_expr(); - if (s1 === peg$FAILED) { - s1 = peg$parseexpr(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsearray_index(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f105(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexpr_item_without_union() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsebinary_column_expr(); - if (s1 === peg$FAILED) { - s1 = peg$parse_expr(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsearray_index(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f106(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecast_data_type() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { - s1 = peg$c90; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e90); - } - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parsedata_type(); - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 34) { - s3 = peg$c90; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e90); - } - } - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f107(s1, s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecolumn_list_item() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - s1 = peg$parsestring_constants_escape(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f108(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseexpr_item_without_union(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_DOUBLE_COLON(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsecast_data_type(); - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$currPos; - s8 = peg$parse__(); - s9 = peg$parseadditive_operator(); - if (s9 === peg$FAILED) { - s9 = peg$parsemultiplicative_operator(); - } - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseexpr_item_without_union(); - if (s11 !== peg$FAILED) { - s8 = [s8, s9, s10, s11]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$currPos; - s8 = peg$parse__(); - s9 = peg$parseadditive_operator(); - if (s9 === peg$FAILED) { - s9 = peg$parsemultiplicative_operator(); - } - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseexpr_item_without_union(); - if (s11 !== peg$FAILED) { - s8 = [s8, s9, s10, s11]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - } - s7 = peg$parse__(); - s8 = peg$parsealias_clause(); - if (s8 === peg$FAILED) { - s8 = null; - } - peg$savedPos = s0; - s0 = peg$f109(s1, s3, s5, s6, s8); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseDOT(); - if (s3 !== peg$FAILED) { - s4 = peg$currPos; - s5 = peg$parseident(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseDOT(); - if (s7 !== peg$FAILED) { - s5 = [s5, s6, s7]; - s4 = s5; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 === peg$FAILED) { - s4 = null; - } - s5 = peg$parse__(); - s6 = peg$parseSTAR(); - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f110(s1, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseident(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseDOT(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseSTAR(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f111(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsedouble_quoted_ident(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseDOT(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = peg$currPos; - s4 = peg$f112(s1, s3); - if (s4) { - s4 = peg$FAILED; - } else { - s4 = undefined; - } - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parsealias_clause(); - if (s6 === peg$FAILED) { - s6 = null; - } - peg$savedPos = s0; - s0 = peg$f113(s1, s3, s6); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseexpr_item_without_union(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsealias_clause(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f114(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - } - } - - return s0; - } - - function peg$parsevalue_alias_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_AS(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parsealias_ident(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f115(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsealias_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_AS(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsealias_ident(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f116(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_AS(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseident(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f117(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parseinto_clause() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_INTO(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsevar_decl_list(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f118(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_INTO(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c91) { - s3 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e91); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c92) { - s3 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e92); - } - } - } - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseliteral_string(); - if (s5 === peg$FAILED) { - s5 = peg$parseident(); - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f119(s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsefrom_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_FROM(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsetable_ref_list(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f120(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetable_to_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsetable_to_item(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsetable_to_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsetable_to_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f121(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetable_to_item() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsetable_name(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_TO(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsetable_name(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f122(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseindex_type() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_USING(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c93) { - s3 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e93); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c94) { - s3 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e94); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c95) { - s3 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e95); - } - } - if (s3 === peg$FAILED) { - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c96) { - s3 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e96); - } - } - } - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f123(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseindex_options_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseindex_option(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseindex_option(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseindex_option(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f124(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseindex_options() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseindex_option(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseindex_option(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseindex_option(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f125(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseindex_option() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_KEY_BLOCK_SIZE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ASSIGIN_EQUAL(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseliteral_numeric(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f126(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseident_name(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ASSIGIN_EQUAL(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseliteral_numeric(); - if (s5 === peg$FAILED) { - s5 = peg$parseident(); - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f127(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$parseindex_type(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c97) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e97); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c98) { - s3 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e98); - } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseident_name(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f128(s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c99) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e99); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c100) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e100); - } - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f129(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parsekeyword_comment(); - } - } - } - } - } - - return s0; - } - - function peg$parsetable_ref_list() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsetable_base(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsetable_ref(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsetable_ref(); - } - peg$savedPos = s0; - s0 = peg$f130(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetable_ref() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parse__(); - s2 = peg$parseCOMMA(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parsetable_base(); - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f131(s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parse__(); - s2 = peg$parsetable_join(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f132(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsetable_join() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15; - - s0 = peg$currPos; - s1 = peg$parsejoin_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsetable_base(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseKW_USING(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseLPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseident_name(); - if (s9 !== peg$FAILED) { - s10 = []; - s11 = peg$currPos; - s12 = peg$parse__(); - s13 = peg$parseCOMMA(); - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - s15 = peg$parseident_name(); - if (s15 !== peg$FAILED) { - s12 = [s12, s13, s14, s15]; - s11 = s12; - } else { - peg$currPos = s11; - s11 = peg$FAILED; - } - } else { - peg$currPos = s11; - s11 = peg$FAILED; - } - while (s11 !== peg$FAILED) { - s10.push(s11); - s11 = peg$currPos; - s12 = peg$parse__(); - s13 = peg$parseCOMMA(); - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - s15 = peg$parseident_name(); - if (s15 !== peg$FAILED) { - s12 = [s12, s13, s14, s15]; - s11 = s12; - } else { - peg$currPos = s11; - s11 = peg$FAILED; - } - } else { - peg$currPos = s11; - s11 = peg$FAILED; - } - } - s11 = peg$parse__(); - s12 = peg$parseRPAREN(); - if (s12 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f133(s1, s3, s9, s10); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsejoin_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsetable_base(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseon_clause(); - if (s5 === peg$FAILED) { - s5 = null; - } - peg$savedPos = s0; - s0 = peg$f134(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsejoin_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseunion_stmt(); - if (s5 === peg$FAILED) { - s5 = peg$parsetable_ref_list(); - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsealias_clause(); - if (s9 === peg$FAILED) { - s9 = null; - } - s10 = peg$parse__(); - s11 = peg$parseon_clause(); - if (s11 === peg$FAILED) { - s11 = null; - } - peg$savedPos = s0; - s0 = peg$f135(s1, s5, s9, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - - return s0; - } - - function peg$parsetable_base() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14; - - s0 = peg$currPos; - s1 = peg$parseKW_DUAL(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f136(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsevalue_clause(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsevalue_alias_clause(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f137(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c101) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e101); - } - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseunion_stmt(); - if (s5 === peg$FAILED) { - s5 = peg$parsevalue_clause(); - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsevalue_alias_clause(); - if (s9 === peg$FAILED) { - s9 = null; - } - peg$savedPos = s0; - s0 = peg$f138(s1, s5, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c101) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e101); - } - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsetable_ref_list(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsevalue_alias_clause(); - if (s9 === peg$FAILED) { - s9 = null; - } - peg$savedPos = s0; - s0 = peg$f139(s1, s5, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c101) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e101); - } - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parsefunc_call(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsealias_clause(); - if (s5 === peg$FAILED) { - s5 = null; - } - peg$savedPos = s0; - s0 = peg$f140(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsetable_name(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 11).toLowerCase() === peg$c102) { - s3 = input.substr(peg$currPos, 11); - peg$currPos += 11; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e102); - } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsefunc_call(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$currPos; - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c103) { - s8 = input.substr(peg$currPos, 10); - peg$currPos += 10; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e103); - } - } - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - s10 = peg$parseLPAREN(); - if (s10 !== peg$FAILED) { - s11 = peg$parse__(); - s12 = peg$parseliteral_numeric(); - if (s12 !== peg$FAILED) { - s13 = peg$parse__(); - s14 = peg$parseRPAREN(); - if (s14 !== peg$FAILED) { - s8 = [s8, s9, s10, s11, s12, s13, s14]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parsealias_clause(); - if (s9 === peg$FAILED) { - s9 = null; - } - peg$savedPos = s0; - s0 = peg$f141(s1, s5, s7, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsetable_name(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsealias_clause(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f142(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - } - } - } - - return s0; - } - - function peg$parsejoin_op() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_LEFT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_OUTER(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseKW_JOIN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f143(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_RIGHT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_OUTER(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseKW_JOIN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f144(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_FULL(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_OUTER(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseKW_JOIN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f145(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c104) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e104); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_JOIN(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f146(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_INNER(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parseKW_JOIN(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f147(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - } - - return s0; - } - - function peg$parsetable_name() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$parse__(); - s4 = peg$parseDOT(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parseident(); - if (s6 !== peg$FAILED) { - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseDOT(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseident(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f148(s1, s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseDOT(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseSTAR(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f149(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$parse__(); - s4 = peg$parseDOT(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parseident(); - if (s6 !== peg$FAILED) { - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 === peg$FAILED) { - s2 = null; - } - peg$savedPos = s0; - s0 = peg$f150(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsevar_decl(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f151(s1); - } - s0 = s1; - } - } - } - - return s0; - } - - function peg$parseon_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_ON(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseor_and_where_expr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f152(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsewhere_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_WHERE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseor_and_where_expr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f153(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsegroup_by_clause() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_GROUP(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_BY(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr_list(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f154(s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecolumn_ref_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsecolumn_ref(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn_ref(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn_ref(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f155(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsehaving_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_HAVING(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseor_and_where_expr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f156(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsewindow_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_WINDOW(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsenamed_window_expr_list(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f157(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsenamed_window_expr_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsenamed_window_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsenamed_window_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsenamed_window_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f158(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsenamed_window_expr() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseident_name(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_AS(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseas_window_specification(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f159(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseas_window_specification() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$parseident_name(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsewindow_specification(); - s4 = peg$parse__(); - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f160(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsewindow_specification() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsepartition_by_clause(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseorder_by_clause(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parsewindow_frame_clause(); - if (s5 === peg$FAILED) { - s5 = null; - } - peg$savedPos = s0; - s0 = peg$f161(s1, s3, s5); - - return s0; - } - - function peg$parsewindow_specification_frameless() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsepartition_by_clause(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseorder_by_clause(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f162(s1, s3); - - return s0; - } - - function peg$parsewindow_frame_clause() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseKW_ROWS(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsewindow_frame_following(); - if (s3 === peg$FAILED) { - s3 = peg$parsewindow_frame_preceding(); - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f163(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_ROWS(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_BETWEEN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsewindow_frame_preceding(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseKW_AND(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsewindow_frame_following(); - if (s9 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f164(s5, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsewindow_frame_following() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsewindow_frame_value(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c105) { - s3 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e105); - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f165(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$parsewindow_frame_current_row(); - } - - return s0; - } - - function peg$parsewindow_frame_preceding() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parsewindow_frame_value(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c106) { - s3 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e106); - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f166(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$parsewindow_frame_current_row(); - } - - return s0; - } - - function peg$parsewindow_frame_current_row() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c107) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e107); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c58) { - s3 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e58); - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f167(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsewindow_frame_value() { - var s0, s1; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c108) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e108); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f168(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parseliteral_numeric(); - } - - return s0; - } - - function peg$parsepartition_by_clause() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_PARTITION(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_BY(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsecolumn_clause(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f169(s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseorder_by_clause() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_ORDER(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_BY(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseorder_by_list(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f170(s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseorder_by_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseorder_by_element(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseorder_by_element(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseorder_by_element(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f171(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseorder_by_element() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - s1 = peg$parseexpr(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_DESC(); - if (s3 === peg$FAILED) { - s3 = peg$parseKW_ASC(); - } - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c13) { - s6 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e13); - } - } - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c14) { - s8 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e14); - } - } - if (s8 === peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c15) { - s8 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s8 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e15); - } - } - } - if (s8 === peg$FAILED) { - s8 = null; - } - s6 = [s6, s7, s8]; - s5 = s6; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - if (s5 === peg$FAILED) { - s5 = null; - } - peg$savedPos = s0; - s0 = peg$f172(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsenumber_or_param() { - var s0; - - s0 = peg$parseliteral_numeric(); - if (s0 === peg$FAILED) { - s0 = peg$parsevar_decl(); - if (s0 === peg$FAILED) { - s0 = peg$parseparam(); - } - } - - return s0; - } - - function peg$parselimit_clause() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_LIMIT(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parsenumber_or_param(); - if (s4 === peg$FAILED) { - s4 = peg$parseKW_ALL(); - } - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$currPos; - s4 = peg$parseKW_OFFSET(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parsenumber_or_param(); - if (s6 !== peg$FAILED) { - s4 = [s4, s5, s6]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f173(s1, s3); - - return s0; - } - - function peg$parseupdate_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16; - - s0 = peg$currPos; - s1 = peg$parse__(); - s2 = peg$parsewith_clause(); - if (s2 === peg$FAILED) { - s2 = null; - } - s3 = peg$parse__(); - s4 = peg$parseKW_UPDATE(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parsetable_ref_list(); - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - s8 = peg$parseKW_SET(); - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - s10 = peg$parseset_list(); - if (s10 !== peg$FAILED) { - s11 = peg$parse__(); - s12 = peg$parsefrom_clause(); - if (s12 === peg$FAILED) { - s12 = null; - } - s13 = peg$parse__(); - s14 = peg$parsewhere_clause(); - if (s14 === peg$FAILED) { - s14 = null; - } - s15 = peg$parse__(); - s16 = peg$parsereturning_stmt(); - if (s16 === peg$FAILED) { - s16 = null; - } - peg$savedPos = s0; - s0 = peg$f174(s2, s6, s10, s12, s14, s16); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsedelete_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_DELETE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsetable_ref_list(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parsefrom_clause(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsewhere_clause(); - if (s7 === peg$FAILED) { - s7 = null; - } - peg$savedPos = s0; - s0 = peg$f175(s3, s5, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseset_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseset_item(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseset_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseset_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f176(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseset_item() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseident(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseDOT(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parsecolumn(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (input.charCodeAt(peg$currPos) === 61) { - s5 = peg$c109; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e109); - } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseadditive_expr(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f177(s1, s3, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseident(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseDOT(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parsecolumn(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (input.charCodeAt(peg$currPos) === 61) { - s5 = peg$c109; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e109); - } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseKW_VALUES(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseLPAREN(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parsecolumn_ref(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - s13 = peg$parseRPAREN(); - if (s13 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f178(s1, s3, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parseconflict_stmt() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parseKW_ON(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c110) { - s3 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e110); - } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s1 = [s1, s2, s3, s4]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsereturning_stmt() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_RETURNING(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecolumn_clause(); - if (s3 === peg$FAILED) { - s3 = peg$parseselect_stmt(); - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f179(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseinsert_value_clause() { - var s0; - - s0 = peg$parsevalue_clause(); - if (s0 === peg$FAILED) { - s0 = peg$parseselect_stmt_nake(); - } - - return s0; - } - - function peg$parseinsert_partition() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - s1 = peg$parseKW_PARTITION(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseident_name(); - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$currPos; - s8 = peg$parse__(); - s9 = peg$parseCOMMA(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseident_name(); - if (s11 !== peg$FAILED) { - s8 = [s8, s9, s10, s11]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$currPos; - s8 = peg$parse__(); - s9 = peg$parseCOMMA(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseident_name(); - if (s11 !== peg$FAILED) { - s8 = [s8, s9, s10, s11]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - } - s7 = peg$parse__(); - s8 = peg$parseRPAREN(); - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f180(s5, s6); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_PARTITION(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsevalue_item(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f181(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsereplace_insert_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17; - - s0 = peg$currPos; - s1 = peg$parsereplace_insert(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_INTO(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parsetable_name(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseinsert_partition(); - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parseLPAREN(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parsecolumn_list(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - s13 = peg$parseRPAREN(); - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - s15 = peg$parseinsert_value_clause(); - if (s15 !== peg$FAILED) { - s16 = peg$parse__(); - s17 = peg$parsereturning_stmt(); - if (s17 === peg$FAILED) { - s17 = null; - } - peg$savedPos = s0; - s0 = peg$f182(s1, s5, s7, s11, s15, s17); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseinsert_no_columns_stmt() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; - - s0 = peg$currPos; - s1 = peg$parsereplace_insert(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_IGNORE(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseKW_INTO(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parsetable_name(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseinsert_partition(); - if (s9 === peg$FAILED) { - s9 = null; - } - s10 = peg$parse__(); - s11 = peg$parseinsert_value_clause(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - s13 = peg$parsereturning_stmt(); - if (s13 === peg$FAILED) { - s13 = null; - } - peg$savedPos = s0; - s0 = peg$f183(s1, s3, s5, s7, s9, s11, s13); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsereplace_insert() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_INSERT(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f184(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_REPLACE(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f185(); - } - s0 = s1; - } - - return s0; - } - - function peg$parsevalue_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_VALUES(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsevalue_list(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f186(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsevalue_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsevalue_item(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsevalue_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsevalue_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f187(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsevalue_item() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseexpr_list(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f188(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexpr_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseexpr_item(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseexpr_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseexpr_item(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f189(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseinterval_expr() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_INTERVAL(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseexpr(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseinterval_unit(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f190(s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_INTERVAL(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseliteral_string(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f191(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsecase_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - s1 = peg$parseKW_CASE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecase_when_then_list(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsecase_else(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseKW_END(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseKW_CASE(); - if (s9 === peg$FAILED) { - s9 = null; - } - peg$savedPos = s0; - s0 = peg$f192(s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_CASE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseexpr(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsecase_when_then_list(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecase_else(); - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parseKW_END(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseKW_CASE(); - if (s11 === peg$FAILED) { - s11 = null; - } - peg$savedPos = s0; - s0 = peg$f193(s3, s5, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsecase_when_then_list() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parsecase_when_then(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = []; - s4 = peg$currPos; - s5 = peg$parse__(); - s6 = peg$parsecase_when_then(); - if (s6 !== peg$FAILED) { - s5 = [s5, s6]; - s4 = s5; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$currPos; - s5 = peg$parse__(); - s6 = peg$parsecase_when_then(); - if (s6 !== peg$FAILED) { - s5 = [s5, s6]; - s4 = s5; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f194(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecase_when_then() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_WHEN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseor_and_where_expr(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseKW_THEN(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseexpr(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f195(s3, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecase_else() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_ELSE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseexpr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f196(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parse_expr() { - var s0; - - s0 = peg$parselogic_operator_expr(); - if (s0 === peg$FAILED) { - s0 = peg$parseor_expr(); - if (s0 === peg$FAILED) { - s0 = peg$parseunary_expr(); - } - } - - return s0; - } - - function peg$parseexpr() { - var s0; - - s0 = peg$parse_expr(); - if (s0 === peg$FAILED) { - s0 = peg$parseunion_stmt(); - } - - return s0; - } - - function peg$parselogic_operator_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseprimary(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseLOGIC_OPERATOR(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseprimary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseLOGIC_OPERATOR(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseprimary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parsecomparison_op_right(); - if (s4 === peg$FAILED) { - s4 = null; - } - peg$savedPos = s0; - s0 = peg$f197(s1, s2, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseunary_expr() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseadditive_operator(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseprimary(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseprimary(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f198(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsebinary_column_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parse_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseKW_AND(); - if (s5 === peg$FAILED) { - s5 = peg$parseKW_OR(); - if (s5 === peg$FAILED) { - s5 = peg$parseLOGIC_OPERATOR(); - } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parse_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseKW_AND(); - if (s5 === peg$FAILED) { - s5 = peg$parseKW_OR(); - if (s5 === peg$FAILED) { - s5 = peg$parseLOGIC_OPERATOR(); - } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parse_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f199(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseor_and_where_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseexpr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseKW_AND(); - if (s5 === peg$FAILED) { - s5 = peg$parseKW_OR(); - if (s5 === peg$FAILED) { - s5 = peg$parseCOMMA(); - } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseexpr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseKW_AND(); - if (s5 === peg$FAILED) { - s5 = peg$parseKW_OR(); - if (s5 === peg$FAILED) { - s5 = peg$parseCOMMA(); - } - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseexpr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f200(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseor_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseand_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse___(); - if (s4 !== peg$FAILED) { - s5 = peg$parseKW_OR(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseand_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse___(); - if (s4 !== peg$FAILED) { - s5 = peg$parseKW_OR(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseand_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f201(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseand_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsenot_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse___(); - if (s4 !== peg$FAILED) { - s5 = peg$parseKW_AND(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsenot_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse___(); - if (s4 !== peg$FAILED) { - s5 = peg$parseKW_AND(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsenot_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f202(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsenot_expr() { - var s0, s1, s2, s3, s4; - - s0 = peg$parsecomparison_expr(); - if (s0 === peg$FAILED) { - s0 = peg$parseexists_expr(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_NOT(); - if (s1 === peg$FAILED) { - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 33) { - s2 = peg$c111; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e111); - } - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - peg$silentFails++; - if (input.charCodeAt(peg$currPos) === 61) { - s4 = peg$c109; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e109); - } - } - peg$silentFails--; - if (s4 === peg$FAILED) { - s3 = undefined; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsenot_expr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f203(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - - return s0; - } - - function peg$parsecomparison_expr() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseadditive_expr(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecomparison_op_right(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f204(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$parseliteral_string(); - if (s0 === peg$FAILED) { - s0 = peg$parsecolumn_ref(); - } - } - - return s0; - } - - function peg$parseexists_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseexists_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseunion_stmt(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f205(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexists_op() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_NOT(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseKW_EXISTS(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f206(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parseKW_EXISTS(); - } - - return s0; - } - - function peg$parsecomparison_op_right() { - var s0; - - s0 = peg$parsearithmetic_op_right(); - if (s0 === peg$FAILED) { - s0 = peg$parsein_op_right(); - if (s0 === peg$FAILED) { - s0 = peg$parsebetween_op_right(); - if (s0 === peg$FAILED) { - s0 = peg$parseis_op_right(); - if (s0 === peg$FAILED) { - s0 = peg$parselike_op_right(); - if (s0 === peg$FAILED) { - s0 = peg$parsejsonb_op_right(); - } - } - } - } - } - - return s0; - } - - function peg$parsearithmetic_op_right() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = []; - s2 = peg$currPos; - s3 = peg$parse__(); - s4 = peg$parsearithmetic_comparison_operator(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parseadditive_expr(); - if (s6 !== peg$FAILED) { - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$currPos; - s3 = peg$parse__(); - s4 = peg$parsearithmetic_comparison_operator(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parseadditive_expr(); - if (s6 !== peg$FAILED) { - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f207(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsearithmetic_comparison_operator() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c112) { - s0 = peg$c112; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e112); - } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 62) { - s0 = peg$c113; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e113); - } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c114) { - s0 = peg$c114; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e114); - } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c115) { - s0 = peg$c115; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e115); - } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 60) { - s0 = peg$c116; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e116); - } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 61) { - s0 = peg$c109; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e109); - } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c117) { - s0 = peg$c117; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e117); - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parseis_op_right() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - s1 = peg$parseKW_IS(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseadditive_expr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f208(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_IS(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$currPos; - s4 = peg$parseKW_DISTINCT(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parseKW_FROM(); - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - s8 = peg$parsetable_name(); - if (s8 !== peg$FAILED) { - s4 = [s4, s5, s6, s7, s8]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f209(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_IS(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseKW_NOT(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseadditive_expr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f210(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - - return s0; - } - - function peg$parsebetween_op_right() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsebetween_or_not_between_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseadditive_expr(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseKW_AND(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseadditive_expr(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f211(s1, s3, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsebetween_or_not_between_op() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_NOT(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseKW_BETWEEN(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f212(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parseKW_BETWEEN(); - } - - return s0; - } - - function peg$parselike_op() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_NOT(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseKW_LIKE(); - if (s4 === peg$FAILED) { - s4 = peg$parseKW_ILIKE(); - } - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f213(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parseKW_LIKE(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_ILIKE(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c118) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e118); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_TO(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f214(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_NOT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c118) { - s3 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e118); - } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseKW_TO(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f215(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - } - - return s0; - } - - function peg$parseescape_op() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c119) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e119); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseliteral_string(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f216(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsein_op() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseKW_NOT(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseKW_IN(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f217(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parseKW_IN(); - } - - return s0; - } - - function peg$parselike_op_right() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parselike_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseliteral(); - if (s3 === peg$FAILED) { - s3 = peg$parsecomparison_expr(); - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseescape_op(); - if (s5 === peg$FAILED) { - s5 = null; - } - peg$savedPos = s0; - s0 = peg$f218(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsein_op_right() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsein_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr_list(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f219(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsein_op(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsevar_decl(); - if (s3 === peg$FAILED) { - s3 = peg$parseliteral_string(); - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f220(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsejsonb_op_right() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c120) { - s1 = peg$c120; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e120); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c121) { - s1 = peg$c121; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e121); - } - } - if (s1 === peg$FAILED) { - s1 = peg$parseOPERATOR_CONCATENATION(); - if (s1 === peg$FAILED) { - s1 = peg$parseDOUBLE_WELL_ARROW(); - if (s1 === peg$FAILED) { - s1 = peg$parseWELL_ARROW(); - if (s1 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 63) { - s1 = peg$c122; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e122); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c123) { - s1 = peg$c123; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e123); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c124) { - s1 = peg$c124; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e124); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c125) { - s1 = peg$c125; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e125); - } - } - } - } - } - } - } - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsecolumn_list_item(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f221(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseadditive_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsemultiplicative_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseadditive_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsemultiplicative_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseadditive_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsemultiplicative_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f222(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseadditive_operator() { - var s0; - - if (input.charCodeAt(peg$currPos) === 43) { - s0 = peg$c126; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e126); - } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 45) { - s0 = peg$c127; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e127); - } - } - } - - return s0; - } - - function peg$parsemultiplicative_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseprimary(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsemultiplicative_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseprimary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsemultiplicative_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseprimary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f223(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsemultiplicative_operator() { - var s0; - - if (input.charCodeAt(peg$currPos) === 42) { - s0 = peg$c128; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e128); - } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 47) { - s0 = peg$c129; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e129); - } - } - if (s0 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 37) { - s0 = peg$c130; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e130); - } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 2) === peg$c131) { - s0 = peg$c131; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e131); - } - } - } - } - } - - return s0; - } - - function peg$parseprimary() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$parsecast_expr(); - if (s0 === peg$FAILED) { - s0 = peg$parseliteral(); - if (s0 === peg$FAILED) { - s0 = peg$parseaggr_func(); - if (s0 === peg$FAILED) { - s0 = peg$parsewindow_func(); - if (s0 === peg$FAILED) { - s0 = peg$parsefunc_call(); - if (s0 === peg$FAILED) { - s0 = peg$parsecase_expr(); - if (s0 === peg$FAILED) { - s0 = peg$parseinterval_expr(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsecolumn_ref(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsearray_index(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f224(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$parsecolumn_ref(); - if (s0 === peg$FAILED) { - s0 = peg$parseparam(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseor_and_where_expr(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f225(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$parsevar_decl(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parse__(); - if (input.charCodeAt(peg$currPos) === 36) { - s2 = peg$c132; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e132); - } - } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 60) { - s3 = peg$c116; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e116); - } - } - if (s3 !== peg$FAILED) { - s4 = peg$parseliteral_numeric(); - if (s4 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 62) { - s5 = peg$c113; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e113); - } - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f226(s2, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parsestring_constants_escape() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 1).toLowerCase() === peg$c133) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e133); - } - } - if (s1 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 39) { - s2 = peg$c71; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e71); - } - } - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = []; - s5 = peg$parsesingle_char(); - while (s5 !== peg$FAILED) { - s4.push(s5); - s5 = peg$parsesingle_char(); - } - s5 = peg$parse__(); - if (input.charCodeAt(peg$currPos) === 39) { - s6 = peg$c71; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e71); - } - } - if (s6 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f227(s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecolumn_ref() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$parsestring_constants_escape(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseident(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseDOT(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseSTAR(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f228(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseident(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseDOT(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parsecolumn(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = []; - s6 = peg$currPos; - s7 = peg$parseDOUBLE_ARROW(); - if (s7 === peg$FAILED) { - s7 = peg$parseSINGLE_ARROW(); - } - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseliteral_string(); - if (s9 === peg$FAILED) { - s9 = peg$parseliteral_numeric(); - } - if (s9 !== peg$FAILED) { - s7 = [s7, s8, s9]; - s6 = s7; - } else { - peg$currPos = s6; - s6 = peg$FAILED; - } - } else { - peg$currPos = s6; - s6 = peg$FAILED; - } - if (s6 !== peg$FAILED) { - while (s6 !== peg$FAILED) { - s5.push(s6); - s6 = peg$currPos; - s7 = peg$parseDOUBLE_ARROW(); - if (s7 === peg$FAILED) { - s7 = peg$parseSINGLE_ARROW(); - } - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseliteral_string(); - if (s9 === peg$FAILED) { - s9 = peg$parseliteral_numeric(); - } - if (s9 !== peg$FAILED) { - s7 = [s7, s8, s9]; - s6 = s7; - } else { - peg$currPos = s6; - s6 = peg$FAILED; - } - } else { - peg$currPos = s6; - s6 = peg$FAILED; - } - } - } else { - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f229(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$parse__(); - s4 = peg$parseDOT(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parseident(); - if (s6 !== peg$FAILED) { - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseDOT(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f230(s1, s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseident(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseDOT(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsecolumn(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f231(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsecolumn(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f232(s1); - } - s0 = s1; - } - } - } - } - } - - return s0; - } - - function peg$parsecolumn_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsecolumn(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsecolumn(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f233(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseident() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parseident_name(); - if (s1 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s2 = peg$f234(s1); - if (s2) { - s2 = peg$FAILED; - } else { - s2 = undefined; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f235(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsequoted_ident(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f236(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parsealias_ident() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - s1 = peg$parseident_name(); - if (s1 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s2 = peg$f237(s1); - if (s2) { - s2 = peg$FAILED; - } else { - s2 = undefined; - } - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseLPAREN(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parsecolumn_list(); - if (s6 !== peg$FAILED) { - s7 = peg$parse__(); - s8 = peg$parseRPAREN(); - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f238(s1, s6); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseident_name(); - if (s1 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s2 = peg$f239(s1); - if (s2) { - s2 = peg$FAILED; - } else { - s2 = undefined; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f240(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsequoted_ident(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f241(s1); - } - s0 = s1; - } - } - - return s0; - } - - function peg$parsequoted_ident() { - var s0; - - s0 = peg$parsedouble_quoted_ident(); - if (s0 === peg$FAILED) { - s0 = peg$parsesingle_quoted_ident(); - if (s0 === peg$FAILED) { - s0 = peg$parsebackticks_quoted_ident(); - } - } - - return s0; - } - - function peg$parsedouble_quoted_ident() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { - s1 = peg$c90; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e90); - } - } - if (s1 !== peg$FAILED) { - s2 = []; - if (peg$r0.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e134); - } - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - if (peg$r0.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e134); - } - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 34) { - s3 = peg$c90; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e90); - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f242(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsesingle_quoted_ident() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { - s1 = peg$c71; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e71); - } - } - if (s1 !== peg$FAILED) { - s2 = []; - if (peg$r1.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e135); - } - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - if (peg$r1.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e135); - } - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 39) { - s3 = peg$c71; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e71); - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f243(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsebackticks_quoted_ident() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 96) { - s1 = peg$c134; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e136); - } - } - if (s1 !== peg$FAILED) { - s2 = []; - if (peg$r2.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e137); - } - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - if (peg$r2.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e137); - } - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 96) { - s3 = peg$c134; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e136); - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f244(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseident_without_kw() { - var s0; - - s0 = peg$parseident_name(); - if (s0 === peg$FAILED) { - s0 = peg$parsequoted_ident(); - } - - return s0; - } - - function peg$parsecolumn() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parsecolumn_name(); - if (s1 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s2 = peg$f245(s1); - if (s2) { - s2 = peg$FAILED; - } else { - s2 = undefined; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f246(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$parsequoted_ident(); - } - - return s0; - } - - function peg$parsecolumn_name() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseident_start(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parsecolumn_part(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parsecolumn_part(); - } - peg$savedPos = s0; - s0 = peg$f247(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseident_name() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseident_start(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$parseident_part(); - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$parseident_part(); - } - peg$savedPos = s0; - s0 = peg$f248(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseident_start() { - var s0; - - if (peg$r3.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e138); - } - } - - return s0; - } - - function peg$parseident_part() { - var s0; - - if (peg$r4.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e139); - } - } - - return s0; - } - - function peg$parsecolumn_part() { - var s0; - - if (peg$r5.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e140); - } - } - - return s0; - } - - function peg$parseparam() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 58) { - s2 = peg$c135; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e141); - } - } - if (s2 !== peg$FAILED) { - s3 = peg$parseident_name(); - if (s3 !== peg$FAILED) { - s2 = [s2, s3]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f249(s1); - } - s0 = s1; - - return s0; - } - - function peg$parseon_update_current_timestamp() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - s1 = peg$parseKW_ON(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_UPDATE(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseKW_CURRENT_TIMESTAMP(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseLPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseexpr_list(); - if (s9 === peg$FAILED) { - s9 = null; - } - s10 = peg$parse__(); - s11 = peg$parseRPAREN(); - if (s11 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f250(s5, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_ON(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_UPDATE(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseKW_CURRENT_TIMESTAMP(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f251(s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parseover_partition() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c136) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e142); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseas_window_specification(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f252(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c136) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e142); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsepartition_by_clause(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseorder_by_clause(); - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parseRPAREN(); - if (s9 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f253(s5, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$parseon_update_current_timestamp(); - } - } - - return s0; - } - - function peg$parseaggr_filter() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c137) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e143); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsewhere_clause(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f254(s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseaggr_func() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseaggr_fun_count(); - if (s1 === peg$FAILED) { - s1 = peg$parseaggr_fun_smma(); - if (s1 === peg$FAILED) { - s1 = peg$parseaggr_array_agg(); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseaggr_filter(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f255(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsewindow_func() { - var s0; - - s0 = peg$parsewindow_fun_rank(); - if (s0 === peg$FAILED) { - s0 = peg$parsewindow_fun_laglead(); - if (s0 === peg$FAILED) { - s0 = peg$parsewindow_fun_firstlast(); - } - } - - return s0; - } - - function peg$parsewindow_fun_rank() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_WIN_FNS_RANK(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseover_partition(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f256(s1, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsewindow_fun_laglead() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - s1 = peg$parseKW_LAG_LEAD(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr_list(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseconsider_nulls_clause(); - if (s9 === peg$FAILED) { - s9 = null; - } - s10 = peg$parse__(); - s11 = peg$parseover_partition(); - if (s11 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f257(s1, s5, s9, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsewindow_fun_firstlast() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - s1 = peg$parseKW_FIRST_LAST_VALUE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseconsider_nulls_clause(); - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parseRPAREN(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseover_partition(); - if (s11 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f258(s1, s5, s7, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_FIRST_LAST_VALUE() { - var s0; - - if (input.substr(peg$currPos, 11).toLowerCase() === peg$c138) { - s0 = input.substr(peg$currPos, 11); - peg$currPos += 11; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e144); - } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c139) { - s0 = input.substr(peg$currPos, 10); - peg$currPos += 10; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e145); - } - } - } - - return s0; - } - - function peg$parseKW_WIN_FNS_RANK() { - var s0; - - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c140) { - s0 = input.substr(peg$currPos, 10); - peg$currPos += 10; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e146); - } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c141) { - s0 = input.substr(peg$currPos, 10); - peg$currPos += 10; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e147); - } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c142) { - s0 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e148); - } - } - } - } - - return s0; - } - - function peg$parseKW_LAG_LEAD() { - var s0; - - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c143) { - s0 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e149); - } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c144) { - s0 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e150); - } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c145) { - s0 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e151); - } - } - } - } - - return s0; - } - - function peg$parseconsider_nulls_clause() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c146) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e152); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c147) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e153); - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c13) { - s3 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e13); - } - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f259(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseaggr_fun_smma() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseKW_SUM_MAX_MIN_AVG(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseadditive_expr(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseover_partition(); - if (s9 === peg$FAILED) { - s9 = null; - } - peg$savedPos = s0; - s0 = peg$f260(s1, s5, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SUM_MAX_MIN_AVG() { - var s0; - - s0 = peg$parseKW_SUM(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_MAX(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_MIN(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_AVG(); - } - } - } - - return s0; - } - - function peg$parseaggr_fun_count() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19; - - s0 = peg$currPos; - s1 = peg$parseKW_COUNT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_GROUP_CONCAT(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsecount_arg(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseover_partition(); - if (s9 === peg$FAILED) { - s9 = null; - } - peg$savedPos = s0; - s0 = peg$f261(s1, s5, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 15).toLowerCase() === peg$c148) { - s1 = input.substr(peg$currPos, 15); - peg$currPos += 15; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e154); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 15).toLowerCase() === peg$c149) { - s1 = input.substr(peg$currPos, 15); - peg$currPos += 15; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e155); - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseliteral_numeric(); - if (s5 === peg$FAILED) { - s5 = peg$parseliteral_array(); - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c150) { - s9 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e156); - } - } - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseKW_GROUP(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - s13 = peg$parseLPAREN(); - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - s15 = peg$parseorder_by_clause(); - if (s15 !== peg$FAILED) { - s16 = peg$parse__(); - s17 = peg$parseRPAREN(); - if (s17 !== peg$FAILED) { - s18 = peg$parse__(); - s19 = peg$parseover_partition(); - if (s19 === peg$FAILED) { - s19 = null; - } - peg$savedPos = s0; - s0 = peg$f262(s1, s5, s15, s19); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c83) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e157); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c150) { - s7 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e156); - } - } - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseKW_GROUP(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseLPAREN(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - s13 = peg$parseorder_by_clause(); - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - s15 = peg$parseRPAREN(); - if (s15 !== peg$FAILED) { - s16 = peg$parse__(); - s17 = peg$parseover_partition(); - if (s17 === peg$FAILED) { - s17 = null; - } - peg$savedPos = s0; - s0 = peg$f263(s1, s13, s17); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - - return s0; - } - - function peg$parseconcat_separator() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c151) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e158); - } - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseliteral_string(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f264(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsedistinct_args() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - s1 = peg$parseKW_DISTINCT(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseorder_by_clause(); - if (s9 === peg$FAILED) { - s9 = null; - } - s10 = peg$parse__(); - s11 = peg$parseconcat_separator(); - if (s11 === peg$FAILED) { - s11 = null; - } - peg$savedPos = s0; - s0 = peg$f265(s1, s5, s9, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_DISTINCT(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseexpr(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseorder_by_clause(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseconcat_separator(); - if (s7 === peg$FAILED) { - s7 = null; - } - peg$savedPos = s0; - s0 = peg$f266(s1, s3, s5, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsecount_arg() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parsestar_expr(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f267(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parsedistinct_args(); - } - - return s0; - } - - function peg$parseaggr_array_agg() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - s1 = peg$currPos; - s2 = peg$parseident(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseDOT(); - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseKW_ARRAY_AGG(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseLPAREN(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsedistinct_args(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseorder_by_clause(); - if (s9 === peg$FAILED) { - s9 = null; - } - s10 = peg$parse__(); - s11 = peg$parseRPAREN(); - if (s11 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f268(s1, s3, s7, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsestar_expr() { - var s0, s1; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 42) { - s1 = peg$c128; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e128); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f269(); - } - s0 = s1; - - return s0; - } - - function peg$parsetrim_position() { - var s0; - - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c152) { - s0 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e159); - } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c153) { - s0 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e160); - } - } - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c154) { - s0 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e161); - } - } - } - } - - return s0; - } - - function peg$parsetrim_rem() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsetrim_position(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseliteral_string(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseKW_FROM(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f270(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetrim_func_clause() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c155) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e162); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsetrim_rem(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseexpr(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseRPAREN(); - if (s9 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f271(s5, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsefunc_call() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15; - - s0 = peg$parsetrim_func_clause(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c156) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e163); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr_list(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c157) { - s9 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s9 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e164); - } - } - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseKW_TIME(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c158) { - s13 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s13 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e165); - } - } - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - s15 = peg$parseliteral_string(); - if (s15 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f272(s1, s5, s15); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsescalar_func(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr_list(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseover_partition(); - if (s9 === peg$FAILED) { - s9 = null; - } - peg$savedPos = s0; - s0 = peg$f273(s1, s5, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseproc_func_name(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseor_and_where_expr(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f274(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$parseextract_func(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsescalar_time_func(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseon_update_current_timestamp(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f275(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - } - } - - return s0; - } - - function peg$parseextract_filed() { - var s0, s1; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c159) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e166); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c160) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e167); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c161) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e168); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c162) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e169); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c163) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e170); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c164) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e171); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c165) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e172); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c166) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e173); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c167) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e174); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c168) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e175); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c169) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e176); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c170) { - s1 = input.substr(peg$currPos, 10); - peg$currPos += 10; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e177); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c171) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e178); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c172) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e179); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c173) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e180); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c174) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e181); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c175) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e182); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c176) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e183); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 13).toLowerCase() === peg$c177) { - s1 = input.substr(peg$currPos, 13); - peg$currPos += 13; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e184); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 15).toLowerCase() === peg$c178) { - s1 = input.substr(peg$currPos, 15); - peg$currPos += 15; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e185); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c179) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e186); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c180) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e187); - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f276(s1); - } - s0 = s1; - - return s0; - } - - function peg$parseextract_func() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13; - - s0 = peg$currPos; - s1 = peg$parseKW_EXTRACT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseextract_filed(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseKW_FROM(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseKW_TIMESTAMP(); - if (s9 === peg$FAILED) { - s9 = peg$parseKW_INTERVAL(); - if (s9 === peg$FAILED) { - s9 = peg$parseKW_TIME(); - if (s9 === peg$FAILED) { - s9 = peg$parseKW_DATE(); - } - } - } - if (s9 === peg$FAILED) { - s9 = null; - } - s10 = peg$parse__(); - s11 = peg$parseexpr(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - s13 = peg$parseRPAREN(); - if (s13 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f277(s1, s5, s9, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_EXTRACT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseextract_filed(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseKW_FROM(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseexpr(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseRPAREN(); - if (s11 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f278(s1, s5, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsescalar_time_func() { - var s0; - - s0 = peg$parseKW_CURRENT_DATE(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_CURRENT_TIME(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_CURRENT_TIMESTAMP(); - } - } - - return s0; - } - - function peg$parsescalar_func() { - var s0; - - s0 = peg$parsescalar_time_func(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_CURRENT_USER(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_USER(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_SESSION_USER(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_SYSTEM_USER(); - if (s0 === peg$FAILED) { - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c181) { - s0 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e188); - } - } - } - } - } - } - } - - return s0; - } - - function peg$parsecast_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11, s12, s13, s14, s15, s16, s17, s18, s19, s20, s21; - - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseliteral(); - if (s3 === peg$FAILED) { - s3 = peg$parseaggr_func(); - if (s3 === peg$FAILED) { - s3 = peg$parsewindow_func(); - if (s3 === peg$FAILED) { - s3 = peg$parsefunc_call(); - if (s3 === peg$FAILED) { - s3 = peg$parsecase_expr(); - if (s3 === peg$FAILED) { - s3 = peg$parseinterval_expr(); - if (s3 === peg$FAILED) { - s3 = peg$parsecolumn_ref(); - if (s3 === peg$FAILED) { - s3 = peg$parseparam(); - } - } - } - } - } - } - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseKW_DOUBLE_COLON(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsedata_type(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parsealias_clause(); - if (s11 === peg$FAILED) { - s11 = null; - } - peg$savedPos = s0; - s0 = peg$f279(s3, s7, s9, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseliteral(); - if (s1 === peg$FAILED) { - s1 = peg$parseaggr_func(); - if (s1 === peg$FAILED) { - s1 = peg$parsewindow_func(); - if (s1 === peg$FAILED) { - s1 = peg$parsefunc_call(); - if (s1 === peg$FAILED) { - s1 = peg$parsecase_expr(); - if (s1 === peg$FAILED) { - s1 = peg$parseinterval_expr(); - if (s1 === peg$FAILED) { - s1 = peg$parsecolumn_ref(); - if (s1 === peg$FAILED) { - s1 = peg$parseparam(); - } - } - } - } - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_DOUBLE_COLON(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsedata_type(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsealias_clause(); - if (s7 === peg$FAILED) { - s7 = null; - } - peg$savedPos = s0; - s0 = peg$f280(s1, s3, s5, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_CAST(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseKW_AS(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsedata_type(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseRPAREN(); - if (s11 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f281(s1, s5, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_CAST(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseKW_AS(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseKW_DECIMAL(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseLPAREN(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - s13 = peg$parseint(); - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - s15 = peg$parseRPAREN(); - if (s15 !== peg$FAILED) { - s16 = peg$parse__(); - s17 = peg$parseRPAREN(); - if (s17 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f282(s1, s5, s13); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_CAST(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseKW_AS(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseKW_DECIMAL(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseLPAREN(); - if (s11 !== peg$FAILED) { - s12 = peg$parse__(); - s13 = peg$parseint(); - if (s13 !== peg$FAILED) { - s14 = peg$parse__(); - s15 = peg$parseCOMMA(); - if (s15 !== peg$FAILED) { - s16 = peg$parse__(); - s17 = peg$parseint(); - if (s17 !== peg$FAILED) { - s18 = peg$parse__(); - s19 = peg$parseRPAREN(); - if (s19 !== peg$FAILED) { - s20 = peg$parse__(); - s21 = peg$parseRPAREN(); - if (s21 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f283(s1, s5, s13, s17); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_CAST(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseKW_AS(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsesignedness(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parseKW_INTEGER(); - if (s11 === peg$FAILED) { - s11 = null; - } - s12 = peg$parse__(); - s13 = peg$parseRPAREN(); - if (s13 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f284(s1, s5, s9, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - } - } - - return s0; - } - - function peg$parsesignedness() { - var s0; - - s0 = peg$parseKW_SIGNED(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_UNSIGNED(); - } - - return s0; - } - - function peg$parseliteral() { - var s0; - - s0 = peg$parseliteral_string(); - if (s0 === peg$FAILED) { - s0 = peg$parseliteral_numeric(); - if (s0 === peg$FAILED) { - s0 = peg$parseliteral_bool(); - if (s0 === peg$FAILED) { - s0 = peg$parseliteral_null(); - if (s0 === peg$FAILED) { - s0 = peg$parseliteral_datetime(); - if (s0 === peg$FAILED) { - s0 = peg$parseliteral_array(); - } - } - } - } - } - - return s0; - } - - function peg$parseliteral_array() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_ARRAY(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLBRAKE(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseexpr_list(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseRBRAKE(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f285(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseliteral_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseliteral(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseliteral(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseliteral(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f286(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseliteral_null() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_NULL(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f287(); - } - s0 = s1; - - return s0; - } - - function peg$parseliteral_not_null() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_NOT_NULL(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f288(); - } - s0 = s1; - - return s0; - } - - function peg$parseliteral_bool() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_TRUE(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f289(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_FALSE(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f290(); - } - s0 = s1; - } - - return s0; - } - - function peg$parseliteral_string() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { - s2 = peg$c71; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e71); - } - } - if (s2 !== peg$FAILED) { - s3 = []; - s4 = peg$parsesingle_char(); - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parsesingle_char(); - } - if (input.charCodeAt(peg$currPos) === 39) { - s4 = peg$c71; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e71); - } - } - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - s2 = []; - if (peg$r6.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e189); - } - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - if (peg$r6.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e189); - } - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { - s5 = peg$c71; - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e71); - } - } - if (s5 !== peg$FAILED) { - s6 = []; - s7 = peg$parsesingle_char(); - while (s7 !== peg$FAILED) { - s6.push(s7); - s7 = peg$parsesingle_char(); - } - if (input.charCodeAt(peg$currPos) === 39) { - s7 = peg$c71; - peg$currPos++; - } else { - s7 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e71); - } - } - if (s7 !== peg$FAILED) { - s5 = [s5, s6, s7]; - s4 = s5; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f291(s1, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { - s2 = peg$c71; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e71); - } - } - if (s2 !== peg$FAILED) { - s3 = []; - s4 = peg$parsesingle_char(); - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parsesingle_char(); - } - if (input.charCodeAt(peg$currPos) === 39) { - s4 = peg$c71; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e71); - } - } - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f292(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { - s2 = peg$c90; - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e90); - } - } - if (s2 !== peg$FAILED) { - s3 = []; - s4 = peg$parsesingle_quote_char(); - while (s4 !== peg$FAILED) { - s3.push(s4); - s4 = peg$parsesingle_quote_char(); - } - if (input.charCodeAt(peg$currPos) === 34) { - s4 = peg$c90; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e90); - } - } - if (s4 !== peg$FAILED) { - s2 = [s2, s3, s4]; - s1 = s2; - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - } else { - peg$currPos = s1; - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseDOT(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f293(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - - return s0; - } - - function peg$parseliteral_datetime() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parseKW_TIME(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DATE(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_TIMESTAMP(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DATETIME(); - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 39) { - s4 = peg$c71; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e71); - } - } - if (s4 !== peg$FAILED) { - s5 = []; - s6 = peg$parsesingle_char(); - while (s6 !== peg$FAILED) { - s5.push(s6); - s6 = peg$parsesingle_char(); - } - if (input.charCodeAt(peg$currPos) === 39) { - s6 = peg$c71; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e71); - } - } - if (s6 !== peg$FAILED) { - s4 = [s4, s5, s6]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f294(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_TIME(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DATE(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_TIMESTAMP(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DATETIME(); - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { - s4 = peg$c90; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e90); - } - } - if (s4 !== peg$FAILED) { - s5 = []; - s6 = peg$parsesingle_quote_char(); - while (s6 !== peg$FAILED) { - s5.push(s6); - s6 = peg$parsesingle_quote_char(); - } - if (input.charCodeAt(peg$currPos) === 34) { - s6 = peg$c90; - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e90); - } - } - if (s6 !== peg$FAILED) { - s4 = [s4, s5, s6]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f295(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsesingle_quote_char() { - var s0; - - if (peg$r7.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e190); - } - } - if (s0 === peg$FAILED) { - s0 = peg$parseescape_char(); - } - - return s0; - } - - function peg$parsesingle_char() { - var s0; - - if (peg$r8.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e191); - } - } - if (s0 === peg$FAILED) { - s0 = peg$parseescape_char(); - } - - return s0; - } - - function peg$parseescape_char() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c182) { - s1 = peg$c182; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e192); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f296(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c183) { - s1 = peg$c183; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e193); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f297(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c184) { - s1 = peg$c184; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e194); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f298(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c185) { - s1 = peg$c185; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e195); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f299(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c186) { - s1 = peg$c186; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e196); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f300(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c187) { - s1 = peg$c187; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e197); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f301(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c188) { - s1 = peg$c188; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e198); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f302(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c189) { - s1 = peg$c189; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e199); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f303(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c190) { - s1 = peg$c190; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e200); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f304(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c191) { - s1 = peg$c191; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e201); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsehexDigit(); - if (s2 !== peg$FAILED) { - s3 = peg$parsehexDigit(); - if (s3 !== peg$FAILED) { - s4 = peg$parsehexDigit(); - if (s4 !== peg$FAILED) { - s5 = peg$parsehexDigit(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f305(s2, s3, s4, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 92) { - s1 = peg$c192; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e202); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f306(); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c193) { - s1 = peg$c193; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e203); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f307(); - } - s0 = s1; - } - } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parseline_terminator() { - var s0; - - if (peg$r9.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e204); - } - } - - return s0; - } - - function peg$parseliteral_numeric() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parsenumber(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f308(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsenumber() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseint(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parsefrac(); - if (s2 !== peg$FAILED) { - s3 = peg$parseexp(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f309(s1, s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseint(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parsefrac(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f310(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseint(); - if (s1 !== peg$FAILED) { - s2 = peg$parseexp(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f311(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseint(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f312(s1); - } - s0 = s1; - } - } - } - - return s0; - } - - function peg$parseint() { - var s0, s1, s2; - - s0 = peg$parsedigits(); - if (s0 === peg$FAILED) { - s0 = peg$parsedigit(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 45) { - s1 = peg$c127; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e127); - } - } - if (s1 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 43) { - s1 = peg$c126; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e126); - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsedigits(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f313(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 45) { - s1 = peg$c127; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e127); - } - } - if (s1 === peg$FAILED) { - if (input.charCodeAt(peg$currPos) === 43) { - s1 = peg$c126; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e126); - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsedigit(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f314(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - - return s0; - } - - function peg$parsefrac() { - var s0, s1, s2; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 46) { - s1 = peg$c194; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e205); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parsedigits(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f315(s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseexp() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = peg$parsee(); - if (s1 !== peg$FAILED) { - s2 = peg$parsedigits(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f316(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsedigits() { - var s0, s1, s2; - - s0 = peg$currPos; - s1 = []; - s2 = peg$parsedigit(); - if (s2 !== peg$FAILED) { - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$parsedigit(); - } - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f317(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsedigit() { - var s0; - - if (peg$r10.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e206); - } - } - - return s0; - } - - function peg$parsehexDigit() { - var s0; - - if (peg$r11.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e207); - } - } - - return s0; - } - - function peg$parsee() { - var s0, s1, s2; - - s0 = peg$currPos; - if (peg$r12.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e208); - } - } - if (s1 !== peg$FAILED) { - if (peg$r13.test(input.charAt(peg$currPos))) { - s2 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s2 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e209); - } - } - if (s2 === peg$FAILED) { - s2 = null; - } - peg$savedPos = s0; - s0 = peg$f318(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_NULL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c195) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e210); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DEFAULT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c23) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e23); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_NOT_NULL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c196) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e211); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TRUE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c197) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e212); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TO() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c198) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e213); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_FALSE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c199) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e214); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SHOW() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c200) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e215); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DROP() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c201) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e216); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f319(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_USE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c202) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e217); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ALTER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c203) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e218); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SELECT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c204) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e219); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UPDATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c205) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e220); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CREATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c206) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e221); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TEMPORARY() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c207) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e222); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f320(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TEMP() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c208) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e223); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f321(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DELETE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c209) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e224); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_INSERT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c210) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e225); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_RECURSIVE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9) === peg$c211) { - s1 = peg$c211; - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e226); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REPLACE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c212) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e227); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_RETURNING() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c213) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e228); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f322(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_RENAME() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c214) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e229); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_IGNORE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c146) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e152); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_EXPLAIN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c215) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e230); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_PARTITION() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c216) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e231); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f323(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_INTO() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c217) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e232); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_FROM() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c218) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e233); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SET() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c61) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e61); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_LOCK() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c33) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e33); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_AS() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c219) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e234); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TABLE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c220) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e235); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f324(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DATABASE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c221) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e236); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f325(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SCHEME() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c222) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e237); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f326(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SEQUENCE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c223) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e238); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f327(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TABLESPACE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c224) { - s1 = input.substr(peg$currPos, 10); - peg$currPos += 10; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e239); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f328(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_COLLATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c63) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e63); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f329(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DEALLOCATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c225) { - s1 = input.substr(peg$currPos, 10); - peg$currPos += 10; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e240); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f330(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ON() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c48) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e48); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_LEFT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c226) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e241); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_RIGHT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c227) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e242); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_FULL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c228) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e243); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_INNER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c229) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e244); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_JOIN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c230) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e245); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_OUTER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c231) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e246); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNION() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c232) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e247); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_VALUES() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c233) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e248); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_USING() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c234) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e249); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_WHERE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c235) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e250); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_WITH() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c97) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e97); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_GROUP() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c236) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e251); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_BY() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c237) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e252); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ORDER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c238) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e253); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_HAVING() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c239) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e254); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_WINDOW() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c240) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e255); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_LIMIT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c241) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e256); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_OFFSET() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c242) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e257); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f331(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ASC() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c243) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e258); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f332(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DESC() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c244) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e259); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f333(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ALL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c245) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e260); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f334(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DISTINCT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c246) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e261); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f335(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_BETWEEN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c247) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e262); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f336(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_IN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c75) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e75); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f337(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_IS() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c248) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e263); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f338(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_LIKE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c249) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e264); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f339(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ILIKE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c250) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e265); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f340(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_EXISTS() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c251) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e266); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f341(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_NOT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c52) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e52); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f342(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_AND() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c252) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e267); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f343(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_OR() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2).toLowerCase() === peg$c253) { - s1 = input.substr(peg$currPos, 2); - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e268); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f344(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ARRAY() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c254) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e269); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f345(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ARRAY_AGG() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c255) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e270); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f346(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_COUNT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c256) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e271); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f347(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_GROUP_CONCAT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c257) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e272); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f348(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_MAX() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c258) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e273); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f349(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_MIN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c259) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e274); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f350(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SUM() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c260) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e275); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f351(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_AVG() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c261) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e276); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f352(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_EXTRACT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c262) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e277); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f353(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CALL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c263) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e278); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f354(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CASE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c264) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e279); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_WHEN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c265) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e280); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_THEN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c266) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e281); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ELSE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c267) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e282); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_END() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c268) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e283); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CAST() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c269) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e284); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f355(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_BOOL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c270) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e285); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f356(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_BOOLEAN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c271) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e286); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f357(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CHAR() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c272) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e287); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f358(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CHARACTER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c60) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e60); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f359(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_VARCHAR() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c273) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e288); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f360(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_NUMERIC() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c274) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e289); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f361(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DECIMAL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c275) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e290); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f362(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SIGNED() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c276) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e291); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f363(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNSIGNED() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c277) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e292); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f364(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_INT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c278) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e293); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f365(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ZEROFILL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c279) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e294); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f366(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_INTEGER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c280) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e295); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f367(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_JSON() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c281) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e296); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f368(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_JSONB() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c282) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e297); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f369(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_GEOMETRY() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c283) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e298); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f370(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SMALLINT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c284) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e299); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f371(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SERIAL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c285) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e300); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f372(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TINYINT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c286) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e301); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f373(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TINYTEXT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c287) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e302); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f374(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TEXT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c288) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e303); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f375(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_MEDIUMTEXT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c289) { - s1 = input.substr(peg$currPos, 10); - peg$currPos += 10; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e304); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f376(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_LONGTEXT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c290) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e305); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f377(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_BIGINT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c291) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e306); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f378(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ENUM() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c292) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e307); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f379(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_FLOAT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c293) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e308); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f380(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DOUBLE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c294) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e309); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f381(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_BIGSERIAL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c295) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e310); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f382(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REAL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c296) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e311); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f383(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c161) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e168); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f384(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_DATETIME() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c297) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e312); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f385(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ROWS() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c298) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e313); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f386(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TIME() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c299) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e314); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f387(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TIMESTAMP() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c300) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e315); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f388(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_TRUNCATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c301) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e316); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f389(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_USER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c302) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e317); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f390(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UUID() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c303) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e318); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f391(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_OID() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c304) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e319); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f392(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REGCLASS() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c305) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e320); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f393(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REGCOLLATION() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c306) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e321); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f394(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REGCONFIG() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c307) { - s1 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e322); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f395(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REGDICTIONARY() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 13).toLowerCase() === peg$c308) { - s1 = input.substr(peg$currPos, 13); - peg$currPos += 13; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e323); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f396(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REGNAMESPACE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c309) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e324); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f397(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REGOPER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c310) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e325); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f398(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REGOPERATOR() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 11).toLowerCase() === peg$c311) { - s1 = input.substr(peg$currPos, 11); - peg$currPos += 11; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e326); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f399(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REGPROC() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c312) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e327); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f400(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REGPROCEDURE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c313) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e328); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f401(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REGROLE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c314) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e329); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f402(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REGTYPE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c315) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e330); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f403(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CURRENT_DATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c316) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e331); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f404(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_ADD_DATE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c317) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e332); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f405(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_INTERVAL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c318) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e333); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f406(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNIT_YEAR() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c180) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e187); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f407(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNIT_MONTH() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c173) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e180); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f408(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNIT_DAY() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c160) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e167); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f409(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNIT_HOUR() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c166) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e173); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f410(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNIT_MINUTE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c172) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e179); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f411(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNIT_SECOND() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c175) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e182); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f412(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CURRENT_TIME() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c319) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e334); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f413(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CURRENT_TIMESTAMP() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 17).toLowerCase() === peg$c320) { - s1 = input.substr(peg$currPos, 17); - peg$currPos += 17; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e335); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f414(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CURRENT_USER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c321) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e336); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f415(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SESSION_USER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c322) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e337); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f416(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SYSTEM_USER() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 11).toLowerCase() === peg$c323) { - s1 = input.substr(peg$currPos, 11); - peg$currPos += 11; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e338); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f417(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_GLOBAL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c324) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e339); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f418(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SESSION() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c325) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e340); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f419(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_LOCAL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c326) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e341); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f420(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_PERSIST() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c327) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e342); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f421(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_PERSIST_ONLY() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c328) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e343); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f422(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_VAR__PRE_AT() { - var s0; - - if (input.charCodeAt(peg$currPos) === 64) { - s0 = peg$c329; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e344); - } - } - - return s0; - } - - function peg$parseKW_VAR__PRE_AT_AT() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c330) { - s0 = peg$c330; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e345); - } - } - - return s0; - } - - function peg$parseKW_VAR_PRE_DOLLAR() { - var s0; - - if (input.charCodeAt(peg$currPos) === 36) { - s0 = peg$c132; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e132); - } - } - - return s0; - } - - function peg$parseKW_VAR_PRE_DOLLAR_DOUBLE() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c331) { - s0 = peg$c331; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e346); - } - } - - return s0; - } - - function peg$parseKW_VAR_PRE() { - var s0; - - s0 = peg$parseKW_VAR__PRE_AT_AT(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_VAR__PRE_AT(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_VAR_PRE_DOLLAR(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_VAR_PRE_DOLLAR(); - } - } - } - - return s0; - } - - function peg$parseKW_RETURN() { - var s0; - - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c332) { - s0 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e347); - } - } - - return s0; - } - - function peg$parseKW_ASSIGN() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c333) { - s0 = peg$c333; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e348); - } - } - - return s0; - } - - function peg$parseKW_DOUBLE_COLON() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c334) { - s0 = peg$c334; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e349); - } - } - - return s0; - } - - function peg$parseKW_ASSIGIN_EQUAL() { - var s0; - - if (input.charCodeAt(peg$currPos) === 61) { - s0 = peg$c109; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e109); - } - } - - return s0; - } - - function peg$parseKW_DUAL() { - var s0; - - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c335) { - s0 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e350); - } - } - - return s0; - } - - function peg$parseKW_ADD() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c336) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e351); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f423(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_COLUMN() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c337) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e352); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f424(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_INDEX() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c338) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e353); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f425(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_KEY() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 3).toLowerCase() === peg$c18) { - s1 = input.substr(peg$currPos, 3); - peg$currPos += 3; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e18); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f426(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_FULLTEXT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 8).toLowerCase() === peg$c339) { - s1 = input.substr(peg$currPos, 8); - peg$currPos += 8; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e354); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f427(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_SPATIAL() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c340) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e355); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f428(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_UNIQUE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 6).toLowerCase() === peg$c17) { - s1 = input.substr(peg$currPos, 6); - peg$currPos += 6; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e17); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f429(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_KEY_BLOCK_SIZE() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 14).toLowerCase() === peg$c65) { - s1 = input.substr(peg$currPos, 14); - peg$currPos += 14; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e65); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f430(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_COMMENT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c341) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e356); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f431(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CONSTRAINT() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c342) { - s1 = input.substr(peg$currPos, 10); - peg$currPos += 10; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e357); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f432(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_CONCURRENTLY() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c343) { - s1 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e358); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f433(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseKW_REFERENCES() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 10).toLowerCase() === peg$c344) { - s1 = input.substr(peg$currPos, 10); - peg$currPos += 10; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e359); - } - } - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - peg$silentFails++; - s3 = peg$parseident_start(); - peg$silentFails--; - if (s3 === peg$FAILED) { - s2 = undefined; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f434(); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseOPT_SQL_CALC_FOUND_ROWS() { - var s0; - - if (input.substr(peg$currPos, 19).toLowerCase() === peg$c345) { - s0 = input.substr(peg$currPos, 19); - peg$currPos += 19; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e360); - } - } - - return s0; - } - - function peg$parseOPT_SQL_CACHE() { - var s0; - - if (input.substr(peg$currPos, 9).toLowerCase() === peg$c346) { - s0 = input.substr(peg$currPos, 9); - peg$currPos += 9; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e361); - } - } - - return s0; - } - - function peg$parseOPT_SQL_NO_CACHE() { - var s0; - - if (input.substr(peg$currPos, 12).toLowerCase() === peg$c347) { - s0 = input.substr(peg$currPos, 12); - peg$currPos += 12; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e362); - } - } - - return s0; - } - - function peg$parseOPT_SQL_SMALL_RESULT() { - var s0; - - if (input.substr(peg$currPos, 16).toLowerCase() === peg$c348) { - s0 = input.substr(peg$currPos, 16); - peg$currPos += 16; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e363); - } - } - - return s0; - } - - function peg$parseOPT_SQL_BIG_RESULT() { - var s0; - - if (input.substr(peg$currPos, 14).toLowerCase() === peg$c349) { - s0 = input.substr(peg$currPos, 14); - peg$currPos += 14; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e364); - } - } - - return s0; - } - - function peg$parseOPT_SQL_BUFFER_RESULT() { - var s0; - - if (input.substr(peg$currPos, 17).toLowerCase() === peg$c350) { - s0 = input.substr(peg$currPos, 17); - peg$currPos += 17; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e365); - } - } - - return s0; - } - - function peg$parseDOT() { - var s0; - - if (input.charCodeAt(peg$currPos) === 46) { - s0 = peg$c194; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e205); - } - } - - return s0; - } - - function peg$parseCOMMA() { - var s0; - - if (input.charCodeAt(peg$currPos) === 44) { - s0 = peg$c351; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e366); - } - } - - return s0; - } - - function peg$parseSTAR() { - var s0; - - if (input.charCodeAt(peg$currPos) === 42) { - s0 = peg$c128; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e128); - } - } - - return s0; - } - - function peg$parseLPAREN() { - var s0; - - if (input.charCodeAt(peg$currPos) === 40) { - s0 = peg$c88; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e88); - } - } - - return s0; - } - - function peg$parseRPAREN() { - var s0; - - if (input.charCodeAt(peg$currPos) === 41) { - s0 = peg$c89; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e89); - } - } - - return s0; - } - - function peg$parseLBRAKE() { - var s0; - - if (input.charCodeAt(peg$currPos) === 91) { - s0 = peg$c352; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e367); - } - } - - return s0; - } - - function peg$parseRBRAKE() { - var s0; - - if (input.charCodeAt(peg$currPos) === 93) { - s0 = peg$c353; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e368); - } - } - - return s0; - } - - function peg$parseSEMICOLON() { - var s0; - - if (input.charCodeAt(peg$currPos) === 59) { - s0 = peg$c87; - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e87); - } - } - - return s0; - } - - function peg$parseSINGLE_ARROW() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c354) { - s0 = peg$c354; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e369); - } - } - - return s0; - } - - function peg$parseDOUBLE_ARROW() { - var s0; - - if (input.substr(peg$currPos, 3) === peg$c355) { - s0 = peg$c355; - peg$currPos += 3; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e370); - } - } - - return s0; - } - - function peg$parseWELL_ARROW() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c356) { - s0 = peg$c356; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e371); - } - } - - return s0; - } - - function peg$parseDOUBLE_WELL_ARROW() { - var s0; - - if (input.substr(peg$currPos, 3) === peg$c357) { - s0 = peg$c357; - peg$currPos += 3; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e372); - } - } - - return s0; - } - - function peg$parseOPERATOR_CONCATENATION() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c131) { - s0 = peg$c131; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e131); - } - } - - return s0; - } - - function peg$parseOPERATOR_AND() { - var s0; - - if (input.substr(peg$currPos, 2) === peg$c358) { - s0 = peg$c358; - peg$currPos += 2; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e373); - } - } - - return s0; - } - - function peg$parseLOGIC_OPERATOR() { - var s0; - - s0 = peg$parseOPERATOR_CONCATENATION(); - if (s0 === peg$FAILED) { - s0 = peg$parseOPERATOR_AND(); - } - - return s0; - } - - function peg$parse__() { - var s0, s1; - - s0 = []; - s1 = peg$parsewhitespace(); - if (s1 === peg$FAILED) { - s1 = peg$parsecomment(); - } - while (s1 !== peg$FAILED) { - s0.push(s1); - s1 = peg$parsewhitespace(); - if (s1 === peg$FAILED) { - s1 = peg$parsecomment(); - } - } - - return s0; - } - - function peg$parse___() { - var s0, s1; - - s0 = []; - s1 = peg$parsewhitespace(); - if (s1 === peg$FAILED) { - s1 = peg$parsecomment(); - } - if (s1 !== peg$FAILED) { - while (s1 !== peg$FAILED) { - s0.push(s1); - s1 = peg$parsewhitespace(); - if (s1 === peg$FAILED) { - s1 = peg$parsecomment(); - } - } - } else { - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsecomment() { - var s0; - - s0 = peg$parseblock_comment(); - if (s0 === peg$FAILED) { - s0 = peg$parseline_comment(); - } - - return s0; - } - - function peg$parseblock_comment() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c359) { - s1 = peg$c359; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e374); - } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - if (input.substr(peg$currPos, 2) === peg$c360) { - s5 = peg$c360; - peg$currPos += 2; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e375); - } - } - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = undefined; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - s5 = peg$currPos; - peg$silentFails++; - if (input.substr(peg$currPos, 2) === peg$c359) { - s6 = peg$c359; - peg$currPos += 2; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e374); - } - } - peg$silentFails--; - if (s6 === peg$FAILED) { - s5 = undefined; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - s6 = peg$parsechar(); - if (s6 !== peg$FAILED) { - s4 = [s4, s5, s6]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 === peg$FAILED) { - s3 = peg$parseblock_comment(); - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - if (input.substr(peg$currPos, 2) === peg$c360) { - s5 = peg$c360; - peg$currPos += 2; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e375); - } - } - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = undefined; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - s5 = peg$currPos; - peg$silentFails++; - if (input.substr(peg$currPos, 2) === peg$c359) { - s6 = peg$c359; - peg$currPos += 2; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e374); - } - } - peg$silentFails--; - if (s6 === peg$FAILED) { - s5 = undefined; - } else { - peg$currPos = s5; - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - s6 = peg$parsechar(); - if (s6 !== peg$FAILED) { - s4 = [s4, s5, s6]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - if (s3 === peg$FAILED) { - s3 = peg$parseblock_comment(); - } - } - if (input.substr(peg$currPos, 2) === peg$c360) { - s3 = peg$c360; - peg$currPos += 2; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e375); - } - } - if (s3 !== peg$FAILED) { - s1 = [s1, s2, s3]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseline_comment() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 2) === peg$c361) { - s1 = peg$c361; - peg$currPos += 2; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e376); - } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parseEOL(); - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = undefined; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - s5 = peg$parsechar(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parseEOL(); - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = undefined; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - s5 = peg$parsechar(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsepound_sign_comment() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 35) { - s1 = peg$c362; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e377); - } - } - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parseEOL(); - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = undefined; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - s5 = peg$parsechar(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$currPos; - peg$silentFails++; - s5 = peg$parseEOL(); - peg$silentFails--; - if (s5 === peg$FAILED) { - s4 = undefined; - } else { - peg$currPos = s4; - s4 = peg$FAILED; - } - if (s4 !== peg$FAILED) { - s5 = peg$parsechar(); - if (s5 !== peg$FAILED) { - s4 = [s4, s5]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - s1 = [s1, s2]; - s0 = s1; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsekeyword_comment() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseKW_COMMENT(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ASSIGIN_EQUAL(); - if (s3 === peg$FAILED) { - s3 = null; - } - s4 = peg$parse__(); - s5 = peg$parseliteral_string(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f435(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsechar() { - var s0; - - if (input.length > peg$currPos) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e378); - } - } - - return s0; - } - - function peg$parseinterval_unit() { - var s0; - - s0 = peg$parseKW_UNIT_YEAR(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_UNIT_MONTH(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_UNIT_DAY(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_UNIT_HOUR(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_UNIT_MINUTE(); - if (s0 === peg$FAILED) { - s0 = peg$parseKW_UNIT_SECOND(); - } - } - } - } - } - - return s0; - } - - function peg$parsewhitespace() { - var s0; - - if (peg$r14.test(input.charAt(peg$currPos))) { - s0 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s0 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e379); - } - } - - return s0; - } - - function peg$parseEOL() { - var s0, s1; - - s0 = peg$parseEOF(); - if (s0 === peg$FAILED) { - s0 = []; - if (peg$r9.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e204); - } - } - if (s1 !== peg$FAILED) { - while (s1 !== peg$FAILED) { - s0.push(s1); - if (peg$r9.test(input.charAt(peg$currPos))) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e204); - } - } - } - } else { - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parseEOF() { - var s0, s1; - - s0 = peg$currPos; - peg$silentFails++; - if (input.length > peg$currPos) { - s1 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e378); - } - } - peg$silentFails--; - if (s1 === peg$FAILED) { - s0 = undefined; - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseproc_stmts() { - var s0, s1; - - s0 = []; - s1 = peg$parseproc_stmt(); - while (s1 !== peg$FAILED) { - s0.push(s1); - s1 = peg$parseproc_stmt(); - } - - return s0; - } - - function peg$parseproc_stmt() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - peg$savedPos = peg$currPos; - s1 = peg$f436(); - if (s1) { - s1 = undefined; - } else { - s1 = peg$FAILED; - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseassign_stmt(); - if (s3 === peg$FAILED) { - s3 = peg$parsereturn_stmt(); - } - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f437(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseassign_stmt() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parsevar_decl(); - if (s1 === peg$FAILED) { - s1 = peg$parsewithout_prefix_var_decl(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_ASSIGN(); - if (s3 === peg$FAILED) { - s3 = peg$parseKW_ASSIGIN_EQUAL(); - } - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseproc_expr(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f438(s1, s3, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsereturn_stmt() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_RETURN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseproc_expr(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f439(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseproc_expr() { - var s0; - - s0 = peg$parseselect_stmt(); - if (s0 === peg$FAILED) { - s0 = peg$parseproc_join(); - if (s0 === peg$FAILED) { - s0 = peg$parseproc_additive_expr(); - if (s0 === peg$FAILED) { - s0 = peg$parseproc_array(); - } - } - } - - return s0; - } - - function peg$parseproc_additive_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseproc_multiplicative_expr(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseadditive_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseproc_multiplicative_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseadditive_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseproc_multiplicative_expr(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f440(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseproc_multiplicative_expr() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseproc_primary(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsemultiplicative_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseproc_primary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parsemultiplicative_operator(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseproc_primary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f441(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseproc_join() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsevar_decl(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsejoin_op(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parsevar_decl(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseon_clause(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f442(s1, s3, s5, s7); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseproc_primary() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$parseliteral(); - if (s0 === peg$FAILED) { - s0 = peg$parsevar_decl(); - if (s0 === peg$FAILED) { - s0 = peg$parseproc_func_call(); - if (s0 === peg$FAILED) { - s0 = peg$parseparam(); - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseLPAREN(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseproc_additive_expr(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRPAREN(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f443(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - } - } - - return s0; - } - - function peg$parseproc_func_name() { - var s0, s1, s2, s3, s4, s5, s6; - - s0 = peg$currPos; - s1 = peg$parseident_name(); - if (s1 !== peg$FAILED) { - s2 = peg$currPos; - s3 = peg$parse__(); - s4 = peg$parseDOT(); - if (s4 !== peg$FAILED) { - s5 = peg$parse__(); - s6 = peg$parseident_name(); - if (s6 !== peg$FAILED) { - s3 = [s3, s4, s5, s6]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - if (s2 === peg$FAILED) { - s2 = null; - } - peg$savedPos = s0; - s0 = peg$f444(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseproc_func_call() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseproc_func_name(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseproc_primary_list(); - if (s5 === peg$FAILED) { - s5 = null; - } - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f445(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseproc_func_name(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f446(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parseproc_primary_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseproc_primary(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseproc_primary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseproc_primary(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f447(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parseproc_array() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - s1 = peg$parseLBRAKE(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseproc_primary_list(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRBRAKE(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f448(s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsevar_decl_list() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parsevar_decl(); - if (s1 !== peg$FAILED) { - s2 = []; - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsevar_decl(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - while (s3 !== peg$FAILED) { - s2.push(s3); - s3 = peg$currPos; - s4 = peg$parse__(); - s5 = peg$parseCOMMA(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parsevar_decl(); - if (s7 !== peg$FAILED) { - s4 = [s4, s5, s6, s7]; - s3 = s4; - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } else { - peg$currPos = s3; - s3 = peg$FAILED; - } - } - peg$savedPos = s0; - s0 = peg$f449(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsevar_decl() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8; - - s0 = peg$currPos; - s1 = peg$parseKW_VAR_PRE_DOLLAR_DOUBLE(); - if (s1 !== peg$FAILED) { - s2 = []; - if (peg$r15.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e380); - } - } - while (s3 !== peg$FAILED) { - s2.push(s3); - if (peg$r15.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e380); - } - } - } - s3 = peg$parseKW_VAR_PRE_DOLLAR_DOUBLE(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f450(s1, s2, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_VAR_PRE_DOLLAR(); - if (s1 !== peg$FAILED) { - s2 = peg$parseident(); - if (s2 !== peg$FAILED) { - s3 = peg$parseKW_VAR_PRE_DOLLAR(); - if (s3 !== peg$FAILED) { - s4 = []; - if (peg$r15.test(input.charAt(peg$currPos))) { - s5 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e380); - } - } - while (s5 !== peg$FAILED) { - s4.push(s5); - if (peg$r15.test(input.charAt(peg$currPos))) { - s5 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e380); - } - } - } - s5 = peg$parseKW_VAR_PRE_DOLLAR(); - if (s5 !== peg$FAILED) { - s6 = peg$parseident(); - if (s6 !== peg$FAILED) { - peg$savedPos = peg$currPos; - s7 = peg$f451(s2, s4, s6); - if (s7) { - s7 = peg$FAILED; - } else { - s7 = undefined; - } - if (s7 !== peg$FAILED) { - s8 = peg$parseKW_VAR_PRE_DOLLAR(); - if (s8 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f452(s2, s4, s6); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_VAR_PRE(); - if (s1 !== peg$FAILED) { - s2 = peg$parsewithout_prefix_var_decl(); - if (s2 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f453(s1, s2); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - - return s0; - } - - function peg$parsewithout_prefix_var_decl() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 34) { - s1 = peg$c90; - peg$currPos++; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e90); - } - } - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parseident_name(); - if (s2 !== peg$FAILED) { - s3 = peg$parsemem_chain(); - if (input.charCodeAt(peg$currPos) === 34) { - s4 = peg$c90; - peg$currPos++; - } else { - s4 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e90); - } - } - if (s4 === peg$FAILED) { - s4 = null; - } - peg$savedPos = s0; - s0 = peg$f454(s1, s2, s3, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseliteral_numeric(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f455(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parsemem_chain() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = []; - s2 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 46) { - s3 = peg$c194; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e205); - } - } - if (s3 !== peg$FAILED) { - s4 = peg$parseident_name(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - while (s2 !== peg$FAILED) { - s1.push(s2); - s2 = peg$currPos; - if (input.charCodeAt(peg$currPos) === 46) { - s3 = peg$c194; - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e205); - } - } - if (s3 !== peg$FAILED) { - s4 = peg$parseident_name(); - if (s4 !== peg$FAILED) { - s3 = [s3, s4]; - s2 = s3; - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } else { - peg$currPos = s2; - s2 = peg$FAILED; - } - } - peg$savedPos = s0; - s1 = peg$f456(s1); - s0 = s1; - - return s0; - } - - function peg$parsedata_type() { - var s0; - - s0 = peg$parsearray_type(); - if (s0 === peg$FAILED) { - s0 = peg$parsecharacter_string_type(); - if (s0 === peg$FAILED) { - s0 = peg$parsenumeric_type(); - if (s0 === peg$FAILED) { - s0 = peg$parsedatetime_type(); - if (s0 === peg$FAILED) { - s0 = peg$parsejson_type(); - if (s0 === peg$FAILED) { - s0 = peg$parsegeometry_type(); - if (s0 === peg$FAILED) { - s0 = peg$parsetext_type(); - if (s0 === peg$FAILED) { - s0 = peg$parseuuid_type(); - if (s0 === peg$FAILED) { - s0 = peg$parseboolean_type(); - if (s0 === peg$FAILED) { - s0 = peg$parseenum_type(); - if (s0 === peg$FAILED) { - s0 = peg$parseserial_interval_type(); - if (s0 === peg$FAILED) { - s0 = peg$parsebinary_type(); - if (s0 === peg$FAILED) { - s0 = peg$parseoid_type(); - } - } - } - } - } - } - } - } - } - } - } - } - - return s0; - } - - function peg$parsearray_type() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parsenumeric_type(); - if (s1 === peg$FAILED) { - s1 = peg$parsecharacter_string_type(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLBRAKE(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRBRAKE(); - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseLBRAKE(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parseRBRAKE(); - if (s9 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f457(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parsenumeric_type(); - if (s1 === peg$FAILED) { - s1 = peg$parsecharacter_string_type(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLBRAKE(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = peg$parseRBRAKE(); - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f458(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parseboolean_type() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_BOOL(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_BOOLEAN(); - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f459(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsebinary_type() { - var s0, s1; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 5).toLowerCase() === peg$c363) { - s1 = input.substr(peg$currPos, 5); - peg$currPos += 5; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e381); - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f460(); - } - s0 = s1; - - return s0; - } - - function peg$parsecharacter_string_type() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_CHAR(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_VARCHAR(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = []; - if (peg$r10.test(input.charAt(peg$currPos))) { - s6 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e206); - } - } - if (s6 !== peg$FAILED) { - while (s6 !== peg$FAILED) { - s5.push(s6); - if (peg$r10.test(input.charAt(peg$currPos))) { - s6 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e206); - } - } - } - } else { - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f461(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_CHAR(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_CHARACTER(); - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f462(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_VARCHAR(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f463(s1); - } - s0 = s1; - } - } - - return s0; - } - - function peg$parsenumeric_type_suffix() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_UNSIGNED(); - if (s1 === peg$FAILED) { - s1 = null; - } - s2 = peg$parse__(); - s3 = peg$parseKW_ZEROFILL(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f464(s1, s3); - - return s0; - } - - function peg$parsenumeric_type() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9, s10, s11; - - s0 = peg$currPos; - s1 = peg$parseKW_NUMERIC(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DECIMAL(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_INT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_INTEGER(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_SMALLINT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_TINYINT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_BIGINT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_FLOAT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DOUBLE(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_SERIAL(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_BIGSERIAL(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_REAL(); - } - } - } - } - } - } - } - } - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = []; - if (peg$r10.test(input.charAt(peg$currPos))) { - s6 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e206); - } - } - if (s6 !== peg$FAILED) { - while (s6 !== peg$FAILED) { - s5.push(s6); - if (peg$r10.test(input.charAt(peg$currPos))) { - s6 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e206); - } - } - } - } else { - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$currPos; - s8 = peg$parseCOMMA(); - if (s8 !== peg$FAILED) { - s9 = peg$parse__(); - s10 = []; - if (peg$r10.test(input.charAt(peg$currPos))) { - s11 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s11 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e206); - } - } - if (s11 !== peg$FAILED) { - while (s11 !== peg$FAILED) { - s10.push(s11); - if (peg$r10.test(input.charAt(peg$currPos))) { - s11 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s11 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e206); - } - } - } - } else { - s10 = peg$FAILED; - } - if (s10 !== peg$FAILED) { - s8 = [s8, s9, s10]; - s7 = s8; - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - } else { - peg$currPos = s7; - s7 = peg$FAILED; - } - if (s7 === peg$FAILED) { - s7 = null; - } - s8 = peg$parse__(); - s9 = peg$parseRPAREN(); - if (s9 !== peg$FAILED) { - s10 = peg$parse__(); - s11 = peg$parsenumeric_type_suffix(); - peg$savedPos = s0; - s0 = peg$f465(s1, s5, s7, s11); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_NUMERIC(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DECIMAL(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_INT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_INTEGER(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_SMALLINT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_TINYINT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_BIGINT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_FLOAT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DOUBLE(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_SERIAL(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_BIGSERIAL(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_REAL(); - } - } - } - } - } - } - } - } - } - } - } - if (s1 !== peg$FAILED) { - s2 = []; - if (peg$r10.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e206); - } - } - if (s3 !== peg$FAILED) { - while (s3 !== peg$FAILED) { - s2.push(s3); - if (peg$r10.test(input.charAt(peg$currPos))) { - s3 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s3 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e206); - } - } - } - } else { - s2 = peg$FAILED; - } - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parsenumeric_type_suffix(); - peg$savedPos = s0; - s0 = peg$f466(s1, s2, s4); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_NUMERIC(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DECIMAL(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_INT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_INTEGER(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_SMALLINT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_TINYINT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_BIGINT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_FLOAT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DOUBLE(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_SERIAL(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_BIGSERIAL(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_REAL(); - } - } - } - } - } - } - } - } - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsenumeric_type_suffix(); - s4 = peg$parse__(); - peg$savedPos = s0; - s0 = peg$f467(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - } - - return s0; - } - - function peg$parseoid_type() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_OID(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_REGCLASS(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_REGCOLLATION(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_REGCONFIG(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_REGDICTIONARY(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_REGNAMESPACE(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_REGOPER(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_REGOPERATOR(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_REGPROC(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_REGPROCEDURE(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_REGROLE(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_REGTYPE(); - } - } - } - } - } - } - } - } - } - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f468(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsetimezone() { - var s0, s1, s2, s3, s4, s5; - - s0 = peg$currPos; - if (input.substr(peg$currPos, 7).toLowerCase() === peg$c364) { - s1 = input.substr(peg$currPos, 7); - peg$currPos += 7; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e382); - } - } - if (s1 === peg$FAILED) { - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c97) { - s1 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s1 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e97); - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseKW_TIME(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - if (input.substr(peg$currPos, 4).toLowerCase() === peg$c158) { - s5 = input.substr(peg$currPos, 4); - peg$currPos += 4; - } else { - s5 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e383); - } - } - if (s5 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f469(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsetime_type() { - var s0, s1, s2, s3, s4, s5, s6, s7, s8, s9; - - s0 = peg$currPos; - s1 = peg$parseKW_TIME(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_TIMESTAMP(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = []; - if (peg$r10.test(input.charAt(peg$currPos))) { - s6 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e206); - } - } - if (s6 !== peg$FAILED) { - while (s6 !== peg$FAILED) { - s5.push(s6); - if (peg$r10.test(input.charAt(peg$currPos))) { - s6 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e206); - } - } - } - } else { - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - s8 = peg$parse__(); - s9 = peg$parsetimezone(); - if (s9 === peg$FAILED) { - s9 = null; - } - peg$savedPos = s0; - s0 = peg$f470(s1, s5, s9); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_TIME(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_TIMESTAMP(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsetimezone(); - if (s3 === peg$FAILED) { - s3 = null; - } - peg$savedPos = s0; - s0 = peg$f471(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } - - return s0; - } - - function peg$parsedatetime_type() { - var s0, s1, s2, s3, s4, s5, s6, s7; - - s0 = peg$currPos; - s1 = peg$parseKW_DATE(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DATETIME(); - } - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parseLPAREN(); - if (s3 !== peg$FAILED) { - s4 = peg$parse__(); - s5 = []; - if (peg$r10.test(input.charAt(peg$currPos))) { - s6 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e206); - } - } - if (s6 !== peg$FAILED) { - while (s6 !== peg$FAILED) { - s5.push(s6); - if (peg$r10.test(input.charAt(peg$currPos))) { - s6 = input.charAt(peg$currPos); - peg$currPos++; - } else { - s6 = peg$FAILED; - if (peg$silentFails === 0) { - peg$fail(peg$e206); - } - } - } - } else { - s5 = peg$FAILED; - } - if (s5 !== peg$FAILED) { - s6 = peg$parse__(); - s7 = peg$parseRPAREN(); - if (s7 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f472(s1, s5); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_DATE(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_DATETIME(); - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f473(s1); - } - s0 = s1; - if (s0 === peg$FAILED) { - s0 = peg$parsetime_type(); - } - } - - return s0; - } - - function peg$parseenum_type() { - var s0, s1, s2, s3; - - s0 = peg$currPos; - s1 = peg$parseKW_ENUM(); - if (s1 !== peg$FAILED) { - s2 = peg$parse__(); - s3 = peg$parsevalue_item(); - if (s3 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f474(s1, s3); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - - return s0; - } - - function peg$parsejson_type() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_JSON(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_JSONB(); - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f475(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsegeometry_type() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_GEOMETRY(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f476(s1); - } - s0 = s1; - - return s0; - } - - function peg$parseserial_interval_type() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_SERIAL(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_INTERVAL(); - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f477(s1); - } - s0 = s1; - - return s0; - } - - function peg$parsetext_type() { - var s0, s1, s2, s3, s4; - - s0 = peg$currPos; - s1 = peg$parseKW_TINYTEXT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_TEXT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_MEDIUMTEXT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_LONGTEXT(); - } - } - } - if (s1 !== peg$FAILED) { - s2 = peg$parseLBRAKE(); - if (s2 !== peg$FAILED) { - s3 = peg$parse__(); - s4 = peg$parseRBRAKE(); - if (s4 !== peg$FAILED) { - peg$savedPos = s0; - s0 = peg$f478(s1); - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - } else { - peg$currPos = s0; - s0 = peg$FAILED; - } - if (s0 === peg$FAILED) { - s0 = peg$currPos; - s1 = peg$parseKW_TINYTEXT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_TEXT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_MEDIUMTEXT(); - if (s1 === peg$FAILED) { - s1 = peg$parseKW_LONGTEXT(); - } - } - } - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f479(s1); - } - s0 = s1; - } - - return s0; - } - - function peg$parseuuid_type() { - var s0, s1; - - s0 = peg$currPos; - s1 = peg$parseKW_UUID(); - if (s1 !== peg$FAILED) { - peg$savedPos = s0; - s1 = peg$f480(s1); - } - s0 = s1; - - return s0; - } - - const reservedMap = { - ALTER: true, - ALL: true, - ADD: true, - AND: true, - AS: true, - ASC: true, - - BETWEEN: true, - BY: true, - - CALL: true, - CASE: true, - CREATE: true, - CONTAINS: true, - CURRENT_DATE: true, - CURRENT_TIME: true, - CURRENT_TIMESTAMP: true, - CURRENT_USER: true, - - DELETE: true, - DESC: true, - DISTINCT: true, - DROP: true, - - ELSE: true, - END: true, - EXISTS: true, - EXPLAIN: true, - - FALSE: true, - FROM: true, - FULL: true, - - GROUP: true, - - HAVING: true, - - IN: true, - INNER: true, - INSERT: true, - INTO: true, - IS: true, - - JOIN: true, - JSON: true, - - // 'KEY': true, - - LEFT: true, - LIKE: true, - LIMIT: true, - - NOT: true, - NULL: true, - NULLS: true, - - OFFSET: true, - ON: true, - OR: true, - ORDER: true, - OUTER: true, - - RECURSIVE: true, - RENAME: true, - // 'REPLACE': true, - RIGHT: true, - - SELECT: true, - SESSION_USER: true, - SET: true, - SHOW: true, - SYSTEM_USER: true, - - TABLE: true, - THEN: true, - TRUE: true, - TRUNCATE: true, - - UNION: true, - UPDATE: true, - USING: true, - - // 'VALUES': true, - - WITH: true, - WHEN: true, - WHERE: true, - WINDOW: true, - - GLOBAL: true, - SESSION: true, - LOCAL: true, - PERSIST: true, - PERSIST_ONLY: true, - }; - - function createUnaryExpr(op, e) { - return { - type: 'unary_expr', - operator: op, - expr: e, - }; - } - - function createBinaryExpr(op, left, right) { - return { - type: 'binary_expr', - operator: op, - left: left, - right: right, - }; - } - - function isBigInt(numberStr) { - const previousMaxSafe = BigInt(Number.MAX_SAFE_INTEGER); - const num = BigInt(numberStr); - if (num < previousMaxSafe) return false; - return true; - } - - function createList(head, tail, po = 3) { - const result = [head]; - for (let i = 0; i < tail.length; i++) { - delete tail[i][po].tableList; - delete tail[i][po].columnList; - result.push(tail[i][po]); - } - return result; - } - - function createBinaryExprChain(head, tail) { - let result = head; - for (let i = 0; i < tail.length; i++) { - result = createBinaryExpr(tail[i][1], result, tail[i][3]); - } - return result; - } - - function queryTableAlias(tableName) { - const alias = tableAlias[tableName]; - if (alias) return alias; - if (tableName) return tableName; - return null; - } - - function columnListTableAlias(columnList) { - const newColumnsList = new Set(); - const symbolChar = '::'; - for (let column of columnList.keys()) { - const columnInfo = column.split(symbolChar); - if (!columnInfo) { - newColumnsList.add(column); - break; - } - if (columnInfo && columnInfo[1]) columnInfo[1] = queryTableAlias(columnInfo[1]); - newColumnsList.add(columnInfo.join(symbolChar)); - } - return Array.from(newColumnsList); - } - - function refreshColumnList(columnList) { - const columns = columnListTableAlias(columnList); - columnList.clear(); - columns.forEach((col) => columnList.add(col)); - } - - function commonStrToLiteral(strOrLiteral) { - return typeof strOrLiteral === 'string' ? { type: 'same', value: strOrLiteral } : strOrLiteral; - } - - const cmpPrefixMap = { - '+': true, - '-': true, - '*': true, - '/': true, - '>': true, - '<': true, - '!': true, - '=': true, - - //between - B: true, - b: true, - //for is or in - I: true, - i: true, - //for like - L: true, - l: true, - //for not - N: true, - n: true, - }; - - // used for dependency analysis - let varList = []; - - const tableList = new Set(); - const columnList = new Set(); - const tableAlias = {}; - - peg$result = peg$startRuleFunction(); - - if (peg$result !== peg$FAILED && peg$currPos === input.length) { - return peg$result; - } else { - if (peg$result !== peg$FAILED && peg$currPos < input.length) { - peg$fail(peg$endExpectation()); - } - - throw peg$buildStructuredError( - peg$maxFailExpected, - peg$maxFailPos < input.length ? input.charAt(peg$maxFailPos) : null, - peg$maxFailPos < input.length - ? peg$computeLocation(peg$maxFailPos, peg$maxFailPos + 1) - : peg$computeLocation(peg$maxFailPos, peg$maxFailPos), - ); - } -} - -module.exports = { - SyntaxError: peg$SyntaxError, - parse: peg$parse, -}; diff --git a/packages/core/database/src/sql-parser/readme.md b/packages/core/database/src/sql-parser/readme.md deleted file mode 100644 index 14f4c2b812..0000000000 --- a/packages/core/database/src/sql-parser/readme.md +++ /dev/null @@ -1,2 +0,0 @@ -use peggy to transform pegjs to sql parser -https://github.com/peggyjs/peggy diff --git a/packages/core/database/src/sql-parser/sql.pegjs b/packages/core/database/src/sql-parser/sql.pegjs deleted file mode 100644 index 22a45a4bca..0000000000 --- a/packages/core/database/src/sql-parser/sql.pegjs +++ /dev/null @@ -1,1297 +0,0 @@ -{ - const reservedMap = { - 'ALL': true, - 'AND': true, - 'AS': true, - 'ASC': true, - - 'BETWEEN': true, - 'BY': true, - - 'CASE': true, - 'CREATE': true, - 'CONTAINS': true, - 'CURRENT_DATE': true, - 'CURRENT_TIME': true, - 'CURRENT_TIMESTAMP': true, - 'CURRENT_USER': true, - - 'DELETE': true, - 'DESC': true, - 'DISTINCT': true, - 'DROP': true, - - 'ELSE': true, - 'END': true, - 'EXISTS': true, - 'EXPLAIN': true, - - 'FALSE': true, - 'FROM': true, - 'FULL': true, - - 'GROUP': true, - - 'HAVING': true, - - 'IN': true, - 'INDEX': true, - 'INNER': true, - 'INSERT': true, - 'INTO': true, - 'IS': true, - - 'JOIN': true, - 'JSON': true, - - 'LEFT': true, - 'LIKE': true, - 'LIMIT': true, - - 'NOT': true, - 'NULL': true, - - 'ON': true, - 'OR': true, - 'ORDER': true, - 'OUTER': true, - - 'RECURSIVE': true, - 'REPLACE': true, - 'RIGHT': true, - - 'SELECT': true, - 'SESSION_USER': true, - 'SET': true, - 'SHOW': true, - 'STATUS': true, // reserved (MySQL) - 'SYSTEM_USER': true, - - 'TABLE': true, - 'THEN': true, - 'TRUE': true, - 'TYPE': true, // reserved (MySQL) - - 'UNION': true, - 'UPDATE': true, - 'USER': true, - 'USING': true, - - 'VALUES': true, - - 'WITH': true, - 'WHEN': true, - 'WHERE': true - }; - - function createUnaryExpr(op, e) { - return { - type: 'unary_expr', - operator: op, - expr: e - }; - } - - function createBinaryExpr(op, left, right) { - return { - type: 'binary_expr', - operator: op, - left: left, - right: right - }; - } - - function createList(head, tail) { - const result = [head]; - for (let i = 0; i < tail.length; i++) { - result.push(tail[i][3]); - } - return result; - } - - function createBinaryExprChain(head, tail) { - let result = head; - for (let i = 0; i < tail.length; i++) { - result = createBinaryExpr(tail[i][1], result, tail[i][3]); - } - return result; - } - - const cmpPrefixMap = { - '+': true, - '-': true, - '*': true, - '/': true, - '>': true, - '<': true, - '!': true, - '=': true, - - //between - 'B': true, - 'b': true, - //for is or in - 'I': true, - 'i': true, - //for like - 'L': true, - 'l': true, - //for not - 'N': true, - 'n': true - }; - - // used for dependency analysis - let varList = []; - - const tableList = new Set(); - const columnList = new Set(); -} - -start - = multiple_stmt - / crud_stmt - -crud_stmt - = union_stmt - / update_stmt - / replace_insert_stmt - / insert_no_columns_stmt - / delete_stmt - / proc_stmts - -multiple_stmt - = head:crud_stmt tail:(__ SEMICOLON __ crud_stmt)+ { - const cur = [head && head.ast || head]; - for (let i = 0; i < tail.length; i++) { - if(!tail[i][3] || tail[i][3].length === 0) continue; - cur.push(tail[i][3] && tail[i][3].ast || tail[i][3]); - } - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: cur - } - } - -union_stmt - = head:select_stmt tail:(__ KW_UNION __ select_stmt)* { - let cur = head; - for (let i = 0; i < tail.length; i++) { - cur._next = tail[i][3]; - cur = cur._next - } - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: head - } - } - -select_stmt - = select_stmt_nake - / s:('(' __ select_stmt __ ')') { - return s[2]; - } - -with_clause - = KW_WITH __ head:cte_definition tail:(__ COMMA __ cte_definition)* { - return createList(head, tail); - } - / __ KW_WITH __ KW_RECURSIVE __ cte:cte_definition { - cte.recursive = true; - return [cte] - } - -cte_definition - = name:ident_name __ columns:cte_column_definition? __ KW_AS __ LPAREN __ stmt:union_stmt __ RPAREN { - return { name, stmt, columns }; - } - -cte_column_definition - = LPAREN __ head:column tail:(__ COMMA __ column)* __ RPAREN { - return createList(head, tail); - } - -select_stmt_nake - = cte:with_clause? __ KW_SELECT __ - opts:option_clause? __ - d:KW_DISTINCT? __ - c:column_clause __ - f:from_clause? __ - w:where_clause? __ - g:group_by_clause? __ - h:having_clause? __ - o:order_by_clause? __ - l:limit_clause? { - if(f) f.forEach(info => info.table && tableList.add(`select::${info.db}::${info.table}`)); - return { - with: cte, - type: 'select', - options: opts, - distinct: d, - columns: c, - from: f, - where: w, - groupby: g, - having: h, - orderby: o, - limit: l - }; - } - -// MySQL extensions to standard SQL -option_clause - = head:query_option tail:(__ query_option)* { - const opts = [head]; - for (let i = 0, l = tail.length; i < l; ++i) { - opts.push(tail[i][1]); - } - return opts; - } - -query_option - = option:( - OPT_SQL_CALC_FOUND_ROWS - / (OPT_SQL_CACHE / OPT_SQL_NO_CACHE) - / OPT_SQL_BIG_RESULT - / OPT_SQL_SMALL_RESULT - / OPT_SQL_BUFFER_RESULT - ) { return option; } - -column_clause - = (KW_ALL / (STAR !ident_start) / STAR) { - columnList.add('select::null::(.*)'); - return '*'; - } - / head:column_list_item tail:(__ COMMA __ column_list_item)* { - return createList(head, tail); - } - -column_list_item - = tbl:ident __ DOT __ STAR { - columnList.add(`select::${tbl}::(.*)`); - return { - expr: { - type: 'column_ref', - table: tbl, - column: '*' - }, - as: null - }; - } - / e:expr __ alias:alias_clause? { - return { expr: e, as: alias }; - } - -alias_clause - = KW_AS __ i:alias_ident { return i; } - / KW_AS? __ i:ident { return i; } - -from_clause - = KW_FROM __ l:table_ref_list { return l; } - -table_ref_list - = head:table_base - tail:table_ref* { - tail.unshift(head); - return tail; - } - -table_ref - = __ COMMA __ t:table_base { return t; } - / __ t:table_join { return t; } - - -table_join - = op:join_op __ t:table_base __ KW_USING __ LPAREN __ head:ident_name tail:(__ COMMA __ ident_name)* __ RPAREN { - t.join = op; - t.using = createList(head, tail); - return t; - } - / op:join_op __ t:table_base __ expr:on_clause? { - t.join = op; - t.on = expr; - return t; - } - / op:join_op __ LPAREN __ stmt:union_stmt __ RPAREN __ alias:alias_clause? __ expr:on_clause? { - stmt.parentheses = true; - return { - expr: stmt, - as: alias, - join: op, - on: expr - }; - } - -//NOTE that, the table assigned to `var` shouldn't write in `table_join` -table_base - = KW_DUAL { - return { - type: 'dual' - }; - } - / t:table_name __ alias:alias_clause? { - if (t.type === 'var') { - t.as = alias; - return t; - } else { - return { - db: t.db, - table: t.table, - as: alias - }; - } - } - / LPAREN __ stmt:union_stmt __ RPAREN __ alias:alias_clause? { - stmt.parentheses = true; - return { - expr: stmt, - as: alias - }; - } - -join_op - = KW_LEFT __ KW_OUTER? __ KW_JOIN { return 'LEFT JOIN'; } - / KW_RIGHT __ KW_OUTER? __ KW_JOIN { return 'RIGHT JOIN'; } - / KW_FULL __ KW_OUTER? __ KW_JOIN { return 'FULL JOIN'; } - / (KW_INNER __)? KW_JOIN { return 'INNER JOIN'; } - -table_name - = dt:ident tail:(__ DOT __ ident)? { - const obj = { db: null, table: dt }; - if (tail !== null) { - obj.db = dt; - obj.table = tail[3]; - } - return obj; - } - / v:var_decl { - v.db = null; - v.table = v.name; - return v; - } - -on_clause - = KW_ON __ e:expr { return e; } - -where_clause - = KW_WHERE __ e:expr { return e; } - -group_by_clause - = KW_GROUP __ KW_BY __ l:column_ref_list { return l; } - -column_ref_list - = head:column_ref tail:(__ COMMA __ column_ref)* { - return createList(head, tail); - } - -having_clause - = KW_HAVING __ e:expr { return e; } - -order_by_clause - = KW_ORDER __ KW_BY __ l:order_by_list { return l; } - -order_by_list - = head:order_by_element tail:(__ COMMA __ order_by_element)* { - return createList(head, tail); - } - -order_by_element - = e:expr __ d:(KW_DESC / KW_ASC)? { - const obj = { expr: e, type: 'ASC' }; - if (d === 'DESC') obj.type = 'DESC'; - return obj; - } - -number_or_param - = literal_numeric - / param - -limit_clause - = KW_LIMIT __ i1:(number_or_param) __ tail:(COMMA __ number_or_param)? { - const res = [i1]; - if (tail === null) res.unshift({ type: 'number', value: 0 }); - else res.push(tail[2]); - return res; - } - -update_stmt - = KW_UPDATE __ - t:table_name __ - KW_SET __ - l:set_list __ - w:where_clause? { - if(t.table) tableList.add(`update::${t.db}::${t.table}`); - if(l) l.forEach(col => columnList.add(`update::${t.table}::${col.column}`)); - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: { - type: 'update', - db: t.db, - table: t.table, - set: l, - where: w - } - }; - } - -delete_stmt - = KW_DELETE __ - t: table_ref_list? __ - f:from_clause __ - w:where_clause? { - if(f) f.forEach(info => { - info.table && tableList.add(`delete::${info.db}::${info.table}`); - columnList.add(`delete::${info.table}::(.*)`); - }); - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: { - type: 'delete', - tables: t, - from: f, - where: w - } - }; - } -set_list - = head:set_item tail:(__ COMMA __ set_item)* { - return createList(head, tail); - } - -/** - * here only use `additive_expr` to support 'col1 = col1+2' - * if you want to use lower operator, please use '()' like below - * 'col1 = (col2 > 3)' - */ -set_item - = tbl:(ident __ DOT)? __ c:column_name __ '=' __ v:additive_expr { - return { column: c, value: v, table: tbl && tbl[0] }; - } - -replace_insert_stmt - = ri:replace_insert __ - KW_INTO __ - t:table_name __ LPAREN __ - c:column_list __ RPAREN __ - v:value_clause { - if (t.table) tableList.add(`insert::${t.db}::${t.table}`); - if (c) c.forEach(c => columnList.add(`insert::${t.table}::${c}`)); - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: { - type: ri, - db: t.db, - table: t.table, - columns: c, - values: v - } - }; - } - -insert_no_columns_stmt - = ri:replace_insert __ - KW_INTO __ - t:table_name __ - v:value_clause { - if (t.table) tableList.add(`insert::${t.db}::${t.table}`); - columnList.add(`insert::${t.table}::(.*)`); - return { - tableList: Array.from(tableList), - columnList: Array.from(columnList), - ast: { - type: ri, - db: t.db, - table: t.table, - columns: null, - values: v - } - }; - } - -replace_insert - = KW_INSERT { return 'insert'; } - / KW_REPLACE { return 'replace'; } - -value_clause - = KW_VALUES __ l:value_list { return l; } - -value_list - = head:value_item tail:(__ COMMA __ value_item)* { - return createList(head, tail); - } - -value_item - = LPAREN __ l:expr_list __ RPAREN { - return l; - } - -expr_list - = head:expr tail:(__ COMMA __ expr)* { - const el = { type: 'expr_list' }; - el.value = createList(head, tail); - return el; - } - -interval_expr - = KW_INTERVAL __ - n:number __ - u: interval_unit { - return { - type: 'interval', - value: [n, u] - } - } - -case_expr - = KW_CASE __ - expr:expr? __ - condition_list:case_when_then+ __ - otherwise:case_else? __ - KW_END __ KW_CASE? { - if (otherwise) condition_list.push(otherwise); - return { - type: 'case', - expr: expr || null, - args: condition_list - }; - } - -case_when_then - = KW_WHEN __ condition:expr __ KW_THEN __ result:expr __ { - return { - type: 'when', - cond: condition, - result: result - }; - } - -case_else = KW_ELSE __ result:expr { - return { type: 'else', result: result }; - } - -/** - * Borrowed from PL/SQL ,the priority of below list IS ORDER BY DESC - * --------------------------------------------------------------------------------------------------- - * | +, - | identity, negation | - * | *, / | multiplication, division | - * | +, - | addition, subtraction, concatenation | - * | =, <, >, <=, >=, <>, !=, IS, LIKE, BETWEEN, IN | comparion | - * | !, NOT | logical negation | - * | AND | conjunction | - * | OR | inclusion | - * --------------------------------------------------------------------------------------------------- - */ - -expr - = or_expr - / select_stmt - -or_expr - = head:and_expr tail:(__ KW_OR __ and_expr)* { - return createBinaryExprChain(head, tail); - } - -and_expr - = head:not_expr tail:(__ KW_AND __ not_expr)* { - return createBinaryExprChain(head, tail); - } - -//here we should use `NOT` instead of `comparision_expr` to support chain-expr -not_expr - = comparison_expr - / exists_expr - / (KW_NOT / "!" !"=") __ expr:not_expr { - return createUnaryExpr('NOT', expr); - } - -comparison_expr - = left:additive_expr __ rh:comparison_op_right? { - if (rh === null) return left; - else if (rh.type === 'arithmetic') return createBinaryExprChain(left, rh.tail); - else return createBinaryExpr(rh.op, left, rh.right); - } - -exists_expr - = op:exists_op __ LPAREN __ stmt:union_stmt __ RPAREN { - stmt.parentheses = true; - return createUnaryExpr(op, stmt); - } - -exists_op - = nk:(KW_NOT __ KW_EXISTS) { return nk[0] + ' ' + nk[2]; } - / KW_EXISTS - -comparison_op_right - = arithmetic_op_right - / in_op_right - / between_op_right - / is_op_right - / like_op_right - -arithmetic_op_right - = l:(__ arithmetic_comparison_operator __ additive_expr)+ { - return { type: 'arithmetic', tail: l }; - } - -arithmetic_comparison_operator - = ">=" / ">" / "<=" / "<>" / "<" / "=" / "!=" - -is_op_right - = KW_IS __ right:additive_expr { - return { op: 'IS', right: right }; - } - / (KW_IS __ KW_NOT) __ right:additive_expr { - return { op: 'IS NOT', right: right }; - } - -between_op_right - = op:between_or_not_between_op __ begin:additive_expr __ KW_AND __ end:additive_expr { - return { - op: op, - right: { - type: 'expr_list', - value: [begin, end] - } - }; - } - -between_or_not_between_op - = nk:(KW_NOT __ KW_BETWEEN) { return nk[0] + ' ' + nk[2]; } - / KW_BETWEEN - -like_op - = nk:(KW_NOT __ KW_LIKE) { return nk[0] + ' ' + nk[2]; } - / KW_LIKE - -in_op - = nk:(KW_NOT __ KW_IN) { return nk[0] + ' ' + nk[2]; } - / KW_IN - -like_op_right - = op:like_op __ right:comparison_expr { - return { op: op, right: right }; - } - -in_op_right - = op:in_op __ LPAREN __ l:expr_list __ RPAREN { - return { op: op, right: l }; - } - / op:in_op __ e:var_decl { - return { op: op, right: e }; - } - -additive_expr - = head:multiplicative_expr - tail:(__ additive_operator __ multiplicative_expr)* { - return createBinaryExprChain(head, tail); - } - -additive_operator - = "+" / "-" - -multiplicative_expr - = head:primary - tail:(__ multiplicative_operator __ primary)* { - return createBinaryExprChain(head, tail) - } - -multiplicative_operator - = "*" / "/" / "%" - -primary - = literal - / cast_expr - / aggr_func - / func_call - / case_expr - / interval_expr - / column_ref - / param - / LPAREN __ e:expr __ RPAREN { - e.parentheses = true; - return e; - } - / LPAREN __ list:expr_list __ RPAREN { - list.parentheses = true; - return list; - } - / var_decl - -column_ref - = tbl:ident __ DOT __ col:column { - columnList.add(`select::${tbl}::${col}`); - return { - type: 'column_ref', - table: tbl, - column: col - }; - } - / col:column { - columnList.add(`select::null::${col}`); - return { - type: 'column_ref', - table: null, - column: col - }; - } - -column_list - = head:column tail:(__ COMMA __ column)* { - return createList(head, tail); - } - -ident - = name:ident_name !{ return reservedMap[name.toUpperCase()] === true; } { - return name; - } - / name:quoted_ident { - return name; - } - -alias_ident - = name:ident_name !{ - if (reservedMap[name.toUpperCase()] === true) throw new Error("Error: "+ JSON.stringify(name)+" is a reserved word, can not as alias clause"); - return false - } { - return name; - } - / name:quoted_ident { - return name; - } - -quoted_ident - = double_quoted_ident - / single_quoted_ident - / backticks_quoted_ident - -double_quoted_ident - = '"' chars:[^"]+ '"' { return chars.join(''); } - -single_quoted_ident - = "'" chars:[^']+ "'" { return chars.join(''); } - -backticks_quoted_ident - = "`" chars:[^`]+ "`" { return chars.join(''); } - -column - = name:column_name !{ return reservedMap[name.toUpperCase()] === true; } { return name; } - / quoted_ident - -column_name - = start:ident_start parts:column_part* { return start + parts.join(''); } - -ident_name - = start:ident_start parts:ident_part* { return start + parts.join(''); } - -ident_start = [A-Za-z_] - -ident_part = [A-Za-z0-9_] - -// to support column name like `cf1:name` in hbase -column_part = [A-Za-z0-9_:] - -param - = l:(':' ident_name) { - return { type: 'param', value: l[1] }; - } - -aggr_func - = aggr_fun_count - / aggr_fun_smma - -aggr_fun_smma - = name:KW_SUM_MAX_MIN_AVG __ LPAREN __ e:additive_expr __ RPAREN { - return { - type: 'aggr_func', - name: name, - args: { - expr: e - } - }; - } - -KW_SUM_MAX_MIN_AVG - = KW_SUM / KW_MAX / KW_MIN / KW_AVG - -aggr_fun_count - = name:KW_COUNT __ LPAREN __ arg:count_arg __ RPAREN { - return { - type: 'aggr_func', - name: name, - args: arg - }; - } - -count_arg - = e:star_expr { return { expr: e }; } - / d:KW_DISTINCT? __ c:column_ref { return { distinct: d, expr: c }; } - -star_expr - = "*" { return { type: 'star', value: '*' }; } - -func_call - = name:ident __ LPAREN __ l:expr_list? __ RPAREN { - return { - type: 'function', - name: name, - args: l ? l: { type: 'expr_list', value: [] } - }; - } - / name:scalar_func (__ LPAREN RPAREN __)? { - return { - type: 'function', - name: name, - args: { type: 'expr_list', value: [] } - }; - } - -scalar_func - = KW_CURRENT_DATE - / KW_CURRENT_TIME - / KW_CURRENT_TIMESTAMP - / KW_CURRENT_USER - / KW_USER - / KW_SESSION_USER - / KW_SYSTEM_USER - -cast_expr - = KW_CAST __ LPAREN __ e:expr __ KW_AS __ t:data_type __ RPAREN { - return { - type: 'cast', - expr: e, - target: t - }; - } - / KW_CAST __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ RPAREN __ RPAREN { - return { - type: 'cast', - expr: e, - target: { - dataType: 'DECIMAL(' + precision + ')' - } - }; - } - / KW_CAST __ LPAREN __ e:expr __ KW_AS __ KW_DECIMAL __ LPAREN __ precision:int __ COMMA __ scale:int __ RPAREN __ RPAREN { - return { - type: 'cast', - expr: e, - target: { - dataType: 'DECIMAL(' + precision + ', ' + scale + ')' - } - }; - } - / KW_CAST __ LPAREN __ e:expr __ KW_AS __ s:signedness __ t:KW_INTEGER? __ RPAREN { /* MySQL cast to un-/signed integer */ - return { - type: 'cast', - expr: e, - target: { - dataType: s + (t ? ' ' + t: '') - } - }; - } - -signedness - = KW_SIGNED - / KW_UNSIGNED - -literal - = literal_string - / literal_numeric - / literal_bool - / literal_null - / literal_datetime - -literal_list - = head:literal tail:(__ COMMA __ literal)* { - return createList(head, tail); - } - -literal_null - = KW_NULL { - return { type: 'null', value: null }; - } - -literal_bool - = KW_TRUE { - return { type: 'bool', value: true }; - } - / KW_FALSE { - return { type: 'bool', value: false }; - } - -literal_string - = ca:("'" single_char* "'") { - return { - type: 'string', - value: ca[1].join('') - }; - } - / ca:("\"" single_quote_char* "\"") { - return { - type: 'string', - value: ca[1].join('') - }; - } - -literal_datetime - = type:(KW_TIME / KW_DATE / KW_TIMESTAMP) __ ca:("'" single_char* "'") { - return { - type: type.toLowerCase(), - value: ca[1].join('') - }; - } - -single_quote_char - = [^"\\\0-\x1F\x7f] - / escape_char - -single_char - = [^'\\\0-\x1F\x7f] - / escape_char - -escape_char - = "\\'" { return "'"; } - / '\\"' { return '"'; } - / "\\\\" { return "\\"; } - / "\\/" { return "/"; } - / "\\b" { return "\b"; } - / "\\f" { return "\f"; } - / "\\n" { return "\n"; } - / "\\r" { return "\r"; } - / "\\t" { return "\t"; } - / "\\u" h1:hexDigit h2:hexDigit h3:hexDigit h4:hexDigit { - return String.fromCharCode(parseInt("0x" + h1 + h2 + h3 + h4)); - } - -line_terminator - = [\n\r] - -literal_numeric - = n:number { - return { type: 'number', value: n }; - } - -number - = int_:int frac:frac exp:exp __ { return parseFloat(int_ + frac + exp); } - / int_:int frac:frac __ { return parseFloat(int_ + frac); } - / int_:int exp:exp __ { return parseFloat(int_ + exp); } - / int_:int __ { return parseFloat(int_); } - -int - = digit19:digit19 digits:digits { return digit19 + digits; } - / digit:digit - / op:("-" / "+" ) digit19:digit19 digits:digits { return "-" + digit19 + digits; } - / op:("-" / "+" ) digit:digit { return "-" + digit; } - -frac - = "." digits:digits { return "." + digits; } - -exp - = e:e digits:digits { return e + digits; } - -digits - = digits:digit+ { return digits.join(""); } - -digit = [0-9] -digit19 = [1-9] - -hexDigit - = [0-9a-fA-F] - -e - = e:[eE] sign:[+-]? { return e + (sign !== null ? sign: ''); } - - -KW_NULL = "NULL"i !ident_start -KW_TRUE = "TRUE"i !ident_start -KW_FALSE = "FALSE"i !ident_start - -KW_SHOW = "SHOW"i !ident_start -KW_DROP = "DROP"i !ident_start -KW_SELECT = "SELECT"i !ident_start -KW_UPDATE = "UPDATE"i !ident_start -KW_CREATE = "CREATE"i !ident_start -KW_DELETE = "DELETE"i !ident_start -KW_INSERT = "INSERT"i !ident_start -KW_RECURSIVE= "RECURSIVE" !ident_start -KW_REPLACE = "REPLACE"i !ident_start -KW_EXPLAIN = "EXPLAIN"i !ident_start - -KW_INTO = "INTO"i !ident_start -KW_FROM = "FROM"i !ident_start -KW_SET = "SET"i !ident_start - -KW_AS = "AS"i !ident_start -KW_TABLE = "TABLE"i !ident_start - -KW_ON = "ON"i !ident_start -KW_LEFT = "LEFT"i !ident_start -KW_RIGHT = "RIGHT"i !ident_start -KW_FULL = "FULL"i !ident_start -KW_INNER = "INNER"i !ident_start -KW_JOIN = "JOIN"i !ident_start -KW_OUTER = "OUTER"i !ident_start -KW_UNION = "UNION"i !ident_start -KW_VALUES = "VALUES"i !ident_start -KW_USING = "USING"i !ident_start - -KW_WHERE = "WHERE"i !ident_start -KW_WITH = "WITH"i !ident_start - -KW_GROUP = "GROUP"i !ident_start -KW_BY = "BY"i !ident_start -KW_ORDER = "ORDER"i !ident_start -KW_HAVING = "HAVING"i !ident_start - -KW_LIMIT = "LIMIT"i !ident_start - -KW_ASC = "ASC"i !ident_start { return 'ASC'; } -KW_DESC = "DESC"i !ident_start { return 'DESC'; } - -KW_ALL = "ALL"i !ident_start { return 'ALL'; } -KW_DISTINCT = "DISTINCT"i !ident_start { return 'DISTINCT';} - -KW_BETWEEN = "BETWEEN"i !ident_start { return 'BETWEEN'; } -KW_IN = "IN"i !ident_start { return 'IN'; } -KW_IS = "IS"i !ident_start { return 'IS'; } -KW_LIKE = "LIKE"i !ident_start { return 'LIKE'; } -KW_EXISTS = "EXISTS"i !ident_start { return 'EXISTS'; } - -KW_NOT = "NOT"i !ident_start { return 'NOT'; } -KW_AND = "AND"i !ident_start { return 'AND'; } -KW_OR = "OR"i !ident_start { return 'OR'; } - -KW_COUNT = "COUNT"i !ident_start { return 'COUNT'; } -KW_MAX = "MAX"i !ident_start { return 'MAX'; } -KW_MIN = "MIN"i !ident_start { return 'MIN'; } -KW_SUM = "SUM"i !ident_start { return 'SUM'; } -KW_AVG = "AVG"i !ident_start { return 'AVG'; } - -KW_CASE = "CASE"i !ident_start -KW_WHEN = "WHEN"i !ident_start -KW_THEN = "THEN"i !ident_start -KW_ELSE = "ELSE"i !ident_start -KW_END = "END"i !ident_start - -KW_CAST = "CAST"i !ident_start - -KW_CHAR = "CHAR"i !ident_start { return 'CHAR'; } -KW_VARCHAR = "VARCHAR"i !ident_start { return 'VARCHAR';} -KW_NUMERIC = "NUMERIC"i !ident_start { return 'NUMERIC'; } -KW_DECIMAL = "DECIMAL"i !ident_start { return 'DECIMAL'; } -KW_SIGNED = "SIGNED"i !ident_start { return 'SIGNED'; } -KW_UNSIGNED = "UNSIGNED"i !ident_start { return 'UNSIGNED'; } -KW_INT = "INT"i !ident_start { return 'INT'; } -KW_INTEGER = "INTEGER"i !ident_start { return 'INTEGER'; } -KW_JSON = "JSON"i !ident_start { return 'JSON'; } -KW_SMALLINT = "SMALLINT"i !ident_start { return 'SMALLINT'; } -KW_DATE = "DATE"i !ident_start { return 'DATE'; } -KW_TIME = "TIME"i !ident_start { return 'TIME'; } -KW_TIMESTAMP= "TIMESTAMP"i!ident_start { return 'TIMESTAMP'; } -KW_USER = "USER"i !ident_start { return 'USER'; } - -KW_CURRENT_DATE = "CURRENT_DATE"i !ident_start { return 'CURRENT_DATE'; } -KW_ADD_DATE = "ADDDATE"i !ident_start { return 'ADDDATE'; } -KW_INTERVAL = "INTERVAL"i !ident_start { return 'INTERVAL'; } -KW_UNIT_YEAR = "YEAR"i !ident_start { return 'YEAR'; } -KW_UNIT_MONTH = "MONTH"i !ident_start { return 'MONTH'; } -KW_UNIT_DAY = "DAY"i !ident_start { return 'DAY'; } -KW_UNIT_HOUR = "HOUR"i !ident_start { return 'HOUR'; } -KW_UNIT_MINUTE = "MINUTE"i !ident_start { return 'MINUTE'; } -KW_UNIT_SECOND = "SECOND"i !ident_start { return 'SECOND'; } -KW_CURRENT_TIME = "CURRENT_TIME"i !ident_start { return 'CURRENT_TIME'; } -KW_CURRENT_TIMESTAMP= "CURRENT_TIMESTAMP"i !ident_start { return 'CURRENT_TIMESTAMP'; } -KW_CURRENT_USER = "CURRENT_USER"i !ident_start { return 'CURRENT_USER'; } -KW_SESSION_USER = "SESSION_USER"i !ident_start { return 'SESSION_USER'; } -KW_SYSTEM_USER = "SYSTEM_USER"i !ident_start { return 'SYSTEM_USER'; } - -KW_VAR_PRE = '$' -KW_RETURN = 'return'i -KW_ASSIGN = ':=' - -KW_DUAL = "DUAL"i - -// MySQL extensions to SQL -OPT_SQL_CALC_FOUND_ROWS = "SQL_CALC_FOUND_ROWS"i -OPT_SQL_CACHE = "SQL_CACHE"i -OPT_SQL_NO_CACHE = "SQL_NO_CACHE"i -OPT_SQL_SMALL_RESULT = "SQL_SMALL_RESULT"i -OPT_SQL_BIG_RESULT = "SQL_BIG_RESULT"i -OPT_SQL_BUFFER_RESULT = "SQL_BUFFER_RESULT"i - -//special character -DOT = '.' -COMMA = ',' -STAR = '*' -LPAREN = '(' -RPAREN = ')' - -LBRAKE = '[' -RBRAKE = ']' - -SEMICOLON = ';' - -// separator -__ - = (whitespace / comment)* - -comment - = block_comment - / line_comment - -block_comment - = "/*" (!"*/" char)* "*/" - -line_comment - = "--" (!EOL char)* - -char = . - -interval_unit - = KW_UNIT_YEAR - / KW_UNIT_MONTH - / KW_UNIT_DAY - / KW_UNIT_HOUR - / KW_UNIT_MINUTE - / KW_UNIT_SECOND - -whitespace = - [ \t\n\r] - -EOL - = EOF - / [\n\r]+ - -EOF = !. - -//begin procedure extension -proc_stmts - = proc_stmt* - -proc_stmt - = &{ varList = []; return true; } __ s:(assign_stmt / return_stmt) { - return { stmt: s, vars: varList }; - } - -assign_stmt - = va:var_decl __ KW_ASSIGN __ e:proc_expr { - return { - type: 'assign', - left: va, - right: e - }; - } - -return_stmt - = KW_RETURN __ e:proc_expr { - return { type: 'return', expr: e }; - } - -proc_expr - = select_stmt - / proc_join - / proc_additive_expr - / proc_array - -proc_additive_expr - = head:proc_multiplicative_expr - tail:(__ additive_operator __ proc_multiplicative_expr)* { - return createBinaryExprChain(head, tail); - } - -proc_multiplicative_expr - = head:proc_primary - tail:(__ multiplicative_operator __ proc_primary)* { - return createBinaryExprChain(head, tail); - } - -proc_join - = lt:var_decl __ op:join_op __ rt:var_decl __ expr:on_clause { - return { - type: 'join', - ltable: lt, - rtable: rt, - op: op, - on: expr - }; - } - -proc_primary - = literal - / var_decl - / proc_func_call - / param - / LPAREN __ e:proc_additive_expr __ RPAREN { - e.parentheses = true; - return e; - } - -proc_func_call - = name:ident __ LPAREN __ l:proc_primary_list __ RPAREN { - //compatible with original func_call - return { - type: 'function', - name: name, - args: { - type: 'expr_list', - value: l - } - }; - } - -proc_primary_list - = head:proc_primary tail:(__ COMMA __ proc_primary)* { - return createList(head, tail); - } - -proc_array = - LBRAKE __ l:proc_primary_list __ RBRAKE { - return { type: 'array', value: l }; - } - -var_decl - = KW_VAR_PRE name:ident_name m:mem_chain { - //push for analysis - varList.push(name); - return { - type: 'var', - name: name, - members: m - }; - } - -mem_chain - = l:('.' ident_name)* { - const s = []; - for (let i = 0; i < l.length; i++) { - s.push(l[i][1]); - } - return s; - } - -data_type - = character_string_type - / numeric_type - / datetime_type - / json_type - -character_string_type - = t:(KW_CHAR / KW_VARCHAR) __ LPAREN __ l:[0-9]+ __ RPAREN __ { - return { dataType: t, length: parseInt(l.join(''), 10) }; - } - / t:KW_CHAR { return { dataType: t }; } - / t:KW_VARCHAR { return { dataType: t }; } - -numeric_type - = t:(KW_NUMERIC / KW_DECIMAL / KW_INT / KW_INTEGER / KW_SMALLINT) { return { dataType: t }; } - -datetime_type - = t:(KW_DATE / KW_TIME / KW_TIMESTAMP) { return { dataType: t }; } - -json_type - = t:KW_JSON { return { dataType: t }; } diff --git a/packages/plugins/@nocobase/plugin-backup-restore/src/server/__tests__/index.ts b/packages/plugins/@nocobase/plugin-backup-restore/src/server/__tests__/index.ts index 29895b02b4..34990d8c7c 100644 --- a/packages/plugins/@nocobase/plugin-backup-restore/src/server/__tests__/index.ts +++ b/packages/plugins/@nocobase/plugin-backup-restore/src/server/__tests__/index.ts @@ -11,7 +11,7 @@ import { createMockServer } from '@nocobase/test'; export default async function createApp() { const app = await createMockServer({ - plugins: ['nocobase'], + plugins: ['nocobase', 'collection-sql'], }); return app; } diff --git a/packages/plugins/@nocobase/plugin-collection-sql/.npmignore b/packages/plugins/@nocobase/plugin-collection-sql/.npmignore new file mode 100644 index 0000000000..65f5e8779f --- /dev/null +++ b/packages/plugins/@nocobase/plugin-collection-sql/.npmignore @@ -0,0 +1,2 @@ +/node_modules +/src diff --git a/packages/plugins/@nocobase/plugin-collection-sql/README.md b/packages/plugins/@nocobase/plugin-collection-sql/README.md new file mode 100644 index 0000000000..2c8f2016c0 --- /dev/null +++ b/packages/plugins/@nocobase/plugin-collection-sql/README.md @@ -0,0 +1 @@ +# @nocobase/plugin-collection-sql diff --git a/packages/plugins/@nocobase/plugin-collection-sql/client.d.ts b/packages/plugins/@nocobase/plugin-collection-sql/client.d.ts new file mode 100644 index 0000000000..6c459cbac4 --- /dev/null +++ b/packages/plugins/@nocobase/plugin-collection-sql/client.d.ts @@ -0,0 +1,2 @@ +export * from './dist/client'; +export { default } from './dist/client'; diff --git a/packages/plugins/@nocobase/plugin-collection-sql/client.js b/packages/plugins/@nocobase/plugin-collection-sql/client.js new file mode 100644 index 0000000000..b6e3be70e6 --- /dev/null +++ b/packages/plugins/@nocobase/plugin-collection-sql/client.js @@ -0,0 +1 @@ +module.exports = require('./dist/client/index.js'); diff --git a/packages/plugins/@nocobase/plugin-collection-sql/package.json b/packages/plugins/@nocobase/plugin-collection-sql/package.json new file mode 100644 index 0000000000..e0baa5fcd1 --- /dev/null +++ b/packages/plugins/@nocobase/plugin-collection-sql/package.json @@ -0,0 +1,21 @@ +{ + "name": "@nocobase/plugin-collection-sql", + "displayName": "Collection: SQL", + "displayName.zh-CN": "数据表: SQL", + "description": "Provides SQL collection template", + "description.zh-CN": "提供 SQL 数据表模板", + "version": "1.0.0-alpha.14", + "homepage": "https://docs-cn.nocobase.com/handbook/collection-sql", + "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/collection-sql", + "main": "dist/server/index.js", + "license": "AGPL-3.0", + "dependencies": {}, + "peerDependencies": { + "@nocobase/client": "0.x", + "@nocobase/server": "0.x", + "@nocobase/test": "0.x" + }, + "keywords": [ + "Collections" + ] +} diff --git a/packages/plugins/@nocobase/plugin-collection-sql/server.d.ts b/packages/plugins/@nocobase/plugin-collection-sql/server.d.ts new file mode 100644 index 0000000000..c41081ddc6 --- /dev/null +++ b/packages/plugins/@nocobase/plugin-collection-sql/server.d.ts @@ -0,0 +1,2 @@ +export * from './dist/server'; +export { default } from './dist/server'; diff --git a/packages/plugins/@nocobase/plugin-collection-sql/server.js b/packages/plugins/@nocobase/plugin-collection-sql/server.js new file mode 100644 index 0000000000..972842039a --- /dev/null +++ b/packages/plugins/@nocobase/plugin-collection-sql/server.js @@ -0,0 +1 @@ +module.exports = require('./dist/server/index.js'); diff --git a/packages/plugins/@nocobase/plugin-collection-sql/src/client/index.tsx b/packages/plugins/@nocobase/plugin-collection-sql/src/client/index.tsx new file mode 100644 index 0000000000..b01c1e30d1 --- /dev/null +++ b/packages/plugins/@nocobase/plugin-collection-sql/src/client/index.tsx @@ -0,0 +1,21 @@ +import { Plugin } from '@nocobase/client'; + +export class PluginCollectionSqlClient extends Plugin { + async afterAdd() { + // await this.app.pm.add() + } + + async beforeLoad() {} + + // You can get and modify the app instance here + async load() { + console.log(this.app); + // this.app.addComponents({}) + // this.app.addScopes({}) + // this.app.addProvider() + // this.app.addProviders() + // this.app.router.add() + } +} + +export default PluginCollectionSqlClient; diff --git a/packages/plugins/@nocobase/plugin-collection-sql/src/index.ts b/packages/plugins/@nocobase/plugin-collection-sql/src/index.ts new file mode 100644 index 0000000000..7e74612df8 --- /dev/null +++ b/packages/plugins/@nocobase/plugin-collection-sql/src/index.ts @@ -0,0 +1,2 @@ +export * from './server'; +export { default } from './server'; diff --git a/packages/plugins/@nocobase/plugin-data-source-main/src/server/__tests__/sql/sql-collection.test.ts b/packages/plugins/@nocobase/plugin-collection-sql/src/server/__tests__/actions.test.ts similarity index 97% rename from packages/plugins/@nocobase/plugin-data-source-main/src/server/__tests__/sql/sql-collection.test.ts rename to packages/plugins/@nocobase/plugin-collection-sql/src/server/__tests__/actions.test.ts index 61a0f746f9..0685eae2ce 100644 --- a/packages/plugins/@nocobase/plugin-data-source-main/src/server/__tests__/sql/sql-collection.test.ts +++ b/packages/plugins/@nocobase/plugin-collection-sql/src/server/__tests__/actions.test.ts @@ -7,7 +7,8 @@ * For more information, please refer to: https://www.nocobase.com/agreement. */ -import { Database, SQLModel } from '@nocobase/database'; +import { Database } from '@nocobase/database'; +import { SQLModel } from '../sql-collection'; import { MockServer, createMockServer } from '@nocobase/test'; describe('sql collection', () => { @@ -17,7 +18,7 @@ describe('sql collection', () => { beforeEach(async () => { app = await createMockServer({ - plugins: ['data-source-main', 'error-handler'], + plugins: ['data-source-main', 'error-handler', 'collection-sql'], }); db = app.db; db.options.underscored = false; diff --git a/packages/core/database/src/__tests__/sql-collection/infer-fields.test.ts b/packages/plugins/@nocobase/plugin-collection-sql/src/server/__tests__/infer-fields.test.ts similarity index 87% rename from packages/core/database/src/__tests__/sql-collection/infer-fields.test.ts rename to packages/plugins/@nocobase/plugin-collection-sql/src/server/__tests__/infer-fields.test.ts index e67b033296..5bb99776d7 100644 --- a/packages/core/database/src/__tests__/sql-collection/infer-fields.test.ts +++ b/packages/plugins/@nocobase/plugin-collection-sql/src/server/__tests__/infer-fields.test.ts @@ -7,9 +7,8 @@ * For more information, please refer to: https://www.nocobase.com/agreement. */ -import Database from '../../database'; -import { mockDatabase } from '../../mock-database'; -import { SQLModel } from '../../sql-collection/sql-model'; +import { Database, mockDatabase } from '@nocobase/database'; +import { SQLModel } from '../sql-collection'; describe('infer fields', () => { let db: Database; @@ -103,4 +102,18 @@ left join roles r on ru.role_name=r.name`; name: { type: 'string', source: 'roles.name' }, }); }); + + it('should infer fields for without collection', async () => { + const model = class extends SQLModel {}; + model.init(null, { + modelName: 'test', + tableName: 'test', + sequelize: db.sequelize, + }); + model.database = db; + model.sql = `select a from a3`; + expect(model.inferFields()).toMatchObject({ + a: {}, + }); + }); }); diff --git a/packages/core/database/src/__tests__/sql-collection/select-query.test.ts b/packages/plugins/@nocobase/plugin-collection-sql/src/server/__tests__/select-query.test.ts similarity index 97% rename from packages/core/database/src/__tests__/sql-collection/select-query.test.ts rename to packages/plugins/@nocobase/plugin-collection-sql/src/server/__tests__/select-query.test.ts index 1b115c3537..47512e5ada 100644 --- a/packages/core/database/src/__tests__/sql-collection/select-query.test.ts +++ b/packages/plugins/@nocobase/plugin-collection-sql/src/server/__tests__/select-query.test.ts @@ -7,7 +7,7 @@ * For more information, please refer to: https://www.nocobase.com/agreement. */ -import { SQLModel } from '../../sql-collection/sql-model'; +import { SQLModel } from '../sql-collection'; import { Sequelize } from 'sequelize'; describe('select query', () => { diff --git a/packages/core/database/src/__tests__/sql-collection/sql-collection.test.ts b/packages/plugins/@nocobase/plugin-collection-sql/src/server/__tests__/sql-collection.test.ts similarity index 63% rename from packages/core/database/src/__tests__/sql-collection/sql-collection.test.ts rename to packages/plugins/@nocobase/plugin-collection-sql/src/server/__tests__/sql-collection.test.ts index 91a51444ea..d3ca5537a8 100644 --- a/packages/core/database/src/__tests__/sql-collection/sql-collection.test.ts +++ b/packages/plugins/@nocobase/plugin-collection-sql/src/server/__tests__/sql-collection.test.ts @@ -7,15 +7,28 @@ * For more information, please refer to: https://www.nocobase.com/agreement. */ -import { mockDatabase } from '../../mock-database'; -import { SqlCollection } from '../../sql-collection'; +import { Collection, mockDatabase } from '@nocobase/database'; +import { SQLCollection } from '../sql-collection'; test('sql-collection', async () => { const db = mockDatabase({ tablePrefix: '' }); await db.clean({ drop: true }); - const collection = db.collectionFactory.createCollection({ + db.collectionFactory.registerCollectionType(SQLCollection, { + condition: (options) => { + return options.sql; + }, + + async onSync() { + return; + }, + + async onDump(dumper, collection: Collection) { + return; + }, + }); + const collection = db.collectionFactory.createCollection({ name: 'test', - sql: true, + sql: 'SELECT * FROM test;', }); expect(collection.isSql()).toBe(true); expect(collection.collectionSchema()).toBeUndefined(); diff --git a/packages/plugins/@nocobase/plugin-collection-sql/src/server/collections/.gitkeep b/packages/plugins/@nocobase/plugin-collection-sql/src/server/collections/.gitkeep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/plugins/@nocobase/plugin-collection-sql/src/server/index.ts b/packages/plugins/@nocobase/plugin-collection-sql/src/server/index.ts new file mode 100644 index 0000000000..b68aea57f9 --- /dev/null +++ b/packages/plugins/@nocobase/plugin-collection-sql/src/server/index.ts @@ -0,0 +1 @@ +export { default } from './plugin'; diff --git a/packages/plugins/@nocobase/plugin-collection-sql/src/server/plugin.ts b/packages/plugins/@nocobase/plugin-collection-sql/src/server/plugin.ts new file mode 100644 index 0000000000..1cea609a90 --- /dev/null +++ b/packages/plugins/@nocobase/plugin-collection-sql/src/server/plugin.ts @@ -0,0 +1,40 @@ +/** + * This file is part of the NocoBase (R) project. + * Copyright (c) 2020-2024 NocoBase Co., Ltd. + * Authors: NocoBase Team. + * + * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. + * For more information, please refer to: https://www.nocobase.com/agreement. + */ + +import { Plugin } from '@nocobase/server'; +import { Collection } from '@nocobase/database'; +import { SQLCollection } from './sql-collection'; +import sqlResourcer from './resources/sql'; + +export class PluginCollectionSQLServer extends Plugin { + async beforeLoad() { + this.app.db.collectionFactory.registerCollectionType(SQLCollection, { + condition: (options) => { + return options.sql; + }, + + async onSync() { + return; + }, + + async onDump(dumper, collection: Collection) { + return; + }, + }); + + this.app.resourceManager.define(sqlResourcer); + + this.app.acl.registerSnippet({ + name: `pm.data-source-manager.collection-sql `, + actions: ['sqlCollection:*'], + }); + } +} + +export default PluginCollectionSQLServer; diff --git a/packages/plugins/@nocobase/plugin-data-source-main/src/server/resourcers/sql.ts b/packages/plugins/@nocobase/plugin-collection-sql/src/server/resources/sql.ts similarity index 87% rename from packages/plugins/@nocobase/plugin-data-source-main/src/server/resourcers/sql.ts rename to packages/plugins/@nocobase/plugin-collection-sql/src/server/resources/sql.ts index e44d7b95c7..8b1e66aafe 100644 --- a/packages/plugins/@nocobase/plugin-data-source-main/src/server/resourcers/sql.ts +++ b/packages/plugins/@nocobase/plugin-collection-sql/src/server/resources/sql.ts @@ -8,13 +8,12 @@ */ import { Context, Next } from '@nocobase/actions'; -import { SQLModel, SqlCollection } from '@nocobase/database'; -import { CollectionModel } from '../models'; +import { SQLCollection, SQLModel } from '../sql-collection'; const updateCollection = async (ctx: Context, transaction: any) => { const { filterByTk, values } = ctx.action.params; const repo = ctx.db.getRepository('collections'); - const collection: CollectionModel = await repo.findOne({ + const collection = await repo.findOne({ filter: { name: filterByTk, }, @@ -47,7 +46,7 @@ export default { if (!/^select/i.test(sql) && !/^with([\s\S]+)select([\s\S]+)/i.test(sql)) { ctx.throw(400, ctx.t('Only supports SELECT statements or WITH clauses')); } - const tmpCollection = new SqlCollection({ name: 'tmp', sql }, { database: ctx.db }); + const tmpCollection = new SQLCollection({ name: 'tmp', sql }, { database: ctx.db }); const model = tmpCollection.model as typeof SQLModel; // The result is for preview only, add limit clause to avoid too many results const data = await model.findAll({ attributes: ['*'], limit: 5, raw: true }); @@ -65,7 +64,13 @@ export default { ctx.logger.warn(`resource: sql-collection, action: execute, error: ${err}`); fields = {}; } - const sources = Array.from(new Set(Object.values(fields).map((field) => field.collection))); + const sources = Array.from( + new Set( + Object.values(fields) + .map((field) => field.collection) + .filter((c) => c), + ), + ); ctx.body = { data, fields, sources }; await next(); }, @@ -90,7 +95,7 @@ export default { try { const { upRes } = await updateCollection(ctx, transaction); const [collection] = upRes; - await (collection as CollectionModel).load({ transaction, resetFields: true }); + await collection.load({ transaction, resetFields: true }); await transaction.commit(); ctx.body = upRes; } catch (e) { diff --git a/packages/core/database/src/sql-collection/index.ts b/packages/plugins/@nocobase/plugin-collection-sql/src/server/sql-collection/index.ts similarity index 100% rename from packages/core/database/src/sql-collection/index.ts rename to packages/plugins/@nocobase/plugin-collection-sql/src/server/sql-collection/index.ts diff --git a/packages/core/database/src/sql-collection/query-generator.ts b/packages/plugins/@nocobase/plugin-collection-sql/src/server/sql-collection/query-generator.ts similarity index 98% rename from packages/core/database/src/sql-collection/query-generator.ts rename to packages/plugins/@nocobase/plugin-collection-sql/src/server/sql-collection/query-generator.ts index 3fb8cc5f5f..6efc564aed 100644 --- a/packages/core/database/src/sql-collection/query-generator.ts +++ b/packages/plugins/@nocobase/plugin-collection-sql/src/server/sql-collection/query-generator.ts @@ -10,7 +10,7 @@ import { GroupOption, Order, ProjectionAlias, WhereOptions } from 'sequelize'; import { SQLModel } from './sql-model'; import { lodash } from '@nocobase/utils'; -import { Collection } from '../collection'; +import { Collection } from '@nocobase/database'; export function selectQuery( tableName: string, diff --git a/packages/core/database/src/sql-collection/sql-collection.ts b/packages/plugins/@nocobase/plugin-collection-sql/src/server/sql-collection/sql-collection.ts similarity index 80% rename from packages/core/database/src/sql-collection/sql-collection.ts rename to packages/plugins/@nocobase/plugin-collection-sql/src/server/sql-collection/sql-collection.ts index 5f2e94a862..9c6e807378 100644 --- a/packages/core/database/src/sql-collection/sql-collection.ts +++ b/packages/plugins/@nocobase/plugin-collection-sql/src/server/sql-collection/sql-collection.ts @@ -7,10 +7,11 @@ * For more information, please refer to: https://www.nocobase.com/agreement. */ -import { Collection, CollectionContext, CollectionOptions } from '../collection'; +import { Collection, CollectionContext, CollectionOptions } from '@nocobase/database'; import { SQLModel } from './sql-model'; +import { QueryInterfaceDropTableOptions } from 'sequelize'; -export class SqlCollection extends Collection { +export class SQLCollection extends Collection { constructor(options: CollectionOptions, context: CollectionContext) { options.autoGenId = false; options.timestamps = false; @@ -51,7 +52,7 @@ export class SqlCollection extends Collection { model.removeAttribute('id'); } - model.sql = sql; + model.sql = sql?.endsWith(';') ? sql.slice(0, -1) : sql; model.database = this.context.database; model.collection = this; @@ -64,4 +65,10 @@ export class SqlCollection extends Collection { }, }); } + + async removeFromDb(options?: QueryInterfaceDropTableOptions & { dropCollection?: boolean }) { + if (options?.dropCollection !== false) { + return this.remove(); + } + } } diff --git a/packages/core/database/src/sql-collection/sql-model.ts b/packages/plugins/@nocobase/plugin-collection-sql/src/server/sql-collection/sql-model.ts similarity index 57% rename from packages/core/database/src/sql-collection/sql-model.ts rename to packages/plugins/@nocobase/plugin-collection-sql/src/server/sql-collection/sql-model.ts index 7ebff659d8..de2d6a5e96 100644 --- a/packages/core/database/src/sql-collection/sql-model.ts +++ b/packages/plugins/@nocobase/plugin-collection-sql/src/server/sql-collection/sql-model.ts @@ -7,8 +7,7 @@ * For more information, please refer to: https://www.nocobase.com/agreement. */ -import { Model } from '../model'; -import sqlParser from '../sql-parser'; +import { Model, sqlParser, SQLParserTypes } from '@nocobase/database'; import { selectQuery } from './query-generator'; export class SQLModel extends Model { @@ -37,6 +36,78 @@ export class SQLModel extends Model { static async sync(): Promise {} + private static getTableNameWithSchema(table: string) { + if (this.database.inDialect('postgres') && !table.includes('.')) { + const schema = process.env.DB_SCHEMA || 'public'; + return `${schema}.${table}`; + } + return table; + } + + private static parseSelectAST(ast: SQLParserTypes.Select) { + const tablesMap: { [table: string]: { name: string; as?: string }[] } = {}; // table => columns + const tableAliases = {}; + ast.from.forEach((fromItem: SQLParserTypes.From) => { + tablesMap[fromItem.table] = []; + if (fromItem.as) { + tableAliases[fromItem.as] = fromItem.table; + } + }); + ast.columns.forEach((column: SQLParserTypes.Column) => { + const expr = column.expr as SQLParserTypes.ColumnRef; + if (expr.type !== 'column_ref') { + return; + } + const table = expr.table; + const name = tableAliases[table] || table; + const columnAttr = { name: expr.column as string, as: column.as }; + if (!name) { + Object.keys(tablesMap).forEach((n) => { + tablesMap[n].push(columnAttr); + }); + } else if (tablesMap[name]) { + tablesMap[name].push(columnAttr); + } + }); + return tablesMap; + } + + private static parseTablesAndColumns(): { + table: string; + columns: { name: string; as?: string }[]; + }[] { + let { ast: _ast } = sqlParser.parse(this.sql); + if (Array.isArray(_ast)) { + _ast = _ast[0]; + } + const ast = _ast as SQLParserTypes.Select; + ast.from = ast.from || []; + ast.columns = ast.columns || []; + if (ast.with) { + // The type definition of the AST is not accurate in node-sql-parser 4.18.0 + // So we need to use any here temporarily + const withAST = ast.with as any; + withAST.forEach((withItem: any) => { + const as = withItem.name.value; + const withAst = withItem.stmt.ast; + ast.from.push(...withAst.from.map((f: any) => ({ ...f, as }))); + ast.columns.push( + ...withAst.columns.map((c: any) => ({ + ...c, + expr: { + ...c.expr, + table: as, + }, + })), + ); + }); + } + const tablesMap = this.parseSelectAST(ast); + return Object.entries(tablesMap) + .filter(([_, columns]) => columns) + .map(([table, columns]) => ({ table, columns })); + } + static inferFields(): { [field: string]: { type: string; @@ -50,11 +121,19 @@ export class SQLModel extends Model { const tableName = this.getTableNameWithSchema(table); const collection = this.database.tableNameCollectionMap.get(tableName); if (!collection) { - return fields; + const originFields = {}; + columns.forEach((column) => { + if (column.name === '*') { + return; + } + originFields[column.as || column.name] = {}; + }); + return { ...fields, ...originFields }; } + const all = columns.some((column) => column.name === '*'); const attributes = collection.model.getAttributes(); const sourceFields = {}; - if (columns === '*') { + if (all) { Object.values(attributes).forEach((attribute) => { const field = collection.getField((attribute as any).fieldName); if (!field?.options.interface) { @@ -69,105 +148,25 @@ export class SQLModel extends Model { }; }); } else { - (columns as { name: string; as: string }[]).forEach((column) => { + columns.forEach((column) => { + let options = {}; const modelField = Object.values(attributes).find((attribute) => attribute.field === column.name); - if (!modelField) { - return; + if (modelField) { + const field = collection.getField((modelField as any).fieldName); + if (field?.options.interface) { + options = { + collection: field.collection.name, + type: field.type, + source: `${field.collection.name}.${field.name}`, + interface: field.options.interface, + uiSchema: field.options.uiSchema, + }; + } } - const field = collection.getField((modelField as any).fieldName); - if (!field?.options.interface) { - return; - } - sourceFields[column.as || column.name] = { - collection: field.collection.name, - type: field.type, - source: `${field.collection.name}.${field.name}`, - interface: field.options.interface, - uiSchema: field.options.uiSchema, - }; + sourceFields[column.as || column.name] = options; }); } return { ...fields, ...sourceFields }; }, {}); } - - private static parseTablesAndColumns(): { - table: string; - columns: string | { name: string; as: string }[]; - }[] { - let { ast } = sqlParser.parse(this.sql); - if (Array.isArray(ast)) { - ast = ast[0]; - } - ast.from = ast.from || []; - ast.columns = ast.columns || []; - if (ast.with) { - ast.with.forEach((withItem: any) => { - const as = withItem.name; - const withAst = withItem.stmt.ast; - ast.from.push(...withAst.from.map((f: any) => ({ ...f, as }))); - ast.columns.push( - ...withAst.columns.map((c: any) => ({ - ...c, - expr: { - ...c.expr, - table: as, - }, - })), - ); - }); - } - if (ast.columns === '*') { - const tables = new Set(); - ast.from.forEach((fromItem: { table: string; as: string }) => { - tables.add(fromItem.table); - }); - return Array.from(tables).map((table) => ({ table, columns: '*' })); - } - const tableAliases = {}; - ast.from.forEach((fromItem: { table: string; as: string }) => { - if (!fromItem.as) { - return; - } - tableAliases[fromItem.as] = fromItem.table; - }); - const columns: string[] = ast.columns.reduce( - ( - tableMp: { [table: string]: { name: string; as: string }[] }, - column: { - as: string; - expr: { - table: string; - column: string; - type: string; - }; - }, - ) => { - if (column.expr.type !== 'column_ref') { - return tableMp; - } - const table = column.expr.table; - const name = tableAliases[table] || table; - const columnAttr = { name: column.expr.column, as: column.as }; - if (!tableMp[name]) { - tableMp[name] = [columnAttr]; - } else { - tableMp[name].push(columnAttr); - } - return tableMp; - }, - {}, - ); - return Object.entries(columns) - .filter(([_, columns]) => columns) - .map(([table, columns]) => ({ table, columns })); - } - - private static getTableNameWithSchema(table: string) { - if (this.database.inDialect('postgres') && !table.includes('.')) { - const schema = process.env.DB_SCHEMA || 'public'; - return `${schema}.${table}`; - } - return table; - } } diff --git a/packages/plugins/@nocobase/plugin-data-source-main/src/server/server.ts b/packages/plugins/@nocobase/plugin-data-source-main/src/server/server.ts index ae4e90a5c5..cbd4537df8 100644 --- a/packages/plugins/@nocobase/plugin-data-source-main/src/server/server.ts +++ b/packages/plugins/@nocobase/plugin-data-source-main/src/server/server.ts @@ -26,7 +26,6 @@ import { beforeCreateForValidateField, beforeUpdateForValidateField } from './ho import { beforeCreateForViewCollection } from './hooks/beforeCreateForViewCollection'; import { CollectionModel, FieldModel } from './models'; import collectionActions from './resourcers/collections'; -import sqlResourcer from './resourcers/sql'; import viewResourcer from './resourcers/views'; export class PluginDataSourceMainServer extends Plugin { @@ -293,11 +292,6 @@ export class PluginDataSourceMainServer extends Plugin { name: `pm.data-source-manager.collection-view `, actions: ['dbViews:*'], }); - - this.app.acl.registerSnippet({ - name: `pm.data-source-manager.collection-sql `, - actions: ['sqlCollection:*'], - }); } async load() { @@ -324,7 +318,6 @@ export class PluginDataSourceMainServer extends Plugin { }); this.app.resource(viewResourcer); - this.app.resource(sqlResourcer); this.app.actions(collectionActions); const handleFieldSource = (fields) => { diff --git a/packages/presets/nocobase/package.json b/packages/presets/nocobase/package.json index 9573762ec6..4e855f6142 100644 --- a/packages/presets/nocobase/package.json +++ b/packages/presets/nocobase/package.json @@ -23,6 +23,7 @@ "@nocobase/plugin-calendar": "1.0.0-alpha.14", "@nocobase/plugin-charts": "1.0.0-alpha.14", "@nocobase/plugin-client": "1.0.0-alpha.14", + "@nocobase/plugin-collection-sql": "1.0.0-alpha.14", "@nocobase/plugin-data-source-main": "1.0.0-alpha.14", "@nocobase/plugin-data-source-manager": "1.0.0-alpha.14", "@nocobase/plugin-data-visualization": "1.0.0-alpha.14", diff --git a/packages/presets/nocobase/src/server/index.ts b/packages/presets/nocobase/src/server/index.ts index 00161d4f2c..25a0238926 100644 --- a/packages/presets/nocobase/src/server/index.ts +++ b/packages/presets/nocobase/src/server/index.ts @@ -51,6 +51,7 @@ export class PresetNocoBase extends Plugin { 'kanban', 'action-duplicate', 'action-print', + 'collection-sql', ]; localPlugins = [ diff --git a/yarn.lock b/yarn.lock index 5633fd27f8..a7444835ce 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8947,7 +8947,7 @@ bessel@^1.0.2: resolved "https://registry.npmmirror.com/bessel/-/bessel-1.0.2.tgz#828812291e0b62e94959cdea43fac186e8a7202d" integrity sha512-Al3nHGQGqDYqqinXhQzmwmcRToe/3WyBv4N8aZc5Pef8xw2neZlR9VPi84Sa23JtgWcucu18HxVZrnI0fn2etw== -big-integer@^1.6.44: +big-integer@^1.6.44, big-integer@^1.6.48: version "1.6.52" resolved "https://registry.npmmirror.com/big-integer/-/big-integer-1.6.52.tgz#60a887f3047614a8e1bffe5d7173490a97dc8c85" integrity sha512-QxD8cf2eVqJOOz63z6JIN9BzvVs/dlySa5HGSBH5xtR8dPteIRQnBxxKqkNTiT6jbDTF6jAfrd4oMcND9RGbQg== @@ -19039,6 +19039,13 @@ node-releases@^2.0.14: resolved "https://registry.npmmirror.com/node-releases/-/node-releases-2.0.14.tgz#2ffb053bceb8b2be8495ece1ab6ce600c4461b0b" integrity sha512-y10wOWt8yZpqXmOgRo77WaHEmhYQYGNA6y421PKsKYWEK8aW+cqAphborZDhqfyKrbZEN92CN1X2KbafY2s7Yw== +node-sql-parser@^4.18.0: + version "4.18.0" + resolved "https://registry.npmmirror.com/node-sql-parser/-/node-sql-parser-4.18.0.tgz#516b6e633c55c5abbba1ca588ab372db81ae9318" + integrity sha512-2YEOR5qlI1zUFbGMLKNfsrR5JUvFg9LxIRVE+xJe962pfVLH0rnItqLzv96XVs1Y1UIR8FxsXAuvX/lYAWZ2BQ== + dependencies: + big-integer "^1.6.48" + node-xlsx@^0.16.1: version "0.16.2" resolved "https://registry.npmmirror.com/node-xlsx/-/node-xlsx-0.16.2.tgz#40f580187eae0e032cac96e958e97cb6ceca09f6"