manticoresearch
manticoresearch copied to clipboard
select COUNT DISTINCT on 2 indices when result is zero throws internal error
Doing
SELECT COUNT(DISTINCT field_id) FROM index_one, index_two WHERE 1=0
throws this error
ERROR 1064 (42000): internal error: column '@distinct/count(distinct field_id)' not found in result set schema.
when doing
SELECT COUNT(DISTINCT field_id) FROM index_one WHERE 1=0
and
SELECT COUNT(DISTINCT field_id) FROM index_two WHERE 1=0
both work and return 0 results
This is basically happening when COUNT(DISTINCT field_id) will return 0 results for both indices used
PS: Tested on manticoresearch 5.0.2
PPS: index_one and index_two have the same structure (one being a delta index and one being a full index)
PPPS: sometimes I do get this in the log
-------------- backtrace begins here ---------------
Program compiled with Clang 13.0.1
Configured with flags: Configured with these definitions: -DDISTR_BUILD=jammy -DUSE_SYSLOG=1 -DWITH_GALERA=1 -DWITH_RE2=1 -DWITH_RE2_FORCE_STATIC=1 -DWITH_STEMMER=1 -DWITH_STEMMER_FORCE_STA
TIC=1 -DWITH_ICU=1 -DWITH_ICU_FORCE_STATIC=1 -DWITH_SSL=1 -DWITH_ZLIB=1 -DWITH_ZSTD=1 -DDL_ZSTD=1 -DZSTD_LIB=libzstd.so.1 -DWITH_ODBC=1 -DDL_ODBC=1 -DODBC_LIB=libodbc.so.2 -DWITH_EXPAT=1 -D
DL_EXPAT=1 -DEXPAT_LIB=libexpat.so.1 -DWITH_ICONV=1 -DWITH_MYSQL=1 -DDL_MYSQL=1 -DMYSQL_LIB=libmysqlclient.so.21 -DWITH_POSTGRESQL=1 -DDL_POSTGRESQL=1 -DPOSTGRESQL_LIB=libpq.so.5 -DLOCALDAT
ADIR=/var/lib/manticore/data -DFULL_SHARE_DIR=/usr/share/manticore
Host OS is Linux x86_64
Stack bottom = 0x7fbba4068200, thread stack size = 0x20000
Trying manual backtrace:
Something wrong with thread stack, manual backtrace may be incorrect (fp=0x7fbbb800cee0)
Wrong stack limit or frame pointer, manual backtrace failed (fp=0x7fbbb800cee0, stack=0x7fbba4070000, stacksize=0x20000)
Trying system backtrace:
begin of system symbols:
/usr/bin/searchd[0x599161]
/usr/bin/searchd[0x47b4ef]
/lib/x86_64-linux-gnu/libc.so.6( 0x42520)[0x7fbbd5eb5520]
/usr/bin/searchd[0x5a7d3f]
/usr/bin/searchd[0x63fd40]
/usr/bin/searchd[0x63f596]
/usr/bin/searchd[0x48c32c]
/usr/bin/searchd[0x4934fd]
/usr/bin/searchd[0x48f693]
/usr/bin/searchd[0x4b44e5]
/usr/bin/searchd[0x4c0e67]
/usr/bin/searchd[0x46aa60]
/usr/bin/searchd[0x467f7d]
/usr/bin/searchd[0xd7f20c]
/usr/bin/searchd[0xd9bc7f]
Trying boost backtrace:
0# 0x00000000005991B4 in /usr/bin/searchd
1# 0x000000000047B4EF in /usr/bin/searchd
2# 0x00007FBBD5EB5520 in /lib/x86_64-linux-gnu/libc.so.6
3# 0x00000000005A7D3F in /usr/bin/searchd
4# 0x000000000063FD40 in /usr/bin/searchd
5# 0x000000000063F596 in /usr/bin/searchd
6# 0x000000000048C32C in /usr/bin/searchd
7# 0x00000000004934FD in /usr/bin/searchd
8# 0x000000000048F693 in /usr/bin/searchd
9# 0x00000000004B44E5 in /usr/bin/searchd
10# 0x00000000004C0E67 in /usr/bin/searchd
11# 0x000000000046AA60 in /usr/bin/searchd
12# 0x0000000000467F7D in /usr/bin/searchd
13# 0x0000000000D7F20C in /usr/bin/searchd
14# 0x0000000000D9BC7F in /usr/bin/searchd
-------------- backtrace ends here ---------------
MRE
mysql> drop table if exists t1; drop table if exists t2; create table t1(f text, a int); create table t2 like t1; select count(distinct a) from t1, t2;
--------------
drop table if exists t1
--------------
Query OK, 0 rows affected (0.05 sec)
--------------
drop table if exists t2
--------------
Query OK, 0 rows affected (0.02 sec)
--------------
create table t1(f text, a int)
--------------
Query OK, 0 rows affected (0.03 sec)
--------------
create table t2 like t1
--------------
Query OK, 0 rows affected (0.00 sec)
--------------
select count(distinct a) from t1, t2
--------------
ERROR 1064 (42000): internal error: column '@distinct/count(distinct a)' not found in result set schema
➤ Ilya Kuznetsov commented:
Fixed in d3273164