sqlancer
sqlancer copied to clipboard
Implement Handling for Insertions into Views in YSQLSchema
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_typecolumn frominformation_schema.tablesto accurately determine if a table is a view. - Check Insertability: Utilize the
is_insertable_intocolumn to determine if a view can be inserted into.
what I'll do
- [ ] Implement the changes in the
YSQLSchemaclass. - [ ] 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.