Re: Too short field

From: Thomas Kellerer <spam_eater(at)gmx(dot)net>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Re: Too short field
Date: 2019-07-03 11:56:03
Message-ID: b56469aa-4a9c-f678-a950-39fdcd43fb97@gmx.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Karl Martin Skoldebrand schrieb am 03.07.2019 um 13:30:
> Now, we have a bug in another application that prevents an automatic
> tool to enter certain users in the database. The organisational field
> is varchar(60) while the actual Organisation “abbreviation” may be as
> long as 70 characters (don’t ask why).
>
> What happens to data if I simple redefine the table field as
> varchar(80) (or something, at least 70+). Does “everything” break
> database side or can I just go on running the app as is.

Nothing will break on the database size.

> Do we need to restart databases or something else that requires an
> interrupted service?

No, you just run

ALTER the_table ALTER COLUMN organisational TYPE varchar(80);

It requires an exclusive lock on the table, but the actual operation
will finish in a few milliseconds because the table is not physically
changed (as the limit is only increased).

Getting the exlusive lock might take a while if the table is actively
used, so the ALTER statement itself might look as it would take a while,
but once the lock could be obtained the change is very fast.

There is no real need to stop anything if you can anticipate that there
will be a few (milli)seconds where the ALTER statement succeeds in
obtainin (and releasing) the lock.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Karl Martin Skoldebrand 2019-07-03 12:02:16 RE: Too short field
Previous Message Karl Martin Skoldebrand 2019-07-03 11:30:09 Too short field