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: 'name' attribute of DOid datum is lost during spilling to disk #78547

Open
yuzefovich opened this issue Mar 26, 2022 · 1 comment
Open
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team

Comments

@yuzefovich
Copy link
Member

yuzefovich commented Mar 26, 2022

If we force spilling to disk, then we have some failures for pg_catalog test file. Namely, we lose name attribute of DOid datums for regproc type. For example, for this query:

query OTOOOOOOO colnames
SELECT oid, typname, typinput, typoutput, typreceive, typsend, typmodin, typmodout, typanalyze
FROM pg_catalog.pg_type
ORDER BY oid
----
oid         typname                                typinput        typoutput        typreceive        typsend           typmodin  typmodout  typanalyze
16          bool                                   boolin          boolout          boolrecv          boolsend          0         0          0
...

typinput, typoutput, typreceive, typsend columns will be printed incorrectly and will be incorrectly sent across the wire.

The root cause is that we're only encoding / decoding the integer when writing to disk, so we end up with an unpopulated DOid.name field.

As a possible solution we could include name into encoding / decoding as well, but that means we might make some data already written into the database no longer readable. My guess is that spilling to disk doesn't occur often enough, so we're probably ok with keeping this incompatibility unaddressed.

Jira issue: CRDB-14176

@yuzefovich yuzefovich added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-sql-pgcompat Semantic compatibility with PostgreSQL labels Mar 26, 2022
@blathers-crl blathers-crl bot added T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) T-sql-queries SQL Queries Team labels Mar 26, 2022
craig bot pushed a commit that referenced this issue Mar 27, 2022
78548: sql: populate semantic type of DOid correctly in some cases r=yuzefovich a=yuzefovich

This commit is a small step towards preserving the information of
a `DOid` during serialization / deserialization. Namely, we now preserve
the semantic type in some cases. There might be more cases where we want
to set a custom semantic type. Futhermore, `name` field is not preserved
at the moment.

Touches: #78547.

Release note: None

78563: sql/rowexec: make bulk row writer (materialized view/ctas) write-at-now r=dt a=dt

Release note: none.

Co-authored-by: Yahor Yuzefovich <[email protected]>
Co-authored-by: David Taylor <[email protected]>
@mgartner mgartner self-assigned this Mar 29, 2022
@mgartner
Copy link
Collaborator

mgartner commented Mar 29, 2022

This causes inconsistencies with Postgres for tables with REG* columns:

CockroachDB v21.2.7

defaultdb> create table t (r regtype);
CREATE TABLE

defaultdb> insert into t values ('int4'::regtype), ('bool'::regtype);
INSERT 2

defaultdb> select * from t;
  r
------
  23
  16
(2 rows)

Postgres 14.2

marcus=# create table t (r regtype);
CREATE TABLE

marcus=# insert into t values ('int4'::regtype), ('bool'::regtype);
INSERT 0 2

marcus=# select * from t;
    r
---------
 integer
 boolean
(2 rows)

@mgartner mgartner removed their assignment Mar 29, 2022
@exalate-issue-sync exalate-issue-sync bot removed the T-sql-queries SQL Queries Team label Jun 1, 2023
@mgartner mgartner moved this to Backlog (DO NOT ADD NEW ISSUES) in SQL Queries Jul 24, 2023
@mgartner mgartner moved this from Backlog (DO NOT ADD NEW ISSUES) to New Backlog in SQL Queries Feb 1, 2024
@yuzefovich yuzefovich added the T-sql-queries SQL Queries Team label May 2, 2024
@yuzefovich yuzefovich removed the T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) label Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. T-sql-queries SQL Queries Team
Projects
Status: Backlog
Development

No branches or pull requests

2 participants