Package com.foundationdb.sql.optimizer.plan

Examples of com.foundationdb.sql.optimizer.plan.BasePlannable


                    }
                    param.setUserData(type);
                }
            }
        }
        BasePlannable result = compiler.compile(dmlStmt, params, planContext);
        PostgresType[] parameterTypes = getParameterTypes(result.getParameterTypes(),
                                                          paramTypes,
                                                          server.typesTranslator());

        final PostgresBaseOperatorStatement pbos;
        if (result.isUpdate())
            pbos = compiler.generateUpdate(this,
                                           (PhysicalUpdate)result, stmt.statementToString(),
                                           parameterTypes);
        else
            pbos = compiler.generateSelect(this,
View Full Code Here


            if (updateStmt.getReturningList() != null)
                throw JDBCException.wrapped("Statement already has RETURNING");
            addAutoGeneratedReturning(updateStmt, autoGeneratedKeys);
        }
        PlanContext planContext = new ServerPlanContext(this, context);
        BasePlannable result = compile(sqlStmt, sqlParams, planContext);
        Operator resultOperator = (Operator)result.getPlannable();
        JDBCResultSetMetaData resultSetMetaData = null;
        if (!result.isUpdate() || ((PhysicalUpdate)result).isReturning()) {
            List<ResultColumn> columns = new ArrayList<>();
            for (PhysicalResultColumn column : result.getResultColumns()) {
                columns.add((ResultColumn)column);
            }
            resultSetMetaData = new JDBCResultSetMetaData(getTypesTranslator(), columns);
        }
        JDBCParameterMetaData parameterMetaData = null;
        if (result.getParameterTypes() != null) {
            List<ParameterType> jdbcParams = new ArrayList<>();
            for (BasePlannable.ParameterType paramType : result.getParameterTypes()) {
                int jdbcType = Types.OTHER;
                DataTypeDescriptor sqlType = paramType.getSQLType();
                TInstance type = paramType.getType();
                if (type != null) {
                    jdbcType = TInstance.tClass(type).jdbcType();
                }
                else if (sqlType != null) {
                    jdbcType = sqlType.getJDBCTypeId();
                }
                jdbcParams.add(new ParameterType(sqlType, jdbcType, type));
            }
            parameterMetaData = new JDBCParameterMetaData(getTypesTranslator(), jdbcParams);
            if (getParameterNames) {
                // TODO: Only case through here will be ? = CALL fun(?,?,...),
                // which will look like SELECT fun(...).
            }
        }
        if (result.isUpdate())
            return new ExecutableModifyOperatorStatement(getSchema(),
                                                         resultOperator,
                                                         resultSetMetaData,
                                                         parameterMetaData);
        else
            return new ExecutableQueryOperatorStatement(getSchema(),
                                                        resultOperator,
                                                        resultSetMetaData,
                                                        parameterMetaData,
                                                        result.getCostEstimate());
    }
View Full Code Here

        Explainable explainable;
        if (innerStmt instanceof CallStatementNode) {
            explainable = PostgresCallStatementGenerator.explainable(server, (CallStatementNode)innerStmt, params, paramTypes);
        }
        else {
            BasePlannable result = compiler.compile((DMLStatementNode)innerStmt, params, context);
            explainable = result.getPlannable();
        }
        List<String> explain;
        if (compiler instanceof PostgresJsonCompiler) {
            JsonFormatter f = new JsonFormatter();
            explain = Collections.singletonList(f.format(explainable.getExplainer(context.getExplainContext())));
View Full Code Here

            StoreAdapter adapter = store.createAdapter(session, SchemaCache.globalSchema(onlineAIS));
            CreateAsCompiler compiler = new CreateAsCompiler(server, adapter, false, onlineAIS);
            DMLStatementNode dmlStmt = (DMLStatementNode) stmt;
            PlanContext planContext = new PlanContext(compiler);

            BasePlannable result = compiler.compile(dmlStmt, null, planContext);

            Plannable plannable = result.getPlannable();
            QueryContext newContext = contextIfNull(context, adapter);
            getTransformCache(session, server);
            runPlan(session, newContext, schemaManager, txnService, (Operator) plannable, null);
        }finally{
            txnService.commitTransaction(session);
View Full Code Here

                    throw new SQLParserInternalException(e);
                }
                StoreAdapter adapter = givenStore.createAdapter(session, SchemaCache.globalSchema(newAIS));
                CreateAsCompiler compiler = new CreateAsCompiler(server, adapter, true, newAIS);
                PlanContext planContext = new PlanContext(compiler);
                BasePlannable insertResult = compiler.compile((DMLStatementNode) insertStmt, null, planContext);
                insertPlan = insertResult.getPlannable();
                deletePlan = new Delete_Returning(insertPlan.getInputOperators().iterator().next(), false);
            }
            int tableID = cs.getTableId();
            TableRowType newType = newSchema.tableRowType(tableID);
            TableTransform transform = buildTableTransform(cs, changeLevel, oldAIS, newType, typesRegistry,
View Full Code Here

    @Override
    public String generateResult() throws Exception {
        StatementNode stmt = parser.parseStatement(sql);
        ExplainPlanContext context = new ExplainPlanContext(compiler, new SimpleQueryContext(null));
        BasePlannable result = compiler.compile((DMLStatementNode)stmt,
                                                parser.getParameterList(), context);
        return result.explainToString(context.getExplainContext(), OptimizerTestBase.DEFAULT_SCHEMA, DefaultFormatter.LevelOfDetail.VERBOSE_WITHOUT_COST);
    }
View Full Code Here

TOP

Related Classes of com.foundationdb.sql.optimizer.plan.BasePlannable

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.