Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Routine


            }

            @Override
            public Row next() {
                while(it.hasNext()) {
                    Routine routine = it.next();
                    if(isAccessible(session, routine.getName())) {
                        String routineType = (routine.getName().inSystemSchema() ? "SYSTEM " : "") +
                                             (routine.isProcedure() ? "PROCEDURE" : "FUNCTION");
                        return new ValuesRow(rowType,
                                            null,
                                             routine.getName().getSchemaName(),
                                             routine.getName().getTableName(),
                                            null,
                                             routine.getName().getSchemaName(),
                                             routine.getName().getTableName(),
                                             routineType,
                                             null, null, null,                  // module catalog/schema/name
                                             null, null, null,                  // udt catalog/schema/name
                                             routine.getLanguage().equals("SQL") ? "SQL" : "EXTERNAL", // body
                                             routine.getDefinition(),                           // definition
                                             routine.getExternalName(),                         //external name
                                             routine.getLanguage(),                             //language
                                             routine.getCallingConvention().name(), //parameter_style
                                             boolResult(false),                     //is deterministic
                                             (routine.getSQLAllowed() == null) ? null : routine.getSQLAllowed().name().replace('_', ' '),
                                             routine.isProcedure() ? null : boolResult(!routine.isCalledOnNullInput()),
                                             null, //sql path
                                             boolResult(true),      // schema level routine
                                             (long)(routine.getDynamicResultSets()),
                                             null, null, // defined cast, implicit invoke
                                             null, //security type
                                             null, //as locator
                                             boolResult(false), //is udt dependent
                                             null, //created timestamp
View Full Code Here


                            break;
                        }
                    }
                    if (!routinesIt.hasNext())
                        return null;
                    Routine routine = routinesIt.next();
                    if (!isAccessible(session, routine.getName()))
                        continue;
                    paramsIt = routine.getParameters().iterator();
                    ordinal = 0;
                    param = routine.getReturnValue();
                    if (param != null) {
                        ordinal++;
                        break;
                    }
                }
View Full Code Here

            }

            @Override
            public Row next() {
                while (it.hasNext()) {
                    Routine routine = it.next();
                    if (!isAccessible(session, routine.getName()))
                        continue;
                    SQLJJar jar = routine.getSQLJJar();
                    if (jar != null) {
                        return new ValuesRow(rowType,
                                            null,       // routine catalog
                                             routine.getName().getSchemaName(),
                                             routine.getName().getTableName(),
                                            null,       // jar catalog
                                             jar.getName().getSchemaName(),
                                             jar.getName().getTableName(),
                                             ++rowCounter /*hidden pk*/);
                    }
View Full Code Here

                    case PROCEDURE:
                    case FUNCTION:
                        stmtOkay = true;
                        {
                            TableName routineName = DDLHelper.convertName(server.getDefaultSchemaName(), dropAlias.getObjectName());
                            Routine routine = server.getAIS().getRoutine(routineName);
                            if (routine != null) {
                                SQLJJar sqljjar = routine.getSQLJJar();
                                thisjarOkay = ((sqljjar != null) &&
                                               jarName.equals(sqljjar.getName()));
                            }
                        }
                        break;
View Full Code Here

    protected ScriptEngineManager getManager(Session session) {
        return engineProvider.getManager();
    }

    protected synchronized CacheEntry getEntry(Session session, TableName routineName) {
        Routine routine = dxlService.ddlFunctions().getAIS(session).getRoutine(routineName);
        if (null == routine)
            throw new NoSuchRoutineException(routineName);
        long currentVersion = routine.getVersion();       
        CacheEntry entry = cache.get(routineName);
        if ((entry != null) && (entry.version == currentVersion))
            return entry;
        ScriptEngine engine = getManager(session).getEngineByName(routine.getLanguage());
        if (engine == null)
            throw new ExternalRoutineInvocationException(routineName, "Cannot find " + routine.getLanguage()
                    + " script engine");
        entry = new CacheEntry(routine, engine);
        cache.put(routineName, entry);
        return entry;
    }
View Full Code Here

                        operands.add(toExpression(javaValue, null, false, projects));
                    }
                }
                DataTypeDescriptor sqlType = valueNode.getType();
                TInstance type = typesTranslator.typeForSQLType(sqlType);
                Routine routine = (Routine)methodCall.getUserData();
                if (routine != null) {
                    if (asCondition)
                        return new RoutineCondition(routine, operands,
                                sqlType, valueNode, type);
                    else
View Full Code Here

    public static PostgresStatement statement(PostgresServerSession server,
                                              ServerCallInvocation invocation,
                                              List<ParameterNode> params,
                                              int[] paramTypes) {
        Routine routine = invocation.getRoutine();
        List<String> columnNames;
        List<PostgresType> columnTypes;
        List<Column> aisColumns;
        switch (server.getOutputFormat()) {
        case JSON:
        case JSON_WITH_META_DATA:
            columnNames = jsonColumnNames();
            columnTypes = jsonColumnTypes(server.typesTranslator().typeForString());
            aisColumns = jsonAISColumns();
            break;
        default:
            columnTypes = columnTypes(routine);
            if (columnTypes.isEmpty()) {
                columnTypes = null;
                columnNames = null;
                aisColumns = null;
            }
            else {
                columnNames = columnNames(routine);
                aisColumns = Collections.nCopies(columnTypes.size(), null);
            }
            break;
        }
        PostgresType[] parameterTypes;
        if ((params == null) || params.isEmpty())
            parameterTypes = null;
        else
            parameterTypes = parameterTypes(invocation, params.size(), paramTypes);
        switch (routine.getCallingConvention()) {
        case JAVA:
            return PostgresJavaMethod.statement(server, invocation,
                                                columnNames, columnTypes, aisColumns,
                                                parameterTypes);
        case SCRIPT_FUNCTION_JAVA:
View Full Code Here

    @Override
    public void output(ServerJavaRoutine javaRoutine) throws IOException {
        messenger.beginMessage(PostgresMessages.DATA_ROW_TYPE.code());
        messenger.writeShort(ncols);
        int fieldIndex = 0;
        Routine routine = javaRoutine.getInvocation().getRoutine();
        List<Parameter> params = routine.getParameters();
        for (int i = 0; i < params.size(); i++) {
            Parameter param = params.get(i);
            if (param.getDirection() == Parameter.Direction.IN) continue;
            output(javaRoutine, param, i, fieldIndex++);
        }
        if (routine.getReturnValue() != null) {
            output(javaRoutine, routine.getReturnValue(), ServerJavaValues.RETURN_VALUE_INDEX, fieldIndex++);
        }
        messenger.sendMessage();
    }
View Full Code Here

            // will be lazily loaded as necessary
            return expression;
        }

        ExpressionNode handleRoutineExpression(RoutineExpression expression) {
            Routine routine = expression.getRoutine();
            List<ExpressionNode> operands = expression.getOperands();
            for (int i = 0; i < operands.size(); i++) {
                ExpressionNode operand = castTo(operands.get(i), routine.getParameters().get(i).getType(),
                                                folder, parametersSync);
                operands.set(i, operand);
            }
            TPreptimeValue tpv = new TPreptimeValue(routine.getReturnValue().getType());
            expression.setPreptimeValue(tpv);
            return expression;
        }
View Full Code Here

            }
            return col;
        }

        protected ExpressionNode routineExpression(RoutineExpression expr) {
            Routine routine = expr.getRoutine();
            boolean allConstant = true, anyNull = false;
            for (ExpressionNode operand : expr.getOperands()) {
                switch (isConstant(operand)) {
                case NULL:
                    anyNull = true;
                    /* falls through */
                case VARIABLE:
                    allConstant = false;
                    break;
                }
            }
            if (allConstant && routine.isDeterministic())
                return evalNow(expr);
            if (anyNull && !routine.isCalledOnNullInput()) {
                return newBooleanConstant(null, expr);
            }
            return expr;
        }
View Full Code Here

TOP

Related Classes of com.foundationdb.ais.model.Routine

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.