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: CHAR behavior inconsistent with Postgres #69673

Open
mgartner opened this issue Aug 31, 2021 · 1 comment
Open

sql: CHAR behavior inconsistent with Postgres #69673

mgartner opened this issue Aug 31, 2021 · 1 comment
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL A-sql-semantics C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. E-quick-win Likely to be a quick win for someone experienced. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) T-sql-queries SQL Queries Team

Comments

@mgartner
Copy link
Collaborator

mgartner commented Aug 31, 2021

In Postgres:

marcus=# CREATE TABLE t (c CHAR);
CREATE TABLE

marcus=# INSERT INTO t VALUES (' '), ('');
INSERT 0 2

marcus=# SELECT c = ' ', c = '' FROM t;
 ?column? | ?column?
----------+----------
 t        | t
 t        | t
(2 rows)

In cockroach v21.1.7:

defaultdb> CREATE TABLE t (c CHAR);
CREATE TABLE

defaultdb> INSERT INTO t VALUES (' '), ('');
INSERT 2

defaultdb> SELECT c = ' ', c = '' FROM t;
  ?column? | ?column?
-----------+-----------
   false   |   true
   false   |   true
(2 rows)

Jira issue: CRDB-9714

@mgartner mgartner added C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. A-sql-semantics labels Aug 31, 2021
@blathers-crl blathers-crl bot added T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) T-sql-queries SQL Queries Team labels Aug 31, 2021
@mgartner mgartner self-assigned this Sep 14, 2021
@mgartner mgartner removed their assignment Jan 7, 2022
@rafiss
Copy link
Collaborator

rafiss commented Apr 21, 2022

More fun behavior on this:

rafiss@127:postgres> select length(c) from t where c = '';
+--------+
| length |
|--------|
| 0      |
| 0      |
+--------+
SELECT 2
Time: 0.008s
rafiss@127:postgres> select length(c) from t where c = ' ';
+--------+
| length |
|--------|
| 0      |
| 0      |
+--------+

@rafiss rafiss added the E-quick-win Likely to be a quick win for someone experienced. label Nov 17, 2022
@rafiss rafiss added the A-sql-pgcompat Semantic compatibility with PostgreSQL label Nov 17, 2022
@mgartner mgartner moved this to New Backlog in SQL Queries Jul 24, 2023
@exalate-issue-sync exalate-issue-sync bot removed the T-sql-queries SQL Queries Team label Apr 16, 2024
@yuzefovich yuzefovich added the T-sql-queries SQL Queries Team label May 2, 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 A-sql-semantics C-bug Code not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior. E-quick-win Likely to be a quick win for someone experienced. T-sql-foundations SQL Foundations Team (formerly SQL Schema + SQL Sessions) T-sql-queries SQL Queries Team
Projects
Status: Backlog
Development

No branches or pull requests

4 participants