-
Notifications
You must be signed in to change notification settings - Fork 477
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'future-migrate' into future-migrate
- Loading branch information
Showing
143 changed files
with
2,081 additions
and
522 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,33 @@ | ||
package org.apache.calcite; | ||
|
||
import io.mycat.Authenticator; | ||
import io.mycat.MetaClusterCurrent; | ||
import io.mycat.MycatDataContext; | ||
import io.mycat.MycatUser; | ||
|
||
public class MycatContext { | ||
public Object[] values; | ||
public static final ThreadLocal<MycatDataContext> CONTEXT = ThreadLocal.withInitial(() -> null); | ||
public static Object getVariable(String name){ | ||
public Object getVariable(String name){ | ||
return CONTEXT.get().getVariable(name); | ||
} | ||
public String getDatabase(){ | ||
return CONTEXT.get().getDefaultSchema(); | ||
} | ||
public Long getLastInsertId(){ | ||
return CONTEXT.get().getLastInsertId(); | ||
} | ||
public Long getConnectionId(){ | ||
return CONTEXT.get().getSessionId(); | ||
} | ||
public String getCurrentUser(){ | ||
MycatUser user = CONTEXT.get().getUser(); | ||
Authenticator authenticator = MetaClusterCurrent.wrapper(Authenticator.class); | ||
return user.getUserName()+"@"+authenticator.getUserInfo(user.getUserName()).getIp(); | ||
} | ||
|
||
public String getUser(){ | ||
MycatUser user = CONTEXT.get().getUser(); | ||
return user.getUserName()+"@"+user.getHost(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
calcite/src/main/java/org/apache/calcite/mycat/MycatConnectionIdFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.apache.calcite.mycat; | ||
|
||
import org.apache.calcite.sql.SqlFunctionCategory; | ||
import org.apache.calcite.sql.type.InferTypes; | ||
import org.apache.calcite.sql.type.OperandTypes; | ||
import org.apache.calcite.sql.type.ReturnTypes; | ||
|
||
public class MycatConnectionIdFunction extends MycatSqlDefinedFunction { | ||
public final static MycatConnectionIdFunction INSTANCE = new MycatConnectionIdFunction(); | ||
|
||
public MycatConnectionIdFunction() { | ||
super("CONNECTION_ID", | ||
ReturnTypes.BIGINT_NULLABLE, | ||
InferTypes.RETURN_TYPE, OperandTypes.NILADIC, null, SqlFunctionCategory.SYSTEM); | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
calcite/src/main/java/org/apache/calcite/mycat/MycatCurrentUserFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.apache.calcite.mycat; | ||
|
||
import org.apache.calcite.sql.SqlFunctionCategory; | ||
import org.apache.calcite.sql.type.InferTypes; | ||
import org.apache.calcite.sql.type.OperandTypes; | ||
import org.apache.calcite.sql.type.ReturnTypes; | ||
|
||
public class MycatCurrentUserFunction extends MycatSqlDefinedFunction { | ||
public final static MycatCurrentUserFunction INSTANCE = new MycatCurrentUserFunction(); | ||
|
||
public MycatCurrentUserFunction() { | ||
super("CURRENT_USER;", | ||
ReturnTypes.VARCHAR_2000, | ||
InferTypes.RETURN_TYPE, OperandTypes.NILADIC, null, SqlFunctionCategory.SYSTEM); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
calcite/src/main/java/org/apache/calcite/mycat/MycatDatabaseFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.apache.calcite.mycat; | ||
|
||
import org.apache.calcite.sql.SqlFunctionCategory; | ||
import org.apache.calcite.sql.type.InferTypes; | ||
import org.apache.calcite.sql.type.OperandTypes; | ||
import org.apache.calcite.sql.type.ReturnTypes; | ||
import org.apache.calcite.sql.type.SqlTypeName; | ||
|
||
public class MycatDatabaseFunction extends MycatSqlDefinedFunction { | ||
public final static MycatDatabaseFunction INSTANCE = new MycatDatabaseFunction(); | ||
|
||
public MycatDatabaseFunction() { | ||
super("DATABASE", | ||
ReturnTypes.explicit(SqlTypeName.VARCHAR), | ||
InferTypes.RETURN_TYPE, OperandTypes.NILADIC, null, SqlFunctionCategory.SYSTEM); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
calcite/src/main/java/org/apache/calcite/mycat/MycatLastInsertIdFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package org.apache.calcite.mycat; | ||
|
||
import org.apache.calcite.sql.SqlFunctionCategory; | ||
import org.apache.calcite.sql.type.InferTypes; | ||
import org.apache.calcite.sql.type.OperandTypes; | ||
import org.apache.calcite.sql.type.ReturnTypes; | ||
import org.apache.calcite.sql.type.SqlTypeName; | ||
|
||
public class MycatLastInsertIdFunction extends MycatSqlDefinedFunction { | ||
public final static MycatLastInsertIdFunction INSTANCE = new MycatLastInsertIdFunction(); | ||
|
||
public MycatLastInsertIdFunction() { | ||
super("LAST_INSERT_ID", | ||
ReturnTypes.BIGINT_NULLABLE, | ||
InferTypes.RETURN_TYPE, OperandTypes.NILADIC, null, SqlFunctionCategory.SYSTEM); | ||
} | ||
} |
3 changes: 1 addition & 2 deletions
3
...qlfunction/MycatSessionValueFunction.java → ...cite/mycat/MycatSessionValueFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
calcite/src/main/java/org/apache/calcite/mycat/MycatUserFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package org.apache.calcite.mycat; | ||
|
||
import org.apache.calcite.sql.SqlFunctionCategory; | ||
import org.apache.calcite.sql.type.InferTypes; | ||
import org.apache.calcite.sql.type.OperandTypes; | ||
import org.apache.calcite.sql.type.ReturnTypes; | ||
|
||
public class MycatUserFunction extends MycatSqlDefinedFunction { | ||
public final static MycatUserFunction INSTANCE = new MycatUserFunction(); | ||
|
||
public MycatUserFunction() { | ||
super("USER", | ||
ReturnTypes.VARCHAR_2000, | ||
InferTypes.RETURN_TYPE, OperandTypes.NILADIC, null, SqlFunctionCategory.SYSTEM); | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
calcite/src/main/java/org/apache/calcite/mycat/MycatVersionFunction.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package org.apache.calcite.mycat; | ||
|
||
import org.apache.calcite.schema.impl.ScalarFunctionImpl; | ||
import org.apache.calcite.sql.SqlFunctionCategory; | ||
import org.apache.calcite.sql.type.InferTypes; | ||
import org.apache.calcite.sql.type.OperandTypes; | ||
import org.apache.calcite.sql.type.ReturnTypes; | ||
import org.apache.calcite.sql.type.SqlTypeName; | ||
|
||
public class MycatVersionFunction extends MycatSqlDefinedFunction { | ||
public final static MycatVersionFunction INSTANCE = new MycatVersionFunction(); | ||
|
||
public MycatVersionFunction() { | ||
super("VERSION", | ||
ReturnTypes.explicit(SqlTypeName.VARCHAR), | ||
InferTypes.RETURN_TYPE, OperandTypes.NILADIC, | ||
ScalarFunctionImpl.create(MycatVersionFunction.class,"version"), | ||
SqlFunctionCategory.SYSTEM); | ||
} | ||
|
||
public static String version(){ | ||
return "8.19"; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...io/mycat/proxy/session/Authenticator.java → ...src/main/java/io/mycat/Authenticator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.