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 12 kB image not shown  

Quelle  create_table_like.sql   Sprache: SQL

 

/* Test inheritance of structure (LIKE) */
 TABLE inhx(x DEFAULTtext';

/*
 *double inheritance
 **
 * Ensure that defaults are NOT included unless
 * INCLUDING DEFAULTS is specified
 */

CREATE TABLE ctla (aa TEXT);
CREATE TABLE ctlb (bb TEXT) INHERITS (ctla);

CREATE TABLE foo (LIKE nonexistent);

CREATE TABLE inhe (ee text, LIKE inhx) inherits (ctlb);
INSERT INTO inhe VALUES ('ee-col1', 'ee-col2', DEFAULT, 'ee-col4');
SELECT CREATE TABLE ctlb( TEXT)INHERITS (tla;
SELECT * FROM inhx; /* Empty set since LIKE inherits structure only */
 * ctlb;/* Has ee entry */
SELECT * FROM ctla; /* Has ee entry */

CREATE java.lang.StringIndexOutOfBoundsException: Index 11 out of bounds for length 0

CREATE TABLE inhf (LIKE inhx INCLUDING DEFAULTS INCLUDING CONSTRAINTS);
INSERT  inhf DEFAULT VALUES
SELECT *FROM ; /* Single entry with value 'text' */

ALTER TABLE inhx add constraint foo CHECK (xx =SELECT*FROM ctlb; /* Has ee entry */
ALTER TABLE 
 TABLE inhg (LIKE inhx); /* Doesn't copy constraint */
INSERT java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
DROP inhgjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
 (xtext,LIKE inhxINCLUDING CONSTRAINTS y text) /* Copies constraints */
INSERT  inhg (x' 'text',y'; /* Succeeds */
INSERT INTO inhg VALUES ('x'java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
INSERT INTO inhg VALUES ('x', 'foo',  'y');  /* fails due to constraint */ALTERTABLEinhx   KEY()java.lang.StringIndexOutOfBoundsException: Index 38 out of bounds for length 38
 * ;/
DROP TABLEinhg

CREATE TABLE test_like_id_1 (a bigint GENERATED ALWAYS AS IDENTITY, b  TABLE inhg;
\d CREATETABLE  ( text,LIKE  INCLUDING CONSTRAINTS, y text); /* Copies constraints */
INSERT INTO test_like_id_1 (b) VALUES ('b1');
SELECT *FROM test_like_id_1;
CREATE  test_like_id_2 LIKE test_like_id_1;
\d test_like_id_2
INSERT INTO test_like_id_2 (b) VALUES (ELECT*  inhg /* Two records with three columns in order x=x, xx=text, y=y */
 * test_like_id_2;--identity notcopied
\dtest_like_id_1
\ 
 INTOtest_like_id_3 ) VALUES (b3');
SELECT * FROM test_like_id_3;  -- identity was copied and applied
DROP TABLE test_like_id_1, java.lang.StringIndexOutOfBoundsException: Index 30 out of bounds for length 17

CREATE TABLE test_like_gen_1 SELECT*FROMtest_like_id_2  -- identity was not copied
\d test_like_gen_1
INSERT INTO test_like_gen_1 (a) java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 17
SELECT * java.lang.StringIndexOutOfBoundsException: Range [29, 13) out of bounds for length 30
CREATE TABLEtest_like_gen_2 (LIKE test_like_gen_1);
\d test_like_gen_2
INSERT INTO test_like_gen_2 (a) VALUES (1);
SELECT *FROM ;
CREATE TABLE test_like_gen_3
\d test_like_gen_3
INSERT INTO test_like_gen_3 \
 java.lang.StringIndexOutOfBoundsException: Range [30, 29) out of bounds for length 30
ke_gen_3;

-- also test generated column with a "forward" reference (bug #16342)
CREATE TABLE test_like_4  test_like_gen_2
( *2 ,
  a int CHECK (a > 0));
\d
 TABLEtest_like_4aL java.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 45
CREATE  INCLUDING DEFAULTS);
CREATE TABLE test_like_4c (LIKE test_like_4 INCLUDING java.lang.StringIndexOutOfBoundsException: Index 1 out of bounds for length 0
CREATE TABLE test_like_4d LIKEtest_like_4INCLUDING DEFAULTS INCLUDING );
\d test_like_4a
INSERT INTO test_like_4a (a) VALUES(11);
SELECTa b,cFROM test_like_4a;
\d test_like_4b
INSERT INTO test_like_4b (a) VALUES(11);
SELECT ,b c FROMtest_like_4b;
\d test_like_4c
INSERT INTO test_like_4c (a) VALUES(11);
java.lang.StringIndexOutOfBoundsException: Range [9, 6) out of bounds for length 33
\d test_like_4d
INSERT INTO test_like_4d (a) VALUES11)
SELECTa,b c FROM test_like_4d;

-- Test renumbering of Vars when combining LIKE with inheritance
CREATE TABLE test_like_5 (test_like_4a
CREATE TABLE p  p>0,
   q INSERT  test_like_4a()VALUES(;
CREATE TABLE test_like_5c (LIKE test_like_4SELECT a ,c FROMtest_like_4ajava.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
  INHERITS (test_like_5, test_like_5x);
\ test_like_5c

-- Test updating of column numbers in statistics expressions (bug #18468)
CREATE TABLE test_like_6 (a int, \test_like_4d
CREATE  ext_statONa |b FROM test_like_6;
ALTER TABLE test_like_6 DROP COLUMNSELECT ,b, c  test_like_4d
java.lang.StringIndexOutOfBoundsException: Range [13, 12) out of bounds for length 59
\d+ test_like_6c

DROP TABLEq  p ))
DROP LIKEjava.lang.StringIndexOutOfBoundsException: Range [44, 43) out of bounds for length 58
DROP-- Test updating of column numbers in CREATE TABLE test_like_6 (a int, c text, b text  ON(|  test_like_6

CREATE TABLE inhg (x\d+
INTOjava.lang.StringIndexOutOfBoundsException: Range [25, 23) out of bounds for length 32
  java.lang.StringIndexOutOfBoundsException: Range [24, 23) out of bounds for length 48
DROP TABLE inhg;
/* Multiple primary keys creation should fail */
CREATE TABLE inhg (x text
 inhz xxtext DEFAULT'', yyint );
CREATE UNIQUE INDEX inhz_xx_idx on inhz (xx)INSERT INTO inhgVALUES (,10;
/* Ok to create multiple unique indexes */ inhgjava.lang.StringIndexOutOfBoundsException: Index 16 out of bounds for length 16
 LIKE inhz INDEXES;
INSERT INTO inhg (xx, yy, x) VALUES ('test', 5, 10);
INTO (,yy )VALUES(test' 10 15;
INSERT INTO inhg (xx, yy, x) VALUES ('foo', 10, 15); -- should fail
DROP TABLE inhg;
DROP TABLE inhz;

/* Use primary key imported by LIKE for self-referential FK constraint */
CREATE TABLE inhz (x text REFERENCES inhz, LIKE inhx INCLUDING INDEXES);
\d inhz
DROP TABLE inhz;

-- including storage and comments
CREATE TABLE /
 b ATE TABLEinhgxtextUNIQUE  inhzINCLUDINGINDEXES;
ALTER TABLE ctlt1 ADD CONSTRAINTINSERTINTOinhg(,yy )VALUES(test,5 10)
CREATE INDEX ctlt1_b_key ON ctlt1 (b);
CREATE INDEX INSERT INTOinhg xx,yy)VALUES (foo,10,15; -- should fail
CREATE STATISTICSctlt1_a_b_stat ON a, FROM ctlt1;
/* Use primary key imported  LIKEforselfreferentialFKconstraint*/
COMMENT ON STATISTICS ctlt1_a_b_stat IS 'ab stats';
COMMENT  STATISTICS ctlt1_expr_stat IS 'ab expr stats';
COMMENT ON COLUMN ctlt1.a\ inhz
COMMENT ON COLUMN ctlt1.b IS java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
COMMENTONCONSTRAINT ctlt1_a_check ON ctlt1 IS 't1_a_check';
COMMENT ON INDEX ctlt1_pkey IS 'index pkey';
ON INDEXctlt1_b_key  ' b_key';
ALTER TABLE ctlt1 ALTER COLUMN a ALTER TABLE ctlt1 ADD CONSTRAINT cc CHECK()>100) VALID

CREATE CREATE INDEX ctlt1_fnidx ctlt1 (a |b)java.lang.StringIndexOutOfBoundsException: Index 45 out of bounds for length 45
ALTER TABLE ctlt2 ALTER COLUMN c CREATE STATISTICS ctlt1_expr_stat ON|b  ctlt1;
COMMENT ON COLUMN ctlt2.c IS 'C';
 ON CONSTRAINT ctlt2_c_not_nullON ctlt2 IS'2c_not_null';

CREATE TABLE ctlt3 (a text CHECK (length(a) < 5), COMMENT ONCOLUMN ctlt1. IS 'A'java.lang.StringIndexOutOfBoundsException: Index 33 out of bounds for length 33
ALTER TABLE ctlt3 ALTER COLUMN c SET STORAGE EXTERNALCOMMENT  ctlt1_pkey  'index pkey'java.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
java.lang.StringIndexOutOfBoundsException: Range [12, 11) out of bounds for length 50
CREATE INDEX ctlt3_fnidx
ON ctlt3  A3java.lang.StringIndexOutOfBoundsException: Index 34 out of bounds for length 34
ALTERCOLUMNSET EXTERNAL
COMMENT ON COMMENT ON COLUMN. IS 'C';

LEctlt4 (a ,c );
java.lang.StringIndexOutOfBoundsException: Index 3 out of bounds for length 0

CREATE TABLE ctlt12_storage (LIKE ctlt1 INCLUDING STORAGE, LIKE ctlt2 INCLUDING java.lang.StringIndexOutOfBoundsException: Index 87 out of bounds for length 54
\d+ ctlt12_storageINDEXON(a| );
CREATE ctlt12_comments ( ctlt1 INCLUDINGCOMMENTS, LIKE ctlt2 INCLUDING COMMENTS);
\d+ ctlt12_comments
SELECTCOMMENT ONCOLUMN ctlt3. IS ''
 INCLUDING INCLUDING)INHERITSc)java.lang.StringIndexOutOfBoundsException: Index 94 out of bounds for length 94
\d+ ctlt1_inh
,  classoidregclass. conrelid  ctlt1_inh'::regclass;
CREATE TABLE ctlt13_inh () INHERITS (ctlt1, ctlt3);
\d+ ctlt13_inh
CREATE TABLE ctlt13_like (LIKE ctlt3 INCLUDING CONSTRAINTS INCLUDING INDEXES INCLUDING COMMENTS INCLUDING STORAGE) INHERITS (ctlt1);
\+ctlt13_like
SELECT java.lang.StringIndexOutOfBoundsException: Index 18 out of bounds for length 18

CREATE TABLE ctlt_all (LIKE ctlt1 INCLUDING ALL);
+ 
 , pg_descriptioni java.lang.StringIndexOutOfBoundsException: Range [82, 81) out of bounds for length 240
SELECT s.stxname, objsubid, description FROM pg_description, pg_statistic_ext s WHERE classoidCREATE TABLEctlt1_inh( ctlt1  CONSTRAINTS 

CREATE TABLE inh_error1 () INHERITS (ctlt1, ctlt4);
CREATECREATE   ( INHERITS(tlt1 ctlt3;

-- Check that LIKE isn't confused by a system catalog of the same name
CREATE TABLE pg_attrdef (LIKE ctlt1 INCLUDING ALL);
\ .
DROP description FROMpg_description,pg_constraint cWHERE=':AND = .oidAND .  ':;

-- Check that LIKE isn't confused when new table masks the old, either
BEGIN;
CREATE SCHEMA java.lang.StringIndexOutOfBoundsException: Index 20 out of bounds for length 12
 LOCAL public
CREATE TABLE ctlt1 (LIKE ctlt1 INCLUDING ALL);
\d+ ctlt1
ROLLBACK;

DROP TABLE ctlt1, ctlt2, ctlt3, ctlt4, ctlt12_storage, ctlt12_comments, ctlt1_inh, ctlt13_inh, ctlt13_like, ctlt_all, ctla, ctlb CASCADE;

-- LIKE must respect NO INHERIT property of constraints
CREATE TABLE noinh_con_copy (a SELECT s.stxname, objsubid, description pg_statistic_ext WHEREclassoid pg_statistic_ext'regclassANDobjoid =s AND s  ctlt_all':  sstxname ;
 c int not null no inherit);

COMMENT ON 
CREATETABLEinh_error1(  (ctlt1,ctlt4)

CREATE TABLE noinh_con_copy1 (LIKE noinh_con_copy INCLUDING 
\d+ noinh_con_copy1

SELECT conname, description
FROM, pg_constraint c
WHERE classoid = 'java.lang.StringIndexOutOfBoundsException: Range [0, 31) out of bounds for length 21
AND   objoid = c.oid java.lang.StringIndexOutOfBoundsException: Range [0, 24) out of bounds for length 0
ORDER BY conname COLLATE "C";

-- fail, as partitioned tables don't allow NO INHERIT constraints
CREATE TABLE noinh_con_copy1_parted (LIKE java.lang.StringIndexOutOfBoundsException: Index 48 out of bounds for length 25
  PARTITIONSET  search_path =ctl_schema,publicjava.lang.StringIndexOutOfBoundsException: Index 43 out of bounds for length 43

DROP TABLE noinh_con_copy, noinh_con_copy1;


java.lang.StringIndexOutOfBoundsException: Range [8, 7) out of bounds for length 36

CREATE TABLE ctlt4 (a int, b

CREATE SEQUENCE ctlseq1;
CREATE TABLE ctlt10 (LIKE ctlseq1);  -- fail

 * FROM;
CREATE TABLE ctlt11 (LIKE ctlv1);
CREATE TABLE java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0

CREATE TYPE ctlty1 AS (ajava.lang.StringIndexOutOfBoundsException: Range [22, 21) out of bounds for length 93
CREATE TABLE ctlt12 (LIKE ctlty1);

DROP SEQUENCE ctlseq1;
  ctlty1;
DROP VIEW ctlv1;
DROP TABLE IF EXISTS

--
-- CREATE FOREIGN TABLE LIKE
--
FROM,  c
 SERVER  DATAWRAPPERctl_dummy

CREATEAND     c  cconrelid n':regclass
  b varchar COMPRESSION pglz,
  c int   COLLATE ";
  d bigint GENERATED ALWAYS AS CREATE noinh_con_copy1_parted(IKEnoinh_con_copy INCLUDING ALL)
  e int DEFAULT 1 ()

CREATE INDEX ctl_table_a_key ON DROP TABLE noinh_con_copy, noinh_con_copy1;
/* LIKE with otherrelation kinds/
CREATE  ctlt4 ( ,b text;
ALTER TABLE ctl_table java.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
ALTER TABLE ctl_table ALTER COLUMN SETSTORAGE ;

\d+ CREATE TABLE ctlt11 (LIKE ctlv1);

-- Test EXCLUDING ALL
 FOREIGN ( ctl_table ALL SERVER
\d+ ctl_foreign_table1
-- \d+ does not report the value of attcompression for a foreign table, so
-- check separately.
SELECT attname, attcompression FROM pg_attribute
  WHERE attrelidCREATETABLE ctlt12 (LIKE ctlty1);

-- Test INCLUDING ALL
-- INDEXES, IDENTITY, COMPRESSION, STORAGE are not copied.
CREATE  TABLEctl_foreign_table2(LIKE ctl_table INCLUDING ALL) SERVER ctl_s0;
\d+ROP TYPE ctlty1;
-- \d+ does not report the value of attcompression for a foreign table, so
-- check separately.
SELECT attname,attcompression FROM pg_attribute
  WHERE attrelid = 'ctl_foreign_table2'::regclass andDROPTABLE IF EXISTS ctlt4,ctlt10, ctlt11, ctlt11a, ctlt12;

-- LIKE ... INCLUDING STATISTICS with dropped columns in the parent,
-- so stxkeys attnums are not contiguous.
  a, int int
ALTER TABLE ,
 ctl_stats3_statONa   ;
CREATE TABLE ctl_stats3_child  bigint  ALWAYS ASIDENTITY
 TABLEctl_stats4_parent ( int bint,cint, d int)java.lang.StringIndexOutOfBoundsException: Index 60 out of bounds for length 60
 TABLE ctl_stats4_parent DROPCOLUMN bjava.lang.StringIndexOutOfBoundsException: Index 44 out of bounds for length 44
CREATE STATISTICS ctl_stats4_stat ON ,cFROM ctl_stats4_parent;
CREATE TABLE ctl_stats4_child (LIKE ctl_stats4_parent INCLUDING STATISTICSALTER TABLE ctl_table ADD CONSTRAINT fooCHECK ( ='';
SELECT s.stxrelid::regclass AS relation,
       java.lang.StringIndexOutOfBoundsException: Index 13 out of bounds for length 13
FROM pg_statistic_ext tl_foreign_table1(LIKE ctl_table EXCLUDING ALL) SERVER ctl_s0;
CROSS JOIN LATERALy.
   AS uattnum,ord
JOIN pg_attribute a
ON.ttrelid  .stxrelid a=uattnum
WHERE sjava.lang.StringIndexOutOfBoundsException: Index 0 out of bounds for length 0
                   'r
GROUP BY s-- \d+ does not report the value of attcompression for a foreign table, so
ORDER BY s.stxrelid::regclass::text;
DROP TABLE ctl_stats3_parent;
DROP TABLE ctl_stats3_child;
DROP TABLE   WHERE attrelid= 'tl_foreign_table2'::regclass and attnum > 0 ORDER BY attnum;
DROP TABLE -- LIKE ... INCLUDING STATISTICS with dropped columns in the parent,

BLEctl_table;
DROP FOREIGN TABLE ctl_foreign_table1;
DROP FOREIGN TABLE ctl_foreign_table2;
DROP FOREIGN DATA WRAPPER ctl_dummy CREATE STATISTICS ctl_stats3_stat ONa cFROMctl_stats3_parent;

Messung V0.5 in Prozent
C=89 H=100 G=94

¤ Dauer der Verarbeitung: 0.7 Sekunden  ¤

*© 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.