To resolve the issue, do as follows:
1. Log into a Linux shell on the NCM PostgreSQL Control Database (controldb) host as 'root'.
2. Run the following command to launch a controldb shell (the current controldb password will be required):
su - pgdba -s /bin/bash -c 'psql voyencedb voyence'
3. Run the following query to find out which column widths are mismatched between the
voyence and
archive versions of the table (where
{table name} is the name of the table cited in any error messages):
PREPARE voyence_vs_archive_type_compare( text ) AS
SELECT
a.table_name,
a.column_name,
v.voyence_type,
a.archive_type
FROM (
SELECT
table_name,
column_name,
'varchar(' || character_maximum_length || ')' AS archive_type
FROM information_schema.columns
WHERE
table_schema = 'archive' AND
table_name = $1
) AS a
JOIN (
SELECT
table_name,
column_name,
'varchar(' || character_maximum_length || ')' AS voyence_type
FROM information_schema.columns
WHERE
table_schema = 'voyence' AND
table_name = $1
) AS v
ON a.column_name = v.column_name
WHERE voyence_type != archive_type;
EXECUTE voyence_vs_archive_type_compare('{table name}');
Example: (Note:
column_name value below may vary according which columns are mismatched between the
voyence and
archive schema versions of the table):
voyencedb=# EXECUTE voyence_vs_archive_type_compare('cm_cel_audit_record');
table_name | column_name | voyence_type | archive_type
---------------------+----------------+---------------+--------------
cm_cel_audit_record | description | varchar(1024) | varchar(500)
(1 row)
Note: The prepared statement can be executed repeatedly using different table names without re-pasting the query.
4. Run the following SQL command to verify the max space required to store a value in the column identified in Step 3 above in the
voyence schema version of the table column (Note: Results may differ by file system, however, we generally expect the result to be the sum of the character width of the column and additional overhead space needed that equates to approximately the same size as it would take to store 4 additional characters - in the example above it would be 1028; substitute the
column_name value identified in Step 3 above in place of the highlighted
{column name} reference in all steps below):
SELECT atttypmod
FROM pg_attribute
WHERE
attrelid = '{schema_name.table_name}'::regclass AND
attname = '{column name}';
Example (Continuation of previous example using the
description column in the
voyence version of the
cm_cel_audit_record table, assuming Step 2 above style login):
voyencedb=# SELECT atttypmod
voyencedb-# FROM pg_attribute
voyencedb-# WHERE
voyencedb-# attrelid = 'voyence.cm_cel_audit_record'::regclass AND
voyencedb-# attname = 'description';
atttypmod
-----------
1028
(1 row)
5. Run the following command to increase the maximum width in characters for the mismatched column in the archive version of the table where:
{new size} is the maximum size of the data allowed for the column in the
voyence schema version of the table as determined in Step 4 above.
{schema_name.table_name} is the name of the archive schema qualified name of the table cited in the error message.
{column name} is the name of the column in question.
UPDATE pg_attribute
SET atttypmod = {new size}
WHERE attrelid = '{schema_name.table_name}'::regclass
AND attname = '{column name}';
Example (Continuation of previous step examples using the
description column in the
archive version of the
cm_cel_audit_record table):
voyencedb=# SELECT atttypmod
voyencedb-# FROM pg_attribute
voyencedb-# WHERE
voyencedb-# attrelid = 'archive.cm_cel_audit_record'::regclass AND
voyencedb-# attname = 'description';
atttypmod
-----------
500
(1 row)
voyencedb=# UPDATE pg_attribute
voyencedb-# SET atttypmod = 1028
voyencedb-# WHERE attrelid = 'archive.cm_cel_audit_record'::regclass AND
voyencedb-# AND attname = 'description';
UPDATE 1
voyencedb=# SELECT atttypmod
voyencedb-# FROM pg_attribute
voyencedb-# WHERE
voyencedb-# attrelid = 'archive.cm_cel_audit_record'::regclass AND
voyencedb-# attname = 'description';
atttypmod
-----------
1028
(1 row)