You are viewing a plain text version of this content. The canonical link for it is here.
Posted to codereview@trafodion.apache.org by rwbzx <gi...@git.apache.org> on 2016/12/06 08:37:59 UTC
[GitHub] incubator-trafodion pull request #868: [TRAFODION-2386]Add UT code for varch...
GitHub user rwbzx opened a pull request:
https://github.com/apache/incubator-trafodion/pull/868
[TRAFODION-2386]Add UT code for varchar 32k issue
Add source code, build files and readme files, and test code runs in following way:
Every time 1 row of data is inserted to a specific table and fetched out into local buffer after insertion is done. And then comparation is made between input buffer and fetch-out buffer, if difference exists, then test fails.
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/rwbzx/incubator-trafodion TRAFODION-2386
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-trafodion/pull/868.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 #868
----
commit ac833c408e21394555725570053764d45ea64f52
Author: rwbzx <xi...@esgyn.cn>
Date: 2016-12-06T08:34:16Z
[TRAFODION-2386]Add UT code for varchar 32k issue
add source code, build files and readme files
----
---
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.
---
[GitHub] incubator-trafodion pull request #868: [TRAFODION-2386]ODBC:add odbc unit-te...
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/incubator-trafodion/pull/868
---
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.
---
[GitHub] incubator-trafodion pull request #868: [TRAFODION-2386]ODBC:add odbc unit-te...
Posted by rwbzx <gi...@git.apache.org>.
Github user rwbzx commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/868#discussion_r91239824
--- Diff: dcs/src/test/odbc/src/common/Global.cpp ---
@@ -0,0 +1,116 @@
+/*************************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+**************************************************************************/
+
+#include "Global.h"
+
+char *rTrim(char *string)
+{
+ char *strPtr;
+
+ for (strPtr = string + strlen(string) - 1;
+ strPtr >= string && (*strPtr == ' ' || *strPtr == '\t');
+ *(strPtr--) = '\0');
+ return(string);
+}
+
+int ConvertCharToCNumeric(SQL_NUMERIC_STRUCT& numericTmp, CHAR* cTmpBuf)
+{
+ unsigned char localBuf[101];
+ char* tempPtr = (char*)localBuf, *tempPtr1;
+ int i, j, a, b, current, calc, length;
+
+ SQLCHAR tempPrecision;
+ SQLCHAR tempScale;
+ SQLCHAR tempSign;
+ SQLCHAR tmpVal[101];
+
+ if (strlen(rTrim(cTmpBuf)) > sizeof(tmpVal))
--- End diff --
thanks for the tip, if strlen(rTrim(cTmpBuf)) == sizeof(tmpVal), strlen(localBuf) will be 101, but there will be risk of stack corrupt. fixed it in latest commit.
---
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.
---
[GitHub] incubator-trafodion pull request #868: [TRAFODION-2386]ODBC:add odbc unit-te...
Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/868#discussion_r91201562
--- Diff: dcs/src/test/odbc/src/Main.cpp ---
@@ -0,0 +1,57 @@
+/*************************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+**************************************************************************/
+
+#include "common/Global.h"
+#include "test/varchar32k/LargeVarcharCol.h"
+
+int main(int argc, char * argv[])
+{
+ if (argc != 7)
+ {
+ std::cout << "Usage: " << argv[0] << " -d [<datasource>][-u <userid>][-p <password>]" << endl;
+ return -1;
+ }
+ char inputArgs[6][100];
+ for (int i = 1; i < argc; i++)
+ strcpy(inputArgs[i - 1], argv[i]);
+
+ if ((strcmp(inputArgs[0], "-d") != 0) || (strcmp(inputArgs[2], "-u") != 0) || (strcmp(inputArgs[4], "-p") != 0))
+ {
+ std::cout << "Usage: " << argv[0] << " -d [<datasource>][-u <userid>][-p <password>]" << endl;
--- End diff --
Same comment as above.
---
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.
---
[GitHub] incubator-trafodion pull request #868: [TRAFODION-2386]ODBC:add odbc unit-te...
Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/868#discussion_r91201853
--- Diff: dcs/src/test/odbc/src/common/Global.cpp ---
@@ -0,0 +1,116 @@
+/*************************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+**************************************************************************/
+
+#include "Global.h"
+
+char *rTrim(char *string)
+{
+ char *strPtr;
+
+ for (strPtr = string + strlen(string) - 1;
+ strPtr >= string && (*strPtr == ' ' || *strPtr == '\t');
+ *(strPtr--) = '\0');
+ return(string);
+}
+
+int ConvertCharToCNumeric(SQL_NUMERIC_STRUCT& numericTmp, CHAR* cTmpBuf)
+{
+ unsigned char localBuf[101];
+ char* tempPtr = (char*)localBuf, *tempPtr1;
+ int i, j, a, b, current, calc, length;
+
+ SQLCHAR tempPrecision;
+ SQLCHAR tempScale;
+ SQLCHAR tempSign;
+ SQLCHAR tmpVal[101];
+
+ if (strlen(rTrim(cTmpBuf)) > sizeof(tmpVal))
--- End diff --
What happens if strlen(rTrim(cTmpBuf)) == sizeof(tmpVal)? Won't you get a buffer overrun at line 52 because there isn't room for the null terminator?
---
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.
---
[GitHub] incubator-trafodion pull request #868: [TRAFODION-2386]ODBC:add odbc unit-te...
Posted by DaveBirdsall <gi...@git.apache.org>.
Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/868#discussion_r91201254
--- Diff: dcs/src/test/odbc/src/Main.cpp ---
@@ -0,0 +1,57 @@
+/*************************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+**************************************************************************/
+
+#include "common/Global.h"
+#include "test/varchar32k/LargeVarcharCol.h"
+
+int main(int argc, char * argv[])
+{
+ if (argc != 7)
+ {
+ std::cout << "Usage: " << argv[0] << " -d [<datasource>][-u <userid>][-p <password>]" << endl;
--- End diff --
If argc has to be exactly 7, then the parameters mentioned in the Usage are not optional. (That is, the square brackets should be removed.)
---
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.
---
[GitHub] incubator-trafodion pull request #868: [TRAFODION-2386]ODBC:add odbc unit-te...
Posted by rwbzx <gi...@git.apache.org>.
Github user rwbzx commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/868#discussion_r91239996
--- Diff: dcs/src/test/odbc/src/Main.cpp ---
@@ -0,0 +1,57 @@
+/*************************************************************************
+// @@@ START COPYRIGHT @@@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+// @@@ END COPYRIGHT @@@
+**************************************************************************/
+
+#include "common/Global.h"
+#include "test/varchar32k/LargeVarcharCol.h"
+
+int main(int argc, char * argv[])
+{
+ if (argc != 7)
+ {
+ std::cout << "Usage: " << argv[0] << " -d [<datasource>][-u <userid>][-p <password>]" << endl;
--- End diff --
yeah these params are mandatory.fixed it in latest commit.
---
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.
---