File tree 1 file changed +20
-1
lines changed
1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change 19
19
20
20
#include "postgres.h"
21
21
#include "utils/json.h"
22
+ #include "utils/jsonfuncs.h"
23
+ #include "common/jsonapi.h"
22
24
23
25
#include "utils/load/ag_load_edges.h"
24
26
#include "utils/load/ag_load_labels.h"
25
27
#include "utils/load/age_load.h"
26
28
27
29
static agtype_value * csv_value_to_agtype_value (char * csv_val );
30
+ static bool json_validate (text * json );
28
31
29
32
agtype * create_empty_agtype (void )
30
33
{
@@ -43,6 +46,22 @@ agtype *create_empty_agtype(void)
43
46
return out ;
44
47
}
45
48
49
+ /*
50
+ * Validate JSON text.
51
+ *
52
+ * Note: this function is borrowed from PG16. It is simplified
53
+ * by removing two parameters as they are not used in age.
54
+ */
55
+ static bool json_validate (text * json )
56
+ {
57
+ JsonLexContext * lex = makeJsonLexContext (json , false);
58
+ JsonParseErrorType result ;
59
+
60
+ result = pg_parse_json (lex , & nullSemAction );
61
+
62
+ return result == JSON_SUCCESS ;
63
+ }
64
+
46
65
/*
47
66
* Converts the given csv value to an agtype_value.
48
67
*
@@ -56,7 +75,7 @@ static agtype_value *csv_value_to_agtype_value(char *csv_val)
56
75
char * new_csv_val ;
57
76
agtype_value * res ;
58
77
59
- if (!json_validate (cstring_to_text (csv_val ), false, false ))
78
+ if (!json_validate (cstring_to_text (csv_val )))
60
79
{
61
80
// wrap the string with double-quote
62
81
int oldlen ;
You can’t perform that action at this time.
0 commit comments