Incorrect result from QLC

Sam Bobroff samb-bulk@REDACTED
Fri Sep 4 07:41:51 CEST 2009


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

The following test program produces a set of results with two entries
for key 1, from an ordered_set table. The result I get is:

Records with val =:= 1: [{rec,1,1},{rec,2,1},{rec,1,1}]

It is clearly incorrect for an 'ordered_set' table to have two entries
with a key of 1 (and the duplicate entry vanishes after the transaction
completes).

I'm running Erlang R13B01 on Ubuntu Linux.

- --- begin ---
%% Bug replication code, save to "bug.erl".
%% Compile with: erlc bug.erl
%% Run with: erl -noshell -run bug -run init stop

- -module(bug).
- -export([start/0]).

- -include_lib("stdlib/include/qlc.hrl").

- -record(rec, {key, val}).

start() ->
	ok = mnesia:start(),
	{atomic, ok} = mnesia:create_table(rec, [{attributes,
record_info(fields, rec)}, {type, ordered_set}, {index, [val]}]),
	{atomic, ok} = mnesia:transaction(fun() -> ok =
mnesia:write({rec,1,1}), ok = mnesia:write({rec,2,1}) end),
	{atomic, _} = mnesia:transaction(fun() ->
		ok = mnesia:write(hd(mnesia:read(rec, 1))),
		io:fwrite("Records with val =:= 1: ~p\n", [
			qlc:e(qlc:q([ R || R <- mnesia:table(rec), R#rec.val =:= 1 ]))
		])
	end).
- --- end ---

Cheers,
	Sam.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFKoKifm97/UHSa/AQRAsddAJ0UXUK+bjJ4KzbZFxTmwFsUw1mPDQCfQqq/
0QJV2U3IipjhfkVFfTGqQIY=
=lg8n
-----END PGP SIGNATURE-----


More information about the erlang-bugs mailing list