<!--#
Test type 2: Single database query
TechEmpower Web Framework Benchmarks
-->
<!--#declaration
#include "world.h"

#ifdef U_STATIC_ORM_DRIVER_PGSQL
static void handlerResult(void* res, uint32_t num_result)
{
   U_TRACE(5, "::handlerResult(%p,%u)", res, num_result)

   U_INTERNAL_ASSERT_EQUALS(num_result, 1)
   U_INTERNAL_ASSERT_EQUALS(PQnfields((PGresult*)res), 1)
   U_INTERNAL_ASSERT_EQUALS(PQntuples((PGresult*)res), 1)

   char* randomNumber = U_SYSCALL(PQgetvalue, "%p,%d,%d", (PGresult*)res, 0, 0);

   World::handlerOneResult(ntohl(*(uint32_t*)randomNumber));
}
#endif

static void usp_init_db() { World::handlerInitSql(); }
static void usp_fork_db() { World::handlerForkSql(); }
-->
<!--#header
-->
<!--#code
#ifdef U_STATIC_ORM_DRIVER_PGSQL
if (World::pstmt)
   {
   World::sendQueryPrepared();

   UServer_Base::handler_db1->handlerQuery(handlerResult);
   }
else
#endif
{
World::pworld_query->id = World::rnumber[0];

(void) World::pstmt_query->execute();

World::handlerOneResult(World::pworld_query->randomNumber);
}
-->
