* DropNativeUser drops a native PostgreSQL role for the user */
| 673 | * DropNativeUser drops a native PostgreSQL role for the user |
| 674 | */ |
| 675 | static void |
| 676 | DropNativeUser(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 | /* |
no test coverage detected