Changeset: 4d0a25760929 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4d0a25760929
Modified Files:
monetdb5/mal/mal_function.c
Branch: Aug2011
Log Message:
When using EXPLAIN, properly pass length to client.
Since changeset fd4bc33ca833 clob columns with width 0 are assumed to
consist of only NULL values. The EXPLAIN query produces also clob
columns with a declared width of 0. We now count the length of the
mal instructions so that we can report the correct column width. This
means an extra loop through the instructions, but that is only done
when we need the information.
diffs (35 lines):
diff --git a/monetdb5/mal/mal_function.c b/monetdb5/mal/mal_function.c
--- a/monetdb5/mal/mal_function.c
+++ b/monetdb5/mal/mal_function.c
@@ -587,17 +587,28 @@ listFunction(stream *fd, MalBlkPtr mb, M
mnstr_printf(fd, "# function definition missing\n");
return;
}
+ first = first<0?0:first;
+ size = size < 0?-size:size;
if (flg & LIST_MAPI) {
+ size_t len = 0;
+ str ps;
/* a bit dirty, but only here we have the number of lines */
mnstr_printf(fd, "&1 0 %d 1 %d\n", /* type id rows columns
tuples */
mb->stop, mb->stop);
mnstr_printf(fd, "%% .explain # table_name\n");
mnstr_printf(fd, "%% mal # name\n");
mnstr_printf(fd, "%% clob # type\n");
- mnstr_printf(fd, "%% 0 # length\n"); /* unknown */
+ for (i = first; i < first +size && i < mb->stop; i++) {
+ ps = instruction2str(mb, stk, getInstrPtr(mb, i), flg);
+ if (ps) {
+ size_t l = strlen(ps);
+ if (l > len)
+ len = l;
+ GDKfree(ps);
+ }
+ }
+ mnstr_printf(fd, "%% " SZFMT " # length\n", len); /*
unknown */
}
- first = first<0?0:first;
- size = size < 0?-size:size;
for (i = first; i < first +size && i < mb->stop; i++)
printInstruction(fd, mb, stk, getInstrPtr(mb, i), flg);
}
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list