Repository navigation
Conversation
tuhaihe
marked this pull request as draft
November 13, 2026 09:25
Contributor
|
Ohh yes issue looks real, will take a look |
Contributor
|
Shoul be fixed once #2284 merge |
Contributor
No. Recheck-separate issue. 2284 does not fix that as-is |
Collaborator
|
to fix the alter_column_type test it is necessary to cherry-pick d36980b7159a343ec56baca40bfe6c67765095b7 too |
Sometimes a table's constraint may depend on a column of another table, so that we have to update the constraint when changing the referenced column's type. We need to have lock on the constraint's table to do that. ATPostAlterTypeCleanup believed that this case was only possible for FOREIGN KEY constraints, but it's wrong at least for CHECK and EXCLUDE constraints; and in general, we'd probably need exclusive lock to alter any sort of constraint. So just remove the contype check and acquire lock for any other table. This prevents a "you don't have lock" assertion failure, though no ill effect is observed in production builds. We'll error out later anyway because we don't presently support physically altering column types within stored composite columns. But the catalog-munging is basically all there, so we may as well make that part work. Bug: #18970 Reported-by: Alexander Lakhin <exclusion@gmail.com> Diagnosed-by: jian he <jian.universality@gmail.com> Author: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://postgr.es/m/18970-a7d1cfe1f8d5d8d9@postgresql.org Backpatch-through: 13 (cherry picked from commit c15798cf94c452f057c6b8dd38c904bb30a8864d)
The upstream fix removed the contype local variable since upstream no longer needs it after dropping the FOREIGN KEY-only lock condition. Cloudberry keeps an extra GPDB-specific rejection of ALTER TYPE on primary key / unique constraint columns (see gpdb#10561), which still references contype. Restore the declaration and assignment so the function keeps compiling and behaves identically to upstream plus the GPDB-only check.
Commits 8319e5cb5 et al missed the fact that ATPostAlterTypeCleanup
contains three calls to ATPostAlterTypeParse, and the other two
also need protection against passing a relid that we don't yet
have lock on. Add similar logic to those code paths, and add
some test cases demonstrating the need for it.
In v18 and master, the test cases demonstrate that there's a
behavioral discrepancy between stored generated columns and virtual
generated columns: we disallow changing the expression of a stored
column if it's used in any composite-type columns, but not that of
a virtual column. Since the expression isn't actually relevant to
either sort of composite-type usage, this prohibition seems
unnecessary; but changing it is a matter for separate discussion.
For now we are just documenting the existing behavior.
Reported-by: jian he <jian.universality@gmail.com>
Author: jian he <jian.universality@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: CACJufxGKJtGNRRSXfwMW9SqVOPEMdP17BJ7DsBf=tNsv9pWU9g@mail.gmail.com
Backpatch-through: 13
(cherry picked from commit d36980b7159a343ec56baca40bfe6c67765095b7)
Cloudberry Debug CI also reaches the missing statistics-table lock:
relation_open -> transformStatsStmt -> ATPostAlterTypeParse -> ATController
The existing alter_column_type test exercises this path. Keep the
Cloudberry-specific ATPostAlterTypeParse context and PK/UNIQUE checks.
reshke
force-pushed
the
fix-2307-alter-column-type-assert
branch
from
November 13, 2026 15:16
d5fa714 to
b5a17b4
Compare
Member
Author
|
hi @reshke @andr-sokolov is there a need to keep this PR? If not, let's close it. |
Collaborator
|
there is no need to keep this PR because #2319 has been merged |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2307
What does this PR do?
Type of Change
Breaking Changes
Test Plan
make installcheckmake -C src/test installcheck-cbdb-parallelImpact
Performance:
User-facing changes:
Dependencies:
Checklist
Additional Context
CI Skip Instructions