mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-25 11:49:53 -05:00
### Does this PR have any customer impact? No ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) Refactoring ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) UDF ### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md)) ### Description Move drop_database function to OSS
27 lines
780 B
PL/PgSQL
27 lines
780 B
PL/PgSQL
/* db.dropDatabase(writeConcern) */
|
|
CREATE OR REPLACE FUNCTION helio_api.drop_database(
|
|
p_database_name text,
|
|
p_write_concern helio_core.bson default null)
|
|
RETURNS void
|
|
SET search_path TO helio_core, pg_catalog
|
|
AS $fn$
|
|
DECLARE
|
|
v_collection record;
|
|
BEGIN
|
|
/* TODO: lock on database to prevent concurrent table addition */
|
|
FOR
|
|
v_collection
|
|
IN
|
|
SELECT
|
|
database_name, collection_name
|
|
FROM
|
|
__API_CATALOG_SCHEMA__.collections
|
|
WHERE
|
|
database_name = p_database_name
|
|
LOOP
|
|
PERFORM helio_api.drop_collection(v_collection.database_name, v_collection.collection_name);
|
|
END LOOP;
|
|
END;
|
|
$fn$ LANGUAGE plpgsql;
|
|
COMMENT ON FUNCTION helio_api.drop_database(text,helio_core.bson)
|
|
IS 'drop a HelioAPI database'; |