Skip to content

Commit fdc1e5f

Browse files
committed
replace GROUP_CONCAT with JSON_ARRAYAGG to avoid errors like Row 19 was cut by GROUP_CONCAT
1 parent 5caf6cd commit fdc1e5f

File tree

1 file changed

+32
-30
lines changed

1 file changed

+32
-30
lines changed

engine/schema/src/main/resources/META-INF/db/schema-42010to42100.sql

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -687,22 +687,23 @@ CREATE TABLE IF NOT EXISTS `cloud`.`backup_details` (
687687
UPDATE `cloud`.`backups` b
688688
INNER JOIN `cloud`.`vm_instance` vm ON b.vm_id = vm.id
689689
SET b.backed_volumes = (
690-
SELECT CONCAT("[",
691-
GROUP_CONCAT(
692-
CONCAT(
693-
"{\"uuid\":\"", v.uuid, "\",",
694-
"\"type\":\"", v.volume_type, "\",",
695-
"\"size\":", v.`size`, ",",
696-
"\"path\":\"", IFNULL(v.path, 'null'), "\",",
697-
"\"deviceId\":", IFNULL(v.device_id, 'null'), ",",
698-
"\"diskOfferingId\":\"", doff.uuid, "\",",
699-
"\"minIops\":", IFNULL(v.min_iops, 'null'), ",",
700-
"\"maxIops\":", IFNULL(v.max_iops, 'null'),
701-
"}"
702-
)
703-
SEPARATOR ","
690+
SELECT COALESCE(
691+
CAST(
692+
JSON_ARRAYAGG(
693+
JSON_OBJECT(
694+
'uuid', v.uuid,
695+
'type', v.volume_type,
696+
'size', v.size,
697+
'path', v.path,
698+
'deviceId', v.device_id,
699+
'diskOfferingId', doff.uuid,
700+
'minIops', v.min_iops,
701+
'maxIops', v.max_iops
702+
)
703+
) AS CHAR
704704
),
705-
"]")
705+
'[]'
706+
)
706707
FROM `cloud`.`volumes` v
707708
LEFT JOIN `cloud`.`disk_offering` doff ON v.disk_offering_id = doff.id
708709
WHERE v.instance_id = vm.id
@@ -711,22 +712,23 @@ SET b.backed_volumes = (
711712
-- Add diskOfferingId, deviceId, minIops and maxIops to backup_volumes in vm_instance table
712713
UPDATE `cloud`.`vm_instance` vm
713714
SET vm.backup_volumes = (
714-
SELECT CONCAT("[",
715-
GROUP_CONCAT(
716-
CONCAT(
717-
"{\"uuid\":\"", v.uuid, "\",",
718-
"\"type\":\"", v.volume_type, "\",",
719-
"\"size\":", v.`size`, ",",
720-
"\"path\":\"", IFNULL(v.path, 'null'), "\",",
721-
"\"deviceId\":", IFNULL(v.device_id, 'null'), ",",
722-
"\"diskOfferingId\":\"", doff.uuid, "\",",
723-
"\"minIops\":", IFNULL(v.min_iops, 'null'), ",",
724-
"\"maxIops\":", IFNULL(v.max_iops, 'null'),
725-
"}"
726-
)
727-
SEPARATOR ","
715+
SELECT COALESCE(
716+
CAST(
717+
JSON_ARRAYAGG(
718+
JSON_OBJECT(
719+
'uuid', v.uuid,
720+
'type', v.volume_type,
721+
'size', v.size,
722+
'path', v.path,
723+
'deviceId', v.device_id,
724+
'diskOfferingId', doff.uuid,
725+
'minIops', v.min_iops,
726+
'maxIops', v.max_iops
727+
)
728+
) AS CHAR
728729
),
729-
"]")
730+
'[]'
731+
)
730732
FROM `cloud`.`volumes` v
731733
LEFT JOIN `cloud`.`disk_offering` doff ON v.disk_offering_id = doff.id
732734
WHERE v.instance_id = vm.id

0 commit comments

Comments
 (0)