Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv14064/src/backends/monet5
Modified Files:
sql.mx sql_result.mx
Log Message:
fixed crash, after add / drop column
fixed passing over seperators, m5 doesn't do de-escaping by default, so
we do it in import and export
Index: sql_result.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql_result.mx,v
retrieving revision 1.81
retrieving revision 1.82
diff -u -d -r1.81 -r1.82
--- sql_result.mx 22 Jan 2008 23:15:35 -0000 1.81
+++ sql_result.mx 30 Jan 2008 10:41:35 -0000 1.82
@@ -383,30 +383,6 @@
return NULL;
}
-static char *
-coerce(char *s)
-{
- char *n = GDKmalloc(strlen(s) + 1);
- char *t = n;
-
- for (; *s; s++)
- switch (*s) {
- case '\\':
- s++;
- if (*s == 'n')
- *t++ = '\n';
- else if (*s == 't')
- *t++ = '\t';
- else if (*s == '\\')
- *t++ = '\\';
- else
- default:
- *t++ = *s;
- }
- *t = 0;
- return n;
-}
-
ptr *
_ASCIIadt_frStr(void *extra, int type, char *s, char *e, char quote)
{
@@ -501,8 +477,6 @@
if (offset > 0)
offset--;
- sep = coerce(sep);
- rsep = coerce(rsep);
if (t->columns.set) {
stream *out = m->scanner.ws;
dec_format *dec;
@@ -551,8 +525,6 @@
GDKfree(dec);
TABLETdestroy_format(&as);
}
- _DELETE(sep);
- _DELETE(rsep);
m->type = Q_UPDATE;
return bats;
@@ -1044,8 +1016,6 @@
size_t count;
stream *s;
BAT *order = NULL;
- char *sep = t->tsep;
- char *rsep = t->rsep;
s = open_wastream(t->filename);
if (!s || stream_errnr(s)) {
@@ -1053,19 +1023,15 @@
return -1;
}
- sep = coerce(sep);
- rsep = coerce(rsep);
if (!t->order) {
- res = mvc_export_row(m, s, t, "", sep, rsep, t->ssep);
+ res = mvc_export_row(m, s, t, "", t->tsep, t->rsep, t->ssep);
} else {
order = BATdescriptor(t->order);
count = BATcount(order);
- res = mvc_export_table(m, s, t, order, 0, count, "", sep, rsep,
t->ssep);
+ res = mvc_export_table(m, s, t, order, 0, count, "", t->tsep,
t->rsep, t->ssep);
BBPunfix(order->batCacheid);
m->results = res_tables_remove(m->results, t);
}
- _DELETE(sep);
- _DELETE(rsep);
stream_close(s);
stream_destroy(s);
return res;
Index: sql.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql.mx,v
retrieving revision 1.250
retrieving revision 1.251
diff -u -d -r1.250 -r1.251
--- sql.mx 29 Jan 2008 15:02:21 -0000 1.250
+++ sql.mx 30 Jan 2008 10:41:35 -0000 1.251
@@ -686,7 +686,7 @@
sql5_export str mvc_clear_table_wrap(lng *res, str *sname, str *tname);
sql5_export str mvc_delete_wrap(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
sql5_export str mvc_result_row_wrap(int *res_id, int *nr_cols, int *qtype, int
*o);
-sql5_export str mvc_result_file_wrap(int *res_id, int *nr_cols, str *file, str
*sep, str *rsep, str *ssep, bat *order_bid);
+sql5_export str mvc_result_file_wrap(int *res_id, int *nr_cols, str *file,
unsigned char* *sep, unsigned char* *rsep, unsigned char* *ssep, bat
*order_bid);
sql5_export str mvc_result_table_wrap(int *res_id, int *nr_cols, int *qtype,
bat *order_bid);
sql5_export str mvc_result_column_wrap(int *ret, int *rs, str *tn, str *name,
str *type, int *digits, int *scale, bat *bid);
@= result_value_export
@@ -704,7 +704,7 @@
sql5_export str mvc_export_result_wrap(int *ret, int *res_id, str *w);
sql5_export str mvc_export_operation_wrap(int *ret, str *w);
sql5_export str mvc_export_value_wrap(MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
-sql5_export str mvc_import_table_wrap(int *res, bstream **s, str *tname, str
*sep, str *rsep, str *ssep, int *sz, int *offset);
+sql5_export str mvc_import_table_wrap(int *res, bstream **s, str *tname,
unsigned char* *sep, unsigned char* *rsep, unsigned char* *ssep, int *sz, int
*offset);
sql5_export str bathash_wrap(int *res, int *bid );
sql5_export str hash_wrap(MalBlkPtr m, MalStkPtr s, InstrPtr p);
sql5_export str setVariable(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
@@ -1530,13 +1530,15 @@
}
str
-mvc_result_file_wrap(int *res_id, int *nr_cols, str *file, str *tsep, str
*rsep, str *ssep, bat *order_bid)
+mvc_result_file_wrap(int *res_id, int *nr_cols, str *file, unsigned char* *T,
unsigned char* *R, unsigned char* *S, bat *order_bid)
{
str res = MAL_SUCCEED;
BAT *order;
mvc *m = NULL;
str msg = getContext(&m, NULL);
res_table *t = NULL;
+ unsigned char *tsep = NULL, *rsep = NULL, *ssep = NULL;
+ ssize_t len;
if (msg)
return msg;
@@ -1546,9 +1548,15 @@
t = res_table_create(m->session->tr, m->result_id++, *nr_cols, Q_TABLE,
m->results, order);
m->results = t;
t->filename = _strdup(*file);
- t->tsep = _strdup(*tsep);
- t->rsep = _strdup(*rsep);
- t->ssep = _strdup(*ssep);
+ len = strlen((char*)(*T));
+ GDKstrFromStr(tsep=GDKmalloc(len+1), *T, len); len = 0;
+ len = strlen((char*)(*R));
+ GDKstrFromStr(rsep=GDKmalloc(len+1), *R, len); len = 0;
+ len = strlen((char*)(*S));
+ GDKstrFromStr(ssep=GDKmalloc(len+1), *S, len); len = 0;
+ t->tsep = (char*)tsep;
+ t->rsep = (char*)rsep;
+ t->ssep = (char*)ssep;
*res_id = t->id;
if (*res_id < 0)
res = createException(SQL, "sql.resultSet", "failed");
@@ -1731,15 +1739,26 @@
}
str
-mvc_import_table_wrap(int *res, bstream **s, str *tname, str *sep, str *rsep,
str *ssep, int *sz, int *offset)
+mvc_import_table_wrap(int *res, bstream **s, str *tname, unsigned char* *T,
unsigned char* *R, unsigned char* *S, int *sz, int *offset)
{
BAT *b;
mvc *m = NULL;
str msg = getContext(&m, NULL);
+ unsigned char *tsep = NULL, *rsep = NULL, *ssep = NULL;
+ ssize_t len = 0;
if (msg)
return msg;
- b = mvc_import_table(m, *s, *tname, *sep, *rsep, *ssep, *sz, *offset);
+ len = strlen((char*)(*T));
+ GDKstrFromStr(tsep=GDKmalloc(len+1), *T, len); len = 0;
+ len = strlen((char*)(*R));
+ GDKstrFromStr(rsep=GDKmalloc(len+1), *R, len); len = 0;
+ len = strlen((char*)(*S));
+ GDKstrFromStr(ssep=GDKmalloc(len+1), *S, len); len = 0;
+ b = mvc_import_table(m, *s, *tname, (char*)tsep, (char*)rsep,
(char*)ssep, *sz, *offset);
+ GDKfree(tsep);
+ GDKfree(rsep);
+ GDKfree(ssep);
if (!b)
throw(SQL, "importTable", "failed to import table");
*res = b->batCacheid;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins