Skip to content

Commit 9dde640

Browse files
committed
fixed two bounds error cases.
renamed temporary table prop to `temporary`
1 parent 924e51c commit 9dde640

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

src/SQLParser.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,9 +175,10 @@ function walk($tokens, $sql, $source_map){
175175
}
176176
}
177177
if (count($temp)) {
178+
178179
$statements[] = array(
179180
"tuples" => $temp,
180-
"sql" => substr($sql, $source_map[$start][0], $source_map[$i][0] - $source_map[$start][0] + $source_map[$i][1]),
181+
"sql" => substr($sql, $source_map[$start][0], $source_map[$i-1][0] - $source_map[$start][0] + $source_map[$i-1][1]),
181182
);
182183
}
183184

@@ -200,7 +201,7 @@ function walk($tokens, $sql, $source_map){
200201
if (StrToUpper($s[0]) == 'CREATE TEMPORARY TABLE'){
201202

202203
$table = $this->parse_create_table($s, 1, count($s));
203-
$table['props']['temp'] = true;
204+
$table['props']['temporary'] = true;
204205
$tables[$table['name']] = $table;
205206
$table['sql'] = $stmt['sql'];
206207
}
@@ -281,6 +282,7 @@ function next_tokens($tokens, $i){
281282
array_shift($args);
282283

283284
foreach ($args as $v){
285+
if ($i >= count($tokens) ) return false;
284286
if (StrToUpper($tokens[$i]) != $v) return false;
285287
$i++;
286288
}

0 commit comments

Comments
 (0)