Package com.foundationdb.ais.model

Examples of com.foundationdb.ais.model.Routine


    public void callProcedure(PrintWriter writer, HttpServletRequest request, String jsonpArgName,
                                 TableName procName, Map<String,List<String>> queryParams, String content) throws SQLException {
        ENTITY_CALL.in();
        try (JDBCConnection conn = jdbcConnection(request, procName.getSchemaName());
             JDBCCallableStatement call = conn.prepareCall(procName)) {
            Routine routine = call.getRoutine();
            switch (routine.getCallingConvention()) {
            case SCRIPT_FUNCTION_JSON:
            case SCRIPT_BINDINGS_JSON:
                callJsonProcedure(writer, request, jsonpArgName, call, queryParams, content);
                break;
            default:
View Full Code Here


    }

    private void dropRoutineCommon(Session session, TableName routineName, boolean inSystem) {
        final AkibanInformationSchema oldAIS = getAISForChange(session, !inSystem);
        checkSystemSchema(routineName, inSystem);
        Routine routine = oldAIS.getRoutine(routineName);
        if (routine == null)
            throw new NoSuchRoutineException(routineName);
        final AkibanInformationSchema newAIS = aisCloner.clone(oldAIS);
        routine = newAIS.getRoutine(routineName);
        newAIS.removeRoutine(routineName);
        if (routine.getSQLJJar() != null)
            routine.getSQLJJar().removeRoutine(routine); // Keep accurate in memory.
        if (inSystem)
            unStoredAISChange(session, newAIS);
        else {
            final String schemaName = routineName.getSchemaName();
            saveAISChange(session, newAIS, Collections.singleton(schemaName));
View Full Code Here

    }

    protected void outputMetaData(AkibanAppender appender) throws IOException, SQLException {
        encoder.appendString("[");
        boolean first = true;
        Routine routine = ((PostgresJavaRoutine)statement).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;
            String name = param.getName();
            if (name == null)
                name = String.format("arg%d", i+1);
            outputParameterMetaData(name, param, appender, first);
            first = false;
        }       
        if (routine.getReturnValue() != null) {
            outputParameterMetaData("return", routine.getReturnValue(), appender, first);
            first = false;
        }
        int i = 0;
        for (ResultSet resultSet : resultSets) {
            i++;
View Full Code Here

    protected void javaValueNode(JavaValueNode javaValue) {
        if ((javaValue instanceof StaticMethodCallNode) &&
            (functionDefined != null)) {
            StaticMethodCallNode methodCall = (StaticMethodCallNode)javaValue;
            Routine routine = null;
            if ((methodCall.getProcedureName() != null) &&
                (methodCall.getProcedureName().hasSchema())) {
                // Qualified name is always a routine and an immediate error if not.
                routine = ais.getRoutine(methodCall.getProcedureName().getSchemaName(),
                                         methodCall.getProcedureName().getTableName());
                if ((routine == null) || !context.isAccessible(routine.getName())) {
                    throw new NoSuchFunctionException(methodCall.getProcedureName().toString());
                }
            }
            else if (!functionDefined.isDefined(methodCall.getMethodName())) {
                // Unqualified only if not a built-in function and error deferred.
                routine = ais.getRoutine(defaultSchemaName, methodCall.getMethodName());
                if ((routine != null) && !context.isAccessible(routine.getName())) {
                    routine = null;
                }
            }
            if (routine != null) {
                if (routine.getReturnValue() == null) {
                    throw new ProcedureCalledAsFunctionException(routine.getName());
                }
                methodCall.setUserData(routine);
            }
        }
    }
View Full Code Here

    }

    protected void outputResults(ServerJavaRoutine javaRoutine, AkibanAppender appender) throws IOException {
        encoder.appendString("{");
        boolean first = true;
        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;
            String name = param.getName();
            if (name == null)
                name = String.format("arg%d", i+1);
            Object value = javaRoutine.getOutParameter(param, i);
            PostgresType pgType = PostgresType.fromAIS(param);
            outputValue(name, value, pgType, appender, first);
            first = false;
        }
        if (routine.getReturnValue() != null) {
            Object value = javaRoutine.getOutParameter(routine.getReturnValue(),
                                                       ServerJavaValues.RETURN_VALUE_INDEX);
            PostgresType pgType = PostgresType.fromAIS(routine.getReturnValue());
            outputValue("return", value, pgType, appender, first);
            first = false;
        }
        int nresults = 0;
        while (!resultSets.isEmpty()) {
View Full Code Here

    }

    protected DataTypeDescriptor methodCallNode(MethodCallNode methodCall)
            throws StandardException {
        if (methodCall.getUserData() != null) {
            Routine routine = (Routine)methodCall.getUserData();
            return routine.getReturnValue().getType().dataTypeDescriptor();
        }
        if ((methodCall.getMethodParameters() == null) ||
            (methodCall.getMethodParameters().length == 0)) {
            return noArgFunction(methodCall.getMethodName());
        }
View Full Code Here

            routineName = methodCall.getProcedureName().getTableName();
        }
        if (schemaName == null) {
            schemaName = server.getDefaultSchemaName();
        }
        Routine routine = server.getAIS().getRoutine(schemaName, routineName);
        if (routine == null)
            throw new NoSuchRoutineException(schemaName, routineName);
        Object[] constantArgs = null;
        int[] parameterArgs = null;
        JavaValueNode[] margs = methodCall.getMethodParameters();
View Full Code Here

        }
        return new ServerCallInvocation(routine, constantArgs, parameterArgs);
    }

    public static ServerCallInvocation of(ServerSession server, TableName routineName) {
        Routine routine = server.getAIS().getRoutine(routineName);
        if (routine == null)
            throw new NoSuchRoutineException(routineName);
        int nparams = routine.getParameters().size();
        Object[] constantArgs = new Object[nparams];
        int[] parameterArgs = new int[nparams];
        for (int i = 0; i < nparams; i++) {
            parameterArgs[i] = i;
        }
View Full Code Here

        builder.routineDeterministic(schemaName, routineName,
                                     aliasInfo.isDeterministic());
        builder.routineCalledOnNullInput(schemaName, routineName,
                                         aliasInfo.calledOnNullInput());
       
        Routine routine = builder.akibanInformationSchema().getRoutine(tableName);
        boolean replaceExisting = createAlias.isCreateOrReplace();
        ddlFunctions.createRoutine(session, routine, replaceExisting);
        if (replaceExisting)
            routineLoader.checkUnloadRoutine(session, tableName);
    }
View Full Code Here

                                   Session session,
                                   String defaultSchemaName,
                                   DropAliasNode dropRoutine,
                                   QueryContext context) {
        TableName routineName = DDLHelper.convertName(defaultSchemaName, dropRoutine.getObjectName());
        Routine routine = ddlFunctions.getAIS(session).getRoutine(routineName);

        if((routine == null) &&
           skipOrThrow(context, dropRoutine.getExistenceCheck(), routine, new NoSuchRoutineException(routineName))) {
            return;
        }
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.