Changeset: 9e857531d690 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9e857531d690
Modified Files:
        gdk/gdk_calc_compare.h
        sql/server/sql_parser.y
        sql/server/sql_scan.c
        sql/storage/bat/bat_storage.c
        sql/test/Tests/identifiers.stable.err
        sql/test/Tests/identifiers.stable.out
Branch: Jan2014
Log Message:

fixed compilation in gdk_calc_compare.h

more valid_idents (a""b)

fixed bug (default value)


diffs (208 lines):

diff --git a/gdk/gdk_calc_compare.h b/gdk/gdk_calc_compare.h
--- a/gdk/gdk_calc_compare.h
+++ b/gdk/gdk_calc_compare.h
@@ -32,7 +32,7 @@ op_typeswitchloop(const void *lft, int t
 
        switch (tp1) {
        case TYPE_void: {
-               oid v;
+               oid v = oid_nil;
 
                assert(incr1 == 1);
                assert(tp2 == TYPE_oid || incr2 == 1); /* if void, incr2==1 */
diff --git a/sql/server/sql_parser.y b/sql/server/sql_parser.y
--- a/sql/server/sql_parser.y
+++ b/sql/server/sql_parser.y
@@ -1061,9 +1061,9 @@ opt_column:
  ;
 
 create_statement:      
-   role_def 
+   create role_def     { $$ = $2; }
  | create table_def    { $$ = $2; }
- | view_def
+ | create view_def     { $$ = $2; }
  | type_def
  | func_def
  | index_def
@@ -1279,18 +1279,18 @@ CREATE [ UNIQUE ] INDEX index_name
 */
 
 role_def:
-    create ROLE ident opt_grantor
+    ROLE ident opt_grantor
        { dlist *l = L();
-         append_string(l, $3);
+         append_string(l, $2);
+         append_int(l, $3);
+         $$ = _symbol_create_list( SQL_CREATE_ROLE, l ); }
+ |  USER ident WITH opt_encrypted PASSWORD string sqlNAME string SCHEMA ident
+       { dlist *l = L();
+         append_string(l, $2);
+         append_string(l, $6);
+         append_string(l, $8);
+         append_string(l, $10);
          append_int(l, $4);
-         $$ = _symbol_create_list( SQL_CREATE_ROLE, l ); }
- |  create USER ident WITH opt_encrypted PASSWORD string sqlNAME string SCHEMA 
ident
-       { dlist *l = L();
-         append_string(l, $3);
-         append_string(l, $7);
-         append_string(l, $9);
-         append_string(l, $11);
-         append_int(l, $5);
          $$ = _symbol_create_list( SQL_CREATE_USER, l ); }
  ;
 
@@ -1725,12 +1725,12 @@ like_table:
  ;
 
 view_def:
-    create VIEW qname opt_column_list AS query_expression opt_with_check_option
+    VIEW qname opt_column_list AS query_expression opt_with_check_option
        {  dlist *l = L();
+         append_list(l, $2);
          append_list(l, $3);
-         append_list(l, $4);
-         append_symbol(l, $6);
-         append_int(l, $7);
+         append_symbol(l, $5);
+         append_int(l, $6);
          append_int(l, TRUE);  /* persistent view */
          $$ = _symbol_create_list( SQL_CREATE_VIEW, l ); 
        }
diff --git a/sql/server/sql_scan.c b/sql/server/sql_scan.c
--- a/sql/server/sql_scan.c
+++ b/sql/server/sql_scan.c
@@ -928,11 +928,11 @@ valid_ident(char *s, char *dst)
        
        if (*s == '%')
                return 0;
-       /* do unescaping in the loop */
+
        while (*s && (*s != '"' || escaped)) {
-               if (*s == '"' && s[1] == '"') {
+               if (*s == '\\' && s[1] == '"') {
                        escaped = !escaped;
-                       if (!escaped) 
+                       if (escaped) 
                                dst[p++] = *s;
                } else if (*s == '"' && escaped) {
                        escaped = 0;
@@ -941,8 +941,6 @@ valid_ident(char *s, char *dst)
                        escaped = 0;
                        dst[p++] = *s;
                }
-               //if (*s == '\\') 
-                       //dst[p++] = *s;
                s++;
                if (p >= 1024)
                        return 0;
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -1752,38 +1752,38 @@ update_table(sql_trans *tr, sql_table *f
                sql_column *cc = n->data;
                sql_column *oc = m->data;
 
-               if (!cc->base.wtime || !cc->base.allocated) {
-                       cc->data = NULL;
-                       cc->base.allocated = cc->base.rtime = cc->base.wtime = 
0;
-                       continue;
-               }
+               if (cc->base.wtime && cc->base.allocated) {
+                       assert(oc->base.wtime < cc->base.wtime);
+                       if (store_nr_active > 1) { /* move delta */
+                               sql_delta *b = cc->data, *p = NULL;
 
-               assert(oc->base.wtime < cc->base.wtime);
-               if (store_nr_active > 1) { /* move delta */
-                       sql_delta *b = cc->data, *p = NULL;
-
-                       cc->data = NULL;
-                       b->next = oc->data;
-                       oc->data = b;
-                       while (b && b->wtime > oldest->stime) {
-                               p = b;
-                               b = b->next;
+                               cc->data = NULL;
+                               b->next = oc->data;
+                               oc->data = b;
+                               while (b && b->wtime > oldest->stime) {
+                                       p = b;
+                                       b = b->next;
+                               }
+                               if (b && b->wtime > oldest->stime && p) {
+                                       p->next = NULL;
+                                       destroy_bat(tr, b);
+                               }
+                       } else {
+                               assert(oc->base.allocated);
+                               tr_update_delta(tr, oc->data, cc->data, 
cc->unique == 1);
                        }
-                       if (b && b->wtime > oldest->stime && p) {
-                               p->next = NULL;
-                               destroy_bat(tr, b);
-                       }
-               } else {
-                       assert(oc->base.allocated);
-                       tr_update_delta(tr, oc->data, cc->data, cc->unique == 
1);
                }
 
                oc->null = cc->null;
                oc->unique = cc->unique;
-               if (cc->storage_type && (!cc->storage_type || 
strcmp(cc->storage_type, oc->storage_type) != 0))
+               if (cc->storage_type && (!oc->storage_type || 
strcmp(cc->storage_type, oc->storage_type) != 0))
                        oc->storage_type = sa_strdup(tr->sa, cc->storage_type);
-               if (cc->def && (!cc->def || strcmp(cc->def, oc->def) != 0))
+               if (!cc->storage_type)
+                       oc->storage_type = NULL;
+               if (cc->def && (!oc->def || strcmp(cc->def, oc->def) != 0))
                        oc->def = sa_strdup(tr->sa, cc->def);
+               if (!cc->def)
+                       oc->def = NULL;
 
                if (oc->base.rtime < cc->base.rtime)
                        oc->base.rtime = cc->base.rtime;
diff --git a/sql/test/Tests/identifiers.stable.err 
b/sql/test/Tests/identifiers.stable.err
--- a/sql/test/Tests/identifiers.stable.err
+++ b/sql/test/Tests/identifiers.stable.err
@@ -28,15 +28,6 @@ stderr of test 'identifiers` in director
 # 18:30:40 >  "mclient" "-lsql" "-ftest" "-Eutf-8" "-i" "-e" 
"--host=/var/tmp/mtest-20764" "--port=38230"
 # 18:30:40 >  
 
-MAPI  = (monetdb) /var/tmp/mtest-20764/.s.monetdb.38230
-QUERY = CREATE TABLE "B\"la\"" (id int); -- should fail
-ERROR = !Invalid identifier 'B\"la\"'
-MAPI  = (monetdb) /var/tmp/mtest-20764/.s.monetdb.38230
-QUERY = SELECT 1 AS "B\"la\""; -- should fail
-ERROR = !Invalid identifier 'B\"la\"'
-MAPI  = (monetdb) /var/tmp/mtest-20764/.s.monetdb.38230
-QUERY = SELECT 1 AS "\"Bla\""; -- should fail
-ERROR = !Invalid identifier '\"Bla\"'
 
 # 18:30:40 >  
 # 18:30:40 >  "Done."
diff --git a/sql/test/Tests/identifiers.stable.out 
b/sql/test/Tests/identifiers.stable.out
--- a/sql/test/Tests/identifiers.stable.out
+++ b/sql/test/Tests/identifiers.stable.out
@@ -55,6 +55,19 @@ Ready.
 % tinyint # type
 % 1 # length
 [ 1    ]
+#CREATE TABLE "B\"la\"" (id int); -- should fail
+#SELECT 1 AS "B\"la\""; -- should fail
+% .L # table_name
+% B\"la\" # name
+% tinyint # type
+% 1 # length
+[ 1    ]
+#SELECT 1 AS "\"Bla\""; -- should fail
+% .L # table_name
+% \"Bla\" # name
+% tinyint # type
+% 1 # length
+[ 1    ]
 
 # 11:50:07 >  
 # 11:50:07 >  Done.
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to