Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Postgres/src/test/regress/sql/   (Postgres Database Version 18.4©)  Datei vom 11.4.2026 mit Größe 3 kB image not shown  

Quelle  hash_part.sql

  Sprache: SQL
 

--
-- Hash partitioning.
--

-- Use hand-rolled hash functions and operator classes to get predictable
-- result on different machines.  See the definitions of
-- part_test_int4_ops and part_test_text_ops in test_setup.sql.

CREATE TABLE mchash (a int, b text, c jsonb)
  PARTITION BY HASH (a part_test_int4_ops, b part_test_text_ops);
CREATE TABLE mchash1
  PARTITION OF mchash FOR VALUES WITH (MODULUS 4, REMAINDER 0);

-- invalid OID, no such table
SELECT satisfies_hash_partition(040NULL);

-- not partitioned
SELECT satisfies_hash_partition('tenk1'::regclass, 40NULL);

-- partition rather than the parent
SELECT satisfies_hash_partition('mchash1'::regclass, 40NULL);

-- invalid modulus
SELECT satisfies_hash_partition('mchash'::regclass, 00NULL);

-- remainder too small
SELECT satisfies_hash_partition('mchash'::regclass, 1, -1NULL);

-- remainder too large
SELECT satisfies_hash_partition('mchash'::regclass, 11NULL);

-- modulus is null
SELECT satisfies_hash_partition('mchash'::regclass, NULL0NULL);

-- remainder is null
SELECT satisfies_hash_partition('mchash'::regclass, 4NULLNULL);

-- too many arguments
SELECT satisfies_hash_partition('mchash'::regclass, 40NULL::intNULL::text, NULL::json);

-- too few arguments
SELECT satisfies_hash_partition('mchash'::regclass, 31NULL::int);

-- wrong argument type
SELECT satisfies_hash_partition('mchash'::regclass, 21NULL::intNULL::int);

-- ok, should be false
SELECT satisfies_hash_partition('mchash'::regclass, 400''::text);

-- ok, should be true
SELECT satisfies_hash_partition('mchash'::regclass, 402''::text);

-- argument via variadic syntax, should fail because not all partitioning
-- columns are of the correct type
SELECT satisfies_hash_partition('mchash'::regclass, 21,
        variadic array[1,2]::int[]);

-- multiple partitioning columns of the same type
CREATE TABLE mcinthash (a int, b int, c jsonb)
  PARTITION BY HASH (a part_test_int4_ops, b part_test_int4_ops);

-- now variadic should work, should be false
SELECT satisfies_hash_partition('mcinthash'::regclass, 40,
        variadic array[00]);

-- should be true
SELECT satisfies_hash_partition('mcinthash'::regclass, 40,
        variadic array[01]);

-- wrong length
SELECT satisfies_hash_partition('mcinthash'::regclass, 40,
        variadic array[]::int[]);

-- wrong type
SELECT satisfies_hash_partition('mcinthash'::regclass, 40,
        variadic array[now(), now()]);

-- check satisfies_hash_partition passes correct collation
create table text_hashp (a text) partition by hash (a);
create table text_hashp0 partition of text_hashp for values with (modulus 2, remainder 0);
create table text_hashp1 partition of text_hashp for values with (modulus 2, remainder 1);
-- The result here should always be true, because 'xxx' must belong to
-- one of the two defined partitions
select satisfies_hash_partition('text_hashp'::regclass, 20'xxx'::text) OR
    satisfies_hash_partition('text_hashp'::regclass, 21'xxx'::text) AS satisfies;

-- cleanup
DROP TABLE mchash;
DROP TABLE mcinthash;
DROP TABLE text_hashp;

Messung V0.5 in Prozent
C=84 H=96 G=90

¤ Dauer der Verarbeitung: 0.11 Sekunden  (vorverarbeitet am  2026-08-08) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.