Update of /cvsroot/monetdb/sql/src/server
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv21465/src/server

Modified Files:
        sql_atom.mx sql_parser.mx sql_select.mx sql_semantic.mx 
        sql_xml.mx 
Log Message:
fixed leaks 

improved handling of xml attributes without name specification
(todo add dynamic checks for valid xml attribute names)

made copy into file adher to the specified quotes.



Index: sql_xml.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_xml.mx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sql_xml.mx  9 Sep 2007 09:35:24 -0000       1.4
+++ sql_xml.mx  5 Jan 2008 10:48:48 -0000       1.5
@@ -151,7 +151,7 @@
        (void)content_option;
        (void)returning;
 
-       if (ns) { 
+       if (ns) {
                ns_st = sql_value_exp(sql, scp, ns, grp, subset, f, knd); 
        } else {
                ns_st = stmt_atom(atom_general(&str_type, NULL, 0));
@@ -226,6 +226,26 @@
 }
 
 static stmt *
+sql_xmlattribute(mvc *sql, scope *scp, symbol *sym, group *grp, stmt *subset, 
int f, exp_kind knd ) 
+{
+       dnode *d = sym->data.lval->h;
+       char *attr_name = d->data.sval;
+       symbol *attr = d->next->data.sym;
+       stmt *attr_st, *attr_name_st = NULL;
+
+       attr_st = sql_value_exp(sql, scp, attr, grp, subset, f, knd); 
+       if (!attr_st)
+               return NULL;
+       if (!attr_name) {
+               /*TODO:convert simple column names into valid attribute names */
+               attr_name = column_name(attr_st);
+       }
+       attr_name_st = stmt_atom_string(_strdup(attr_name));
+       return sql_binop_(sql, scp, NULL, "attribute", attr_name_st, attr_st); 
+}
+
+
+static stmt *
 sql_xmlconcat(mvc *sql, scope *scp, symbol *sym, group *grp, stmt *subset, int 
f, exp_kind knd ) 
 {
        dnode *d = sym->data.lval->h;
@@ -325,6 +345,9 @@
        case SQL_XMLCOMMENT: 
                ret = sql_xmlcomment(sql, scp, s, grp, subset, f, knd);
                break;
+       case SQL_XMLATTRIBUTE: 
+               ret = sql_xmlattribute(sql, scp, s, grp, subset, f, knd);
+               break;
        case SQL_XMLCONCAT: 
                ret = sql_xmlconcat(sql, scp, s, grp, subset, f, knd);
                break;

Index: sql_parser.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_parser.mx,v
retrieving revision 1.268
retrieving revision 1.269
diff -u -d -r1.268 -r1.269
--- sql_parser.mx       3 Jan 2008 09:41:18 -0000       1.268
+++ sql_parser.mx       5 Jan 2008 10:48:48 -0000       1.269
@@ -163,7 +163,7 @@
        SQL_XMLCONCAT,
        SQL_XMLDOCUMENT,
        SQL_XMLELEMENT,
-       SQL_XMLATTRIBUTES,
+       SQL_XMLATTRIBUTE,
        SQL_XMLFOREST,
        SQL_XMLPARSE,
        SQL_XMLPI,
@@ -220,7 +220,7 @@
 #define append_string(l,d)   dlist_append_string( SA, l, d)
 #define append_type(l,d)     dlist_append_type( SA, l, d)
 
-#define _atom_string(t, v)   atom_string(t, v, 0)
+#define _atom_string(t, v)   atom_string2(SA, t, v, 0)
  
 #define YYPARSE_PARAM parm
 #define YYLEX_PARAM parm
@@ -253,7 +253,6 @@
 }
 %{
 extern int sqllex( YYSTYPE *yylval, void *m );
-static symbol * str2atom(sql_allocator *sa, str x);
 /* enable to activate debugging support
 int yydebug=1;
 */
@@ -3663,7 +3662,7 @@
                  int len = _strlen(s);
                  sql_subtype t;
                  sql_find_subtype(&t, "char", len, 0 );
-                 $$ = _newAtomNode( _atom_string(&t, s)); }
+                 $$ = _newAtomNode( atom_string(&t, s, 0)); }
 
  |  HEXADECIMAL { int len = _strlen($1), i = 2, err = 0;
                  char * hexa = $1;
@@ -4550,13 +4549,10 @@
 
 XML_attribute:
   XML_attribute_value opt_XML_attribute_name   
-               { /* what names to use if these aren't given?? */
-                 dlist *l = L();
-                 append_list(l, 
-                       append_string(L(), sa_strdup(SA, "attribute")));
-                 append_symbol(l, str2atom(SA,$2));
-                 append_symbol(l, $1);
-                 $$ = _symbol_create_list( SQL_BINOP, l ); }
+       { dlist *l = L();
+         append_string(l, $2);
+         append_symbol(l, $1);
+         $$ = _symbol_create_list( SQL_XMLATTRIBUTE, l ); }
   ;
 
 opt_XML_attribute_name:
@@ -5057,7 +5053,7 @@
        SQL(XMLCONCAT);
        SQL(XMLDOCUMENT);
        SQL(XMLELEMENT);
-       SQL(XMLATTRIBUTES);
+       SQL(XMLATTRIBUTE);
        SQL(XMLFOREST);
        SQL(XMLPARSE);
        SQL(XMLPI);
@@ -5069,22 +5065,6 @@
        return "unknown";       /* just needed for broken compilers ! */
 }
 
-static symbol* 
-str2atom(sql_allocator *sa, str x)
-{ 
-       atom *a = NULL;
-
-       if (x) {
-               char *s = sql2str(x);
-               int len = _strlen(s);
-               sql_subtype t;
-
-               sql_find_subtype(&t, "char", len, 0 );
-               a = atom_string(&t, s, 0); 
-       }
-       return newAtomNode( sa,  a); 
-}
-
 void *sql_error( mvc * sql, int error_code, char *format, ... )
 {
        va_list ap;

Index: sql_semantic.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_semantic.mx,v
retrieving revision 1.176
retrieving revision 1.177
diff -u -d -r1.176 -r1.177
--- sql_semantic.mx     3 Jan 2008 09:41:18 -0000       1.176
+++ sql_semantic.mx     5 Jan 2008 10:48:48 -0000       1.177
@@ -990,10 +990,12 @@
        case SQL_NEXT:{
                char *seq = qname_table(se->data.lval);
                char *sname = qname_schema(se->data.lval);
+               char *s;
                
                if (!sname)
                        sname = sql->session->schema->base.name;
-               len = snprintf( buf+len, BUFSIZ-len, "next value for 
\"%s\".\"%s\"", sname, sql_escape_ident(seq)); 
+               len = snprintf( buf+len, BUFSIZ-len, "next value for 
\"%s\".\"%s\"", sname, s=sql_escape_ident(seq)); 
+               _DELETE(s);
        }       break;
        case SQL_COLUMN: {
                /* can only be variables */ 

Index: sql_atom.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_atom.mx,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -d -r1.55 -r1.56
--- sql_atom.mx 8 Oct 2007 09:37:59 -0000       1.55
+++ sql_atom.mx 5 Jan 2008 10:48:48 -0000       1.56
@@ -39,6 +39,7 @@
 extern atom *atom_int( sql_subtype *tpe, lng val);
 extern atom *atom_float( sql_subtype *tpe, double val);
 extern atom *atom_string( sql_subtype *tpe, char *val, int destroy);
+extern atom *atom_string2( sql_allocator *sa, sql_subtype *tpe, char *val, int 
destroy);
 extern atom *atom_general( sql_subtype *tpe, char *val, int destroy);
 extern atom *atom_dec( sql_subtype *tpe, lng val, double dval);
 
@@ -141,10 +142,8 @@
 }
 
 atom *
-atom_string(sql_subtype *tpe, char *val, int destroy)
+atom_string_(atom *a, sql_subtype *tpe, char *val, int destroy)
 {
-       atom *a = atom_create();
-
        a->isnull = 1;
        a->tpe = *tpe;
        a->data.val.sval = NULL;
@@ -163,6 +162,23 @@
 }
 
 atom *
+atom_string(sql_subtype *tpe, char *val, int destroy)
+{
+       return atom_string_(atom_create(), tpe, val, destroy);
+}
+
+atom *
+atom_string2( sql_allocator *sa, sql_subtype *tpe, char *val, int destroy)
+{
+       atom *a = SA_NEW(sa, atom);
+
+       a->destroy = 0;
+       memset(&a->data, 0, sizeof(a->data));
+       a->d = dbl_nil;
+       return atom_string_(a, tpe, val, destroy);
+}
+
+atom *
 atom_float(sql_subtype *tpe, double val)
 {
        atom *a = atom_create();

Index: sql_select.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/server/sql_select.mx,v
retrieving revision 1.213
retrieving revision 1.214
diff -u -d -r1.213 -r1.214
--- sql_select.mx       3 Jan 2008 11:45:17 -0000       1.213
+++ sql_select.mx       5 Jan 2008 10:48:48 -0000       1.214
@@ -1764,6 +1764,7 @@
        case SQL_XMLELEMENT:
        case SQL_XMLFOREST:
        case SQL_XMLCOMMENT:
+       case SQL_XMLATTRIBUTE:
        case SQL_XMLCONCAT:
        case SQL_XMLDOCUMENT:
        case SQL_XMLPI:


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
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

Reply via email to