提交 d7adee0b authored 作者: Noel Grandin's avatar Noel Grandin

spellcheck

上级 0c4ecec6
......@@ -702,24 +702,24 @@ public class Parser {
return getSchema(schemaName);
}
/*
* Gets the current schema for scenarios that need a guranteed, non-null schema object.
*
* Gets the current schema for scenarios that need a guaranteed, non-null schema object.
*
* This routine is solely here
* because of the function readIdentifierWithSchema(String defaultSchemaName) - which
* because of the function readIdentifierWithSchema(String defaultSchemaName) - which
* is often called with a null parameter (defaultSchemaName) - then 6 lines into the function
* that routine nullifies the state field schemaName - which I believe is a bug.
*
*
* There are about 7 places where "readIdentifierWithSchema(null)" is called in this file.
*
*
* In other words when is it legal to not have an active schema defined by schemaName ?
* I don't think it's ever a valid case. I don't understand when that would be allowed.
* I spent a long time trying to figure this out.
* I spent a long time trying to figure this out.
* As another proof of this point, the command "SET SCHEMA=NULL" is not a valid command.
*
* I did try to fix this in readIdentifierWithSchema(String defaultSchemaName)
*
* I did try to fix this in readIdentifierWithSchema(String defaultSchemaName)
* - but every fix I tried cascaded so many unit test errors - so
* I gave up. I think this needs a bigger effort to fix his, as part of bigger, dedicated story.
*
*
*/
private Schema getSchemaWithDefault() {
if(schemaName==null){
......@@ -827,7 +827,7 @@ public class Parser {
Expression limit = readTerm().optimize(session);
command.setLimit(limit);
}
setSQL(command, "UPDATE", start);
setSQL(command, "UPDATE", start);
}
private TableFilter readSimpleTableFilter(int orderInFrom) {
......@@ -858,8 +858,8 @@ public class Parser {
}
return new TableFilter(session, table, alias, rightsChecked,
currentSelect, orderInFrom, null);
}
}
private Delete parseDelete() {
Delete command = new Delete(session);
Expression limit = null;
......@@ -1073,7 +1073,7 @@ public class Parser {
read();
return select;
}
private Prepared parseMerge() {
Merge command = new Merge(session);
......@@ -1082,9 +1082,9 @@ public class Parser {
read("INTO");
List<String> excludeIdentifiers = Arrays.asList("USING","KEY","VALUES");
TableFilter targetTableFilter = readSimpleTableFilterWithAliasExcludes(0,excludeIdentifiers);
command.setTargetTableFilter(targetTableFilter);
command.setTargetTableFilter(targetTableFilter);
Table table = command.getTargetTable();
if (readIf("USING")){
return parseMergeUsing(command,start);
}
......@@ -1126,7 +1126,7 @@ public class Parser {
private MergeUsing parseMergeUsing(Merge oldCommand, int start) {
MergeUsing command = new MergeUsing(oldCommand);
currentPrepared = command;
if (readIf("(")) {
/* a select query is supplied */
if (isSelect()) {
......@@ -1134,20 +1134,20 @@ public class Parser {
read(")");
}
command.setQueryAlias(readFromAlias(null, Arrays.asList("ON")));
String[] querySQLOutput = new String[]{null};
List<Column> columnTemplateList = createQueryColumnTemplateList(null, command.getQuery(), querySQLOutput);
TableView temporarySourceTableView = createTemporarySessionView(command.getQueryAlias(), querySQLOutput[0], columnTemplateList, false/*no recursion*/, false/* do not add to session*/);
TableView temporarySourceTableView = createTemporarySessionView(command.getQueryAlias(), querySQLOutput[0], columnTemplateList, false/*no recursion*/, false/* do not add to session*/);
TableFilter sourceTableFilter = new TableFilter(session, temporarySourceTableView, command.getQueryAlias(), rightsChecked,
(Select) command.getQuery(), 0, null);
command.setSourceTableFilter(sourceTableFilter);
command.setSourceTableFilter(sourceTableFilter);
}
else{
/* Its a table name, simulate a query by building a select query for the table */
List<String> excludeIdentifiers = Arrays.asList("ON");
TableFilter sourceTableFilter = readSimpleTableFilterWithAliasExcludes(0,excludeIdentifiers);
command.setSourceTableFilter(sourceTableFilter);
command.setSourceTableFilter(sourceTableFilter);
StringBuilder buff = new StringBuilder(
"SELECT * FROM "+sourceTableFilter.getTable().getName());
if(sourceTableFilter.getTableAlias()!=null){
......@@ -1155,14 +1155,14 @@ public class Parser {
}
Prepared preparedQuery = prepare(session, buff.toString(), null/*paramValues*/);
command.setQuery((Select)preparedQuery);
}
}
read("ON");
read("(");
Expression condition = readExpression();
command.setOnCondition(condition);
read(")");
if(readIfAll("WHEN","MATCHED","THEN")){
int startMatched = lastParseIndex;
if (readIf("UPDATE")){
......@@ -1180,7 +1180,7 @@ public class Parser {
deleteCommand.setTableFilter(filter);
parseDeleteGivenTable(deleteCommand,null,startMatched);
command.setDeleteCommand(deleteCommand);
}
}
}
if(readIfAll("WHEN","NOT","MATCHED","THEN")){
if (readIf("INSERT")){
......@@ -1192,7 +1192,7 @@ public class Parser {
}
setSQL(command, "MERGE", start);
// build and prepare the targetMatchQuery ready to test each rows existence in the target table (using source row to match)
StringBuffer targetMatchQuerySQL = new StringBuffer("SELECT _ROWID_ FROM "+command.getTargetTable().getName());
if(command.getTargetTableFilter().getTableAlias()!=null){
......@@ -1209,7 +1209,7 @@ public class Parser {
// preparedTargetMatchQuery.setExpressions(selectList);
// preparedTargetMatchQuery.init();
command.setTargetMatchQuery((Select)parse(targetMatchQuerySQL.toString()));
// Select command = new Select(session);
// currentSelect = command;
// TableFilter filter = parseValuesTable(0);
......@@ -1217,8 +1217,8 @@ public class Parser {
// list.add(new Wildcard(null, null));
// command.setExpressions(list);
// command.addTableFilter(filter, true);
// command.init();
// command.init();
return command;
}
......@@ -1492,7 +1492,7 @@ public class Parser {
}
return alias;
}
private String readFromAlias(String alias) {
// left and right are not keywords (because they are functions as
// well)
......@@ -1930,7 +1930,7 @@ public class Parser {
private Query parseSelect() {
// This method and its subroutines sometimes resets the schema name - the try-finally block
// makes sure it is reverted if nulled
// makes sure it is reverted if nulled
//String savedSchemaName = schemaName;
Query command = null;
//try{
......@@ -3513,7 +3513,7 @@ public class Parser {
}
return true;
}
private boolean isToken(String token) {
boolean result = equalsToken(token, currentToken) &&
!currentTokenQuoted;
......@@ -3534,7 +3534,7 @@ public class Parser {
}
return false;
}
private boolean equalsTokenIgnoreCase(String a, String b) {
if (a == null) {
return b == null;
......@@ -3545,10 +3545,10 @@ public class Parser {
}
return false;
}
private boolean isTokenInList(Collection<String> upperCaseTokenList){
String upperCaseCurrentToken = currentToken.toUpperCase();
return upperCaseTokenList.contains(upperCaseCurrentToken);
return upperCaseTokenList.contains(upperCaseCurrentToken);
}
private void addExpected(String token) {
......@@ -5259,7 +5259,7 @@ public class Parser {
* Creates a list of column templates from a query (usually from WITH query, but could be any query)
* @param cols - an optional list of column names (can be specified by WITH clause overriding usual select names)
* @param theQuery - the query object we want the column list for
* @param querySQLOutput - array of length 1 to receive extra 'output' field in addition to return value
* @param querySQLOutput - array of length 1 to receive extra 'output' field in addition to return value
* - containing the SQL query of the Query object
* @return a list of column object returned by withQuery
*/
......
......@@ -23,7 +23,6 @@ import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.UUID;
import org.h2.api.Trigger;
import org.h2.command.Parser;
import org.h2.engine.Session;
......@@ -266,7 +265,7 @@ public class FullText {
removeAllTriggers(conn, TRIGGER_PREFIX);
FullTextSettings setting = FullTextSettings.getInstance(conn);
setting.removeAllIndexes();
setting.clearInored();
setting.clearIgnored();
setting.clearWordList();
}
......@@ -1151,8 +1150,8 @@ public class FullText {
return buff.toString();
}
private PreparedStatement getStatement(Connection conn, int indx) throws SQLException {
return useOwnConnection ? conn.prepareStatement(SQL[indx]) : prepStatements[indx];
private PreparedStatement getStatement(Connection conn, int index) throws SQLException {
return useOwnConnection ? conn.prepareStatement(SQL[index]) : prepStatements[index];
}
}
......
......@@ -13,7 +13,6 @@ import java.sql.Statement;
import java.util.Collections;
import java.util.Map;
import java.util.Set;
import org.h2.util.New;
import org.h2.util.SoftHashMap;
......@@ -69,7 +68,7 @@ final class FullTextSettings {
/**
* Clear set of ignored words
*/
public void clearInored() {
public void clearIgnored() {
synchronized (ignoreList) {
ignoreList.clear();
}
......
......@@ -17,7 +17,7 @@ import org.h2.test.TestBase;
*/
public class TestMergeUsing extends TestBase implements Trigger {
private static final String GATHER_ORDERED_RESULTS_SQL = "SELECT ID, NAME FROM PARENT ORDER BY ID ASC";
private static int triggerTestingUpdateCount = 0;
......@@ -34,7 +34,7 @@ public class TestMergeUsing extends TestBase implements Trigger {
@Override
public void test() throws Exception {
// Simple ID,NAME inserts, target table with PK initially empty
testMergeUsing(
"CREATE TABLE PARENT(ID INT, NAME VARCHAR, PRIMARY KEY(ID) );",
......@@ -117,8 +117,8 @@ public class TestMergeUsing extends TestBase implements Trigger {
GATHER_ORDERED_RESULTS_SQL,
"SELECT X AS ID, 'Marcy'||X||X AS NAME FROM SYSTEM_RANGE(2,2) UNION ALL SELECT X AS ID, 'Marcy'||X AS NAME FROM SYSTEM_RANGE(3,3)",
3
);
);
// Only insert clause, no update or delete clauses
testMergeUsing(
"CREATE TABLE PARENT AS (SELECT X AS ID, 'Marcy'||X AS NAME FROM SYSTEM_RANGE(1,1) );"+
......@@ -146,8 +146,8 @@ public class TestMergeUsing extends TestBase implements Trigger {
"SELECT X AS ID, 'Marcy'||X AS NAME FROM SYSTEM_RANGE(1,1) WHERE X<0",
2
);
// Duplicate source keys but different ROWID update - so no error
// SQL standard says duplicate or repeated updates of same row in same statement should cause errors - but because first row is updated, deleted (on source row 1) then inserted (on source row 2)
// Duplicate source keys but different ROWID update - so no error
// SQL standard says duplicate or repeated updates of same row in same statement should cause errors - but because first row is updated, deleted (on source row 1) then inserted (on source row 2)
// it's considered different - with respect to to ROWID - so no error
// One insert, one update one delete happens (on same row) , target table missing PK, no source or target alias
testMergeUsing(
......@@ -158,7 +158,7 @@ public class TestMergeUsing extends TestBase implements Trigger {
"SELECT 1 AS ID, 'Marcy'||X||X UNION ALL SELECT 1 AS ID, 'Marcy2'",
2
);
// Multiple update on same row: SQL standard says duplicate or repeated updates in same statement should cause errors -but because first row is updated, delete then insert it's considered different
// One insert, one update one delete happens (on same row, which is okay), then another update (which is illegal)target table missing PK, no source or target alias
testMergeUsingException(
......@@ -179,7 +179,7 @@ public class TestMergeUsing extends TestBase implements Trigger {
"SELECT X AS ID, 'Marcy'||X||X AS NAME FROM SYSTEM_RANGE(2,2) UNION ALL SELECT X AS ID, 'Marcy'||X AS NAME FROM SYSTEM_RANGE(3,3)",
3,
"Duplicate key updated 3 rows at once, only 1 expected"
);
);
// Missing target columns in ON expression
testMergeUsingException(
"CREATE TABLE PARENT AS (SELECT 1 AS ID, 'Marcy'||X AS NAME FROM SYSTEM_RANGE(1,3) );"+
......@@ -189,7 +189,7 @@ public class TestMergeUsing extends TestBase implements Trigger {
"SELECT X AS ID, 'Marcy'||X||X AS NAME FROM SYSTEM_RANGE(2,2) UNION ALL SELECT X AS ID, 'Marcy'||X AS NAME FROM SYSTEM_RANGE(3,3)",
3,
"No references to target columns found in ON clause"
);
);
// Missing source columns in ON expression
testMergeUsingException(
"CREATE TABLE PARENT AS (SELECT 1 AS ID, 'Marcy'||X AS NAME FROM SYSTEM_RANGE(1,3) );"+
......@@ -199,7 +199,7 @@ public class TestMergeUsing extends TestBase implements Trigger {
"SELECT X AS ID, 'Marcy'||X||X AS NAME FROM SYSTEM_RANGE(2,2) UNION ALL SELECT X AS ID, 'Marcy'||X AS NAME FROM SYSTEM_RANGE(3,3)",
3,
"No references to source columns found in ON clause"
);
);
// Insert does not insert correct values with respect to ON condition (inserts ID value above 100, instead)
testMergeUsingException(
"CREATE TABLE PARENT AS (SELECT 1 AS ID, 'Marcy'||X AS NAME FROM SYSTEM_RANGE(4,4) );"+
......@@ -209,7 +209,7 @@ public class TestMergeUsing extends TestBase implements Trigger {
"SELECT X AS ID, 'Marcy'||X AS NAME FROM SYSTEM_RANGE(4,4)",
1,
"Expected to find key after row inserted, but none found. Insert does not match ON condition."
);
);
// One insert, one update one delete happens, target table missing PK, triggers update all NAME fields
triggerTestingUpdateCount=0;
testMergeUsing(
......@@ -219,7 +219,7 @@ public class TestMergeUsing extends TestBase implements Trigger {
GATHER_ORDERED_RESULTS_SQL,
"SELECT 2 AS ID, 'Marcy22-updated2' AS NAME UNION ALL SELECT X AS ID, 'Marcy'||X||'-inserted'||X AS NAME FROM SYSTEM_RANGE(3,4)",
4
);
);
}
/**
......@@ -243,20 +243,20 @@ public class TestMergeUsing extends TestBase implements Trigger {
try{
stat = conn.createStatement();
stat.execute(setupSQL);
prep = conn.prepareStatement(statementUnderTest);
rowCountUpdate = prep.executeUpdate();
// compare actual results from SQL resultsset with expected results - by diffing (aka set MINUS operation)
// compare actual results from SQL result set with expected results - by diffing (aka set MINUS operation)
rs = stat.executeQuery("( "+gatherResultsSQL+" ) MINUS ( "+expectedResultsSQL+" )");
int rowCount = 0;
StringBuffer diffBuffer = new StringBuffer("");
while (rs.next()) {
rowCount++;
diffBuffer.append("|");
for(int ndx = 1; ndx <= rs.getMetaData().getColumnCount(); ndx++){
diffBuffer.append(rs.getObject(ndx));
for(int i = 1; i <= rs.getMetaData().getColumnCount(); i++){
diffBuffer.append(rs.getObject(i));
diffBuffer.append("|\n");
}
}
......@@ -289,11 +289,11 @@ public class TestMergeUsing extends TestBase implements Trigger {
e.printStackTrace();
}
assertContains(e.getMessage(),exceptionMessage);
return;
return;
}
fail("Failed to see exception with message:"+exceptionMessage);
}
@Override
public void fire(Connection conn, Object[] oldRow, Object[] newRow)
throws SQLException {
......@@ -307,7 +307,7 @@ public class TestMergeUsing extends TestBase implements Trigger {
newRow[1] = newRow[1] + "-updated"+(++triggerTestingUpdateCount);
} else if (triggerName.startsWith("DEL_BEFORE")) {
oldRow[1] = oldRow[1] + "-deleted"+(++triggerTestingUpdateCount);
}
}
}
@Override
......@@ -337,7 +337,7 @@ public class TestMergeUsing extends TestBase implements Trigger {
throw new AssertionError("triggerName: " + trigger + " type:" + type);
}
}
private String getCreateTriggerSQL(){
StringBuffer buf = new StringBuffer();
buf.append("CREATE TRIGGER INS_BEFORE " +
......@@ -351,6 +351,6 @@ public class TestMergeUsing extends TestBase implements Trigger {
"FOR EACH ROW NOWAIT CALL \"" + getClass().getName() + "\";");
return buf.toString();
}
}
......@@ -115,7 +115,7 @@ public class TestScript extends TestBase {
for (String s : new String[] { "array-contains", "array-get",
"array-length", "autocommit", "cancel-session", "casewhen",
"cast", "coalesce", "convert", "csvread", "csvwrite", "currval",
"database-path", "datebase", "decode", "disk-space-used",
"database-path", "database", "decode", "disk-space-used",
"file-read", "file-write", "greatest", "h2version", "identity",
"ifnull", "least", "link-schema", "lock-mode", "lock-timeout",
"memory-free", "memory-used", "nextval", "nullif", "nvl2",
......
......@@ -104,7 +104,7 @@ collaborative collapse collate collateral collation collations collator collator
collect collected collecting collection collections collectively collector
collide collision collisions colon color cols colspan column columnlist columns
com combination combinations combinatorics combine combined combines combining
combo combobox come comes comma command commands commas comment commented
combo combobox come comes coming comma command commands commas comment commented
comments commercial commit commits committed committing common commonly commons
communicates communication community comp compact compacted compacting compaction
compacts companies company comparable comparative comparator compare compared
......@@ -561,7 +561,7 @@ safes safety said sainsbury salary sale sales saload salt salz sam same
sameorigin samp sample samples sanitize sanity sans sastore sat satisfy saturday sauce
sauerkraut sava save saved savepoint savepoints saves saving savings say saying
says sbquo scala scalability scalable scalar scale scaled scales scan scanned
scanner scanners scanning scans scapegoat scc schedule scheduler schem schema
scanner scanners scanning scans scapegoat scc scenarios schedule scheduler schem schema
schemas schemata scheme schmorp school schwietzke sciences scientific scjp scm
scones scoop scope scoped score scott scramble scrambling scratch screen
screenshot script scriptable scriptella scripting scripts scroll scrollable
......@@ -677,7 +677,7 @@ undetected undo undocumented undone unencrypted unenforceable unescape unexpecte
unfortunately unhandled uni unicode unified uniform uniformly unimplemented
unindexed uninitialized uninstall uninteresting uninterpreted uninterruptible
union unique uniquely uniqueness uniques unit united units universal universally
unix unixtime unknown unless unlike unlimited unlink unlinked unload unloaded
unix unixtime unknown unless unlike unlikely unlimited unlink unlinked unload unloaded
unloading unloads unlock unlocked unlocking unlocks unmaintained unmappable
unmapped unmodified unmounted unnamed unnecessarily unnecessary unneeded uno
unofficial unordered unpredictable unquoted unrecognized unrecoverable
......@@ -740,4 +740,10 @@ stumc numbered
reopening cloudera hive clustername whomooz unittest anymore snowflakecomputing unpadded endpoint redshift backingtable
trimming hadoop azure resolves snowflake testsynonym plays charsettable synonyms nonexisting impala codepage recognize
dbm forwarded amazon stmnt excessive testvalue
\ No newline at end of file
dbm forwarded amazon stmnt excessive testvalue
rowids searchers tcnt enforcing timeanddate nullifies determines believe giving
vectorwise preparation corrupting cubrid diffing unrestricted cleanups warns
rowspan specifically unoptimized stand emphasize cascaded exasol minimize rnum figure
emptying goal gathers multithread amend raised iter gathered gather especially requiring
collaboration thank essentially bunch vmlens subroutines nulled
\ No newline at end of file
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论