[
https://issues.apache.org/jira/browse/TRAFODION-2726?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16179873#comment-16179873
]
ASF GitHub Bot commented on TRAFODION-2726:
-------------------------------------------
Github user DaveBirdsall commented on a diff in the pull request:
https://github.com/apache/incubator-trafodion/pull/1237#discussion_r140913298
--- Diff: core/conn/odb/src/JsonReader.c ---
@@ -0,0 +1,563 @@
+//------------------------------------------------------------------
+//
+// @@@ 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 "JsonReader.h"
+#include <errno.h>
+#include <string.h>
+
+JsonReader *jsonReaderNew(const char *path)
+{
+ JsonReader *pJsonReader = (JsonReader *)calloc(1, sizeof(JsonReader));
+ if (!pJsonReader) {
+ return NULL;
+ }
+
+ pJsonReader->jsonFile = fopen(path, "r");
+ if (!pJsonReader->jsonFile) {
+ free(pJsonReader);
+ return NULL;
+ }
+
+ strncpy(pJsonReader->jsonFileName, path,
JSON_PARSER_MAX_FILE_NAME_LEN);
+ pJsonReader->nestDepth = 0;
+ pJsonReader->state = JSON_STATE_START;
+ pJsonReader->errorCode = JSON_SUCCESS;
+ pJsonReader->currentCharPtr = pJsonReader->buf;
+
+ return pJsonReader;
+}
+
+JsonReaderError jsonMoveCurrentCharPtr(JsonReader *pJsonReader)
+{
+ if (pJsonReader->isBufReady) {
+ ++pJsonReader->currentCharPtr;
+ }
+
+ if (pJsonReader->currentCharPtr == pJsonReader->buf +
pJsonReader->numberReadBuf) {
+ if ((pJsonReader->numberReadBuf = fread(pJsonReader->buf,
sizeof(char), JSON_PARSER_BUF_LEN, pJsonReader->jsonFile))) {
+ pJsonReader->currentCharPtr = pJsonReader->buf;
+ pJsonReader->isBufReady = true;
+ }
+ else {
+ pJsonReader->errorCode = JSON_ERROR_PARSE_EOF;
+ }
+ }
+
+ if (*(pJsonReader->currentCharPtr) == '\n') {
--- End diff --
Might this reference the first byte past the end of the buffer in the case
that line 62 was executed? If so that opens the possibility of a segmentation
violation.
> odb support to load json file
> -----------------------------
>
> Key: TRAFODION-2726
> URL: https://issues.apache.org/jira/browse/TRAFODION-2726
> Project: Apache Trafodion
> Issue Type: New Feature
> Components: db-utility-odb
> Reporter: 苏锦佩
> Priority: Minor
> Fix For: 2.3-incubating
>
>
> json is popular data storage format, so we want to support it on odb.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)