Indeed, using correct SQL type(s) is the key, here: ======== $ cat /tmp/y.mal -------- sql.init(); table_names := bat.new(nil:str); bat.append(table_names, "t0"); bat.append(table_names, "t1"); table_attrs := bat.new(nil:str); bat.append(table_attrs, "int_col"); bat.append(table_attrs, "str_col"); table_types := bat.new(nil:str); bat.append(table_types, "int"); bat.append(table_types, "str"); table_lens := bat.new(nil:int); bat.append(table_lens, 1); bat.append(table_lens, 1); table_scales := bat.new(nil:int); bat.append(table_scales, 0); bat.append(table_scales, 0); ints := bat.new(nil:int); bat.append(ints, 42); bat.append(ints, 23); strs := bat.new(nil:str); bat.append(strs, "foo"); bat.append(strs, "bar"); sql.resultSet(table_names, table_attrs, table_types, table_lens, table_scales, ints, strs); ======== $ mclient -lmal /tmp/y.mal -------- * mserver5 crashes with segfault * ======== $ diff -du /tmp/{y,z}.mal -------- --- /tmp/y.mal 2017-11-29 20:36:01.083347399 +0100 +++ /tmp/z.mal 2017-11-29 20:36:34.235347852 +0100 @@ -10,7 +10,7 @@ table_types := bat.new(nil:str); bat.append(table_types, "int"); -bat.append(table_types, "str"); +bat.append(table_types, "varchar"); table_lens := bat.new(nil:int); bat.append(table_lens, 1); ======== $ mclient -lmal /tmp/z.mal -------- % t0, t1 # table_name % int_col, str_col # name % int, varchar # type % 2, 3 # length [ 42, "foo" ] [ 23, "bar" ] ======== Best, Stefan ----- On Nov 29, 2017, at 8:15 PM, Martin Kersten martin@monetdb.org wrote:
On 29/11/2017 16:20, dennis.fassl wrote:
Hi all,
can you help me with the below query? A simple GDB trace shows the following: 0 0x00007fffe84f67ae in sql_init_subtype (res=0x1c28f70, t=0x0, digits=1, scale=0) at /export/scratch1/mk/branches/default//package/sql/common/sql_types.c:158 #1 0x00007fffe84efe86 in res_col_create (tr=0x1b9b110, t=0x1c026d0, tn=0x1c26218 "t1", name=0x1cbab38 "str_col", typename=0x1cbd368 "str", digits=1, scale=0, mtype=4, val=0x19b7660) at /export/scratch1/mk/branches/default//package/sql/storage/bat/res_table.c:65 #2 0x00007fffe83cde30 in mvc_result_column (m=0x1ba11f0, tn=0x1c26218 "t1", name=0x1cbab38 "str_col", typename=0x1cbd368 "str", digits=1, scale=0, b=0x19b7660) at /export/scratch1/mk/branches/default//package/sql/backends/monet5/sql_result.c:2616 #3 0x00007fffe8366971 in mvc_result_set_wrap (cntxt=0x7fffe974d020, mb=0x19c3660, stk=0x6526f0, pci=0x1c16260) at /export/scratch1/mk/branches/default//package/sql/backends/monet5/sql.c:1926 #4 0x00007fffe836a062 in mvc_table_result_wrap (cntxt=0x7fffe974d020, mb=0x19c3660, stk=0x6526f0, pci=0x1c16260) at /export/scratch1/mk/branches/default//package/sql/backends/monet5/sql.c:2300 #5 0x00007ffff79dd2c3 in runMALsequence (cntxt=0x7fffe974d020, mb=0x19c3660, startpc=1, stoppc=0, stk=0x6526f0, env=0x6526f0, pcicaller=0x0) at /export/scratch1/mk/branches/default//package/monetdb5/mal/mal_interpreter.c:645
This implies that the SQL type descriptor relies on a transaction context, which is not set. Whether this can be avoided remains to be seen. You might file a bugreport.
In general, all MAL instructions at the SQL layer depend on the SQL context and often a transaction context. Mimicking this at the MAL layer is hardly feasible.
JDBC is meant to support SQL only.
regards, Martin
Is there an other way to return query results using the jdbc interface (without using sql.resultSet)?
Thanks in advance!
Best regards, Dennis
-------- Ursprüngliche Nachricht -------- Von: Dennis Fassl
Datum: 25.11.17 16:55 (GMT+01:00) An: users-list@monetdb.org Betreff: MAL query "sql.resultSet" Hi all,
I am trying to execute the MAL query below. But the command "sql.resultSet" is terminating mclient. When using the JDBC interface I get "SQLException: Connection to server lost! (mserver still alive?)".
Do you have an idea why this is happening?
Thanks and regards, Dennis
On 29/11/2017 19:55, Stefan Manegold wrote:
First question is what is happening?
Does the mserver5 keep running? Does it crash? are there any messages on the mserver5 console (or in the merovingian.log in case you use merovingian (aka. monetdbd))?
Second question is, why are you using MAL to create a SQL result set and send this via JDBC? What are you trying to do that cannot be done in SQL?
Thanks!
Stefan
----- On Nov 29, 2017, at 4:20 PM, dennis.fassl dennis.fassl@uni-konstanz.de wrote:
Hi all,
can you help me with the below query?
Is there an other way to return query results using the jdbc interface (without using sql.resultSet)?
Thanks in advance!
Best regards, Dennis
-------- Ursprüngliche Nachricht -------- Von: Dennis Fassl
Datum: 25.11.17 16:55 (GMT+01:00) An: users-list@monetdb.org Betreff: MAL query "sql.resultSet" Hi all,
I am trying to execute the MAL query below. But the command "sql.resultSet" is terminating mclient. When using the JDBC interface I get "SQLException: Connection to server lost! (mserver still alive?)".
Do you have an idea why this is happening?
Thanks and regards, Dennis
sql.init();
table_names := bat.new(nil:str); bat.append(table_names, "t0"); bat.append(table_names, "t1");
table_attrs := bat.new(nil:str); bat.append(table_attrs, "int_col"); bat.append(table_attrs, "str_col");
table_types := bat.new(nil:str); bat.append(table_types, "int"); bat.append(table_types, "str");
table_lens := bat.new(nil:int); bat.append(table_lens, 1); bat.append(table_lens, 1);
table_scales := bat.new(nil:int); bat.append(table_scales, 0); bat.append(table_scales, 0);
ints := bat.new(nil:int); bat.append(ints, 42); bat.append(ints, 23);
strs := bat.new(nil:str); bat.append(strs, "foo"); bat.append(strs, "bar");
sql.resultSet(table_names, table_attrs, table_types, table_lens, table_scales, ints, strs);
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
_______________________________________________ users-list mailing list users-list@monetdb.org https://www.monetdb.org/mailman/listinfo/users-list
-- | Stefan.Manegold@CWI.nl | DB Architectures (DA) | | www.CWI.nl/~manegold/ | Science Park 123 (L321) | | +31 (0)20 592-4212 | 1098 XG Amsterdam (NL) |