-
Notifications
You must be signed in to change notification settings - Fork 154
jira 2227 : support json fuction - JSON_OBJECT_FIELD_TEXT #833
Conversation
Can one of the admins verify this patch? |
3 similar comments
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
Can one of the admins verify this patch? |
jenkins, test |
@svarnau , please help to take a look |
jenkins, add user |
Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/1355/ |
Test Failed. https://jenkins.esgyn.com/job/Check-PR-master/1355/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a big check-in, will need to take some time to review the code. Some initial comments embedded.
@@ -0,0 +1,1139 @@ | |||
#include "stringinfo.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Must add license info at the header.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -3925,3 +3925,16 @@ $3~String1. | |||
30047 ZZZZZ 99999 BEGINNER MAJOR DBADMIN NAR details. HexdRow: $0~String0 ErrNum: $1~Int1 ObjectName: $2~TableName PartitionName: $3~String3 FileNum: $4~Int4 RecNum: $5~Int5 | |||
30048 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Fast Load failed. Number of error rows($0~Int0) inserted into the exception table exceeded the max allowed($1~Int1). | |||
30049 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Fast Load succeeded. Number of error rows inserted into the exception table is $0~Int0 | |||
|
|||
32001 ZZZZZ 99999 BEGINNER MAJOR DBADMIN Token is invalid. | |||
32002 ZZZZZ 99999 BEGINNER MAJOR DBADMIN JSON value is invalid. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if possible, considering use 8000~8999 range for function run-time error?
I am not very sure here, need @zellerh, @DaveBirdsall to review as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, agree. Maybe something like 8970-8982.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -0,0 +1,124 @@ | |||
#ifndef JSON_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
license header is required
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, and also please try to follow the naming conventions for source file names. For example, this file in the common directory should probably be called ComJSON.h or similar. That should make it much easier to find. Otherwise, if someone would come across a name like json.cpp or json.h, they would assume that it is not part of Trafodion and/or they would have to do quite a bit of searching to figure out where the file comes from. Overall, I think the idea of putting the JSON-related code into the common directory is a very good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
||
if (str->data != NULL) | ||
free(str->data); | ||
str->data = (char *) malloc(newlen); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I haven't reviewed all of the code. Is there a chance that we will introduce memory leaks? Would it make sense to pass a Trafodion heap pointer (NAMemory *) to a StringInfo object, so we can control the memory allocation better?
* to doing a pure parse with no side-effects, and is therefore exactly | ||
* what the json input routines do. | ||
* | ||
* The 'fname' and 'token' strings passed to these actions are palloc'd. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comments talk about palloc, but we really use malloc in this code. See another comment about whether malloc is the right thing to use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Postgresql uses palloc function to allocate memories from memory pool. So, when I porting the code, I remove that part and use malloc as a replace. For postgresql, developer doesn't need to care about when to release the memory, because when the request is completed, all memory allocated in the request will be release. I'm not sure if Trafodion has the same mechanism to manage memory, if yes, I can use that to replace palloc.
Much of this code is a copy of the PostgreSQL source code. You cannot strip off the PostgreSQL license header and copyright from these files. I'm not quite sure how this should be handled, but my guess would be that you need to leave the PostgreSQL license header in the file and add the Apache License header as well. Also, you may need to add an entry to the RAT_README file in the top-level directory. See also http://www.apache.org/legal/resolved.html, this states that it is ok to include PostgreSQL code in an Apache project. Maybe @gtapper, our new Release Manager, can help you with the details. Our previous release manager, @robertamarton, has a lot of experience with this. |
int cursor; | ||
} StringInfoData; | ||
|
||
typedef StringInfoData *StringInfo; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"StringInfo" is a very generic term and this struct is used for a very specialized purpose here. It would be good to rename it to make it more clear what it is for. For example: ComJSONStringInfo would make it more clear that this is part of the common directory and used for JSON strings. Also, it is not common in Trafodion to typedef a pointer to a regular name, and this will probably confuse people as well. Is it possible to use the Trafodion strings NAString or NAText instead? NAText is basically the same as std::string. Just a question, I realize that it may be too much work to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely right. Such code would also have to be documented in licenses/lic-server-src that is used to build the LICENSE file that goes out with the released code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -33735,7 +33741,6 @@ nonreserved_func_word: TOK_ABS | |||
| TOK_FLOOR | |||
| TOK_FN | |||
| TOK_GREATEST | |||
| TOK_GROUPING_ID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should not remove GROUPING_ID, must be accidental?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merge mistake. add it back.
New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/1358/ |
Test Failed. https://jenkins.esgyn.com/job/Check-PR-master/1358/ |
Previous Test Aborted. New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/1359/ |
Test Failed. https://jenkins.esgyn.com/job/Check-PR-master/1359/ |
New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/1360/ |
Test Failed. https://jenkins.esgyn.com/job/Check-PR-master/1360/ |
New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/1368/ |
Test Passed. https://jenkins.esgyn.com/job/Check-PR-master/1368/ |
int len = _state->lex->prev_token_terminator - start; | ||
|
||
//_state->tresult = cstring_to_text_with_len(start, len); | ||
_state->tresult = (char *)malloc(len + 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not clear where this malloc memory will be free?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be free in ex_function_json_object_field_text::eval().
if (rltStr != NULL)
{
Lng32 rltLen = str_len(rltStr)+1;
str_cpy_all(op_data[0], rltStr, rltLen);
free(rltStr);
// If result is a varchar, store the length of substring
// in the varlen indicator.
if (getOperand(0)->getVCIndicatorLength() > 0)
getOperand(0)->setVarLength(rltLen, op_data[-MAX_OPERANDS]);
}
overall looks good to me. +1 from me.
|
A new jira is created to track the task for updating documents. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rat exclude may not be needed.
license file addition looks good.
ComJSON.cpp | ||
ComJSONFuncs.cpp | ||
ComJSONStringInfo.h | ||
ComJSONStringInfo.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if these are needed here, with the copyright restored and the ASF statements added, but I did not try running RAT without to verify.
Would like a better comment here than BSD license - specify PostgresSQL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have removed json files from .rat-excludes
In good shape from license file view. |
update from apache
There has been a lot of email recently on general incubator and legal lists. The JSon license has been clarified, here is a recap from Apache legal:
>>> o No new project, sub-project or codebase, which has not
>>> used JSON licensed jars (or similar), are allowed to use
>>> them. In other words, if you haven't been using them, you
>>> aren't allowed to start. It is Cat-X.
>>>
>>> o If you have been using it, and have done so in a *release*,
>>> AND there has been NO pushback from your community/eco-system,
>>> you have a temporary exclusion from the Cat-X classification thru
>>> April 30, 2017. At that point in time, ANY and ALL usage
>>> of these JSON licensed artifacts are DISALLOWED. You must
>>> either find a suitably licensed replacement, or do without.
>>> There will be NO exceptions.
>>>
>>> o Any situation not covered by the above is an implicit
>>> DISALLOWAL of usage.
>>>
>>> Also please note that in the 2nd situation (where a temporary
>>> exclusion has been granted), you MUST ensure that NOTICE explicitly
>>> notifies the end-user that a JSON licensed artifact exists. They
>>> may not be aware of it up to now, and that MUST be addressed.
>>>
>>> If there are any questions, please ask on the ***@***.******@***.***>
>>> list.
>>>
>>> --
>>> Jim Jagielski
>>> VP Legal Affairs
I notice that the license for the include files you are BSD which should be fine. I don’t believe you are using any JSON jar files so perhaps the license change does not affect us or Postgres. However, INAL and cannot state positively that we are okay. Should we ask for a clarification from the legal list?
Roberta
From: Liu Ming [mailto:notifications@github.com]
Sent: Wednesday, November 23, 2016 6:01 AM
To: apache/incubator-trafodion <incubator-trafodion@noreply.github.com>
Cc: Roberta Marton <roberta.marton@esgyn.com>; Mention <mention@noreply.github.com>
Subject: Re: [apache/incubator-trafodion] jira 2227 : support json fuction - JSON_OBJECT_FIELD_TEXT (#833)
@svarnau<https://github.com/svarnau> , @gtapper<https://github.com/gtapper> do you have concerns from license point of view of merging this PR?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#833 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/AMa1INImMLs26aPIoaQ6v-BjyrPaGiRCks5rBEc2gaJpZM4Kw61P>.
|
Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/1409/ |
Test Passed. https://jenkins.esgyn.com/job/Check-PR-master/1409/ |
@andyyangcn , you need to fix the conflicts Do a 'git pull' and fix the merge issue, and commit again. |
New Check Test Started: https://jenkins.esgyn.com/job/Check-PR-master/1433/ |
Test Passed. https://jenkins.esgyn.com/job/Check-PR-master/1433/ |
add json parser code and a new json fucntion : JSON_OBJECT_FIELD_TEXT('json string', 'key').