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

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

Github user DaveBirdsall commented on a diff in the pull request:

    https://github.com/apache/incubator-trafodion/pull/647#discussion_r73971774
  
    --- Diff: core/sql/generator/GenResources.cpp ---
    @@ -97,92 +77,74 @@ static ExScratchDiskDrive * genScratchDriveList(const 
NAString &def,
       LIST(ExScratchDiskDrive *) tempList;
       CollHeap *heap = generator->wHeap();
       Space *space = generator->getSpace();
    +  struct stat st;
    +  
    + 
    +  Lng32 nodeNum;
    +  char *token = new(heap) char[PATH_MAX];
     
    -  // ---------------------------------------------------------------------
    -  // process the NT default
    -  // ---------------------------------------------------------------------
    -  while (str && *str)
    +  char *sep = (char *)":";
    +  token = strtok((char *)str,sep);
    +  while (token != NULL)
         {
    -      Lng32 nodeNum;
    -      char *driveLetter = new(heap) char[2];
    -
    -      driveLetter[1] = 0;
    -      if (ValidateDiskListNT::getNextDriveLetterAndAdvance(
    -      str,nodeNum,driveLetter[0]))
    -   {
    -     // syntax error in default, issue a warning (not an error)
    -     *CmpCommon::diags() << DgSqlCode(2055)
    +      //validate the directory
    +      if ((stat(token,&st) != 0 ) &&  !S_ISDIR(st.st_mode) ) //&& (numDirs 
> MAX_SCRATCH_LOCATIONS))
    +        {
    +          // syntax error in default, issue a warning (not an error)
    +          *CmpCommon::diags() << DgSqlCode(2055)
                              << DgString0(def)
                              << DgString1(defName);
    -     // don't continue after a syntax error
    -     str = NULL;
    -   }
    +          // don't continue after a syntax error
    +          str = NULL;
    +        }
           else
    -   {
    -     tempList.insert(new(heap) ExScratchDiskDrive(
    -          driveLetter,
    -          1, // Thanks to Bill Gates
    -          nodeNum));
    -   }
    -
    -      NADELETEBASIC(driveLetter, heap);
    -      driveLetter = NULL;
    -
    +        {
    +          tempList.insert(new(heap) ExScratchDiskDrive(
    +                               token,
    +                               strlen(token) ));
    +        }
    +      token = strtok(NULL,sep);
         }
    +      
    +  NADELETEBASIC(token, heap);
    --- End diff --
    
    I don't think this is doing what you want. My understanding of strtok is 
that it uses a static buffer to store intermediate state. It is *not* using 
your buffer "token" for this purpose. When you call strtok, you are assigning 
addresses from that static buffer into the pointer "token". And when you exit 
the loop, "token" will be NULL, and this NADELETEBASIC will do nothing. So in 
fact you've leaked the buffer that you allocated earlier. Another point: strtok 
is not thread-safe. Consider using strtok_r instead.


> Use of CQD to set scratch directory locations
> ---------------------------------------------
>
>                 Key: TRAFODION-2146
>                 URL: https://issues.apache.org/jira/browse/TRAFODION-2146
>             Project: Apache Trafodion
>          Issue Type: Improvement
>          Components: foundation, sql-exe
>            Reporter: Sandhya Sundaresan
>            Assignee: Sandhya Sundaresan
>
> Allow a CQD specification to override the env settings for STFS locations.
> Currently the scratch directory locations and set at installtion time . The 
> STFS layer that manages the scratch file creation reads the envvar in ms.env 
> to determine where to create the scratch files.
> Now we allow a CQD to be specified that will override the envvar setting. If 
> the CQD is not set (empty) , the envvar setting will work. This will give the 
> user some flexibility to change scratch directory locations. The requirement 
> is that the directoryies MUST exists on every node and that Trafodion user 
> will need permissions to write to those directories. If not an error will be 
> returned when a query invliving sort/hash overflow is executed. . 



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to