drop if exists - first piece

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: "Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: drop if exists - first piece
Date: 2005-11-18 22:42:36
Message-ID: 437E58DC.2090700@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


I will apply the attached patch tomorrow, barring objection. This covers
drop if exists for the following objects:

table view index sequence schema type domain conversion

I have a simple test script as show below, but I am not sure where to
put it in the regression tests - add a new one maybe? The test for each
object proves that the object doesn't exist, shows that we don't
generate an error using IF EXISTS when it doesn't exist, and then shows
that we do drop the object properly if it does exist.

cheers

andrew

--
-- IF EXISTS tests
--

-- table (will be really dropped at the end)

DROP TABLE test_exists;

DROP TABLE IF EXISTS test_exists;

CREATE TABLE test_exists (a int, b text);

-- view

DROP VIEW test_view_exists;

DROP VIEW IF EXISTS test_view_exists;

CREATE VIEW test_view_exists AS select * from test_exists;

DROP VIEW IF EXISTS test_view_exists;

DROP VIEW test_view_exists;

-- index

DROP INDEX test_index_exists;

DROP INDEX IF EXISTS test_index_exists;

CREAT INDEX test_index_exists on test_view_exists(a);

DROP INDEX IF EXISTS test_index_exists;

DROP INDEX test_index_exists;

-- sequence

DROP SEQUENCE test_sequence_exists;

DROP SEQUENCE IF EXISTS test_sequence_exists;

CREATE SEQUENCE test_sequence_exists;

DROP SEQUENCE IF EXISTS test_sequence_exists;

DROP SEQUENCE test_sequence_exists;

-- schema

DROP SCHEMA test_schema_exists;

DROP SCHEMA IF EXISTS test_schema_exists;

CREATE SCHEMA test_schema_exists;

DROP SCHEMA IF EXISTS test_schema_exists;

DROP SCHEMA test_schema_exists;

-- type

DROP TYPE test_type_exists;

DROP TYPE IF EXISTS test__type_exists;

CREATE type test_type_exists as (a int, b text);

DROP TYPE IF EXISTS test__type_exists;

DROP TYPE test_type_exists;

-- domain

DROP DOMAIN test_domain_exists;

DROP DOMAIN IF EXISTS test__domain_exists;

CREATE domain test_domain_exists as int not null check (value > 0);

DROP DOMAIN IF EXISTS test__domain_exists;

DROP DOMAIN test_domain_exists;

-- drop the table

DROP TABLE IF EXISTS test_exists;

DROP TABLE test_exists;

Attachment Content-Type Size
drop-if-exists.patch2 text/plain 33.3 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2005-11-18 23:49:03 Re: drop if exists - first piece
Previous Message Alvaro Herrera 2005-11-18 19:54:30 DROP OWNED again