Changeset: 0c67cb41e11b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0c67cb41e11b
Modified Files:
Branch: jacqueline
Log Message:
Merged from default
diffs (truncated from 5894 to 300 lines):
diff --git a/monetdb5/optimizer/opt_history.mx
b/monetdb5/optimizer/opt_history.mx
--- a/monetdb5/optimizer/opt_history.mx
+++ b/monetdb5/optimizer/opt_history.mx
@@ -255,8 +255,8 @@ OPThistoryImplementation(Client cntxt, M
}
for( ; i<slimit; i++)
- if(old[i])
- freeInstruction(old[i]);
+ if(old[i])
+ freeInstruction(old[i]);
GDKfree(old);
DEBUGoptimizers
mnstr_printf(cntxt->fdout,"#opt_history: code added\n");
diff --git a/monetdb5/optimizer/opt_mergetable.mx
b/monetdb5/optimizer/opt_mergetable.mx
--- a/monetdb5/optimizer/opt_mergetable.mx
+++ b/monetdb5/optimizer/opt_mergetable.mx
@@ -2323,9 +2323,8 @@ OPTmergetableImplementation(Client cntxt
if ( mb->errors == 0) {
for(i=0; i<slimit; i++)
- if (old[i]) {
+ if (old[i])
freeInstruction(old[i]);
- }
GDKfree(old);
}
diff --git a/monetdb5/optimizer/opt_multiplex.mx
b/monetdb5/optimizer/opt_multiplex.mx
--- a/monetdb5/optimizer/opt_multiplex.mx
+++ b/monetdb5/optimizer/opt_multiplex.mx
@@ -296,10 +296,10 @@ OPTmultiplexImplementation(Client cntxt,
for (i = 0; i < limit; i++) {
p = old[i];
- if (msg == MAL_SUCCEED &&
- getModuleId(p) == malRef &&
- getFunctionId(p) == multiplexRef) {
- msg= OPTexpandMultiplex(cntxt, mb, stk, p);
+ if (msg == MAL_SUCCEED &&
+ getModuleId(p) == malRef &&
+ getFunctionId(p) == multiplexRef) {
+ msg = OPTexpandMultiplex(cntxt, mb, stk, p);
if( msg== MAL_SUCCEED){
freeInstruction(p);
old[i]=0;
@@ -307,13 +307,12 @@ OPTmultiplexImplementation(Client cntxt,
pushInstruction(mb, p);
}
actions++;
- } else
- if( old[i])
+ } else if( old[i])
pushInstruction(mb, p);
}
for(;i<slimit; i++)
- if( old[i])
- freeInstruction(old[i]);
+ if( old[i])
+ freeInstruction(old[i]);
GDKfree(old);
DEBUGoptimizers {
mnstr_printf(cntxt->fdout,"#opt_multiplex: %d expansions\n",
actions);
diff --git a/sql/backends/monet5/sql.mx b/sql/backends/monet5/sql.mx
--- a/sql/backends/monet5/sql.mx
+++ b/sql/backends/monet5/sql.mx
@@ -81,7 +81,7 @@ pattern catalog(type:int,user:str,passwd
address SQLcatalog
comment "a user catalog statement";
-pattern
catalog(type:int,tname:str,grantee:str,privs:int,cname:str,grant:int,grantor:int):void
+pattern
catalog(type:int,sname:str,tname:str,grantee:str,privs:int,cname:str,grant:int,grantor:int):void
address SQLcatalog
comment "a grant/revoke privileges statement";
@@ -2390,20 +2390,22 @@ SQLcatalog(Client cntxt, MalBlkPtr mb, M
msg = sql_revoke_role( sql, sname /*grantee */, auth);
} break;
case DDL_GRANT: {
- char *grantee = *(str*)getArgReference(stk, pci, 3);
- int privs = *(int*)getArgReference(stk, pci, 4);
- char *cname = SaveArgReference(stk, pci, 5);
- int grant = *(int*)getArgReference(stk, pci, 6);
- int grantor = *(int*)getArgReference(stk, pci, 7);
- msg = sql_grant_table_privs( sql, grantee, privs, sname, cname,
grant, grantor);
+ char *tname = *(str*)getArgReference(stk, pci, 3);
+ char *grantee = *(str*)getArgReference(stk, pci, 4);
+ int privs = *(int*)getArgReference(stk, pci, 5);
+ char *cname = SaveArgReference(stk, pci, 6);
+ int grant = *(int*)getArgReference(stk, pci, 7);
+ int grantor = *(int*)getArgReference(stk, pci, 8);
+ msg = sql_grant_table_privs( sql, grantee, privs, sname, tname,
cname, grant, grantor);
} break;
case DDL_REVOKE: {
- char *grantee = *(str*)getArgReference(stk, pci, 3);
- int privs = *(int*)getArgReference(stk, pci, 4);
- char *cname = SaveArgReference(stk, pci, 5);
- int grant = *(int*)getArgReference(stk, pci, 6);
- int grantor = *(int*)getArgReference(stk, pci, 7);
- msg = sql_revoke_table_privs( sql, grantee, privs, sname,
cname, grant, grantor);
+ char *tname = *(str*)getArgReference(stk, pci, 3);
+ char *grantee = *(str*)getArgReference(stk, pci, 4);
+ int privs = *(int*)getArgReference(stk, pci, 5);
+ char *cname = SaveArgReference(stk, pci, 6);
+ int grant = *(int*)getArgReference(stk, pci, 7);
+ int grantor = *(int*)getArgReference(stk, pci, 8);
+ msg = sql_revoke_table_privs( sql, grantee, privs, sname,
tname, cname, grant, grantor);
} break;
case DDL_CREATE_USER: {
char *passwd = *(str*)getArgReference(stk, pci, 3);
diff --git a/sql/backends/monet5/sql_gencode.c
b/sql/backends/monet5/sql_gencode.c
--- a/sql/backends/monet5/sql_gencode.c
+++ b/sql/backends/monet5/sql_gencode.c
@@ -280,7 +280,7 @@ _create_relational_function(mvc *m, char
if (s->type == st_list && s->nrcols == 0 && s->key) {
/* row to columns */
node *n;
- list *l = list_new(m->sa);
+ list *l = sa_list(m->sa);
for(n=s->op4.lval->h; n; n = n->next)
list_append(l, const_column(m->sa, n->data));
@@ -2496,7 +2496,7 @@ monet5_create_table_function(ptr M, char
if (s->type == st_list && s->nrcols == 0 && s->key) {
/* row to columns */
node *n;
- list *l = list_new(m->sa);
+ list *l = sa_list(m->sa);
for(n=s->op4.lval->h; n; n = n->next)
list_append(l, const_column(m->sa, n->data));
diff --git a/sql/backends/monet5/sql_optimizer.c
b/sql/backends/monet5/sql_optimizer.c
--- a/sql/backends/monet5/sql_optimizer.c
+++ b/sql/backends/monet5/sql_optimizer.c
@@ -333,7 +333,6 @@ SQLgetStatistics(Client cntxt, mvc *m, M
mode = getVarConstant(mb, getArg(p,5)).val.ival;
}
-
if (s && f == bindidxRef && cname) {
size_t cnt;
sql_idx *i = mvc_bind_idx(m, s, cname);
diff --git a/sql/backends/monet5/sql_user.c b/sql/backends/monet5/sql_user.c
--- a/sql/backends/monet5/sql_user.c
+++ b/sql/backends/monet5/sql_user.c
@@ -209,11 +209,10 @@ monet5_create_privileges(ptr _mvc, sql_s
tpe.digits = t->base.id; /* pass the table through digits */
/* add function */
- l = list_create((fdestroy) &arg_destroy);
+ l = sa_list(m->sa);
/* following funcion returns a table (single column) of user names
with the approriate scenario (sql) */
mvc_create_func(m, s, "db_users", l, &tpe, F_FUNC, "sql", "db_users",
"CREATE FUNCTION db_users () RETURNS TABLE( name varchar(2048)) EXTERNAL NAME
sql.db_users;");
- list_destroy(l);
t = mvc_create_view(m, s, "users", SQL_PERSIST,
"SELECT u.\"name\" AS \"name\", "
diff --git a/sql/common/Makefile.ag b/sql/common/Makefile.ag
--- a/sql/common/Makefile.ag
+++ b/sql/common/Makefile.ag
@@ -26,7 +26,7 @@ lib_sqlcommon = {
NOINST
DIR = libdir
SOURCES = \
- sql_mem.c sql_list.c sql_stack.c sql_backend.c \
+ sql_mem.c sql_list.c sql_hash.c sql_stack.c sql_backend.c \
sql_keyword.c sql_changeset.c sql_types.c sql_string.c \
sql_backend.h sql_string.h sql_types.h
}
diff --git a/sql/common/sql_changeset.c b/sql/common/sql_changeset.c
--- a/sql/common/sql_changeset.c
+++ b/sql/common/sql_changeset.c
@@ -22,20 +22,10 @@
#include "sql_catalog.h"
void
-cs_init(changeset * cs, fdestroy destroy)
-{
- cs->sa = NULL;
- cs->destroy = destroy;
- cs->set = NULL;
- cs->dset = NULL;
- cs->nelm = NULL;
-}
-
-void
-cs_new(changeset * cs, sql_allocator *sa)
+cs_new(changeset * cs, sql_allocator *sa, fdestroy destroy)
{
cs->sa = sa;
- cs->destroy = NULL;
+ cs->destroy = destroy;
cs->set = NULL;
cs->dset = NULL;
cs->nelm = NULL;
@@ -53,12 +43,8 @@ cs_destroy(changeset * cs)
void
cs_add(changeset * cs, void *elm, int flag)
{
- if (!cs->set) {
- if (cs->sa)
- cs->set = list_new(cs->sa);
- else
- cs->set = list_create(cs->destroy);
- }
+ if (!cs->set)
+ cs->set = list_new(cs->sa, cs->destroy);
list_append(cs->set, elm);
if (flag == TR_NEW && !cs->nelm)
cs->nelm = cs->set->t;
@@ -78,12 +64,8 @@ cs_del(changeset * cs, node *elm, int fl
cs->nelm = elm->next;
list_remove_node(cs->set, elm);
} else {
- if (!cs->dset) {
- if (cs->sa)
- cs->dset = list_new(cs->sa);
- else
- cs->dset = list_create(cs->destroy);
- }
+ if (!cs->dset)
+ cs->dset = list_new(cs->sa, cs->destroy);
list_move_data(cs->set, cs->dset, elm->data);
}
}
diff --git a/sql/common/sql_hash.c b/sql/common/sql_hash.c
new file mode 100644
--- /dev/null
+++ b/sql/common/sql_hash.c
@@ -0,0 +1,67 @@
+
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.monetdb.org/Legal/MonetDBLicense
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2012 MonetDB B.V.
+ * All Rights Reserved.
+ */
+
+#include "monetdb_config.h"
+#include "sql_mem.h"
+#include "sql_hash.h"
+
+sql_hash *
+hash_new(sql_allocator *sa, int size, fkeyvalue key)
+{
+ int i;
+ sql_hash *ht = SA_ZNEW(sa, sql_hash);
+
+ ht->sa = sa;
+ ht->size = (size/2)*2;
+ ht->key = key;
+ ht->buckets = SA_NEW_ARRAY(sa, sql_hash_e*, size);
+ for(i = 0; i < size; i++)
+ ht->buckets[i] = NULL;
+ return ht;
+}
+
+sql_hash_e*
+hash_add(sql_hash *h, int key, void *value)
+{
+ sql_hash_e *e = SA_ZNEW(h->sa, sql_hash_e);
+
+ e->chain = h->buckets[key&(h->size-1)];
+ h->buckets[key&(h->size-1)] = e;
+ e->key = key;
+ e->value = value;
+ return e;
+}
+
+int
+hash_key(char *k)
+{
+ char *s = k;
+ int h = 1, l;
+
+ while (*k) {
+ h <<= 5;
+ h += (*k - 'a');
+ k++;
+ }
+ l = (int) (k - s);
+ h <<= 4;
+ h += l;
+ return (h < 0) ? -h : h;
+}
diff --git a/sql/common/sql_list.c b/sql/common/sql_list.c
--- a/sql/common/sql_list.c
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list