-
-
Notifications
You must be signed in to change notification settings - Fork 526
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
select count(1) from <table>
does not return 1
#6120
Comments
I think this is actually expected behavior MySQL: mysql> select count(1);
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.0003 sec)
mysql> select sum(1);
+--------+
| sum(1) |
+--------+
| 1 |
+--------+
1 row in set (0.0003 sec)
mysql> select count(1) from dual;
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.0003 sec)
mysql> select sum(1) from dual;
+--------+
| sum(1) |
+--------+
| 1 |
+--------+
1 row in set (0.0003 sec)
mysql> create table t (i int primary key);
Query OK, 0 rows affected (0.0114 sec)
mysql> select count(1) from t;
+----------+
| count(1) |
+----------+
| 0 |
+----------+
1 row in set (0.0019 sec)
mysql> select sum(1) from t;
+--------+
| sum(1) |
+--------+
| NULL |
+--------+
1 row in set (0.0004 sec)
mysql> insert into t values (1);
Query OK, 1 row affected (0.0016 sec)
mysql> select count(1) from t;
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.0009 sec)
mysql> select sum(1) from t;
+--------+
| sum(1) |
+--------+
| 1 |
+--------+
1 row in set (0.0004 sec)
mysql> insert into t values (2);
Query OK, 1 row affected (0.0045 sec)
mysql> select count(1) from t;
+----------+
| count(1) |
+----------+
| 2 |
+----------+
1 row in set (0.0010 sec)
mysql> select sum(1) from t;
+--------+
| sum(1) |
+--------+
| 2 |
+--------+
1 row in set (0.0004 sec) Dolt: tmp> select count(1);
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.00 sec)
tmp> select sum(1);
+--------+
| sum(1) |
+--------+
| 1 |
+--------+
1 row in set (0.00 sec)
tmp> select count(1) from dual;
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.00 sec)
tmp> select sum(1) from dual;
+--------+
| sum(1) |
+--------+
| 1 |
+--------+
1 row in set (0.00 sec)
tmp> create table t (i int primary key);
tmp> select sum(1) from t;
+--------+
| sum(1) |
+--------+
| NULL |
+--------+
1 row in set (0.00 sec)
tmp> select count(1) from t;
+----------+
| count(1) |
+----------+
| 0 |
+----------+
1 row in set (0.00 sec)
tmp> insert into t values (1);
Query OK, 1 row affected (0.00 sec)
tmp> select count(1) from t;
+----------+
| count(1) |
+----------+
| 1 |
+----------+
1 row in set (0.00 sec)
tmp> select sum(1) from t;
+--------+
| sum(1) |
+--------+
| 1 |
+--------+
1 row in set (0.00 sec)
tmp> insert into t values (2);
Query OK, 1 row affected (0.00 sec)
tmp> select count(1) from t;
+----------+
| count(1) |
+----------+
| 2 |
+----------+
1 row in set (0.00 sec)
tmp> select sum(1) from t;
+--------+
| sum(1) |
+--------+
| 2 |
+--------+
1 row in set (0.00 sec)
tmp> exit I could add some enginetests for specifically |
Update: I was able to find a repro, this happens in |
Fix for this is in dolt main. Will be in next release. |
With no tables works as expected:
Adding a table confuses the analyzer:
The text was updated successfully, but these errors were encountered: