[tarantool-patches] Re: [PATCH 2/2] sql: remove GLOB from Tarantool

Alexander Turenko alexander.turenko at tarantool.org
Mon Oct 29 15:15:29 MSK 2018


Hi!

See remaining comments below.

WBR, Alexander Turenko.

> >> +static const int case_insensitive_like = 1;
> >> +static const int case_sensitive_like = 0;
> > 
> > Are not they are mutually exclusive? Can we leave just one?
> > 
> > Why they are not defines?
> 
> I guess it’s a bad idea since we need pointers to them in some functions.
> e.g:
> 
> 	int *is_like_ci;
> 	if (is_case_sensitive)
> 		is_like_ci = (void *)&case_sensitive_like;
> 	else
> 		is_like_ci = (void *)&case_insensitive_like;
> 	sqlite3CreateFunc(db, "LIKE", 2, 0, is_like_ci, likeFunc, 0, 0, 0);
> 	sqlite3CreateFunc(db, "LIKE", 3, 0, is_like_ci, likeFunc, 0, 0, 0);

I think we can use SQLITE_INT_TO_PTR and SQLITE_PTR_TO_INT to pass an
integer value as a pointer and then cast it back. Maybe we also should
change LIKEFUNC macro.

> >> +       int *is_like_ci;
> >> +       if (is_case_sensitive)
> >> +               is_like_ci = (int *)&case_sensitive_like;
> >> +       else
> >> +               is_like_ci = (int *)&case_insensitive_like;
> > 
> > Discarding const qualifier? It seems not being right thing to do. It is
> > better to define is_like_ci pointer as const.
> 
> It’s not possible due to so-called “down qualification” and will cause
> compiler warnings.

We'll anyway discard it here or there, so nevermind. I proposed to
change it to SQLITE_INT_TO_PTR.




More information about the Tarantool-patches mailing list