Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: pg_attribute table lacks the notion of a 'default' collation #54989

Closed
timgraham opened this issue Sep 30, 2020 · 2 comments · Fixed by #56598
Closed

sql: pg_attribute table lacks the notion of a 'default' collation #54989

timgraham opened this issue Sep 30, 2020 · 2 comments · Fixed by #56598
Assignees
Labels
A-sql-pgcatalog A-sql-semantics C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community X-blathers-triaged blathers was able to find an owner

Comments

@timgraham
Copy link
Contributor

Describe the problem

Unlike PostgreSQL, CockroachDB reports a column's collation, even if none is given when creating the column.

To Reproduce

CREATE TABLE test (name VARCHAR(255) NOT NULL);
SELECT
    a.attname AS column_name,
    NOT (a.attnotnull OR (t.typtype = 'd' AND t.typnotnull)) AS is_nullable,
    pg_get_expr(ad.adbin, ad.adrelid) AS column_default,
    CASE WHEN collname = 'default' THEN NULL ELSE collname END AS collation
FROM pg_attribute a
LEFT JOIN pg_attrdef ad ON a.attrelid = ad.adrelid AND a.attnum = ad.adnum
LEFT JOIN pg_collation co ON a.attcollation = co.oid
JOIN pg_type t ON a.atttypid = t.oid
JOIN pg_class c ON a.attrelid = c.oid
JOIN pg_namespace n ON c.relnamespace = n.oid
WHERE c.relkind IN ('f', 'm', 'p', 'r', 'v')
    AND c.relname = 'test'
    AND n.nspname NOT IN ('pg_catalog', 'pg_toast')
    AND pg_catalog.pg_table_is_visible(c.oid);

  column_name | is_nullable | column_default | collation
--------------+-------------+----------------+------------
  name        |    false    | NULL           | en-US
  rowid       |    false    | unique_rowid() | NULL

Expected behavior

collation for the name column should be NULL rather than en-US.

Environment:

  • CockroachDB version v20.2.0-alpha.1-3651-g1be3227203 @ 2020/09/26 05:50:03

Additional context

Django 3.2 adds support for column collations. This causes Django's inspectdb utility to add the db_collation option to all CharFields. If this behavior can't or won't change, a workaround in the django-cockroachdb adapter may be possible by modifying the CASE WHEN collname = 'default' SQL with a retrieval of the default collation.

@blathers-crl
Copy link

blathers-crl bot commented Sep 30, 2020

Hello, I am Blathers. I am here to help you get the issue triaged.

Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here.

I have CC'd a few people who may be able to assist you:

If we have not gotten back to your issue within a few business days, you can try the following:

  • Join our community slack channel and ask on #cockroachdb.
  • Try find someone from here if you know they worked closely on the area and CC them.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is otan.

@blathers-crl blathers-crl bot added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community X-blathers-triaged blathers was able to find an owner labels Sep 30, 2020
@rafiss
Copy link
Collaborator

rafiss commented Nov 2, 2020

Potentially related to #54817

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-pgcatalog A-sql-semantics C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. O-community Originated from the community X-blathers-triaged blathers was able to find an owner
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants