use of com.wplatform.ddal.command.Parser in project jdbc-shards by wplatform.
the class Column method getCheckConstraint.
/**
* Get the check constraint expression for this column if set.
*
* @param session the session
* @param asColumnName the column name to use
* @return the constraint expression
*/
public Expression getCheckConstraint(Session session, String asColumnName) {
if (checkConstraint == null) {
return null;
}
Parser parser = new Parser(session);
String sql;
synchronized (this) {
String oldName = name;
name = asColumnName;
sql = checkConstraint.getSQL();
name = oldName;
}
Expression expr = parser.parseExpression(sql);
return expr;
}
use of com.wplatform.ddal.command.Parser in project jdbc-shards by wplatform.
the class Session method prepareLocal.
/**
* Parse and prepare the given SQL statement. This method also checks if the
* connection has been closed.
*
* @param sql the SQL statement
* @return the prepared statement
*/
public Command prepareLocal(String sql) {
if (closed) {
throw DbException.get(ErrorCode.CONNECTION_BROKEN_1, "session closed");
}
Command command;
if (queryCacheSize > 0) {
if (queryCache == null) {
queryCache = SmallLRUCache.newInstance(queryCacheSize);
// modificationMetaID = database.getModificationMetaId();
} else {
// ignore table structure modification
/*
* long newModificationMetaID =
* database.getModificationMetaId(); if (newModificationMetaID
* != modificationMetaID) { queryCache.clear();
* modificationMetaID = newModificationMetaID; }
*/
command = queryCache.get(sql);
if (command != null && command.canReuse()) {
command.reuse();
return command;
}
}
}
Parser parser = new Parser(this);
command = parser.prepareCommand(sql);
if (queryCache != null) {
if (command.isCacheable()) {
queryCache.put(sql, command);
}
}
return command;
}
use of com.wplatform.ddal.command.Parser in project jdbc-shards by wplatform.
the class Session method prepare.
/**
* Parse and prepare the given SQL statement.
*
* @param sql the SQL statement
* @param rightsChecked true if the rights have already been checked
* @return the prepared statement
*/
public Prepared prepare(String sql, boolean rightsChecked) {
Parser parser = new Parser(this);
parser.setRightsChecked(rightsChecked);
return parser.prepare(sql);
}
use of com.wplatform.ddal.command.Parser in project jdbc-shards by wplatform.
the class Function method getSequence.
private Sequence getSequence(Session session, Value v0, Value v1) {
String schemaName, sequenceName;
if (v1 == null) {
Parser p = new Parser(session);
String sql = v0.getString();
Expression expr = p.parseExpression(sql);
if (expr instanceof ExpressionColumn) {
ExpressionColumn seq = (ExpressionColumn) expr;
schemaName = seq.getOriginalTableAliasName();
if (schemaName == null) {
schemaName = session.getCurrentSchemaName();
sequenceName = sql;
} else {
sequenceName = seq.getColumnName();
}
} else {
throw DbException.getSyntaxError(sql, 1);
}
} else {
schemaName = v0.getString();
sequenceName = v1.getString();
}
Schema s = database.findSchema(schemaName);
if (s == null) {
schemaName = StringUtils.toUpperEnglish(schemaName);
s = database.getSchema(schemaName);
}
Sequence seq = s.findSequence(sequenceName);
if (seq == null) {
sequenceName = StringUtils.toUpperEnglish(sequenceName);
seq = s.getSequence(sequenceName);
}
return seq;
}