Undefined function: 7 ERROR: function unix_timestamp(character varying) does not exist

Created on 21 October 2021, about 3 years ago
Updated 11 October 2023, about 1 year ago

Problem/Motivation

Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42883]: Undefined function: 7 ERROR: function unix_timestamp(character varying) does not exist LINE 7: ...id" = '1') AND ("a"."status" = 'completed') AND ((UNIX_TIMES... ^ HINT: No function matches the given name and argument types. You might need to add explicit type casts.: SELECT COUNT(*) AS "expression" FROM (SELECT 1 AS "expression" FROM "opigno_learning_path_achievements" "a" INNER JOIN "groups" "g" ON g.id = a.gid WHERE ("a"."uid" = :db_condition_placeholder_0) AND ("a"."status" = :db_condition_placeholder_1) AND ((UNIX_TIMESTAMP(a.completed) >= :timestamp))) "subquery"; Array ( [:db_condition_placeholder_0] => 1 [:db_condition_placeholder_1] => completed [:timestamp] => 1634270400 ) in Drupal\opigno_statistics\Services\UserStatisticsManager->getUserTrainingsNumberByStatus() (line 171 of modules/contrib/opigno_statistics/src/Services/UserStatisticsManager.php).
Drupal\Core\Database\StatementWrapper->execute(Array, Array) (Line: 874)
Drupal\Core\Database\Connection->query('SELECT COUNT(*) AS "expression"
FROM
(SELECT 1 AS "expression"
FROM
{opigno_learning_path_achievements} "a"
INNER JOIN {groups} "g" ON g.id = a.gid
WHERE ("a"."uid" = :db_condition_placeholder_0) AND ("a"."status" = :db_condition_placeholder_1) AND ((UNIX_TIMESTAMP(a.completed) >= :timestamp))) "subquery"', Array, Array) (Line: 183)
Drupal\Core\Database\Driver\pgsql\Connection->query('SELECT COUNT(*) AS "expression"
FROM
(SELECT 1 AS "expression"
FROM
{opigno_learning_path_achievements} "a"
INNER JOIN {groups} "g" ON g.id = a.gid
WHERE ("a"."uid" = :db_condition_placeholder_0) AND ("a"."status" = :db_condition_placeholder_1) AND ((UNIX_TIMESTAMP(a.completed) >= :timestamp))) "subquery"', Array, Array) (Line: 512)
Drupal\Core\Database\Query\Select->execute() (Line: 147)
Drupal\Core\Database\Driver\pgsql\Select->execute() (Line: 171)
Drupal\opigno_statistics\Services\UserStatisticsManager->getUserTrainingsNumberByStatus(7, 1) (Line: 416)
Drupal\opigno_statistics\Services\UserStatisticsManager->renderUserStatistics(7, 1) (Line: 1393)
Drupal\opigno_statistics\Controller\UserController->index(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 578)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 158)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 80)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 67)
Drupal\simple_oauth\HttpMiddleware\BasicAuthSwap->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 52)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 717)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Steps to reproduce

Found this with a d9 install with postgres and went to /user/1

🐛 Bug report
Status

Needs review

Version

3.0

Component

User interface

Created by

🇺🇸United States jakegibs617

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇺Cuba rafageist

    Create the function for PostgreSQL:

    CREATE OR REPLACE FUNCTION unix_timestamp(input_text character varying)
    RETURNS bigint AS $$
    DECLARE
        result bigint;
    BEGIN
        SELECT EXTRACT(epoch FROM TO_TIMESTAMP(input_text, 'YYYY-MM-DD HH24:MI:SS')) INTO result;
    
        RETURN result;
    EXCEPTION
        WHEN others THEN
            RAISE EXCEPTION 'Error';
    END;
    $$ LANGUAGE plpgsql;
    
  • 🇮🇳India mohd sahzad

    I have updated opigno_statistics module for this issue Undefined function: 7 ERROR: function unix_timestamp(character varying) does not exist

  • Status changed to Needs review about 1 year ago
Production build 0.71.5 2024