I have a table in a PG 14 database having a column containing Infinity values in numeric[] arrays as follow:
SELECT id, factors_list FROM mytable ORDER BY id ASC LIMIT 2;
id | factors_list
---+-------------
1 | {Infinity,1,2.91825,2.2911174796669,1.58367915763394,1.96345397169765,1.41599564744287}
2 | {Infinity,1,1.0625,2.114,4.25,2.18021276595745}
The data type of this column is ARRAY (numeric[]) and the length of the array is variable (with some records being NULL):
SELECT column_name, data_type FROM information_schema.columns WHERE
table_name = 'mytable' AND column_name = 'factors_list';
column_name | data_type
----------------+-----------
factors_list | ARRAY
In order to restore this database table into an older (<14) PG database, I need to replace all Infinity values by any valid number, let's say 99999999.
How could I achieve that in an efficient way? (I have roughly 200'000 rows)
Infinityvalues? Support forInfinitygoes back until Postgres 8.2 (and possibly even earlier). What is this "older PG database" that doesn't support Infinity?"PostgreSQL 13.3 on x86_64-pc-linux-musl, compiled by gcc (Alpine 10.2.1_pre1) 10.2.1 20201203, 64-bit":ERROR: cannot convert infinity to numeric SQL state: 0A000numericdoesn't support infinity - but your column must be defined asfloat[]ordouble precision[]- you didn't mention that you want to convert this tonumeric