提交 ddf48534 authored 作者: Thomas Mueller's avatar Thomas Mueller

Documentation.

上级 2ae9a839
......@@ -1446,7 +1446,7 @@ In addition to the built-in functions, this database supports user-defined Java
In this database, Java functions can be used as stored procedures as well.
A function must be declared (registered) before it can be used.
A function can be defined using source code, or as a reference to
a compiled class that is available in the classpath. By default, the
a compiled class that is available in the classpath. By default, the
function aliases are stored in the current schema.
</p>
......
......@@ -4383,23 +4383,22 @@ public class Parser {
}
private FunctionAlias findFunctionAlias(String schema, String aliasName) {
FunctionAlias functionAlias = database.getSchema(schema).findFunction(aliasName);
if (functionAlias != null) {
return functionAlias;
}
String[] schemaNames = session.getSchemaSearchPath();
if (schemaNames != null) {
for (String n : schemaNames) {
functionAlias = database.getSchema(n).findFunction(aliasName);
if (functionAlias != null) {
return functionAlias;
}
}
}
return null;
FunctionAlias functionAlias = database.getSchema(schema).findFunction(aliasName);
if (functionAlias != null) {
return functionAlias;
}
String[] schemaNames = session.getSchemaSearchPath();
if (schemaNames != null) {
for (String n : schemaNames) {
functionAlias = database.getSchema(n).findFunction(aliasName);
if (functionAlias != null) {
return functionAlias;
}
}
}
return null;
}
private Sequence findSequence(String schema, String sequenceName) {
Sequence sequence = database.getSchema(schema).findSequence(sequenceName);
if (sequence != null) {
......
......@@ -46,9 +46,9 @@ public class CreateAggregate extends DefineCommand {
}
public void setSchema(Schema schema) {
this.schema = schema;
this.schema = schema;
}
public void setName(String name) {
this.name = name;
}
......
......@@ -58,7 +58,7 @@ public class CreateFunctionAlias extends SchemaCommand {
}
/**
* Set the qualified method name after removing whitespaces.
* Set the qualified method name after removing whitespace.
*
* @param method the qualified method name
*/
......
......@@ -36,7 +36,7 @@ public class DropFunctionAlias extends SchemaCommand {
throw DbException.get(ErrorCode.FUNCTION_ALIAS_NOT_FOUND_1, aliasName);
}
} else {
db.removeSchemaObject(session, functionAlias);
db.removeSchemaObject(session, functionAlias);
}
return 0;
}
......
......@@ -1956,6 +1956,12 @@ public class Database implements DataHandler {
return exclusiveSession;
}
/**
* Set the session that can exclusively access the database.
*
* @param session the session
* @param closeOthers whether other sessions are closed
*/
public void setExclusiveSession(Session session, boolean closeOthers) {
this.exclusiveSession = session;
if (closeOthers) {
......
......@@ -52,7 +52,7 @@ public class FunctionAlias extends SchemaObjectBase {
/**
* Create a new alias based on a method name.
*
* @param db the database
* @param schema the schema
* @param id the id
* @param name the name
* @param javaClassMethod the class and method name
......@@ -75,7 +75,7 @@ public class FunctionAlias extends SchemaObjectBase {
/**
* Create a new alias based on source code.
*
* @param db the database
* @param schema the schema
* @param id the id
* @param name the name
* @param source the source code
......
......@@ -124,8 +124,8 @@ public class Schema extends DbObjectBase {
database.removeSchemaObject(session, obj);
}
while (functions != null && functions.size() > 0) {
FunctionAlias obj = (FunctionAlias) functions.values().toArray()[0];
database.removeSchemaObject(session, obj);
FunctionAlias obj = (FunctionAlias) functions.values().toArray()[0];
database.removeSchemaObject(session, obj);
}
database.removeMeta(session, getId());
owner = null;
......@@ -169,7 +169,7 @@ public class Schema extends DbObjectBase {
break;
case DbObject.FUNCTION_ALIAS:
result = functions;
break;
break;
default:
throw DbException.throwInternalError("type=" + type);
}
......@@ -302,7 +302,7 @@ public class Schema extends DbObjectBase {
public Constant findConstant(String constantName) {
return constants.get(constantName);
}
/**
* Try to find a user defined function with this name. This method returns
* null if no object with this name exists.
......@@ -486,14 +486,14 @@ public class Schema extends DbObjectBase {
public ArrayList<Table> getAllTablesAndViews() {
return New.arrayList(tablesAndViews.values());
}
/**
* Get all functions.
*
* @return a (possible empty) list of all objects
*/
*/
public ArrayList<FunctionAlias> getAllFunctionAliases() {
return New.arrayList(functions.values());
return New.arrayList(functions.values());
}
/**
......
......@@ -295,9 +295,10 @@ java org.h2.test.TestAll timer
// System.setProperty("h2.lobInDatabase", "true");
// System.setProperty("h2.analyzeAuto", "100");
// System.setProperty("h2.pageSize", "64");
/*
// System.setProperty("h2.pageSize", "64");
test with small freeList pages, page size 64
test services on Windows
......
......@@ -162,8 +162,8 @@ public class TestFunctions extends TestBase implements AggregateFunction {
rs.next();
assertEquals(0, rs.getInt(1));
stat.execute("drop alias getCount");
rs = stat.executeQuery("SELECT * FROM INFORMATION_SCHEMA.FUNCTION_ALIASES WHERE UPPER(ALIAS_NAME) = 'GETCOUNT'");
assertEquals(false, rs.next());
rs = stat.executeQuery("SELECT * FROM INFORMATION_SCHEMA.FUNCTION_ALIASES WHERE UPPER(ALIAS_NAME) = 'GET' || 'COUNT'");
assertFalse(rs.next());
stat.execute("create alias reverse deterministic for \""+getClass().getName()+".reverse\"");
rs = stat.executeQuery("select reverse(x) from system_range(700, 700)");
rs.next();
......@@ -473,10 +473,6 @@ public class TestFunctions extends TestBase implements AggregateFunction {
conn.close();
}
/**
* White spaces in javaMethodDescriptors are deleted during
* CreateFunctionAlias, and all further processing is normalized.
*/
private void testWhiteSpacesInParameters() throws SQLException {
deleteDb("functions");
Connection conn = getConnection("functions");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论