[ 
https://issues.apache.org/jira/browse/TRAFODION-1782?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16511853#comment-16511853
 ] 

ASF GitHub Bot commented on TRAFODION-1782:
-------------------------------------------

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?


> Error 1135 for a primary key column not declared NOT NULL
> ---------------------------------------------------------
>
>                 Key: TRAFODION-1782
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-1782
>             Project: Apache Trafodion
>          Issue Type: Bug
>          Components: sql-cmp
>    Affects Versions: 0.6 (pre-incubation)
>            Reporter: Hans Zeller
>            Assignee: Anoop Sharma
>            Priority: Minor
>
> When creating a table like this:
> create table t(a int primary key)
> or
> create table t(a int, primary key(a))
> Trafodion issues an error 1135 (Clustering key column ID must be assigned a 
> NOT NULL NOT DROPPABLE constraint.). It would be better (and ANSI SQL 
> compliant) if that constraint would be added implicitly, without generating 
> an error.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to