Files
documentdb/pg_documentdb/sql/udfs/schema_mgmt/drop_database--latest.sql
T
Zinan Ren 4e093b2c9d Merged PR 1545484: [OSS] Porting udfs into documentdb - part 2
### 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)
Yes
### Are you introducing any new config? If yes, do you have tests with and without them being set?
No
### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md))

### Description

Porting udfs into documentdb

----
#### AI description  (iteration 1)
#### PR Classification
Code cleanup and feature enhancement.

#### PR Summary
This pull request continues the porting of UDFs into DocumentDB, updating and including various SQL files for better functionality and organization.
- Updated `documentdb--0.24-0.sql` to include new UDFs and operators, replacing old function references.
- Added new UDFs for query, projection, geospatial, aggregation, metadata, schema management, index management, CRUD commands, user management, schema validation, telemetry, TTL, vector search, extension version, diagnostic, and RBAC metadata.
- Removed outdated function definitions and replaced them with updated SQL includes.
2025-01-15 07:48:41 +00:00

27 lines
825 B
PL/PgSQL

/* db.dropDatabase(writeConcern) */
CREATE OR REPLACE FUNCTION __API_SCHEMA_V2__.drop_database(
p_database_name text,
p_write_concern __CORE_SCHEMA_V2__.bson default null)
RETURNS void
SET search_path TO __CORE_SCHEMA_V2__, 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 __API_SCHEMA_V2__.drop_collection(v_collection.database_name, v_collection.collection_name);
END LOOP;
END;
$fn$ LANGUAGE plpgsql;
COMMENT ON FUNCTION __API_SCHEMA_V2__.drop_database(text,__CORE_SCHEMA_V2__.bson)
IS 'drop a mongo database';