Hi,

I am still learning about monetdb internals, so I hope someone can enlighten me here.

I was playing around with monetdb, and run into the following problem:

Suppose we have a table

CREATE TABLE test.simple_table("id" INTEGER);

INSERT INTO test.simple_table VALUES (1),(2),(3),(4),(5);

Let's say I want to run a simple query:

SELECT COUNT(*) AS val 
FROM test.simple_table 
ORDER BY val DESC;

+----+
|   v   |
+==+
|   5   |
+----+

Runs fine.
However, if add a LIMIT clause:

SELECT COUNT(*) AS val 
FROM test.simple_table 
ORDER BY val DESC 
LIMIT 5;

I get the following

TypeException:user.s37_7[17]:'algebra.markT' undefined in: _30:any := algebra.markT(_27:oid, _29:oid)
program contains errors

Now things let's add a primitive HAVING clause

SELECT COUNT(*) AS val 
FROM test.simple_table
HAVING 1 > 0 
ORDER BY val DESC 
LIMIT 5;

+----+
|   v   |
+==+
|   5   |
+----+

And things are magically fine again. Can someone explain what's going on?

Thanks,

George Ramonov
UC Berkeley
B.S. Electrical Engineering & Computer Science '13