@@ -43,10 +43,13 @@ func declare(db *sqlite3.Conn, _, _, _ string, arg ...string) (ret *table, err e
4343
4444 // Row key query.
4545 t .scan = "SELECT * FROM\n " + arg [0 ]
46- stmt , _ , err := db .Prepare (t .scan )
46+ stmt , tail , err := db .PrepareFlags (t .scan , sqlite3 . PREPARE_FROM_DDL )
4747 if err != nil {
4848 return nil , err
4949 }
50+ if tail != "" {
51+ return nil , util .TailErr
52+ }
5053 defer stmt .Close ()
5154
5255 t .keys = make ([]string , stmt .ColumnCount ())
@@ -62,10 +65,13 @@ func declare(db *sqlite3.Conn, _, _, _ string, arg ...string) (ret *table, err e
6265 stmt .Close ()
6366
6467 // Column definition query.
65- stmt , _ , err = db .Prepare ("SELECT * FROM\n " + arg [1 ])
68+ stmt , tail , err = db .PrepareFlags ("SELECT * FROM\n " + arg [1 ], sqlite3 . PREPARE_FROM_DDL )
6669 if err != nil {
6770 return nil , err
6871 }
72+ if tail != "" {
73+ return nil , util .TailErr
74+ }
6975
7076 if stmt .ColumnCount () != 2 {
7177 return nil , util .ErrorString ("pivot: column definition query expects 2 result columns" )
@@ -83,10 +89,13 @@ func declare(db *sqlite3.Conn, _, _, _ string, arg ...string) (ret *table, err e
8389
8490 // Pivot cell query.
8591 t .cell = "SELECT * FROM\n " + arg [2 ]
86- stmt , _ , err = db .Prepare (t .cell )
92+ stmt , tail , err = db .PrepareFlags (t .cell , sqlite3 . PREPARE_FROM_DDL )
8793 if err != nil {
8894 return nil , err
8995 }
96+ if tail != "" {
97+ return nil , util .TailErr
98+ }
9099
91100 if stmt .ColumnCount () != 1 {
92101 return nil , util .ErrorString ("pivot: cell query expects 1 result columns" )
@@ -187,7 +196,7 @@ func (c *cursor) Filter(idxNum int, idxStr string, arg ...sqlite3.Value) error {
187196 return err
188197 }
189198
190- c .scan , _ , err = c .table .db .Prepare (idxStr )
199+ c .scan , _ , err = c .table .db .PrepareFlags (idxStr , sqlite3 . PREPARE_FROM_DDL )
191200 if err != nil {
192201 return err
193202 }
@@ -199,7 +208,7 @@ func (c *cursor) Filter(idxNum int, idxStr string, arg ...sqlite3.Value) error {
199208 }
200209
201210 if c .cell == nil {
202- c .cell , _ , err = c .table .db .Prepare (c .table .cell )
211+ c .cell , _ , err = c .table .db .PrepareFlags (c .table .cell , sqlite3 . PREPARE_PERSISTENT | sqlite3 . PREPARE_FROM_DDL )
203212 if err != nil {
204213 return err
205214 }
0 commit comments