Thread

  1. Re: Can't fix Pgsql Insert Command Issue.

    Erik Wienhold <ewie@ewie.name> — 2024-09-23T23:50:47Z

    On 2024-09-23 18:53 +0200, Mark Kostevych wrote:
    > Could you check please why our insert command doesn't work?
    > 
    > INSERT INTO public.checks(id, name, "number", status, sub_total, tax_total, total, mandatory_tip_amount, open_time, close_time, employee_name, employee_role_name, employee_id, employee, guest_count, "type", type_id, taxed_type, table_name, location, zone, autograt_tax, trading_day_id, trading_day, updated_at, non_revenue_total, revenue_total, outstanding_balance, comp_total, voidcomp_reason_text, voidcomp_type, voidcomp_value)
    > VALUES ('1cfa4fc4-de12-4adc-a5f1-25e27203aeaf','21',5807,'Closed',410.00,35.16,445.16,0.00,'2024-09-22T20:14:42-07:00','2024-09-22T21:45:40-07:00','Kristian  Maxwell-McGeever','Server','da37c15c-2f2d-43f1-9959-070f231dd79a','666692_Kristian_Bird Streets Club_Server',4,'Table',1,'exclusive','21','Bird Streets Club','Restaurant',0.00,'d1abd697-04fa-40d6-8a9e-7c376dc2952d','2024-09-22','2024-09-23T12:19:41.000Z',0,410,0.00, 343, '', '', NULL);
    > 
    > I tried very simple insert command, but it still doesn't work. What
    > should I do?
    
    The attached CSV only shows held locks, nothing that caught my eye.  Can
    you please check pg_blocking_pids() to make sure that there are really
    no blocking sessions?  https://wiki.postgresql.org/wiki/Lock_Monitoring
    says that the listed queries only return row-level locks.  (Not sure if
    that is correct because the docs on pg_locks says that it normally does
    not return row-level locks.)
    
    First, get the PID of the session where you run your INSERT:
    
        SELECT pg_backend_pid();
        INSERT INTO public.checks ...
    
    In a second session, get the info on all backends that block the first
    session:
    
        SELECT * FROM pg_stat_activity WHERE pid = ANY (pg_blocking_pids(:pid));
    
    Please also provide the CREATE TABLE statements (or the output of psql's
    \d) for table "checks" and all tables that are referenced by "checks".
    
    Also, what is the exact Postgres version?
    
    Does the INSERT also hang when executed via psql instead of pgAdmin?
    Just to rule out that pgAdmin is the issue.
    
    -- 
    Erik