mirror of
https://github.com/Icinga/icingadb.git
synced 2026-05-28 04:35:54 -04:00
Merge pull request #461 from Icinga/postgres-integer-like
PostgreSQL: Support LIKE for integer/enum columns
This commit is contained in:
commit
09af3c8184
1 changed files with 18 additions and 0 deletions
|
|
@ -161,6 +161,24 @@ BEGIN
|
|||
END;
|
||||
$$;
|
||||
|
||||
/* At the moment Icinga DB Web doesn't know the column types,
|
||||
so it sends SQL queries with LIKE operators for all suggestions in the search bar,
|
||||
which fails for numeric and enum types on PostgreSQL.
|
||||
To support this, the LIKE operator (internally translated to ~~) is overloaded.
|
||||
Note that this is only a temporary solution until Icinga DB Web provides column type support.
|
||||
*/
|
||||
CREATE OR REPLACE FUNCTION anynonarrayliketext(anynonarray, text)
|
||||
RETURNS bool
|
||||
LANGUAGE plpgsql
|
||||
IMMUTABLE
|
||||
PARALLEL SAFE
|
||||
AS $$
|
||||
BEGIN
|
||||
RETURN $1::TEXT LIKE $2;
|
||||
END;
|
||||
$$;
|
||||
CREATE OPERATOR ~~ (LEFTARG=anynonarray, RIGHTARG=text, PROCEDURE=anynonarrayliketext);
|
||||
|
||||
CREATE TABLE host (
|
||||
id bytea20 NOT NULL,
|
||||
environment_id bytea20 NOT NULL,
|
||||
|
|
|
|||
Loading…
Reference in a new issue