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

Function DetectApiSchemaCommand

pg_documentdb/src/commands/current_op.c:869–1007  ·  view source on GitHub ↗

* Gets the command name and details for a command executing in the * API schema */

Source from the content-addressed store, hash-verified

867 * API schema
868 */
869static const char *
870DetectApiSchemaCommand(const char *topLevelQuery, const char *schemaName,
871 SingleWorkerActivity *activity,
872 pgbson_writer *commandWriter)
873{
874 const char *namespaceQuery = strstr(topLevelQuery, schemaName);
875 if (namespaceQuery == NULL)
876 {
877 return NULL;
878 }
879
880 const char *query = namespaceQuery + strlen(schemaName);
881 if (strstr(query, ".update(") == query)
882 {
883 PgbsonWriterAppendUtf8(commandWriter, "update", 6,
884 activity->processedMongoCollection);
885 return "update";
886 }
887 else if (strstr(query, ".insert(") == query)
888 {
889 PgbsonWriterAppendUtf8(commandWriter, "insert", 6,
890 activity->processedMongoCollection);
891 return "insert";
892 }
893 else if (strstr(query, ".delete(") == query)
894 {
895 PgbsonWriterAppendUtf8(commandWriter, "delete", 6,
896 activity->processedMongoCollection);
897 return "remove";
898 }
899 else if (strstr(query, ".cursor_get_more(") == query)
900 {
901 PgbsonWriterAppendInt64(commandWriter, "getMore", 6, 0);
902 return "getmore";
903 }
904 else if (strstr(query, ".find_cursor_first_page(") == query)
905 {
906 PgbsonWriterAppendUtf8(commandWriter, "find", 4,
907 activity->processedMongoCollection);
908 return "query";
909 }
910 else if (strstr(query, ".find_and_modify(") == query)
911 {
912 PgbsonWriterAppendUtf8(commandWriter, "findAndModify", 13,
913 activity->processedMongoCollection);
914 return "command";
915 }
916 else if (strstr(query, ".aggregate_cursor_first_page(") == query)
917 {
918 PgbsonWriterAppendUtf8(commandWriter, "aggregate", 9,
919 activity->processedMongoCollection);
920 return "command";
921 }
922 else if (strstr(query, "_catalog.bson_aggregation_pipeline(") == query)
923 {
924 PgbsonWriterAppendUtf8(commandWriter, "aggregate", 9,
925 activity->processedMongoCollection);
926 return "command";

Callers 1

Calls 2

PgbsonWriterAppendUtf8Function · 0.85
PgbsonWriterAppendInt64Function · 0.85

Tested by

no test coverage detected