Skip to content

dbeaver/dbeaver#41239 Map PostgreSQL "char" type to CHAR regardless of type category - #43022

Merged
serge-rider merged 2 commits into
dbeaver:develfrom
seonwooj0810:fix/issue-41239-pg-char-type-category
Nov 26, 2026
Merged

serge-rider merged 2 commits into
dbeaver:develfrom
seonwooj0810:fix/issue-41239-pg-char-type-category

Conversation

@seonwooj0810

@seonwooj0810 seonwooj0810 commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #41239

Changing a column from varchar(n) to char(n) on PostgreSQL 15+ generated USING col::char::char(n), which truncates every value to one character. When the user types char(10), the base type resolves to the single-byte "char" type (oid 18). PostgreSQL 15 moved that type from typcategory S to Z (internal-use), and PostgreDataType.readDataType has no case for Z, so the type got Types.OTHER. getConditionTypeCasting() adds an explicit ::char cast for OTHER types, and PostgreSQL reads a bare char as bpchar(1).

Change:

  • readDataType maps oid 18 to Types.CHAR before looking at the category, as the branch for servers without typcategory already does. The USING clause no longer gets the extra cast, so it is col::char(10) again.
  • On PostgreSQL 14 and older the type was in category S and mapped to VARCHAR; it is now CHAR there too, which matches the pre-category branch.
  • Added PostgreCharDataTypeTest: reads oid 18 with category Z and S and checks the JDBC type and that no cast is added. Both tests fail before the change (1111 and 12 instead of 1).

Verification done:

  • Checked on Docker postgres:14 and postgres:17: select oid, typname, typcategory from pg_type where oid = 18 returns S on 14 and Z on 17. On 17, alter table t alter column c type char(10) using c::char::char(10) turns 'abcdefgh' into 'a'.
  • Full CE aggregate build mvn verify -T1C -Pproduct-dbeaver-ce,product-dbeaver-eclipse-ce (with dbeaver-common and datadam-api as siblings). All tests in org.jkiss.dbeaver.ext.postgresql.test pass, including the new ones. Some tests in unrelated modules (SQL parser/completion, cdata, cloudflare d1, and the datadam-api REST client tests) fail in my local setup; they don't touch the PostgreSQL plugin. I haven't run the DBeaver UI against a live server.

AI disclosure: this change was investigated, written and verified with an AI coding assistant (Claude).

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 5 complexity

Metric Results
Complexity 5

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@E1izabeth

Copy link
Copy Markdown
Member

Thanks for the contribution!

@E1izabeth

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-26T10:40:21.180796Z 8c1ca83 Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Bravo.

Reviewed commit: 8c1ca83934

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@serge-rider
serge-rider merged commit 78650be into dbeaver:devel Nov 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wrong alter column type statement when change VARCHAR(n) to CHAR(n) in postgresql

3 participants