コード例 #1
0
        // copy tab(cols) from <file> <where> =>
        // insert into tab(cols) select * from foreign_table(<file>) <where>
        //
        public CopyStmt(BaseTableRef targetref, List <string> cols, string fileName, Expr where, string text) : base(text)
        {
            cols       = cols.Count != 0 ? cols : null;
            targetref_ = targetref; fileName_ = fileName; where_ = where;

            var colrefs = new List <Expr>();

            Utils.Assumes(cols is null);
            if (cols is null)
            {
                colrefs = targetref.AllColumnsRefs();
            }
            ExternalTableRef sourcetab = new ExternalTableRef(fileName, targetref, colrefs);

            select_ = new SelectStmt(new List <Expr> {
                new SelStar(null)
            },
                                     new List <TableRef> {
                sourcetab
            }, where, null, null, null, null, null, null, text);
            insert_ = new InsertStmt(targetref, cols, null, select_, text)
            {
                queryOpt_ = queryOpt_
            };
        }
コード例 #2
0
ファイル: DataType.cs プロジェクト: bigwa/qpmodel
 public ExternalTableRef(string filename, BaseTableRef baseref, List <Expr> colrefs)
 {
     filename_ = filename.Replace('\'', ' ');
     baseref_  = baseref;
     colrefs_  = colrefs;
     alias_    = baseref.alias_;
 }
コード例 #3
0
        // suppport forms
        //   a.i =|>|< 5
        public static IndexDef FilterCanUseIndex(this Expr filter, BaseTableRef table)
        {
            string[] indexops = { "=", ">=", "<=", ">", "<" };
            Debug.Assert(filter.IsBoolean());

            IndexDef ret = null;

            if (filter is BinExpr fb)
            {
                // expression is already normalized, so no swap side shall considered
                Debug.Assert(!(fb.l_() is LiteralExpr && fb.r_() is ColExpr));
                if (indexops.Contains(fb.op_) && fb.l_() is ColExpr cl && fb.r_() is LiteralExpr)
                {
                    var index = table.Table().IndexContains(cl.colName_);
                    if (index != null)
                    {
                        if (index.columns_[0].Equals(cl.colName_))
                        {
                            ret = index;
                        }
                    }
                }
            }

            return(ret);
        }
コード例 #4
0
 public InsertStmt(BaseTableRef target, List <string> cols, List <Expr> vals, SelectStmt select, string text) : base(text)
 {
     targetref_ = target; cols_ = null; vals_ = vals; select_ = select;
     // select_ is a different statement, binding their options
     if (select_ != null)
     {
         select_.queryOpt_ = queryOpt_;
     }
 }
コード例 #5
0
 public CreateIndexStmt(string indexname,
                        BaseTableRef target, bool unique, List <string> columns, Expr where, string text) : base(text)
 {
     targetref_    = target;
     def_          = new IndexDef();
     def_.name_    = indexname;
     def_.unique_  = unique;
     def_.columns_ = columns;
     def_.table_   = target;
     select_       = RawParser.ParseSingleSqlStatement
                         ($"select sysrid_, {string.Join(",", columns)} from {def_.table_.relname_}") as SelectStmt;
 }
コード例 #6
0
        public AnalyzeStmt(BaseTableRef target, string text,
                           SelectStmt.TableSample ts) : base(text)
        {
            // SELECT statement is used so later optimizations can be kicked in easier
            targetref_ = target;
            string sql = $"select * from {target.relname_} ";

            if (ts != null)
            {
                sql += $" tablesample row ({ts.rowcnt_})";
            }

            select_ = RawParser.ParseSingleSqlStatement(sql) as SelectStmt;
            // select_ is a different statement, binding their options
            select_.queryOpt_ = queryOpt_;
        }
コード例 #7
0
ファイル: Index.cs プロジェクト: zhouqingqing/qpmodel
 public CreateIndexStmt(string indexname,
                        BaseTableRef target, bool unique, List <string> columns, Expr where, string text) : base(text)
 {
     targetref_ = target;
     def_       = new IndexDef
     {
         name_    = indexname,
         unique_  = unique,
         columns_ = columns,
         table_   = target
     };
     select_ = RawParser.ParseSingleSqlStatement
                   ($"select sysrid_, {string.Join(",", columns)} from {def_.table_.relname_}") as SelectStmt;
     // select_ is a different statement, binding their options
     select_.queryOpt_ = queryOpt_;
 }
コード例 #8
0
ファイル: stmtDML.cs プロジェクト: wangxiaoying/qpmodel
 public InsertStmt(BaseTableRef target, List <string> cols, List <Expr> vals, SelectStmt select, string text) : base(text)
 {
     targetref_ = target; cols_ = null; vals_ = vals; select_ = select;
 }
コード例 #9
0
ファイル: stmtDML.cs プロジェクト: wangxiaoying/qpmodel
 public AnalyzeStmt(BaseTableRef target, string text) : base(text)
 {
     // SELECT statement is used so later optimizations can be kicked in easier
     targetref_ = target;
     select_    = RawParser.ParseSingleSqlStatement($"select * from {target.relname_}") as SelectStmt;
 }
コード例 #10
0
 public LogicScanStream(BaseTableRef tab) : base(tab)
 {
 }