Commit 8c32ff10 authored by Don Brower's avatar Don Brower Committed by GitHub

Merge pull request #189 from dbrower/issue187

Use physical columns instead of logical columns with simple indicies
parents ba9eea98 f324cece
......@@ -8,6 +8,7 @@
Boy van Duuren <boy@vanduuren.xyz>
Dan Kortschak <dan.kortschak@adelaide.edu.au>
Donald Brower <don.brower@gmail.com>
Geofrey Ernest <geofreyernest@live.com>
Jan Mercl <0xjnml@gmail.com>
Michael Eisendle <michael@eisendle.me>
......
// CAUTION: Generated file - DO NOT EDIT.
// Code generated by goyacc - DO NOT EDIT.
// Copyright (c) 2014 The ql Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
......@@ -1761,6 +1761,7 @@ yystack:
yynewstate:
if yychar < 0 {
yylval.yys = yystate
yychar = yylex1(yylex, &yylval)
var ok bool
if yyxchar, ok = yyXLAT[yychar]; !ok {
......
......@@ -985,7 +985,7 @@ func (db *DB) createIndex2() error {
expr := "id()"
if i != 0 {
expr = t.cols[i-1].name
expr = t.cols0[i-1].name
}
if err := db.insertIndex2(t.name, index.name, []string{expr}, index.unique, true, index.xroot); err != nil {
......
......@@ -3,7 +3,7 @@
//TODO Put your favorite license here
// yacc source generated by ebnf2y[1]
// at 2017-05-22 14:22:16.694201976 +0200 CEST
// at 2017-08-31 17:43:07.227157474 +0200 CEST m=+0.001846399
//
// $ ebnf2y -o ql.y -oe ql.ebnf -start StatementList -pkg ql -p _
//
......
// CAUTION: Generated file - DO NOT EDIT.
// Code generated by golex. DO NOT EDIT.
// Copyright (c) 2014 The ql Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
......
......@@ -330,7 +330,7 @@ func (t *table) findIndexByColName(name string) (*col, *indexedCol) {
continue
}
if c := t.cols[i-1]; c.name == name {
if c := t.cols0[i-1]; c.name == name {
return c, v
}
}
......@@ -784,7 +784,11 @@ func (t *table) row(ctx *execCtx, h int64) (int64, []interface{}, error) {
return -1, nil, err
}
return rec[1].(int64), rec[2:], nil
id := rec[1].(int64)
for i, c := range t.cols {
rec[i] = rec[c.index+2]
}
return id, rec[:len(t.cols)], nil
}
// storage fields
......
......@@ -8446,3 +8446,13 @@ SELECT * FROM t ORDER BY á;
┌Order by á,
└Output field names ["á"]
---- 1355
SELECT * FROM t;
┌Iterate all rows of table "t"
└Output field names ["c"]
---- 1356
SELECT c FROM t WHERE c == "abc";
┌Iterate all rows of table "t" using index "cx" where c == "abc"
└Output field names ["c"]
......@@ -15754,3 +15754,24 @@ SELECT * FROM t ORDER BY á
[1]
[2]
[3]
-- 1355 // https://github.com/cznic/ql/issues/187
BEGIN TRANSACTION;
CREATE TABLE t (b string, c string);
ALTER TABLE t DROP COLUMN b;
CREATE INDEX d ON t (c);
COMMIT;
SELECT * FROM t;
|"c"
-- 1356 // https://github.com/cznic/ql/issues/188
BEGIN TRANSACTION;
CREATE TABLE t (b string, c string);
CREATE INDEX bx ON t (b);
ALTER TABLE t DROP COLUMN b;
CREATE INDEX cx ON t (c);
INSERT INTO t (c) VALUES ("abc");
COMMIT;
SELECT c FROM t WHERE c = "abc";
|"c"
[abc]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment