Github user zellerh commented on a diff in the pull request:
https://github.com/apache/trafodion/pull/1608#discussion_r195274939
--- Diff: core/sql/sqlcomp/CmpSeabaseDDLtable.cpp ---
@@ -8047,14 +8149,36 @@ void
CmpSeabaseDDL::alterSeabaseTableAddPKeyConstraint(
if (cliRC < 0)
{
cliInterface.retrieveSQLDiagnostics(CmpCommon::diags());
+
+ goto label_return;
}
str_sprintf(cqdbuf, "cqd traf_create_table_with_uid '' ;");
cliInterface.executeImmediate(cqdbuf);
- if (cliRC < 0)
+ str_sprintf(cqdbuf, "cqd traf_no_hbase_drop_create 'OFF';");
+ cliInterface.executeImmediate(cqdbuf);
+
+ if (NOT isEmpty) // non-empty table
{
- return;
+ // remove NATable so current definition could be loaded
+ ActiveSchemaDB()->getNATableDB()->removeNATable
+ (cn,
+ ComQiScope::REMOVE_FROM_ALL_USERS,
+ COM_BASE_TABLE_OBJECT,
+ alterAddConstraint->ddlXns(), FALSE);
+
+ // copy tempTable data into newly created table
+ str_sprintf(buf, "insert with no rollback into %s select * from %s",
--- End diff --
A general question, this also happens in the existing code: When we make a
copy of a table in a DDL operation, do we need to make sure that nobody writes
data into the table? If there are inserts or updates, what would happen? Could
the DDL operation fail with a conflict, or would we potentially lose that data?
---