MCPcopy Create free account
hub / github.com/documentdb/documentdb / DropNativeUser

Function DropNativeUser

pg_documentdb/src/commands/users.c:675–703  ·  view source on GitHub ↗

* DropNativeUser drops a native PostgreSQL role for the user */

Source from the content-addressed store, hash-verified

673 * DropNativeUser drops a native PostgreSQL role for the user
674 */
675static void
676DropNativeUser(const char *dropUser)
677{
678 /*Verify that native authentication is enabled*/
679 if (!IsNativeAuthEnabled)
680 {
681 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_COMMANDNOTSUPPORTED),
682 errmsg(
683 "Native authentication is not enabled. Enable native authentication on this cluster to perform native user management operations.")));
684 }
685
686 ReportFeatureUsage(FEATURE_USER_DROP);
687
688 /*Verify that the calling user is also native*/
689 if (IsCallingUserExternal())
690 {
691 ereport(ERROR, (errcode(ERRCODE_DOCUMENTDB_INSUFFICIENTPRIVILEGE),
692 errmsg(
693 "Only native users can create other native users. Authenticate as a built-in native administrative user to perform native user management operations.")));
694 }
695
696 StringInfo dropUserInfo = makeStringInfo();
697 appendStringInfo(dropUserInfo, "DROP ROLE %s;", quote_identifier(dropUser));
698
699 bool readOnly = false;
700 bool isNull = false;
701 ExtensionExecuteQueryViaSPI(dropUserInfo->data, readOnly, SPI_OK_UTILITY,
702 &isNull);
703}
704
705
706/*

Callers 1

Calls 3

ReportFeatureUsageFunction · 0.85
IsCallingUserExternalFunction · 0.85

Tested by

no test coverage detected