Changeset: 6bcb83bcb2f2 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6bcb83bcb2f2 Modified Files: sql/backends/monet5/sql.c sql/test/bincopy/Tests/bincopy_support.py Branch: copybinary Log Message:
Switch to \0 terminated strings diffs (92 lines): diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c --- a/sql/backends/monet5/sql.c +++ b/sql/backends/monet5/sql.c @@ -3342,43 +3342,6 @@ mvc_bin_import_table_wrap(Client cntxt, bstream_destroy(s); joeri_log("mvc_bin_import_table_wrap: onclient done\n"); joeri_role(NULL); - } else if (tpe == TYPE_str) { - /* get the BAT and fill it with the strings */ - c = COLnew(0, TYPE_str, 0, TRANSIENT); - if (c == NULL) { - msg = createException(SQL, "sql", SQLSTATE(HY013) MAL_MALLOC_FAIL); - goto bailout; - } - /* this code should be extended to - * deal with larger text strings. */ - FILE *f = fopen(fname, "r"); - if (f == NULL) { - BBPreclaim(c); - msg = createException(SQL, "sql", SQLSTATE(42000) "Failed to re-open file %s", fname); - goto bailout; - } - - const size_t bufsiz = 128 * BLOCK; - char *buf = GDKmalloc(bufsiz); - if (buf == NULL) { - fclose(f); - BBPreclaim(c); - msg = createException(SQL, "sql", SQLSTATE(HY013) MAL_MALLOC_FAIL); - goto bailout; - } - while (fgets(buf, bufsiz, f) != NULL) { - char *t = strrchr(buf, '\n'); - if (t) - *t = 0; - if (BUNappend(c, buf, false) != GDK_SUCCEED) { - BBPreclaim(c); - fclose(f); - msg = createException(SQL, "sql", SQLSTATE(HY013) MAL_MALLOC_FAIL); - goto bailout; - } - } - fclose(f); - GDKfree(buf); } else { c = BATattach(tpe, fname, TRANSIENT); } diff --git a/sql/test/bincopy/Tests/bincopy_support.py b/sql/test/bincopy/Tests/bincopy_support.py --- a/sql/test/bincopy/Tests/bincopy_support.py +++ b/sql/test/bincopy/Tests/bincopy_support.py @@ -10,7 +10,7 @@ except ImportError: import process # location generated test data files. -TRG = os.environ.get('BINCOPY_FILES', None) or os.environ['TSTTRGDIR'] +BINCOPY_FILES = os.environ.get('BINCOPY_FILES', None) or os.environ['TSTTRGDIR'] def make_fill_in(side): if side.lower() == 'client': @@ -27,7 +27,7 @@ def make_fill_in(side): generator_name = 'gen_' + var if generator_name in globals(): base = f'bincopy_{var}.bin' - filename = os.path.join(TRG, base) + filename = os.path.join(BINCOPY_FILES, base) f = open(filename, 'wb') gen = globals()[generator_name] gen(f) @@ -61,7 +61,7 @@ def gen_more_ints(outfile): def gen_strings(outfile): f = codecs.getwriter('utf-8')(outfile) for i in range(1_000_000): - f.write(f"int{i}\n") + f.write(f"int{i}\0") def gen_null_ints(outfile): nil = -(1<<31) @@ -76,11 +76,11 @@ def gen_large_strings(outfile): if i % 10_000 == 0: n = 280_000 f.write("a" * n) - f.write("\n") + f.write("\0") def gen_broken_strings(outfile): - good = bytes('bröken\n', 'utf-8') - bad = bytes('bröken\n', 'latin1') + good = bytes('bröken\0', 'utf-8') + bad = bytes('bröken\0', 'latin1') for i in range(1_000_000): if i == 123_456: outfile.write(bad) _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list