我可以找到负责在HyperSQL引擎级别上执行SQL查询的代码在哪里?

huangapple go评论72阅读模式
英文:

Where can I find code responsible for SQL query execution on engine level for HyperSQL?

问题

我在下一个git存储库中找到了有关HyperSQL的信息。我正在检查用于数据库使用的JDBC接口

例如,我想要与数据库创建连接,并执行一些语句:

Connection connection = ...
Statement statement = connection.createStatement();
String query = "CREATE TABLE mytable (id IDENTITY , value VARCHAR)";
statement.executeUpdate(query);

从我所看到的情况来看,发生了一系列内部JDBC驱动程序类的调用:

JDBCDriver -> JDBCConnection -> JDBCStatement -> Session -> Result (?) -> ? -> HSQLDB  

关于JDBCStatement

public synchronized ResultSet executeQuery(
            String sql) throws SQLException {

        fetchResult(sql, StatementTypes.RETURN_RESULT,
                    JDBCStatementBase.NO_GENERATED_KEYS, null, null);

        return getResultSet();
}

关于fetchResult

private void fetchResult(String sql, int statementRetType,
                             int generatedKeys, int[] generatedIndexes,
                             String[] generatedNames) throws SQLException {
   ...
   resultIn = connection.sessionProxy.execute(resultOut);
   ...
}

接下来是Session的调用。

但是我在哪里可以找到负责通过DBMS引擎执行SQL语句的代码?

英文:

I found next git repo with HyperSQL. And I'm checking JDBC interfaces for DB usage.

For example, I want to create connection with DB, and execute some statements:

Connection connection = ...
Statement statement = connection.createStatement();
String query = "CREATE TABLE mytable (id IDENTITY , value VARCHAR)";
statement.executeUpdate(query);

As I can see, next sequence of internal JDBC driver classes invocations happens:

JDBCDriver -> JDBCConnection -> JDBCStatement -> Session -> Result (?) -> ? -> HSQLDB  

For JDBCStatement:

public synchronized ResultSet executeQuery(
            String sql) throws SQLException {

        fetchResult(sql, StatementTypes.RETURN_RESULT,
                    JDBCStatementBase.NO_GENERATED_KEYS, null, null);

        return getResultSet();
}

And for fetchResult

private void fetchResult(String sql, int statementRetType,
                             int generatedKeys, int[] generatedIndexes,
                             String[] generatedNames) throws SQLException {
   ...
   resultIn = connection.sessionProxy.execute(resultOut);
   ...
}

Next - Session invocation.

But where can I find code responsible for execution of SQL statements via DBMS engine?

答案1

得分: 1

HSQLDB源代码位于Subversion(非Git)存储库中,托管在SourceForge.net上:https://sourceforge.net/p/hsqldb/svn/HEAD/tree/base/trunk/

如果您从Session.execute(Result...)方法开始,并找到EXECDIRECT的情况,您将看到语句首先被编译,然后执行。您可以从那里开始,其中包括大量负责编译和执行不同类型SQL语句的类。

英文:

HSQLDB source code is in a Subversion (not Git) repository hosted on SourceForge.net: https://sourceforge.net/p/hsqldb/svn/HEAD/tree/base/trunk/

If you follow from The Session.execute(Result ...) method, and find the case for EXECDIRECT, you will see the statement is first compiled, then executed. You can follow from there, which includes a large number of classes responsible for compiling and executing different types of SQL statement.

huangapple
  • 本文由 发表于 2020年9月13日 22:17:51
  • 转载请务必保留本文链接:https://go.coder-hub.com/63871816.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定