12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <!--#
- Test type 4: Fortunes
- TechEmpower Web Framework Benchmarks
- -->
- <!--#declaration
- #include "fortune.h"
- static void handlerQuery()
- {
- U_TRACE_NO_PARAM(5, "::handlerQuery()")
- uint32_t i = 0;
- Fortune::pstmt_fortune->execute();
- do {
- Fortune::replace(i++);
- }
- while (Fortune::pstmt_fortune->nextRow());
- }
- #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), 2)
- int sz;
- char* id;
- char* ptr;
- Fortune::initQuery();
- for (uint32_t i = 0, n = U_SYSCALL(PQntuples, "%p", (PGresult*)res); i < n; ++i)
- {
- id = U_SYSCALL(PQgetvalue, "%p,%d,%d", (PGresult*)res, i, 0);
- ptr = U_SYSCALL(PQgetvalue, "%p,%d,%d", (PGresult*)res, i, 1);
- sz = U_SYSCALL(PQgetlength, "%p,%d,%d", (PGresult*)res, i, 1);
- Fortune::replace(i, ntohl(*(uint32_t*)id), ptr, sz);
- }
- Fortune::endQuery();
- }
- #endif
- static void usp_init_fortune() { Fortune::handlerInitSql(); }
- static void usp_fork_fortune() { Fortune::handlerForkSql(); }
- -->
- <!--#header
- -->
- <!--#code
- #ifdef U_STATIC_ORM_DRIVER_PGSQL
- if (Fortune::pstmt)
- {
- Fortune::sendQueryPrepared();
- UServer_Base::handler_db2->handlerQuery(handlerResult);
- }
- else
- #endif
- {
- Fortune::doQuery(handlerQuery);
- }
- -->
|