summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-03-13 14:54:22 +0100
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-03-13 14:54:22 +0100
commit4d8db5450033edf9319b02873f8c75a9ed36dbd1 (patch)
tree5f76b6e5dff3b3ed9fed8490af8b16009320b01e
parent56604b9b6d2f1184c67dfdf0592116cb2f6f8a3e (diff)
Database schema: Add STABLE and IMMUTABLE qualifiers to function definitions as appropriate.
-rw-r--r--schema.sql12
1 files changed, 6 insertions, 6 deletions
diff --git a/schema.sql b/schema.sql
index 39ddb53..17de70a 100644
--- a/schema.sql
+++ b/schema.sql
@@ -178,7 +178,7 @@ CREATE TYPE characteristic_list AS (
characteristics characteristic[]
);
-CREATE OR REPLACE FUNCTION article_revisions_for_characteristics_with_fixed_ones(
+CREATE FUNCTION article_revisions_for_characteristics_with_fixed_ones(
article INTEGER,
characteristics characteristic_list[],
fixed_characteristics characteristic_list
@@ -223,16 +223,16 @@ BEGIN
RETURN ARRAY[]::INTEGER[];
END IF;
END
-$BODY$ LANGUAGE plpgsql;
+$BODY$ LANGUAGE plpgsql STABLE;
-CREATE OR REPLACE FUNCTION article_revisions_for_characteristics(
+CREATE FUNCTION article_revisions_for_characteristics(
article INTEGER,
characteristics characteristic_list[]
) RETURNS SETOF INTEGER AS $$
BEGIN
RETURN QUERY SELECT unnest(article_revisions_for_characteristics_with_fixed_ones(article, characteristics, ROW(ARRAY[]::characteristic[])::characteristic_list));
END
-$$ LANGUAGE plpgsql;
+$$ LANGUAGE plpgsql STABLE;
-- Usage example:
-- SELECT article_revisions_for_characteristics(70, ARRAY[ROW(ARRAY[ROW('language', 'de')::characteristic])]::characteristic_list[]);
@@ -248,7 +248,7 @@ CREATE FUNCTION older_revision(
SELECT $2 WHERE $1.date >= $2.date OR $1.date IS NULL
UNION
SELECT $1 WHERE $1.date IS NULL AND $2.date IS NULL
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQL IMMUTABLE;
CREATE AGGREGATE oldest_revision (article_revisions) (
SFUNC = older_revision,
@@ -266,7 +266,7 @@ CREATE FUNCTION more_recent_revision(
SELECT $2 WHERE $1.date <= $2.date OR $1.date IS NULL
UNION
SELECT $1 WHERE $1.date IS NULL AND $2.date IS NULL
-$$ LANGUAGE SQL;
+$$ LANGUAGE SQL IMMUTABLE;
CREATE AGGREGATE most_recent_revision (article_revisions) (