trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zellerh <...@git.apache.org>
Subject [GitHub] incubator-trafodion pull request #634: JIRA TRAFODION-2137 metadata access p...
Date Wed, 03 Aug 2016 01:42:34 GMT
Github user zellerh commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/634#discussion_r73268654
  
    --- Diff: core/sql/sqlcomp/CmpSeabaseDDLcommon.cpp ---
    @@ -6019,6 +6181,93 @@ short CmpSeabaseDDL::updateTextTable(ExeCliInterface *cliInterface,
       return 0;
     }
     
    +short CmpSeabaseDDL::updateTextTableWithBinaryData
    +(ExeCliInterface *cliInterface,
    + Int64 objUID, 
    + ComTextType textType, 
    + Lng32 subID, 
    + char * inputData,
    + Int32 inputDataLen,
    + NABoolean withDelete)
    +{
    +  Lng32 cliRC = 0;
    +  if (withDelete)
    +    {
    +      // Note: It might be tempting to try an upsert instead of a
    +      // delete followed by an insert, but this won't work. It is
    +      // possible that the metadata text could shrink and take fewer
    +      // rows in its new form than the old. So we do the simple thing
    +      // to avoid such complications.
    +      cliRC = deleteFromTextTable(cliInterface, objUID, textType, subID);
    +      if (cliRC < 0)
    +        {
    +          return -1;
    +        }
    +    }
    +
    +  // convert input data to utf8 first.
    +  ComDiagsArea * diagsArea = CmpCommon::diags();
    +  char * inputDataUTF8 = new(STMTHEAP) char[inputDataLen*4];
    +  Lng32 inputDataLenUTF8 = 0;
    +  ex_expr::exp_return_type rc =
    +    convDoIt(inputData,
    +             inputDataLen,
    +             REC_BYTE_F_ASCII,
    +             0,
    +             (Int32)CharInfo::ISO88591,
    +             inputDataUTF8,
    +             inputDataLen*4,
    +             REC_BYTE_V_ASCII,
    +             inputDataLen,
    +             (Int32)CharInfo::UTF8,
    +             (char*)&inputDataLenUTF8,
    +             sizeof(Lng32),
    +             STMTHEAP,
    +             &diagsArea,
    +             CONV_ASCII_F_V);
    +  if ((rc != ex_expr::EXPR_OK) ||
    +      (inputDataLenUTF8 <= 0))
    +    {
    +      return -1;
    +    }
    +  
    +  Int32 maxLen = TEXTLEN;
    +  char queryBuf[1000];
    +  Lng32 numRows = (inputDataLenUTF8 / maxLen) + 1;
    +  Lng32 currPos = 0;
    +  Int32 currDataLen = 0;
    +
    +  for (Lng32 i = 0; i < numRows; i++)
    +    {
    +      NAString temp;
    +
    +      if (i < numRows-1)
    +        currDataLen = maxLen;
    +      else
    +        currDataLen = inputDataLenUTF8 - currPos;
    +
    +      str_sprintf(queryBuf, "insert into %s.\"%s\".%s values (%Ld, %d, %d, %d, 0, cast(?
as char(%d bytes) character set utf8 not null))",
    +                  getSystemCatalog(), SEABASE_MD_SCHEMA, SEABASE_TEXT,
    +                  objUID,
    +                  textType,
    +                  subID,
    +                  i,
    +                  currDataLen);
    +      cliRC = cliInterface->executeImmediateCEFC
    +        (queryBuf, &inputData[currPos], currDataLen, NULL, NULL, NULL);
    --- End diff --
    
    Hopefully my last comment about this: The original method, CmpSeabaseDDL::updateTextTable()
seems to have the same problem of chopping UTF-8 characters in half. Maybe we get away with
it. The original method also has a not so great method of dealing with embedded quotes, using
a parameter like it's done here is much better. Would be nice if we could fix CmpSeabaseDDL::updateTextTable()
and call it from here.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message