Changeset: c8eb4eb3fe8c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/c8eb4eb3fe8c
Modified Files:
monetdb5/modules/mal/pcre.c
sql/backends/monet5/sql_cast.c
sql/backends/monet5/sql_round_impl.h
sql/backends/monet5/sql_time.c
sql/server/sql_datetime.c
sql/server/sql_datetime.h
sql/server/sql_decimal.c
sql/server/sql_decimal.h
Branch: Jan2022
Log Message:
Use more const char *.
diffs (truncated from 429 to 300 lines):
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -1296,25 +1296,25 @@ PCREsql2pcre(str *ret, const str *pat, c
}
static inline str
-choose_like_path(char **ppat, bool *use_re, bool *use_strcmp, bool *empty,
const str *pat, const str *esc)
+choose_like_path(char **ppat, bool *use_re, bool *use_strcmp, bool *empty,
const char *pat, const char *esc)
{
str res = MAL_SUCCEED;
*use_re = false;
*use_strcmp = false;
*empty = false;
- if (strNil(*pat) || strNil(*esc)) {
+ if (strNil(pat) || strNil(esc)) {
*empty = true;
} else {
- if (!re_is_pattern_properly_escaped(*pat, (unsigned char)
**esc))
+ if (!re_is_pattern_properly_escaped(pat, (unsigned char) *esc))
throw(MAL, "pcre.sql2pcre", SQLSTATE(22019)
ILLEGAL_ARGUMENT ": (I)LIKE pattern must not end with escape character");
- if (is_strcmpable(*pat, *esc)) {
+ if (is_strcmpable(pat, esc)) {
*use_re = true;
*use_strcmp = true;
- } else if (re_simple(*pat, (unsigned char) **esc)) {
+ } else if (re_simple(pat, (unsigned char) *esc)) {
*use_re = true;
} else {
- if ((res = sql2pcre(ppat, *pat, *esc)) != MAL_SUCCEED)
+ if ((res = sql2pcre(ppat, pat, esc)) != MAL_SUCCEED)
return res;
if (strNil(*ppat)) {
GDKfree(*ppat);
@@ -1335,7 +1335,7 @@ PCRElike_imp(bit *ret, const str *s, con
bool use_re = false, use_strcmp = false, empty = false;
struct RE *re = NULL;
- if ((res = choose_like_path(&ppat, &use_re, &use_strcmp, &empty, pat,
esc)) != MAL_SUCCEED)
+ if ((res = choose_like_path(&ppat, &use_re, &use_strcmp, &empty, *pat,
*esc)) != MAL_SUCCEED)
return res;
MT_thread_setalgorithm(empty ? "pcrelike: trivially empty" : use_strcmp
? "pcrelike: pattern matching using strcmp" :
@@ -1401,7 +1401,7 @@ re_like_build(struct RE **re, uint32_t *
} while (0)
static inline bit
-re_like_proj_apply(str s, struct RE *re, uint32_t *wpat, const char *pat, bool
caseignore, bool anti, bool use_strcmp)
+re_like_proj_apply(const char *s, struct RE *re, uint32_t *wpat, const char
*pat, bool caseignore, bool anti, bool use_strcmp)
{
if (use_strcmp) {
if (caseignore) {
@@ -1518,7 +1518,7 @@ pcre_like_build(
} while(0)
static inline str
-pcre_like_apply(bit *ret, str s,
+pcre_like_apply(bit *ret, const char *s,
#ifdef HAVE_LIBPCRE
pcre *re, pcre_extra *ex
#else
@@ -1618,9 +1618,9 @@ BATPCRElike_imp(Client cntxt, MalBlkPtr
input = *getArgReference_str(stk, pci, 1);
for (BUN p = 0; p < q; p++) {
- const str next_input = b ? BUNtail(bi, p) : input, np =
BUNtail(pi, p);
+ const char *next_input = b ? BUNtail(bi, p) : input,
*np = BUNtail(pi, p);
- if ((msg = choose_like_path(&ppat, &use_re,
&use_strcmp, &empty, &np, esc)) != MAL_SUCCEED) {
+ if ((msg = choose_like_path(&ppat, &use_re,
&use_strcmp, &empty, np, *esc)) != MAL_SUCCEED) {
bat_iterator_end(&pi);
if (b)
bat_iterator_end(&bi);
@@ -1662,7 +1662,7 @@ BATPCRElike_imp(Client cntxt, MalBlkPtr
bat_iterator_end(&bi);
} else {
pat = *getArgReference_str(stk, pci, 2);
- if ((msg = choose_like_path(&ppat, &use_re, &use_strcmp,
&empty, &pat, esc)) != MAL_SUCCEED)
+ if ((msg = choose_like_path(&ppat, &use_re, &use_strcmp,
&empty, pat, *esc)) != MAL_SUCCEED)
goto bailout;
bi = bat_iterator(b);
@@ -1675,7 +1675,7 @@ BATPCRElike_imp(Client cntxt, MalBlkPtr
goto bailout;
}
for (BUN p = 0; p < q; p++) {
- const str s = BUNtail(bi, p);
+ const char *s = BUNtail(bi, p);
ret[p] = re_like_proj_apply(s, re_simple, wpat,
pat, isensitive, anti, use_strcmp);
has_nil |= is_bit_nil(ret[p]);
}
@@ -1689,7 +1689,7 @@ BATPCRElike_imp(Client cntxt, MalBlkPtr
goto bailout;
}
for (BUN p = 0; p < q; p++) {
- const str s = BUNtail(bi, p);
+ const char *s = BUNtail(bi, p);
if ((msg = pcre_like_apply(&(ret[p]), s, re,
ex, ppat, anti)) != MAL_SUCCEED) {
bat_iterator_end(&bi);
goto bailout;
@@ -1883,7 +1883,7 @@ PCRElikeselect(bat *ret, const bat *bid,
assert(ATOMstorage(b->ttype) == TYPE_str);
- if ((msg = choose_like_path(&ppat, &use_re, &use_strcmp, &empty, pat,
esc)) != MAL_SUCCEED)
+ if ((msg = choose_like_path(&ppat, &use_re, &use_strcmp, &empty, *pat,
*esc)) != MAL_SUCCEED)
goto bailout;
/* Since the strimp pre-filtering of a LIKE query produces a superset of
@@ -1994,7 +1994,7 @@ bailout:
vr = VALUE(r, ro - rbase); \
nl = 0; \
use_re = use_strcmp = empty = false; \
- if ((msg = choose_like_path(&pcrepat, &use_re,
&use_strcmp, &empty, (const str*)&vr, (const str*)&esc))) \
+ if ((msg = choose_like_path(&pcrepat, &use_re,
&use_strcmp, &empty, vr, esc))) \
goto bailout; \
if (!empty) { \
if (use_re) { \
diff --git a/sql/backends/monet5/sql_cast.c b/sql/backends/monet5/sql_cast.c
--- a/sql/backends/monet5/sql_cast.c
+++ b/sql/backends/monet5/sql_cast.c
@@ -13,7 +13,7 @@
#include "mal_instruction.h"
static inline str
-str_2_blob_imp(blob **r, size_t *rlen, const str val)
+str_2_blob_imp(blob **r, size_t *rlen, const char *val)
{
ssize_t e = ATOMfromstr(TYPE_blob, (void**)r, rlen, val, false);
if (e < 0 || (ATOMcmp(TYPE_blob, *r, ATOMnilptr(TYPE_blob)) == 0 &&
!strNil(val))) {
diff --git a/sql/backends/monet5/sql_round_impl.h
b/sql/backends/monet5/sql_round_impl.h
--- a/sql/backends/monet5/sql_round_impl.h
+++ b/sql/backends/monet5/sql_round_impl.h
@@ -606,9 +606,9 @@ nil_2dec(TYPE *res, const void *val, con
}
static inline str
-str_2dec_body(TYPE *res, const str val, const int d, const int sc)
+str_2dec_body(TYPE *res, const char *val, const int d, const int sc)
{
- char *s = val;
+ const char *s = val;
int digits;
int scale;
BIG value;
@@ -739,7 +739,7 @@ batstr_2dec(Client cntxt, MalBlkPtr mb,
if (ci.tpe == cand_dense) {
for (BUN i = 0; i < q; i++) {
oid p = (canditer_next_dense(&ci) - off);
- const str next = BUNtail(bi, p);
+ const char *next = BUNtail(bi, p);
if (strNil(next)) {
ret[i] = NIL(TYPE);
@@ -750,7 +750,7 @@ batstr_2dec(Client cntxt, MalBlkPtr mb,
} else {
for (BUN i = 0; i < q; i++) {
oid p = (canditer_next(&ci) - off);
- const str next = BUNtail(bi, p);
+ const char *next = BUNtail(bi, p);
if (strNil(next)) {
ret[i] = NIL(TYPE);
diff --git a/sql/backends/monet5/sql_time.c b/sql/backends/monet5/sql_time.c
--- a/sql/backends/monet5/sql_time.c
+++ b/sql/backends/monet5/sql_time.c
@@ -285,7 +285,7 @@ nil_2time_daytime(Client cntxt, MalBlkPt
}
static inline str
-str_2time_daytimetz_internal_imp(daytime *ret, str next, ssize_t
(*fromstr_func)(const char *, size_t *, daytime **, bool),
+str_2time_daytimetz_internal_imp(daytime *ret, const char *next, ssize_t
(*fromstr_func)(const char *, size_t *, daytime **, bool),
#ifdef HAVE_HGE
hge shift, hge divider, hge multiplier
#else
@@ -366,7 +366,7 @@ str_2time_daytimetz_internal(ptr out, pt
if (ci.tpe == cand_dense) {
for (BUN i = 0 ; i < q && !msg; i++) {
oid p = (canditer_next_dense(&ci) - off);
- str next = BUNtvar(it, p);
+ const char *next = BUNtvar(it, p);
if (strNil(next)) {
ret[i] = daytime_nil;
@@ -378,7 +378,7 @@ str_2time_daytimetz_internal(ptr out, pt
} else {
for (BUN i = 0 ; i < q && !msg; i++) {
oid p = (canditer_next(&ci) - off);
- str next = BUNtvar(it, p);
+ const char *next = BUNtvar(it, p);
if (strNil(next)) {
ret[i] = daytime_nil;
@@ -390,7 +390,7 @@ str_2time_daytimetz_internal(ptr out, pt
}
bat_iterator_end(&it);
} else {
- str next = *(str*)in;
+ const char *next = *(str*)in;
if (strNil(next))
*ret = daytime_nil;
else
@@ -793,7 +793,7 @@ nil_2time_timestamp(Client cntxt, MalBlk
}
static inline str
-str_2time_timestamptz_internal_imp(timestamp *ret, str next, ssize_t
(*fromstr_func)(const char *, size_t *, timestamp **, bool),
+str_2time_timestamptz_internal_imp(timestamp *ret, const char *next, ssize_t
(*fromstr_func)(const char *, size_t *, timestamp **, bool),
#ifdef HAVE_HGE
hge shift, hge divider, hge multiplier
#else
@@ -874,7 +874,7 @@ str_2time_timestamptz_internal(ptr out,
if (ci.tpe == cand_dense) {
for (BUN i = 0 ; i < q && !msg; i++) {
oid p = (canditer_next_dense(&ci) - off);
- str next = BUNtvar(bi, p);
+ const char *next = BUNtvar(bi, p);
if (strNil(next)) {
ret[i] = timestamp_nil;
@@ -886,7 +886,7 @@ str_2time_timestamptz_internal(ptr out,
} else {
for (BUN i = 0 ; i < q && !msg; i++) {
oid p = (canditer_next(&ci) - off);
- str next = BUNtvar(bi, p);
+ const char *next = BUNtvar(bi, p);
if (strNil(next)) {
ret[i] = timestamp_nil;
@@ -898,7 +898,7 @@ str_2time_timestamptz_internal(ptr out,
}
bat_iterator_end(&bi);
} else {
- str next = *(str*)in;
+ const char *next = *(str*)in;
if (strNil(next))
*ret = timestamp_nil;
else
@@ -954,7 +954,7 @@ batstr_2time_timestamp(bat *res, const b
}
static inline str
-month_interval_str_imp(int *ret, str next, int d, int sk)
+month_interval_str_imp(int *ret, const char *next, int d, int sk)
{
lng upcast;
if (interval_from_str(next, d, sk, &upcast) < 0)
@@ -1006,7 +1006,7 @@ month_interval_str(Client cntxt, MalBlkP
if (ci.tpe == cand_dense) {
for (BUN i = 0 ; i < q && !msg; i++) {
oid p = (canditer_next_dense(&ci) - off);
- str next = BUNtvar(bi, p);
+ const char *next = BUNtvar(bi, p);
if (strNil(next)) {
ret[i] = int_nil;
@@ -1018,7 +1018,7 @@ month_interval_str(Client cntxt, MalBlkP
} else {
for (BUN i = 0 ; i < q && !msg; i++) {
oid p = (canditer_next(&ci) - off);
- str next = BUNtvar(bi, p);
+ const char *next = BUNtvar(bi, p);
if (strNil(next)) {
ret[i] = int_nil;
@@ -1030,7 +1030,7 @@ month_interval_str(Client cntxt, MalBlkP
}
bat_iterator_end(&bi);
} else {
- const str next = *getArgReference_str(stk, pci, 1);
+ const char *next = *getArgReference_str(stk, pci, 1);
if (strNil(next))
*ret = int_nil;
@@ -1057,7 +1057,7 @@ bailout:
}
static inline str
-second_interval_str_imp(lng *ret, str next, int d, int sk)
+second_interval_str_imp(lng *ret, const char *next, int d, int sk)
{
if (interval_from_str(next, d, sk, ret) < 0)
return createException(SQL, "batcalc.second_interval_str",
SQLSTATE(42000) "Wrong format (%s)", next);
@@ -1106,7 +1106,7 @@ second_interval_str(Client cntxt, MalBlk
if (ci.tpe == cand_dense) {
for (BUN i = 0 ; i < q && !msg; i++) {
oid p = (canditer_next_dense(&ci) - off);
- str next = BUNtvar(bi, p);
+ const char *next = BUNtvar(bi, p);
if (strNil(next)) {
ret[i] = lng_nil;
@@ -1118,7 +1118,7 @@ second_interval_str(Client cntxt, MalBlk
} else {
for (BUN i = 0 ; i < q && !msg; i++) {
oid p = (canditer_next(&ci) - off);
- str next = BUNtvar(bi, p);
+ const char *next = BUNtvar(bi, p);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list