This story by the nineteenth-century Spanish author Juan Valera appears in his Cuentos y chascarrillos andaluces (Humorous Andalusian Stories and Tales, 1896). In the prologue he states that all the selections come directly from the oral tradition of southern Spain and that some are notable for their “coarseness and crudeness” (crudeza y grosería), and some, like this one, triggered by an embarrassing mishap, for their earthy sense of humor.
Fedorchek, Robert M.. "The Queen Mother." Marvels & Tales 17.2 (2003). Web. <https://digitalcommons.wayne.edu/marvels/vol17/iss2/6>.