Changeset: e6a2bc6861b5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e6a2bc6861b5
Modified Files:
        sql/backends/monet5/sql_result.c
Branch: protocol
Log Message:

Zero pad varchar strings instead of padding with uninitialized memory for 
better compressability.


diffs (31 lines):

diff --git a/sql/backends/monet5/sql_result.c b/sql/backends/monet5/sql_result.c
--- a/sql/backends/monet5/sql_result.c
+++ b/sql/backends/monet5/sql_result.c
@@ -2196,19 +2196,24 @@ static int mvc_export_resultset_prot10(r
                                if (c->type.digits > 0) {
                                        // varchar
                                        size_t buflen = c->type.digits * (row - 
srow);
-                                       char *tmpbuf = malloc(buflen);
+                                       char *tmpbuf = GDKmalloc(buflen);
                                        char *bufptr = tmpbuf;
+                                       char *ptr;
                                        assert(tmpbuf);
                                        for(crow = srow; crow < row; crow++) {
-                                               strcpy(bufptr, (char*) 
BUNtail(iterators[i], crow));
+                                               ptr = stpcpy(bufptr, (char*) 
BUNtail(iterators[i], crow));
                                                bufptr += c->type.digits;
+                                               while(ptr < bufptr) {
+                                                       *ptr++ = '\0';
+                                               }
                                        }
                                        if (mnstr_write(s, tmpbuf, buflen, 1) 
!= 1) {
+                                               GDKfree(tmpbuf);
                                                fres = -1;
                                                fprintf(stderr,"Sending data 
failed.\n");
                                                goto cleanup;
                                        }
-                                       free(tmpbuf);
+                                       GDKfree(tmpbuf);
                                } else {
                                        // variable length string
                                        if (!mnstr_writeLng(s, var_col_len[i])) 
{
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to