From e89b4a0e9d09647f83e7ca95142da04bc70e66bf Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Mon, 8 Sep 2025 22:27:53 +0000 Subject: [PATCH] Add nonnegative macros/substitution --- db/include/tablemacros.m4 | 12 ++++++++++++ doc/src/epilog.inc.m4 | 3 +++ 2 files changed, 15 insertions(+) diff --git a/db/include/tablemacros.m4 b/db/include/tablemacros.m4 index 05de965..32e7d10 100644 --- a/db/include/tablemacros.m4 +++ b/db/include/tablemacros.m4 @@ -226,6 +226,18 @@ define([noseconds_check], [ CONSTRAINT "$1: Cannot contain seconds CHECK (EXTRACT(SECONDS FROM $1) = 0)])dnl changequote(`,')dnl See above +-- A column must be non-negative +-- +-- Syntax: nonnegative_check(col) +-- +-- Input: +-- col Name of the column to check. +-- +changequote([,]) +define([nonnegative_check], [ CONSTRAINT "$1: must be bigger than or equal to 0" + CHECK ($1 >= 0)])dnl +changequote(`,')dnl See above + -- A pair of columns must both be either NULL or non-NULL. -- -- Syntax: null_iff_null(col1, col2) diff --git a/doc/src/epilog.inc.m4 b/doc/src/epilog.inc.m4 index 7fc21f0..5a67339 100644 --- a/doc/src/epilog.inc.m4 +++ b/doc/src/epilog.inc.m4 @@ -307,6 +307,9 @@ sdb_generated_rst()dnl This column may be empty text. It need not contain characters, but it may not contain only whitespace characters. +.. |nonnegative| replace:: + This column may not contain a negative value. + .. Used in code table documentation of the key columns. .. |keycol| replace:: |unique| |notnull| |notempty| |nospaces| -- 2.34.1