Skip to content

Commit cbd19e2

Browse files
committed
Fix for nested lists
1 parent 328b014 commit cbd19e2

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/postgres_text_reader.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ void ParsePostgresNested(T &parser, string_t list, char start, char end) {
119119
parser.Initialize();
120120
bool quoted = false;
121121
bool was_quoted = false;
122+
vector<char> delims;
122123
string current_string;
123124
for (idx_t i = 1; i < size - 1; i++) {
124125
auto c = str[i];
@@ -142,11 +143,32 @@ void ParsePostgresNested(T &parser, string_t list, char start, char end) {
142143
continue;
143144
}
144145
switch (c) {
146+
case '{':
147+
delims.push_back('}');
148+
current_string += c;
149+
break;
150+
case '(':
151+
delims.push_back(')');
152+
current_string += c;
153+
break;
154+
case '}':
155+
case ')':
156+
if (delims.empty() || delims.back() != c) {
157+
throw InvalidInputException("Failed to convert list %s - mismatch in brackets", list.GetString());
158+
}
159+
delims.pop_back();
160+
current_string += c;
161+
break;
145162
case '"':
146163
quoted = true;
147164
was_quoted = true;
148165
break;
149166
case ',':
167+
if (!delims.empty()) {
168+
// in a nested struct
169+
current_string += c;
170+
break;
171+
}
150172
// next element
151173
if (!current_string.empty() || was_quoted) {
152174
parser.AddString(current_string, was_quoted);

0 commit comments

Comments
 (0)