sqlancer / sqlancer/sqlancer

Implement Handling for Insertions into Views in YSQLSchema

Open
#1,158 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
1.8k
Forks
397
Avg merge
21h 41m
Merged PRs (30d)
3

Description

The YSQLSchema class in the SQLancer repository currently has a TODO comment indicating that the functionality for handling insertions into views is not fully implemented. This enhancement will ensure that views are correctly identified and their insertability is accurately determined, improving the robustness of the YSQL database testing framework.

Current Code Context

In the YSQLSchema class, the method responsible for retrieving table information includes a TODO comment related to views:

while (rs.next()) {
                        String tableName = rs.getString("table_name");
                        String tableTypeSchema = rs.getString("table_schema");
                        boolean isInsertable = rs.getBoolean("is_insertable_into");
                        // TODO: also check insertable
                        // TODO: insert into view?
                        boolean isView = tableName.startsWith("v"); // tableTypeStr.contains("VIEW") ||
                        // tableTypeStr.contains("LOCAL TEMPORARY") &&
                        // !isInsertable;
                        YSQLTable.TableType tableType = getTableType(tableTypeSchema);
                        List<YSQLColumn> databaseColumns = getTableColumns(con, tableName);
                        List<YSQLIndex> indexes = getIndexes(con, tableName);
                        List<YSQLStatisticsObject> statistics = getStatistics(con);
                        YSQLTable t = new YSQLTable(tableName, databaseColumns, indexes, tableType, statistics, isView,
                                isInsertable);
                        for (YSQLColumn c : databaseColumns) {
                            c.setTable(t);
                        }
                        databaseTables.add(t);
What I'll changes
  • Identify Views Properly: Use the table_type column from information_schema.tables to accurately determine if a table is a view.
  • Check Insertability: Utilize the is_insertable_into column to determine if a view can be inserted into.

what I'll do

  • Implement the changes in the YSQLSchema class.
  • Add unit tests to verify the correct identification and handling of views.
  • Update documentation to reflect these changes.

Please let me know if you need further clarification.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the YSQLSchema class at the method that retrieves table information, using the information_schema table_type and is_insertable_into columns as the relevant context. Add tests covering view identification and insertability, then verify the YSQL database-testing behavior and update documentation if needed.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.