updated sample queries
This commit is contained in:
parent
adcdc490dd
commit
7d2cc528b3
|
@ -76,7 +76,7 @@
|
|||
<script type="text/javascript">
|
||||
$(function() {
|
||||
function addSampleQuery(name, query) {
|
||||
var btn = $('<button type="button" class="btn btn-success">' + name + '</button>');
|
||||
var btn = $('<button type="button" class="btn btn-sm btn-success">' + name + '</button>');
|
||||
btn.click(function(evt) {
|
||||
$('#queryInput').val(query);
|
||||
if (!evt.shiftKey) {
|
||||
|
@ -87,7 +87,7 @@ $(function() {
|
|||
}
|
||||
|
||||
function addBuggyQuery(name, query) {
|
||||
var btn = $('<button type="button" class="btn btn-danger">' + name + '</button>');
|
||||
var btn = $('<button type="button" class="btn btn-sm btn-danger">' + name + '</button>');
|
||||
btn.click(function(evt) {
|
||||
$('#queryInput').val(query);
|
||||
if (!evt.shiftKey) {
|
||||
|
@ -176,26 +176,28 @@ $(function() {
|
|||
return true;
|
||||
});
|
||||
|
||||
addBuggyQuery('GROUP', 'SELECT AVG(grade) FROM (SELECT city, AVG(grade) FROM students GROUP BY city) t1');
|
||||
addBuggyQuery('UNION (kills hyrise)', 'SELECT name FROM students WHERE grade > 2.0 UNION SELECT name FROM students');
|
||||
|
||||
|
||||
//////////////////////////////////////////////////
|
||||
// Load sample queries
|
||||
$.get('sample-queries.sql', function(data) {
|
||||
var lines = data.split('\n');
|
||||
var name, query = "";
|
||||
var name, query = "", isBuggy = false;
|
||||
$.each(lines, function(i, line) {
|
||||
if (line[0] == '#') {
|
||||
// Append last query
|
||||
if (name && !isBuggy) addSampleQuery(name, query);
|
||||
if (name && isBuggy) addBuggyQuery(name, query);
|
||||
|
||||
// New query
|
||||
if (name) addSampleQuery(name, query);
|
||||
name = line.substring(1);
|
||||
isBuggy = (line[1] == '!');
|
||||
name = line.substring((isBuggy) ? 3 : 2);
|
||||
query = "";
|
||||
} else {
|
||||
query += line + '\n';
|
||||
}
|
||||
});
|
||||
if (name) addSampleQuery(name, query);
|
||||
|
||||
if (name && !isBuggy) addSampleQuery(name, query);
|
||||
if (name && isBuggy) addBuggyQuery(name, query);
|
||||
});
|
||||
//////////////////////////////////////////////////
|
||||
|
||||
|
|
|
@ -26,3 +26,13 @@ SELECT * FROM test;
|
|||
CREATE TABLE IF NOT EXISTS test (v1 INTEGER, v2 INTEGER, v3 INTEGER);
|
||||
INSERT INTO test VALUES (1, 12, 43);
|
||||
SELECT * FROM test;
|
||||
#! GROUP
|
||||
SELECT AVG(grade) FROM (SELECT city, AVG(grade) FROM students GROUP BY city) t1
|
||||
#! UNION (kills hyrise)
|
||||
SELECT name FROM students WHERE grade > 2.0 UNION SELECT name FROM students
|
||||
#! UPDATE
|
||||
UPDATE companies SET company_id = 44 WHERE company_name = 'Microsoft';
|
||||
#! SELECT
|
||||
SELECT * FROM companies;
|
||||
#! SELECT Microsoft
|
||||
SELECT * FROM companies WHERE company_name = 'Microsoft';
|
|
@ -6,7 +6,7 @@ BIN_DIR = ../bin
|
|||
CC = g++
|
||||
CFLAGS = -O3 -I./ -Ilib/ -Ilib/statements/ -Iparser/ -std=c++11 -pthread -Wall -g
|
||||
|
||||
LIB_FILES = $(shell find lib/ -name '*.cpp') $(shell find lib/ -name '*.h') parser/bison_parser.cpp parser/flex_lexer.cpp parser/SQLParser.cpp
|
||||
LIB_HEADERS = $(shell find lib/ -name '*.h') parser/bison_parser.h parser/flex_lexer.h parser/SQLParser.h
|
||||
LIB_SOURCES = $(shell find lib/ -name '*.cpp') parser/bison_parser.cpp parser/flex_lexer.cpp parser/SQLParser.cpp
|
||||
TEST_SOURCES = $(shell find tests/ -name '*.cpp')
|
||||
|
||||
|
@ -14,7 +14,8 @@ TEST_SOURCES = $(shell find tests/ -name '*.cpp')
|
|||
build: clean
|
||||
make -C parser/
|
||||
mkdir $(BUILD_DIR)
|
||||
cp $(LIB_FILES) $(BUILD_DIR)
|
||||
cp $(LIB_SOURCES) $(BUILD_DIR)
|
||||
cp $(LIB_HEADERS) $(BUILD_DIR)
|
||||
|
||||
|
||||
analysis: $(LIB_SOURCES) sql_analysis.cpp
|
||||
|
|
|
@ -19,6 +19,7 @@ struct UpdateStatement : SQLStatement {
|
|||
|
||||
virtual ~UpdateStatement(); // defined in destructors.cpp
|
||||
|
||||
// TODO: switch to char* instead of TableRef
|
||||
TableRef* table;
|
||||
List<UpdateClause*>* updates;
|
||||
Expr* where;
|
||||
|
|
Loading…
Reference in New Issue