Changeset: 344c0aa93cdf for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=344c0aa93cdf Modified Files: sql/backends/monet5/sql.mx sql/benchmarks/tpch/dbgen/BUGS sql/benchmarks/tpch/dbgen/CHANGES sql/benchmarks/tpch/dbgen/HISTORY sql/benchmarks/tpch/dbgen/PORTING.NOTES sql/benchmarks/tpch/dbgen/bcd2.c sql/benchmarks/tpch/dbgen/bcd2.h sql/benchmarks/tpch/dbgen/bm_utils.c sql/benchmarks/tpch/dbgen/build.c sql/benchmarks/tpch/dbgen/config.h sql/benchmarks/tpch/dbgen/dists.dss sql/benchmarks/tpch/dbgen/driver.c sql/benchmarks/tpch/dbgen/dss.ddl sql/benchmarks/tpch/dbgen/dss.h sql/benchmarks/tpch/dbgen/dss.ri sql/benchmarks/tpch/dbgen/dsstypes.h sql/benchmarks/tpch/dbgen/history.html sql/benchmarks/tpch/dbgen/load_stub.c sql/benchmarks/tpch/dbgen/makefile.suite sql/benchmarks/tpch/dbgen/permute.c sql/benchmarks/tpch/dbgen/permute.h sql/benchmarks/tpch/dbgen/print.c sql/benchmarks/tpch/dbgen/qgen.c sql/benchmarks/tpch/dbgen/rnd.c sql/benchmarks/tpch/dbgen/rnd.h sql/benchmarks/tpch/dbgen/shared.h sql/benchmarks/tpch/dbgen/speed_seed.c sql/benchmarks/tpch/dbgen/text.c sql/benchmarks/tpch/dbgen/tpcd.h sql/benchmarks/tpch/dbgen/varsub.c sql/server/rel_bin.c sql/server/rel_select.c Branch: default Log Message:
Merge with Dec2011 branch.
diffs (truncated from 10763 to 300 lines):
diff --git a/clients/mapiclient/mclient.1 b/clients/mapiclient/mclient.1
--- a/clients/mapiclient/mclient.1
+++ b/clients/mapiclient/mclient.1
@@ -172,6 +172,10 @@ to the client),
is a pretty format which is meant for human consumption, and
.B xml
is a valid (in the XML sense) document.
+In addition to plain \fBcsv\fP, two other forms are possible.
+\fBcsv=\fP\fIc\fP uses \fIc\fP as column separator; \fBcsv+\fP\fIc\fP
+uses \fIc\fP as column separator, but produces a single header line in
+addition to the data.
.TP
\fB\-\-echo\fP (\fB\-e\fP)
Echo the query.
@@ -288,13 +292,10 @@ Echo the query in SQL formatting mode.
Use the specified
.I format
mode to format the output.
-Possible modes are
-.BR csv ,
-.BR tab ,
-.BR raw ,
-.BR sql ,
-and
-.BR xml .
+Possible modes the same as for the
+.B \-\-format
+.RB ( \-f )
+option.
.TP
\fB\ew\fP \fIwidth\fP
Set the maximum page width for rendering in the
diff --git a/clients/mapiclient/mclient.c b/clients/mapiclient/mclient.c
--- a/clients/mapiclient/mclient.c
+++ b/clients/mapiclient/mclient.c
@@ -111,12 +111,13 @@ enum formatters {
RAWformatter,
TABLEformatter,
CSVformatter,
- TABformatter,
XMLformatter,
TESTformatter
};
static enum formatters formatter = NOformatter;
char *output = NULL; /* output format as string */
+char *separator = NULL; /* column separator for CSV/TAB format
*/
+int csvheader = 0; /* include header line in CSV format */
#define DEFWIDTH 80
@@ -634,9 +635,20 @@ CSVrenderer(MapiHdl hdl)
{
int fields;
char *s;
- char *sep = formatter == CSVformatter ? "," : "\t";
+ char *sep = separator;
int i;
+ if (csvheader) {
+ fields = mapi_get_field_count(hdl);
+ for (i = 0; i < fields; i++) {
+ s = mapi_get_name(hdl, i);
+ if (s == NULL)
+ s = "";
+ mnstr_printf(toConsole, "%s%s",
+ i == 0 ? "" : sep, s ? s : "");
+ }
+ mnstr_printf(toConsole, "\n");
+ }
while (!mnstr_errnr(toConsole) && (fields = fetch_row(hdl)) != 0) {
for (i = 0; i < fields; i++) {
s = mapi_fetch_field(hdl, i);
@@ -660,7 +672,7 @@ CSVrenderer(MapiHdl hdl)
mnstr_write(toConsole, "\\\\",
1, 2);
break;
case '"':
- mnstr_write(toConsole, "\\\"",
1, 2);
+ mnstr_write(toConsole, "\"\"",
1, 2);
break;
default:
if (*s == *sep)
@@ -1280,27 +1292,41 @@ SQLrenderer(MapiHdl hdl, char singleinst
static void
setFormatter(char *s)
{
+ if (separator)
+ free(separator);
+ separator = NULL;
+ csvheader = 0;
#ifdef WIN32
if (formatter == TESTformatter)
_set_output_format(0);
#endif
- if (strcmp(s, "sql") == 0)
+ if (strcmp(s, "sql") == 0) {
formatter = TABLEformatter;
- else if (strcmp(s, "csv") == 0)
+ } else if (strcmp(s, "csv") == 0) {
formatter = CSVformatter;
- else if (strcmp(s, "tab") == 0)
- formatter = TABformatter;
- else if (strcmp(s, "raw") == 0)
+ separator = strdup(",");
+ } else if (strncmp(s, "csv=", 4) == 0) {
+ formatter = CSVformatter;
+ separator = strdup(s + 4);
+ } else if (strncmp(s, "csv+", 4) == 0) {
+ formatter = CSVformatter;
+ separator = strdup(s + 4);
+ csvheader = 1;
+ } else if (strcmp(s, "tab") == 0) {
+ formatter = CSVformatter;
+ separator = strdup("\t");
+ } else if (strcmp(s, "raw") == 0) {
formatter = RAWformatter;
- else if (strcmp(s, "xml") == 0)
+ } else if (strcmp(s, "xml") == 0) {
formatter = XMLformatter;
- else if (strcmp(s, "test") == 0) {
+ } else if (strcmp(s, "test") == 0) {
#ifdef WIN32
_set_output_format(_TWO_DIGIT_EXPONENT);
#endif
formatter = TESTformatter;
- } else
+ } else {
mnstr_printf(toConsole, "unsupported formatter\n");
+ }
}
static void
@@ -1494,7 +1520,6 @@ format_result(Mapi mid, MapiHdl hdl, cha
XMLrenderer(hdl);
break;
case CSVformatter:
- case TABformatter:
CSVrenderer(hdl);
break;
case TESTformatter:
@@ -2349,10 +2374,7 @@ doFileByLines(Mapi mid, FILE *fp, const
mnstr_printf(toConsole,
"sql\n");
break;
case CSVformatter:
- mnstr_printf(toConsole,
"csv\n");
- break;
- case TABformatter:
- mnstr_printf(toConsole,
"tab\n");
+ mnstr_printf(toConsole,
"%s\n", separator[0] == '\t' ? "tab" : "csv");
break;
case TESTformatter:
mnstr_printf(toConsole,
"test\n");
diff --git a/clients/odbc/driver/SQLSpecialColumns.c
b/clients/odbc/driver/SQLSpecialColumns.c
--- a/clients/odbc/driver/SQLSpecialColumns.c
+++ b/clients/odbc/driver/SQLSpecialColumns.c
@@ -427,15 +427,6 @@ SQLSpecialColumns_(ODBCStmt *stmt,
query_end += strlen(query_end);
}
- /* we don't actually need a UNION. Except for a bug
- * in the server, we could use instead: "select
- * sk.scope, sk.column_name, sk.data_type,
- * sk.type_name, sk.column_size, sk.buffer_length,
- * sk.decimal_digits, sk.pseudo_column from sk where
- * (sk.type = 0 and sk.table_id in (select tid from
- * tid)) or (sk.type = 1 and sk.table_id not in
- * (select tid from tid))" as SELECT query after the
- * definition of "tid". */
strcpy(query_end,
"),"
" tid as ("
@@ -448,19 +439,13 @@ SQLSpecialColumns_(ODBCStmt *stmt,
" sc.buffer_length, sc.decimal_digits,"
" sc.pseudo_column"
" from sc"
- " where sc.type = 0 and"
- " sc.table_id in (select tid from tid)"
- " union"
- " select sc.scope, sc.column_name, sc.data_type,"
- " sc.type_name, sc.column_size,"
- " sc.buffer_length, sc.decimal_digits,"
- " sc.pseudo_column"
- " from sc"
- " where sc.type = 1 and"
- " sc.table_id not in (select tid from tid)");
+ " where (sc.type = 0 and"
+ " sc.table_id in (select tid from tid)) or"
+ " (sc.type = 1 and"
+ " sc.table_id not in (select tid from tid))");
query_end += strlen(query_end);
- /* no ordering needed */
+ /* ordering on SCOPE not needed (since it is constant) */
} else {
assert(IdentifierType == SQL_ROWVER);
/* The backend does not have such info available */
diff --git a/monetdb5/modules/mal/Tests/inspect05.stable.out
b/monetdb5/modules/mal/Tests/inspect05.stable.out
--- a/monetdb5/modules/mal/Tests/inspect05.stable.out
+++ b/monetdb5/modules/mal/Tests/inspect05.stable.out
@@ -4749,23 +4749,23 @@ end main;
[ "sht", "command", "calc", "(x:chr):sht
",
"CALCchr2sht;"
]
[ "sht", "command", "calc", "(x:bit):sht
",
"CALCbit2sht;"
]
[ "sht", "command", "calc", "(x:oid):sht
",
"CALCoid2sht;"
]
-[ "sign", "command", "calc", "(x:dbl):dbl
",
"CALCunarydblSIGN;"
]
+[ "sign", "command", "calc", "(x:dbl):int
",
"CALCunarydblSIGN;"
]
[ "sizeof", "command", "calc", "(x:dbl):int
",
"CALCsizeofdbl;"
]
-[ "sign", "command", "calc", "(x:lng):lng
",
"CALCunarylngSIGN;"
]
+[ "sign", "command", "calc", "(x:lng):int
",
"CALCunarylngSIGN;"
]
[ "sizeof", "command", "calc", "(x:lng):int
",
"CALCsizeoflng;"
]
-[ "sign", "command", "calc", "(x:flt):flt
",
"CALCunaryfltSIGN;"
]
+[ "sign", "command", "calc", "(x:flt):int
",
"CALCunaryfltSIGN;"
]
[ "sizeof", "command", "calc", "(x:flt):int
",
"CALCsizeofflt;"
]
-[ "sign", "command", "calc", "(x:wrd):wrd
",
"CALCunarywrdSIGN;"
]
+[ "sign", "command", "calc", "(x:wrd):int
",
"CALCunarywrdSIGN;"
]
[ "sizeof", "command", "calc", "(x:wrd):int
",
"CALCsizeofwrd;"
]
[ "sign", "command", "calc", "(x:int):int
",
"CALCunaryintSIGN;"
]
[ "sizeof", "command", "calc", "(x:int):int
",
"CALCsizeofint;"
]
-[ "sign", "command", "calc", "(x:sht):sht
",
"CALCunaryshtSIGN;"
]
+[ "sign", "command", "calc", "(x:sht):int
",
"CALCunaryshtSIGN;"
]
[ "sizeof", "command", "calc", "(x:sht):int
",
"CALCsizeofsht;"
]
-[ "sign", "command", "calc", "(x:bte):bte
",
"CALCunarybteSIGN;"
]
+[ "sign", "command", "calc", "(x:bte):int
",
"CALCunarybteSIGN;"
]
[ "sizeof", "command", "calc", "(x:bte):int
",
"CALCsizeofbte;"
]
-[ "sign", "command", "calc", "(x:chr):chr
",
"CALCunarychrSIGN;"
]
+[ "sign", "command", "calc", "(x:chr):int
",
"CALCunarychrSIGN;"
]
[ "sizeof", "command", "calc", "(x:chr):int
",
"CALCsizeofchr;"
]
-[ "sign", "command", "calc", "(x:bit):bit
",
"CALCunarybitSIGN;"
]
+[ "sign", "command", "calc", "(x:bit):int
",
"CALCunarybitSIGN;"
]
[ "sizeof", "command", "calc", "(x:bit):int
",
"CALCsizeofbit;"
]
[ "sqladd", "command", "calc",
"(left:lng,right:dbl):dbl ",
"CALCbinarySQLADDlngdbl;" ]
[ "sqladd", "command", "calc",
"(left:lng,right:flt):dbl ",
"CALCbinarySQLADDlngflt;" ]
diff --git a/monetdb5/modules/mal/Tests/inspect05.stable.out.Windows
b/monetdb5/modules/mal/Tests/inspect05.stable.out.Windows
--- a/monetdb5/modules/mal/Tests/inspect05.stable.out.Windows
+++ b/monetdb5/modules/mal/Tests/inspect05.stable.out.Windows
@@ -4738,23 +4738,23 @@ end main;
[ "sht", "command", "calc", "(x:chr):sht
",
"CALCchr2sht;"
]
[ "sht", "command", "calc", "(x:bit):sht
",
"CALCbit2sht;"
]
[ "sht", "command", "calc", "(x:oid):sht
",
"CALCoid2sht;"
]
-[ "sign", "command", "calc", "(x:dbl):dbl
",
"CALCunarydblSIGN;"
]
+[ "sign", "command", "calc", "(x:dbl):int
",
"CALCunarydblSIGN;"
]
[ "sizeof", "command", "calc", "(x:dbl):int
",
"CALCsizeofdbl;"
]
-[ "sign", "command", "calc", "(x:lng):lng
",
"CALCunarylngSIGN;"
]
+[ "sign", "command", "calc", "(x:lng):int
",
"CALCunarylngSIGN;"
]
[ "sizeof", "command", "calc", "(x:lng):int
",
"CALCsizeoflng;"
]
-[ "sign", "command", "calc", "(x:flt):flt
",
"CALCunaryfltSIGN;"
]
+[ "sign", "command", "calc", "(x:flt):int
",
"CALCunaryfltSIGN;"
]
[ "sizeof", "command", "calc", "(x:flt):int
",
"CALCsizeofflt;"
]
-[ "sign", "command", "calc", "(x:wrd):wrd
",
"CALCunarywrdSIGN;"
]
+[ "sign", "command", "calc", "(x:wrd):int
",
"CALCunarywrdSIGN;"
]
[ "sizeof", "command", "calc", "(x:wrd):int
",
"CALCsizeofwrd;"
]
[ "sign", "command", "calc", "(x:int):int
",
"CALCunaryintSIGN;"
]
[ "sizeof", "command", "calc", "(x:int):int
",
"CALCsizeofint;"
]
-[ "sign", "command", "calc", "(x:sht):sht
",
"CALCunaryshtSIGN;"
]
+[ "sign", "command", "calc", "(x:sht):int
",
"CALCunaryshtSIGN;"
]
[ "sizeof", "command", "calc", "(x:sht):int
",
"CALCsizeofsht;"
]
-[ "sign", "command", "calc", "(x:bte):bte
",
"CALCunarybteSIGN;"
]
+[ "sign", "command", "calc", "(x:bte):int
",
"CALCunarybteSIGN;"
]
[ "sizeof", "command", "calc", "(x:bte):int
",
"CALCsizeofbte;"
]
-[ "sign", "command", "calc", "(x:chr):chr
",
"CALCunarychrSIGN;"
]
+[ "sign", "command", "calc", "(x:chr):int
",
"CALCunarychrSIGN;"
]
[ "sizeof", "command", "calc", "(x:chr):int
",
"CALCsizeofchr;"
]
-[ "sign", "command", "calc", "(x:bit):bit
",
"CALCunarybitSIGN;"
]
+[ "sign", "command", "calc", "(x:bit):int
",
"CALCunarybitSIGN;"
]
[ "sizeof", "command", "calc", "(x:bit):int
",
"CALCsizeofbit;"
]
[ "sqladd", "command", "calc",
"(left:lng,right:dbl):dbl ",
"CALCbinarySQLADDlngdbl;" ]
[ "sqladd", "command", "calc",
"(left:lng,right:flt):dbl ",
"CALCbinarySQLADDlngflt;" ]
diff --git a/sql/ChangeLog.Dec2011 b/sql/ChangeLog.Dec2011
--- a/sql/ChangeLog.Dec2011
+++ b/sql/ChangeLog.Dec2011
@@ -1,3 +1,8 @@
# ChangeLog file for sql
# This file is updated with Maddlog
+* Thu Nov 3 2011 Sjoerd Mullender <[email protected]>
+- mclient: The csv output format can now also be of the form csv=c and
+ csv+c where c is the column separator. The form with csv+ produces
+ a single header line with column names.
+
diff --git a/sql/backends/monet5/sql.mx b/sql/backends/monet5/sql.mx
--- a/sql/backends/monet5/sql.mx
+++ b/sql/backends/monet5/sql.mx
@@ -4829,7 +4829,7 @@ str bat@2_dec2_@1( int *res, int *s1, in
if ( b->T->nonil){
if (scale)
for (; p<q; p++, o++)
- *o = (@1) ((*p + (*p<0)?-5:5) / scales[scale]);
+ *o = (@1) ((*p + ((*p<0)?-5:5)) /
scales[scale]);
else
for (; p<q; p++, o++)
*o = (@1) (*p);
@@ -4839,7 +4839,7 @@ str bat@2_dec2_@1( int *res, int *s1, in
*o = @1_nil;
bn->T->nonil= FALSE;
} else if (scale) {
- *o = (@1) ((*p + (*p<0)?-5:5) / scales[scale]);
+ *o = (@1) ((*p + ((*p<0)?-5:5)) /
scales[scale]);
} else {
*o = (@1) (*p);
}
@@ -5327,7 +5327,7 @@ str bat@2_dec2_@1( int *res, int *s1, in
if ( b->T->nonil){
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list
