Changeset: b400d6d90551 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b400d6d90551 Modified Files: sql/backends/monet5/sql.c Branch: Jul2017 Log Message:
Dereference early once instead of at each use. diffs (truncated from 855 to 300 lines): diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c --- a/sql/backends/monet5/sql.c +++ b/sql/backends/monet5/sql.c @@ -619,16 +619,16 @@ mvc_next_value(Client cntxt, MalBlkPtr m str msg; sql_schema *s; lng *res = getArgReference_lng(stk, pci, 0); - str *sname = getArgReference_str(stk, pci, 1); - str *seqname = getArgReference_str(stk, pci, 2); + str sname = *getArgReference_str(stk, pci, 1); + str seqname = *getArgReference_str(stk, pci, 2); if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL) return msg; if ((msg = checkSQLContext(cntxt)) != NULL) return msg; - s = mvc_bind_schema(m, *sname); + s = mvc_bind_schema(m, sname); if (s) { - sql_sequence *seq = find_sql_sequence(s, *seqname); + sql_sequence *seq = find_sql_sequence(s, seqname); if (seq && seq_next_value(seq, res)) { m->last_id = *res; @@ -652,15 +652,15 @@ mvc_bat_next_value(Client cntxt, MalBlkP seqbulk *sb = NULL; BATiter bi; bat *res = getArgReference_bat(stk, pci, 0); - bat *sid = getArgReference_bat(stk, pci, 1); - str *seqname = getArgReference_str(stk, pci, 2); + bat sid = *getArgReference_bat(stk, pci, 1); + str seqname = *getArgReference_str(stk, pci, 2); if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL) return msg; if ((msg = checkSQLContext(cntxt)) != NULL) return msg; - if ((b = BATdescriptor(*sid)) == NULL) + if ((b = BATdescriptor(sid)) == NULL) throw(SQL, "sql.next_value", "Cannot access descriptor"); r = COLnew(b->hseqbase, TYPE_lng, BATcount(b), TRANSIENT); @@ -686,7 +686,7 @@ mvc_bat_next_value(Client cntxt, MalBlkP seqbulk_destroy(sb); s = mvc_bind_schema(m, sname); seq = NULL; - if (!s || (seq = find_sql_sequence(s, *seqname)) == NULL || !(sb = seqbulk_create(seq, BATcount(b)))) { + if (!s || (seq = find_sql_sequence(s, seqname)) == NULL || !(sb = seqbulk_create(seq, BATcount(b)))) { BBPunfix(b->batCacheid); BBPunfix(r->batCacheid); throw(SQL, "sql.next_value", "error"); @@ -721,16 +721,16 @@ mvc_get_value(Client cntxt, MalBlkPtr mb str msg; sql_schema *s; lng *res = getArgReference_lng(stk, pci, 0); - str *sname = getArgReference_str(stk, pci, 1); - str *seqname = getArgReference_str(stk, pci, 2); + str sname = *getArgReference_str(stk, pci, 1); + str seqname = *getArgReference_str(stk, pci, 2); if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL) return msg; if ((msg = checkSQLContext(cntxt)) != NULL) return msg; - s = mvc_bind_schema(m, *sname); + s = mvc_bind_schema(m, sname); if (s) { - sql_sequence *seq = find_sql_sequence(s, *seqname); + sql_sequence *seq = find_sql_sequence(s, seqname); if (seq && seq_get_value(seq, res)) return MAL_SUCCEED; @@ -763,26 +763,26 @@ mvc_restart_seq(Client cntxt, MalBlkPtr str msg; sql_schema *s; lng *res = getArgReference_lng(stk, pci, 0); - str *sname = getArgReference_str(stk, pci, 1); - str *seqname = getArgReference_str(stk, pci, 2); - lng *start = getArgReference_lng(stk, pci, 3); + str sname = *getArgReference_str(stk, pci, 1); + str seqname = *getArgReference_str(stk, pci, 2); + lng start = *getArgReference_lng(stk, pci, 3); if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL) return msg; if ((msg = checkSQLContext(cntxt)) != NULL) return msg; - if (*start == lng_nil) + if (start == lng_nil) throw(SQL, "sql.restart", "cannot (re)start with NULL"); - s = mvc_bind_schema(m, *sname); + s = mvc_bind_schema(m, sname); if (s) { - sql_sequence *seq = find_sql_sequence(s, *seqname); + sql_sequence *seq = find_sql_sequence(s, seqname); if (seq) { - *res = sql_trans_sequence_restart(m->session->tr, seq, *start); + *res = sql_trans_sequence_restart(m->session->tr, seq, start); return MAL_SUCCEED; } } - throw(SQL, "sql.restart", "sequence %s not found", *sname); + throw(SQL, "sql.restart", "sequence %s not found", sname); } static BAT * @@ -834,16 +834,16 @@ mvc_bind_wrap(Client cntxt, MalBlkPtr mb int coltype = getBatType(getArgType(mb, pci, 0)); mvc *m = NULL; str msg; - str *sname = getArgReference_str(stk, pci, 2 + upd); - str *tname = getArgReference_str(stk, pci, 3 + upd); - str *cname = getArgReference_str(stk, pci, 4 + upd); - int *access = getArgReference_int(stk, pci, 5 + upd); + str sname = *getArgReference_str(stk, pci, 2 + upd); + str tname = *getArgReference_str(stk, pci, 3 + upd); + str cname = *getArgReference_str(stk, pci, 4 + upd); + int access = *getArgReference_int(stk, pci, 5 + upd); if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL) return msg; if ((msg = checkSQLContext(cntxt)) != NULL) return msg; - b = mvc_bind(m, *sname, *tname, *cname, *access); + b = mvc_bind(m, sname, tname, cname, access); if (b && b->ttype != coltype) throw(SQL,"sql.bind","tail type mismatch"); if (b) { @@ -853,14 +853,14 @@ mvc_bind_wrap(Client cntxt, MalBlkPtr mb int part_nr = *getArgReference_int(stk, pci, 6 + upd); int nr_parts = *getArgReference_int(stk, pci, 7 + upd); - if (*access == 0) { + if (access == 0) { psz = cnt ? (cnt / nr_parts) : 0; bn = BATslice(b, part_nr * psz, (part_nr + 1 == nr_parts) ? cnt : ((part_nr + 1) * psz)); BAThseqbase(bn, part_nr * psz); } else { /* BAT b holds the UPD_ID bat */ oid l, h; - BAT *c = mvc_bind(m, *sname, *tname, *cname, 0); + BAT *c = mvc_bind(m, sname, tname, cname, 0); if (c == NULL) throw(SQL,"sql.bind","Cannot access the update column"); @@ -875,7 +875,7 @@ mvc_bind_wrap(Client cntxt, MalBlkPtr mb BBPunfix(b->batCacheid); b = bn; } else if (upd) { - BAT *uv = mvc_bind(m, *sname, *tname, *cname, RD_UPD_VAL); + BAT *uv = mvc_bind(m, sname, tname, cname, RD_UPD_VAL); bat *uvl = getArgReference_bat(stk, pci, 1); if (uv == NULL) @@ -888,8 +888,8 @@ mvc_bind_wrap(Client cntxt, MalBlkPtr mb bat *uvl = getArgReference_bat(stk, pci, 1); if (BATcount(b)) { - BAT *uv = mvc_bind(m, *sname, *tname, *cname, RD_UPD_VAL); - BAT *ui = mvc_bind(m, *sname, *tname, *cname, RD_UPD_ID); + BAT *uv = mvc_bind(m, sname, tname, cname, RD_UPD_VAL); + BAT *ui = mvc_bind(m, sname, tname, cname, RD_UPD_ID); BAT *id; BAT *vl; if (ui == NULL) @@ -909,9 +909,9 @@ mvc_bind_wrap(Client cntxt, MalBlkPtr mb BBPkeepref(*bid = id->batCacheid); BBPkeepref(*uvl = vl->batCacheid); } else { - sql_schema *s = mvc_bind_schema(m, *sname); - sql_table *t = mvc_bind_table(m, s, *tname); - sql_column *c = mvc_bind_column(m, t, *cname); + sql_schema *s = mvc_bind_schema(m, sname); + sql_table *t = mvc_bind_table(m, s, tname); + sql_column *c = mvc_bind_column(m, t, cname); *bid = e_bat(TYPE_oid); *uvl = e_bat(c->type.type->localtype); @@ -922,9 +922,9 @@ mvc_bind_wrap(Client cntxt, MalBlkPtr mb } return MAL_SUCCEED; } - if (*sname && strcmp(*sname, str_nil) != 0) - throw(SQL, "sql.bind", "unable to find %s.%s(%s)", *sname, *tname, *cname); - throw(SQL, "sql.bind", "unable to find %s(%s)", *tname, *cname); + if (sname && strcmp(sname, str_nil) != 0) + throw(SQL, "sql.bind", "unable to find %s.%s(%s)", sname, tname, cname); + throw(SQL, "sql.bind", "unable to find %s(%s)", tname, cname); } /* str mvc_bind_idxbat_wrap(int *bid, str *sname, str *tname, str *iname, int *access); */ @@ -937,16 +937,16 @@ mvc_bind_idxbat_wrap(Client cntxt, MalBl int coltype = getBatType(getArgType(mb, pci, 0)); mvc *m = NULL; str msg; - str *sname = getArgReference_str(stk, pci, 2 + upd); - str *tname = getArgReference_str(stk, pci, 3 + upd); - str *iname = getArgReference_str(stk, pci, 4 + upd); - int *access = getArgReference_int(stk, pci, 5 + upd); + str sname = *getArgReference_str(stk, pci, 2 + upd); + str tname = *getArgReference_str(stk, pci, 3 + upd); + str iname = *getArgReference_str(stk, pci, 4 + upd); + int access = *getArgReference_int(stk, pci, 5 + upd); if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL) return msg; if ((msg = checkSQLContext(cntxt)) != NULL) return msg; - b = mvc_bind_idxbat(m, *sname, *tname, *iname, *access); + b = mvc_bind_idxbat(m, sname, tname, iname, access); if (b && b->ttype != coltype) throw(SQL,"sql.bind","tail type mismatch"); if (b) { @@ -956,14 +956,14 @@ mvc_bind_idxbat_wrap(Client cntxt, MalBl int part_nr = *getArgReference_int(stk, pci, 6 + upd); int nr_parts = *getArgReference_int(stk, pci, 7 + upd); - if (*access == 0) { + if (access == 0) { psz = cnt ? (cnt / nr_parts) : 0; bn = BATslice(b, part_nr * psz, (part_nr + 1 == nr_parts) ? cnt : ((part_nr + 1) * psz)); BAThseqbase(bn, part_nr * psz); } else { /* BAT b holds the UPD_ID bat */ oid l, h; - BAT *c = mvc_bind_idxbat(m, *sname, *tname, *iname, 0); + BAT *c = mvc_bind_idxbat(m, sname, tname, iname, 0); if ( c == NULL) throw(SQL,"sql.bindidx","can not access index column"); cnt = BATcount(c); @@ -977,7 +977,7 @@ mvc_bind_idxbat_wrap(Client cntxt, MalBl BBPunfix(b->batCacheid); b = bn; } else if (upd) { - BAT *uv = mvc_bind_idxbat(m, *sname, *tname, *iname, RD_UPD_VAL); + BAT *uv = mvc_bind_idxbat(m, sname, tname, iname, RD_UPD_VAL); bat *uvl = getArgReference_bat(stk, pci, 1); if ( uv == NULL) throw(SQL,"sql.bindidx","can not access index column"); @@ -989,8 +989,8 @@ mvc_bind_idxbat_wrap(Client cntxt, MalBl bat *uvl = getArgReference_bat(stk, pci, 1); if (BATcount(b)) { - BAT *uv = mvc_bind_idxbat(m, *sname, *tname, *iname, RD_UPD_VAL); - BAT *ui = mvc_bind_idxbat(m, *sname, *tname, *iname, RD_UPD_ID); + BAT *uv = mvc_bind_idxbat(m, sname, tname, iname, RD_UPD_VAL); + BAT *ui = mvc_bind_idxbat(m, sname, tname, iname, RD_UPD_ID); BAT *id, *vl; if ( ui == NULL) throw(SQL,"sql.bindidx","can not access index column"); @@ -1009,8 +1009,8 @@ mvc_bind_idxbat_wrap(Client cntxt, MalBl BBPkeepref(*bid = id->batCacheid); BBPkeepref(*uvl = vl->batCacheid); } else { - sql_schema *s = mvc_bind_schema(m, *sname); - sql_idx *i = mvc_bind_idx(m, s, *iname); + sql_schema *s = mvc_bind_schema(m, sname); + sql_idx *i = mvc_bind_idx(m, s, iname); *bid = e_bat(TYPE_oid); *uvl = e_bat((i->type==join_idx)?TYPE_oid:TYPE_lng); @@ -1021,9 +1021,9 @@ mvc_bind_idxbat_wrap(Client cntxt, MalBl } return MAL_SUCCEED; } - if (*sname) - throw(SQL, "sql.idxbind", "unable to find index %s for %s.%s", *iname, *sname, *tname); - throw(SQL, "sql.idxbind", "unable to find index %s for %s", *iname, *tname); + if (sname) + throw(SQL, "sql.idxbind", "unable to find index %s for %s.%s", iname, sname, tname); + throw(SQL, "sql.idxbind", "unable to find index %s for %s", iname, tname); } str mvc_append_column(sql_trans *t, sql_column *c, BAT *ins) { @@ -1163,17 +1163,17 @@ mvc_clear_table_wrap(Client cntxt, MalBl mvc *m = NULL; str msg; lng *res = getArgReference_lng(stk, pci, 0); - str *sname = getArgReference_str(stk, pci, 1); - str *tname = getArgReference_str(stk, pci, 2); + str sname = *getArgReference_str(stk, pci, 1); + str tname = *getArgReference_str(stk, pci, 2); if ((msg = getSQLContext(cntxt, mb, &m, NULL)) != NULL) return msg; if ((msg = checkSQLContext(cntxt)) != NULL) return msg; - s = mvc_bind_schema(m, *sname); + s = mvc_bind_schema(m, sname); if (s == NULL) throw(SQL, "sql.clear_table", "3F000!Schema missing"); - t = mvc_bind_table(m, s, *tname); + t = mvc_bind_table(m, s, tname); if (t == NULL) throw(SQL, "sql.clear_table", "42S02!Table missing"); *res = mvc_clear_table(m, t); @@ -1849,10 +1849,10 @@ mvc_export_table_wrap( Client cntxt, Mal str filename = *getArgReference_str(stk,pci,1); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list