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