From b009fda5c23a352a8c3761b1d392c8032c3eeafe Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Thu, 2 Oct 2025 22:43:30 +0000 Subject: [PATCH] Add sdb_case_equalivance() macro for use in indexes --- db/include/indexmacros.m4 | 52 +++++++++++++++++++++++++++++++++++++++ doc/src/epilog.inc.m4 | 2 +- 2 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 db/include/indexmacros.m4 diff --git a/db/include/indexmacros.m4 b/db/include/indexmacros.m4 new file mode 100644 index 0000000..e5da79a --- /dev/null +++ b/db/include/indexmacros.m4 @@ -0,0 +1,52 @@ +dnl Copyright (C) 2025 The Meme Factory, Inc. http://www.karlpinc.com/ +dnl +dnl This program is free software: you can redistribute it and/or modify +dnl it under the terms of the GNU Affero General Public License as published +dnl by the Free Software Foundation, either version 3 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU Affero General Public License for more details. +dnl +dnl You should have received a copy of the GNU Affero General Public License +dnl along with this program. If not, see . +dnl +dnl Karl O. Pinc +dnl +dnl Macros used when creating indexes. +dnl +dnl +dnl Define m4 macros so we don't have to type so much. +dnl (Or at least type stuff that's more fun.) +dnl +dnl Watch out for using the single quote char as it has special +dnl meaning to m4. +dnl +dnl Bugs: +dnl +changequote([{[,]}])dnl m4 foolery so includes include only once. +dnl Once the macro is in the text, change the quotes back +ifdef([{[_indexmacros.m4]}], [{[changequote(`,')]}], [{[dnl +changequote(`,')dnl +dnl +dnl Standard test for having already included the file. +define(`_indexmacros.m4')dnl +dnl + +dnl Include standard macros +include(macros.m4) +dnl Don't output anything while defining macros. +divert(`-1') + +-- Case equalivance +-- Note that this is not exactly as good as unicode case folding, but +-- this is what we seem to have. +-- Syntax: sdb_case_equvalence(sql_expression) +define(`sdb_case_equivalence', `lower(normalize($1))') + +-- Done defining macros. +divert(`0')dnl + +]}])dnl End of ifdef over the whole file. diff --git a/doc/src/epilog.inc.m4 b/doc/src/epilog.inc.m4 index 619b490..cdc3a9d 100644 --- a/doc/src/epilog.inc.m4 +++ b/doc/src/epilog.inc.m4 @@ -312,7 +312,7 @@ sdb_generated_rst()dnl .. |unique| replace:: Each value stored in this column must be unique. -.. The unique() macro is used for uniquenocase. +.. The sdb_case_equalivance() macro is used in indexes for uniquenocase. .. |uniquenocase| replace:: Each value stored in this column must be unique, independent of character case. -- 2.34.1