Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="org.apache.dolphinscheduler.dao.mapper.PluginDefineMapper">
<select id="checkTableExist" resultType="int">
select count(*) from information_schema.TABLES where table_name = 't_ds_plugin_define'
select count(*) from information_schema.tables where table_name = 't_ds_plugin_define'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all mysql will be case sensitive. This needs to distinguish between mysql and postgres.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not all mysql will be case sensitive. This needs to distinguish between mysql and postgres.

I've tested this on both MySQL 5.x and 8.x, and both information_schema.tables and information_schema.TABLES execute without any issues.

I don't have the environment to test every version of MySQL and PostgreSQL, so I asked an AI this question: For information_schema.tables and information_schema.TABLES, which casing should I use to ensure compatibility with both MySQL and PostgreSQL?

-------------------------------Here is the AI's answer:-----------------------------------
To ensure compatibility across both MySQL and PostgreSQL, it is highly recommended to use lowercase (i.e., information_schema.tables).
Here is the breakdown of why lowercase is the best choice:

  1. PostgreSQL's Default Behavior
    PostgreSQL automatically folds (converts) unquoted identifiers to lowercase. So, whether you write information_schema.tables or information_schema.TABLES, PostgreSQL treats them exactly the same. Using lowercase aligns perfectly with PostgreSQL's internal logic and standard conventions.
  2. MySQL's Compatibility
    MySQL fully supports lowercase information_schema.tables. While MySQL 8.0 treats INFORMATION_SCHEMA as case-insensitive, older versions (like MySQL 5.x on Linux) can be case-sensitive depending on the OS file system and the lower_case_table_names setting. Lowercase is universally safe.
  3. The Risk of Using Uppercase
    While uppercase works in most cases, it can cause issues if someone accidentally uses double quotes. In PostgreSQL, double quotes force strict case sensitivity (e.g., "INFORMATION_SCHEMA" is different from information_schema). Sticking to lowercase avoids this trap entirely.
    Best Practice for Cross-Database Scripts:
    When writing SQL that needs to run on multiple database engines, always use lowercase for both the schema name, table names, and column names (e.g., SELECT table_name FROM information_schema.tables WHERE table_schema = 'my_db';).

</select>

<select id="queryAllPluginDefineList" resultType="org.apache.dolphinscheduler.dao.entity.PluginDefine">
Expand Down
Loading