Technical validation on altering atttypmod for numeric column in PostgreSQL - Mailing list pgsql-admin

From Mauricio Martini
Subject Technical validation on altering atttypmod for numeric column in PostgreSQL
Date
Msg-id BN7PR10MB2609BBFDA87D4BBC22ABF14D824BA@BN7PR10MB2609.namprd10.prod.outlook.com
Whole thread Raw
Responses Re: Technical validation on altering atttypmod for numeric column in PostgreSQL
Re: Technical validation on altering atttypmod for numeric column in PostgreSQL
Re: Technical validation on altering atttypmod for numeric column in PostgreSQL
List pgsql-admin
Hi team,
I am evaluating an approach to change the scale of a numeric column from numeric(18,2) to numeric(18,4) in a large table, aiming to avoid the cost of a full table rewrite.
The proposed approach involves directly updating the PostgreSQL system catalog:
UPDATE pg_attribute SET atttypmod = (18 << 16 | 4) + 4 WHERE attrelid = 'table'::regclass  AND attname  = 'column';
Before considering this in practice, I would like to validate a few points:
  • Is this approach considered safe from a data integrity perspective?
  • Is there a risk of inconsistencies in the internal representation of the numeric type (especially regarding scale)?
  • Could this impact indexes, functions, or aggregation operations?
  • Is there any official recommendation or prior experience using this approach in production environments?
  • Are there additional risks related to rollback, maintenance, or future operations (e.g., dump/restore, upgrades)?
The goal is to determine whether this alternative is viable, or if we should stick with more standard approaches (e.g., shadow column, incremental migration, etc.).
If anyone has experience with a similar scenario, your insights would be appreciated.
Thanks.


Att. Mauricio Martini

pgsql-admin by date:

Previous
From: Edwin UY
Date:
Subject: Re: Is the resultset from these queries has_table_privilege and information_schema.role_table_grants supposed to match?
Next
From: Holger Jakobs
Date:
Subject: Re: Technical validation on altering atttypmod for numeric column in PostgreSQL