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:27:54 GMT
Github user zellerh commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/634#discussion_r73267635
  
    --- 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 --
    
    Sorry, a better method is findStartOfChar() in the same file.


---
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