fortune.usp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <!--#
  2. Test type 4: Fortunes
  3. TechEmpower Web Framework Benchmarks
  4. -->
  5. <!--#declaration
  6. #include "fortune.h"
  7. static void handlerQuery()
  8. {
  9. U_TRACE_NO_PARAM(5, "::handlerQuery()")
  10. uint32_t i = 0;
  11. Fortune::pstmt_fortune->execute();
  12. do {
  13. Fortune::replace(i++);
  14. }
  15. while (Fortune::pstmt_fortune->nextRow());
  16. }
  17. #ifdef U_STATIC_ORM_DRIVER_PGSQL
  18. static void handlerResult(void* res, uint32_t num_result)
  19. {
  20. U_TRACE(5, "::handlerResult(%p,%u)", res, num_result)
  21. U_INTERNAL_ASSERT_EQUALS(num_result, 1)
  22. U_INTERNAL_ASSERT_EQUALS(PQnfields((PGresult*)res), 2)
  23. int sz;
  24. char* id;
  25. char* ptr;
  26. Fortune::initQuery();
  27. for (uint32_t i = 0, n = U_SYSCALL(PQntuples, "%p", (PGresult*)res); i < n; ++i)
  28. {
  29. id = U_SYSCALL(PQgetvalue, "%p,%d,%d", (PGresult*)res, i, 0);
  30. ptr = U_SYSCALL(PQgetvalue, "%p,%d,%d", (PGresult*)res, i, 1);
  31. sz = U_SYSCALL(PQgetlength, "%p,%d,%d", (PGresult*)res, i, 1);
  32. Fortune::replace(i, ntohl(*(uint32_t*)id), ptr, sz);
  33. }
  34. Fortune::endQuery();
  35. }
  36. #endif
  37. static void usp_init_fortune() { Fortune::handlerInitSql(); }
  38. static void usp_fork_fortune() { Fortune::handlerForkSql(); }
  39. -->
  40. <!--#header
  41. -->
  42. <!--#code
  43. #ifdef U_STATIC_ORM_DRIVER_PGSQL
  44. if (Fortune::pstmt)
  45. {
  46. Fortune::sendQueryPrepared();
  47. UServer_Base::handler_db2->handlerQuery(handlerResult);
  48. }
  49. else
  50. #endif
  51. {
  52. Fortune::doQuery(handlerQuery);
  53. }
  54. -->