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: return value for indoption column doesn't have proper encoding #111907

Closed
giangpham712 opened this issue Oct 6, 2023 · 1 comment · Fixed by #111911
Closed

sql: return value for indoption column doesn't have proper encoding #111907

giangpham712 opened this issue Oct 6, 2023 · 1 comment · Fixed by #111911
Assignees
Labels
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

@giangpham712
Copy link

giangpham712 commented Oct 6, 2023

Describe the problem

In this query

SELECT
  idxcls.oid AS idx_oid,
  nspname,
  cls.relname AS cls_relname,
  idxcls.relname AS idx_relname,
  indisunique,
  false AS indnullsnotdistinct,
  indnkeyatts,
  amcanorder,
  indkey,
  amname,
  indclass,
  indoption,
  indcollation,
  CASE
    WHEN indexprs IS NULL THEN NULL
    ELSE pg_get_expr(indexprs, cls.oid)
  END AS exprs,
  CASE
    WHEN indpred IS NULL THEN NULL
    ELSE pg_get_expr(indpred, cls.oid)
  END AS pred
FROM pg_class AS cls
JOIN pg_namespace AS ns ON ns.oid = cls.relnamespace
JOIN pg_index AS idx ON indrelid = cls.oid
JOIN pg_class AS idxcls ON idxcls.oid = indexrelid
JOIN pg_am AS am ON am.oid = idxcls.relam
WHERE
  cls.relkind = 'r' AND
  nspname NOT IN ('pg_catalog', 'information_schema', 'crdb_internal') AND
  NOT indisprimary AND
  cls.relname <> '__EFMigrationsHistory' AND
  -- Exclude tables which are members of PG extensions
  NOT EXISTS (
    SELECT 1 FROM pg_depend WHERE
      classid=(
        SELECT cls.oid
        FROM pg_class AS cls
        JOIN pg_namespace AS ns ON ns.oid = cls.relnamespace
        WHERE relname='pg_class' AND ns.nspname='pg_catalog'
      ) AND
      objid=cls.oid AND
      deptype IN ('e', 'x')
  );

The return value for indoption uses int64 encoding instead of int16

Additional context
This affects efcore.pg tests

@fqazi

Jira issue: CRDB-32127

@giangpham712 giangpham712 added the C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. label Oct 6, 2023
@blathers-crl
Copy link

blathers-crl bot commented Oct 6, 2023

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:

  • @cockroachdb/sql-foundations (found keywords: pg_)

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 dev-inf.

@blathers-crl blathers-crl bot added O-community Originated from the community X-blathers-triaged blathers was able to find an owner labels Oct 6, 2023
@fqazi fqazi self-assigned this Oct 6, 2023
fqazi added a commit to fqazi/cockroach that referenced this issue Oct 6, 2023
Previously, the indoption field inside pg_index was encoded incorrectly,
which could cause problems for binary clients. Specifically, an int8 was
being sent across the wire, then int2vectors are supposed to be made of
int2. To address this, this patch ensures that an int2 is used and adds
assertion inside the conversion code (for int2vector) to avoid future
problems.

Fixes: cockroachdb#111907

Release note (bug fix): indoption inside pg_index was not properly
encoded, causing clients to be unable to decode it as int2vector.
fqazi added a commit to fqazi/cockroach that referenced this issue Oct 6, 2023
Previously, the indoption field inside pg_index was encoded incorrectly,
which could cause problems for binary clients. Specifically, an int8 was
being sent across the wire, then int2vectors are supposed to be made of
int2. To address this, this patch ensures that an int2 is used and adds
assertion inside the conversion code (for int2vector) to avoid future
problems.

Fixes: cockroachdb#111907

Release note (bug fix): indoption inside pg_index was not properly
encoded, causing clients to be unable to decode it as int2vector.
craig bot pushed a commit that referenced this issue Oct 6, 2023
111911: pg_catalog: indoption was not encoded correctly r=fqazi a=fqazi

Previously, the indoption field inside pg_index was encoded incorrectly, which could cause problems for binary clients. Specifically, an int8 was being sent across the wire, then int2vectors are supposed to be made of int2. To address this, this patch ensures that an int2 is used and adds assertion inside the conversion code (for int2vector) to avoid future problems.

Fixes: #111907

Release note (bug fix): indoption inside pg_index was not properly encoded, causing clients to be unable to decode it as int2vector.

Co-authored-by: Faizan Qazi <[email protected]>
@craig craig bot closed this as completed in 1588a76 Oct 6, 2023
blathers-crl bot pushed a commit that referenced this issue Oct 6, 2023
Previously, the indoption field inside pg_index was encoded incorrectly,
which could cause problems for binary clients. Specifically, an int8 was
being sent across the wire, then int2vectors are supposed to be made of
int2. To address this, this patch ensures that an int2 is used and adds
assertion inside the conversion code (for int2vector) to avoid future
problems.

Fixes: #111907

Release note (bug fix): indoption inside pg_index was not properly
encoded, causing clients to be unable to decode it as int2vector.
blathers-crl bot pushed a commit that referenced this issue Oct 6, 2023
Previously, the indoption field inside pg_index was encoded incorrectly,
which could cause problems for binary clients. Specifically, an int8 was
being sent across the wire, then int2vectors are supposed to be made of
int2. To address this, this patch ensures that an int2 is used and adds
assertion inside the conversion code (for int2vector) to avoid future
problems.

Fixes: #111907

Release note (bug fix): indoption inside pg_index was not properly
encoded, causing clients to be unable to decode it as int2vector.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

2 participants