Changeset: 135d53262752 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=135d53262752
Modified Files:
        sql/server/sql_atom.c
        sql/test/miscellaneous/Tests/simple_selects.sql
        sql/test/miscellaneous/Tests/simple_selects.stable.out
Branch: default
Log Message:

Cleaned up blobs at atom2sql. Now back into serious things


diffs (115 lines):

diff --git a/sql/server/sql_atom.c b/sql/server/sql_atom.c
--- a/sql/server/sql_atom.c
+++ b/sql/server/sql_atom.c
@@ -457,9 +457,16 @@ atom2sql(atom *a)
                return res;
        } break;
        case EC_BLOB: {
-               char *_buf = buf;
-               size_t _bufsiz = BUFSIZ;
-               BLOBtostr(&_buf, &_bufsiz, &a->data.val.pval, true);
+               char *res;
+               blob *b = (blob*)a->data.val.pval;
+               size_t blob_size = (24 + (b->nitems * 3));
+
+               if ((res = NEW_ARRAY(char, blob_size + 8))) {
+                       char *tail = stpcpy(res, "blob '");
+                       ssize_t bloblen = BLOBtostr(&tail, &blob_size, b, true);
+                       strcpy(res + bloblen + 6, "'");
+               }
+               return res;
        } break;
        case EC_MONTH:
        case EC_SEC: {
diff --git a/sql/test/miscellaneous/Tests/simple_selects.sql 
b/sql/test/miscellaneous/Tests/simple_selects.sql
--- a/sql/test/miscellaneous/Tests/simple_selects.sql
+++ b/sql/test/miscellaneous/Tests/simple_selects.sql
@@ -169,11 +169,13 @@ select greatest(null, null);
 select sql_min(null, null);
 
 start transaction;
-create table tab1(col1 blob);
+create table tab1(col1 blob default blob '1122');
 insert into tab1 values('2233');
 select length(col1) from tab1;
 insert into tab1 values(null), (null), ('11'), ('2233');
 select length(col1) from tab1;
+insert into tab1 values(default);
+select col1 from tab1;
 rollback;
 
 select 'a' like 'a' escape 'a'; --error, like sequence ending with escape 
character 
diff --git a/sql/test/miscellaneous/Tests/simple_selects.stable.out 
b/sql/test/miscellaneous/Tests/simple_selects.stable.out
--- a/sql/test/miscellaneous/Tests/simple_selects.stable.out
+++ b/sql/test/miscellaneous/Tests/simple_selects.stable.out
@@ -116,20 +116,20 @@ stdout of test 'simple_selects` in direc
 % bigint # type
 % 1 # length
 #select cast(sum(42) as bigint) group by 1;
+% .%3 # table_name
+% %3 # name
+% bigint # type
+% 2 # length
+[ 42   ]
+#select cast(sum(42) as bigint) limit 2;
 % .%2 # table_name
 % %2 # name
 % bigint # type
 % 2 # length
 [ 42   ]
-#select cast(sum(42) as bigint) limit 2;
-% .%1 # table_name
-% %1 # name
-% bigint # type
-% 2 # length
-[ 42   ]
 #select cast(sum(42) as bigint) having 42>80;
-% .%1 # table_name
-% %1 # name
+% .%2 # table_name
+% %2 # name
 % bigint # type
 % 1 # length
 #select 1 having false;
@@ -270,8 +270,8 @@ stdout of test 'simple_selects` in direc
 #create table x (a int GENERATED ALWAYS AS IDENTITY);
 #alter table x alter a set default 1; --ok, remove sequence
 #SELECT CAST(COUNT(*) - (SELECT m FROM myvar) AS BIGINT) FROM sequences; --the 
total count, cannot change
-% .%4 # table_name
-% %4 # name
+% .%3 # table_name
+% %3 # name
 % bigint # type
 % 1 # length
 [ 0    ]
@@ -283,8 +283,8 @@ stdout of test 'simple_selects` in direc
 #create table x (a int GENERATED ALWAYS AS IDENTITY);
 #alter table x alter a drop default; --ok, remove sequence
 #SELECT CAST(COUNT(*) - (SELECT m FROM myvar) AS BIGINT) FROM sequences; --the 
total count, cannot change
-% .%4 # table_name
-% %4 # name
+% .%3 # table_name
+% %3 # name
 % bigint # type
 % 1 # length
 [ 0    ]
@@ -330,6 +330,19 @@ stdout of test 'simple_selects` in direc
 [ NULL ]
 [ 1    ]
 [ 2    ]
+#insert into tab1 values(default);
+[ 1    ]
+#select col1 from tab1;
+% sys.tab1 # table_name
+% col1 # name
+% blob # type
+% 0 # length
+[ 2233 ]
+[ NULL ]
+[ NULL ]
+[ 11   ]
+[ 2233 ]
+[ 1122 ]
 #rollback;
 #select cast(x as interval second) from (values ('1'), (NULL), ('100'), 
(NULL)) as x(x);
 % .%6 # table_name
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to