private static Function lookupUserDefinedFunctionDecl(MetadataTransactionContext mdTxnCtx, FunctionSignature signature) throws AlgebricksException { if (signature.getNamespace() == null) { return null; } return MetadataManager.INSTANCE.getFunction(mdTxnCtx, signature); }
MetadataManager.INSTANCE.getFunction(metadataProvider.getMetadataTxnContext(), signature); if (function == null) { return null;
protected void handleFunctionDropStatement(MetadataProvider metadataProvider, Statement stmt) throws Exception { FunctionDropStatement stmtDropFunction = (FunctionDropStatement) stmt; SourceLocation sourceLoc = stmtDropFunction.getSourceLocation(); FunctionSignature signature = stmtDropFunction.getFunctionSignature(); signature.setNamespace(getActiveDataverseName(signature.getNamespace())); MetadataTransactionContext mdTxnCtx = MetadataManager.INSTANCE.beginTransaction(); metadataProvider.setMetadataTxnContext(mdTxnCtx); MetadataLockUtil.functionStatementBegin(lockManager, metadataProvider.getLocks(), signature.getNamespace(), signature.getNamespace() + "." + signature.getName()); try { Function function = MetadataManager.INSTANCE.getFunction(mdTxnCtx, signature); // If function == null && stmtDropFunction.getIfExists() == true, commit txn directly. if (function == null && !stmtDropFunction.getIfExists()) { throw new CompilationException(ErrorCode.UNKNOWN_FUNCTION, sourceLoc, signature); } else if (function != null) { if (isFunctionUsed(mdTxnCtx, signature, null)) { throw new MetadataException(ErrorCode.METADATA_DROP_FUCTION_IN_USE, sourceLoc, signature); } else { MetadataManager.INSTANCE.dropFunction(mdTxnCtx, signature); } } MetadataManager.INSTANCE.commitTransaction(mdTxnCtx); } catch (Exception e) { abort(e, e, mdTxnCtx); throw e; } finally { metadataProvider.getLocks().unlock(); } }
List<FunctionSignature> appliedFunctions = cfs.getAppliedFunctions(); for (FunctionSignature func : appliedFunctions) { if (MetadataManager.INSTANCE.getFunction(mdTxnCtx, func) == null) { throw new CompilationException(ErrorCode.FEED_CONNECT_FEED_APPLIED_INVALID_FUNCTION, sourceLoc, func.getName());