@@ -370,4 +370,70 @@ SELECT create_hash_partitions('drop_index.test', 'val', 2);
370
370
DROP INDEX CONCURRENTLY drop_index.test_0_val_idx;
371
371
DROP SCHEMA drop_index CASCADE;
372
372
NOTICE: drop cascades to 3 other objects
373
+ /*
374
+ * Checking that ALTER TABLE IF EXISTS with loaded (and created) pg_pathman extension works the same as in vanilla
375
+ */
376
+ CREATE SCHEMA test_nonexistance;
377
+ ALTER TABLE IF EXISTS test_nonexistance.nonexistent_table RENAME TO other_table_name;
378
+ NOTICE: relation "nonexistent_table" does not exist, skipping
379
+ /* renaming existent tables already tested earlier (see rename.plain_test) */
380
+ ALTER TABLE IF EXISTS test_nonexistance.nonexistent_table ADD COLUMN IF NOT EXISTS j INT4;
381
+ NOTICE: relation "nonexistent_table" does not exist, skipping
382
+ CREATE TABLE test_nonexistance.existent_table(i INT4);
383
+ ALTER TABLE IF EXISTS test_nonexistance.existent_table ADD COLUMN IF NOT EXISTS i INT4;
384
+ NOTICE: column "i" of relation "existent_table" already exists, skipping
385
+ ALTER TABLE IF EXISTS test_nonexistance.existent_table ADD COLUMN IF NOT EXISTS j INT4;
386
+ SELECT attname FROM pg_attribute WHERE attnum > 0 AND attrelid = 'test_nonexistance.existent_table'::REGCLASS;
387
+ attname
388
+ ---------
389
+ i
390
+ j
391
+ (2 rows)
392
+
393
+ DROP TABLE test_nonexistance.existent_table;
394
+ ALTER TABLE IF EXISTS test_nonexistance.nonexistent_table DROP COLUMN IF EXISTS i;
395
+ NOTICE: relation "nonexistent_table" does not exist, skipping
396
+ CREATE TABLE test_nonexistance.existent_table(i INT4);
397
+ ALTER TABLE IF EXISTS test_nonexistance.existent_table DROP COLUMN IF EXISTS i;
398
+ ALTER TABLE IF EXISTS test_nonexistance.existent_table DROP COLUMN IF EXISTS nonexistent_column;
399
+ NOTICE: column "nonexistent_column" of relation "existent_table" does not exist, skipping
400
+ SELECT attname FROM pg_attribute WHERE attnum > 0 AND attrelid = 'test_nonexistance.existent_table'::REGCLASS;
401
+ attname
402
+ ------------------------------
403
+ ........pg.dropped.1........
404
+ (1 row)
405
+
406
+ DROP TABLE test_nonexistance.existent_table;
407
+ ALTER TABLE IF EXISTS test_nonexistance.nonexistent_table RENAME COLUMN i TO j;
408
+ NOTICE: relation "nonexistent_table" does not exist, skipping
409
+ CREATE TABLE test_nonexistance.existent_table(i INT4);
410
+ ALTER TABLE IF EXISTS test_nonexistance.existent_table RENAME COLUMN i TO j;
411
+ SELECT attname FROM pg_attribute WHERE attnum > 0 AND attrelid = 'test_nonexistance.existent_table'::REGCLASS;
412
+ attname
413
+ ---------
414
+ j
415
+ (1 row)
416
+
417
+ DROP TABLE test_nonexistance.existent_table;
418
+ ALTER TABLE IF EXISTS test_nonexistance.nonexistent_table RENAME CONSTRAINT baz TO bar;
419
+ NOTICE: relation "nonexistent_table" does not exist, skipping
420
+ CREATE TABLE test_nonexistance.existent_table(i INT4 CONSTRAINT existent_table_i_check CHECK (i < 100));
421
+ ALTER TABLE IF EXISTS test_nonexistance.existent_table RENAME CONSTRAINT existent_table_i_check TO existent_table_i_other_check;
422
+ DROP TABLE test_nonexistance.existent_table;
423
+ ALTER TABLE IF EXISTS test_nonexistance.nonexistent_table SET SCHEMA nonexistent_schema;
424
+ NOTICE: relation "nonexistent_table" does not exist, skipping
425
+ CREATE TABLE test_nonexistance.existent_table(i INT4);
426
+ ALTER TABLE IF EXISTS test_nonexistance.existent_table SET SCHEMA nonexistent_schema;
427
+ ERROR: schema "nonexistent_schema" does not exist
428
+ CREATE SCHEMA test_nonexistance2;
429
+ ALTER TABLE IF EXISTS test_nonexistance.existent_table SET SCHEMA test_nonexistance2;
430
+ DROP TABLE test_nonexistance2.existent_table;
431
+ DROP SCHEMA test_nonexistance2 CASCADE;
432
+ ALTER TABLE IF EXISTS test_nonexistance.nonexistent_table SET TABLESPACE nonexistent_tablespace;
433
+ NOTICE: relation "nonexistent_table" does not exist, skipping
434
+ CREATE TABLE test_nonexistance.existent_table(i INT4);
435
+ ALTER TABLE IF EXISTS test_nonexistance.existent_table SET TABLESPACE nonexistent_tablespace;
436
+ ERROR: tablespace "nonexistent_tablespace" does not exist
437
+ DROP TABLE test_nonexistance.existent_table;
438
+ DROP SCHEMA test_nonexistance CASCADE;
373
439
DROP EXTENSION pg_pathman;
0 commit comments