[GitHub] trafodion pull request #1677: TRAFODION-3146 Support ANSI OVERLAY function

2018-08-03 Thread asfgit
Github user asfgit closed the pull request at:

https://github.com/apache/trafodion/pull/1677


---


[GitHub] trafodion pull request #1677: TRAFODION-3146 Support ANSI OVERLAY function

2018-08-03 Thread arvind-narain
Github user arvind-narain commented on a diff in the pull request:

https://github.com/apache/trafodion/pull/1677#discussion_r207587748
  
--- Diff: core/sql/regress/charsets/TEST315 ---
@@ -315,6 +315,26 @@ select converttohex(_ucs2 x'515a515b515c515d') from 
dual;
 select char_length(reverse(_ucs2 x'515a515b515c515d')) from dual;
 select converttohex(reverse(_ucs2 x'515a515b515c515d')) from dual;
 
+-- tests for OVERLAY function
+select overlay('w1234567xyz' placing 'abcde' from 3)  from dual;
+select overlay('w1234567xyz' placing 'abcde' from 3 for 4)  from dual;
--- End diff --

Do we need a test case to cover the example in the description  where 
numeric length is 0?

> select overlay('w1234567xyz' placing 'abcde' from 3 for 0)  from dual;


---


[GitHub] trafodion pull request #1677: TRAFODION-3146 Support ANSI OVERLAY function

2018-08-02 Thread anoopsharma00
Github user anoopsharma00 commented on a diff in the pull request:

https://github.com/apache/trafodion/pull/1677#discussion_r207433722
  
--- Diff: core/sql/exp/exp_function.cpp ---
@@ -786,13 +786,18 @@ ExpRaiseErrorFunction::ExpRaiseErrorFunction 
(Attributes **attr,
  NABoolean raiseError,
  const char *constraintName,
  const char *tableName,
- const NABoolean hasStringExp) 
 // -- Triggers
+  const NABoolean 
hasStringExp,  // -- Triggers
+  const char * optionalStr)
 : ex_function_clause (ITM_RAISE_ERROR, (hasStringExp ? 2 : 1), attr, 
space),
-theSQLCODE_(sqlCode),
-constraintName_((char *)constraintName),
-tableName_((char *)tableName)
+  theSQLCODE_(sqlCode),
+  constraintName_((char *)constraintName),
+  tableName_((char *)tableName)
 {
-setRaiseError(raiseError);
+  setRaiseError(raiseError);
+
+
+  strncpy(optionalStr_, optionalStr, MAX_OPTIONAL_STR_LEN);
--- End diff --

thanks, good catch. this showed up during regr failures as well.
It is fixed.


---


[GitHub] trafodion pull request #1677: TRAFODION-3146 Support ANSI OVERLAY function

2018-08-02 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:

https://github.com/apache/trafodion/pull/1677#discussion_r207411473
  
--- Diff: core/sql/exp/exp_function.cpp ---
@@ -786,13 +786,18 @@ ExpRaiseErrorFunction::ExpRaiseErrorFunction 
(Attributes **attr,
  NABoolean raiseError,
  const char *constraintName,
  const char *tableName,
- const NABoolean hasStringExp) 
 // -- Triggers
+  const NABoolean 
hasStringExp,  // -- Triggers
+  const char * optionalStr)
 : ex_function_clause (ITM_RAISE_ERROR, (hasStringExp ? 2 : 1), attr, 
space),
-theSQLCODE_(sqlCode),
-constraintName_((char *)constraintName),
-tableName_((char *)tableName)
+  theSQLCODE_(sqlCode),
+  constraintName_((char *)constraintName),
+  tableName_((char *)tableName)
 {
-setRaiseError(raiseError);
+  setRaiseError(raiseError);
+
+
+  strncpy(optionalStr_, optionalStr, MAX_OPTIONAL_STR_LEN);
--- End diff --

This will abend if "optionalStr" is null


---


[GitHub] trafodion pull request #1677: TRAFODION-3146 Support ANSI OVERLAY function

2018-08-02 Thread DaveBirdsall
Github user DaveBirdsall commented on a diff in the pull request:

https://github.com/apache/trafodion/pull/1677#discussion_r207412672
  
--- Diff: core/sql/bin/SqlciErrors.txt ---
@@ -1535,6 +1535,7 @@ $1~String1 
 8142 Z 9 ADVANCED INFRM LOGONLY An error was artificially 
injected, to test error handling. Testpoint $0~string0, Value $1~string1.
 8143 Z 9 ADVANCED INFRM LOGONLY The requested operation stopped 
$0~Int0 server processes.
 8144 Z 9 ADVANCED MAJOR DIALOUT Corruption is detected in table 
$0~string0$1~string1.
+8145 Z 9 BEGINNER MAJOR DBADMIN This statement is not supported or 
incorrect options were specified. Reason: $0~string0
--- End diff --

Could you add this to the Messages Guide too?


---


[GitHub] trafodion pull request #1677: TRAFODION-3146 Support ANSI OVERLAY function

2018-08-02 Thread anoopsharma00
GitHub user anoopsharma00 opened a pull request:

https://github.com/apache/trafodion/pull/1677

TRAFODION-3146 Support ANSI OVERLAY function

OVERLAY modifies a source string by replacing a given
substring of the string, which is specified by a given numeric starting
position and a given numeric length, with a replacement string).

When the length of the substring is zero, nothing is removed
from the source string and the string returned by the function is the
result of inserting the replacement string into the source string at the
starting position.

STUFF is syntactic variation of OVERLAY.

Example:
  overlay ('source original string' placing 'modified ' from 8 for 9)
  stuff ('source original string', 8, 9, 'modified ')
will return:

  'source modified string'

  overlay ('source original string' placing 'modified ' from 8 for 0)
will return:

  'source modified original string'

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/anoopsharma00/trafodion ansharma_overlay_br

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/trafodion/pull/1677.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1677


commit ab38cbc907036e88a2f53092738e119b2acc19b9
Author: Anoop Sharma 
Date:   2018-08-02T21:31:08Z

TRAFODION-3146 Support ANSI OVERLAY function

OVERLAY modifies a source string by replacing a given
substring of the string, which is specified by a given numeric starting
position and a given numeric length, with a replacement string).

When the length of the substring is zero, nothing is removed
from the source string and the string returned by the function is the
result of inserting the replacement string into the source string at the
starting position.

STUFF is syntactic variation of OVERLAY.

Example:
  overlay ('source original string' placing 'modified ' from 8 for 9)
  stuff ('source original string', 8, 9, 'modified ')
will return:

  'source modified string'

  overlay ('source original string' placing 'modified ' from 8 for 0)
will return:

  'source modified original string'




---