@@ -133,11 +133,11 @@ inline string begin_array(bool bulk) {
133
133
return " array[" ;
134
134
}
135
135
136
- inline string end_array (bool bulk, pqxx::work& t, const std::string& schema, const std::string& table ) {
136
+ inline string end_array (bool bulk, pqxx::work& t, const std::string& schema, const std::string& type ) {
137
137
if (bulk)
138
138
return " }" ;
139
139
else
140
- return " ]::" + t.quote_name (schema) + " ." + t.quote_name (table ) + " []" ;
140
+ return " ]::" + t.quote_name (schema) + " ." + t.quote_name (type ) + " []" ;
141
141
}
142
142
143
143
inline string begin_object_in_array (bool bulk) {
@@ -1053,18 +1053,12 @@ struct session : enable_shared_from_this<session> {
1053
1053
fill_value (bulk, nested_bulk, t, base_name + field.name + " _" , fields, values, bin, f);
1054
1054
} else if (field.type ->array_of && field.type ->array_of ->filled_struct ) {
1055
1055
fields += " , " + t.quote_name (base_name + field.name );
1056
- if (bulk)
1057
- values += " \t {" ;
1058
- else
1059
- values += " , array[" ;
1056
+ values += sep (bulk) + begin_array (bulk);
1060
1057
uint32_t n = read_varuint32 (bin);
1061
1058
for (uint32_t i = 0 ; i < n; ++i) {
1062
1059
if (i)
1063
1060
values += " ," ;
1064
- if (bulk)
1065
- values += " \" (" ;
1066
- else
1067
- values += " (" ;
1061
+ values += begin_object_in_array (bulk);
1068
1062
string struct_fields;
1069
1063
string struct_values;
1070
1064
for (auto & f : field.type ->array_of ->fields )
@@ -1073,15 +1067,9 @@ struct session : enable_shared_from_this<session> {
1073
1067
values += struct_values.substr (1 );
1074
1068
else
1075
1069
values += struct_values.substr (2 );
1076
- if (bulk)
1077
- values += " )\" " ;
1078
- else
1079
- values += " )" ;
1070
+ values += end_object_in_array (bulk);
1080
1071
}
1081
- if (bulk)
1082
- values += " }" ;
1083
- else
1084
- values += " ]::" + t.quote_name (schema) + " ." + t.quote_name (field.type ->array_of ->name ) + " []" ;
1072
+ values += end_array (bulk, t, schema, field.type ->array_of ->name );
1085
1073
} else {
1086
1074
auto abi_type = field.type ->name ;
1087
1075
bool is_optional = false ;
@@ -1146,12 +1134,7 @@ struct session : enable_shared_from_this<session> {
1146
1134
values += sep (bulk) + null_value (bulk);
1147
1135
}
1148
1136
1149
- if (bulk) {
1150
- write_stream (block_index, t, " block_info" , values);
1151
- } else {
1152
- string query = " insert into " + t.quote_name (schema) + " .block_info(" + fields + " ) values (" + values + " )" ;
1153
- pipeline.insert (query);
1154
- }
1137
+ write (block_index, t, pipeline, bulk, " block_info" , fields, values);
1155
1138
} // receive_block
1156
1139
1157
1140
void receive_deltas (uint32_t block_num, input_buffer buf, bool bulk, pqxx::work& t, pqxx::pipeline& pipeline) {
0 commit comments