bigsql / plprofiler

Other
87 stars 23 forks source link

AttributeError: module 'cgi' has no attribute 'escape' #3

Closed kotsachin closed 2 years ago

kotsachin commented 3 years ago

Hi,

I am hitting AttributeError: module 'cgi' has no attribute 'escape' while running sample test report with plprofiler.

Environment: Ubuntu 20.04 (Focal), PostgreSQL-12.6, plprofiler code from git master branch.

  1. Prepare sample database

    $ ./prepdb.sh 
    dropping old tables...
    creating tables...
    generating data...
    100000 of 1000000 tuples (10%) done (elapsed 0.09 s, remaining 0.82 s)
    200000 of 1000000 tuples (20%) done (elapsed 0.19 s, remaining 0.78 s)
    300000 of 1000000 tuples (30%) done (elapsed 0.30 s, remaining 0.69 s)
    400000 of 1000000 tuples (40%) done (elapsed 0.41 s, remaining 0.62 s)
    500000 of 1000000 tuples (50%) done (elapsed 0.53 s, remaining 0.53 s)
    600000 of 1000000 tuples (60%) done (elapsed 0.64 s, remaining 0.42 s)
    700000 of 1000000 tuples (70%) done (elapsed 0.75 s, remaining 0.32 s)
    800000 of 1000000 tuples (80%) done (elapsed 0.87 s, remaining 0.22 s)
    900000 of 1000000 tuples (90%) done (elapsed 1.04 s, remaining 0.12 s)
    1000000 of 1000000 tuples (100%) done (elapsed 1.16 s, remaining 0.00 s)
    vacuuming...
    creating primary keys...
    done.
    CREATE FUNCTION
    CREATE FUNCTION
    CREATE FUNCTION
    CREATE FUNCTION
    CREATE FUNCTION
    CREATE FUNCTION
    DROP EXTENSION IF EXISTS plprofiler;
    DROP EXTENSION
    CREATE EXTENSION plprofiler;
    CREATE EXTENSION
    DROP SEQUENCE IF EXISTS pgbench_category_seq;
    DROP SEQUENCE
    CREATE SEQUENCE pgbench_category_seq;
    CREATE SEQUENCE
    DROP TABLE IF EXISTS pgbench_accounts_new;
    NOTICE:  table "pgbench_accounts_new" does not exist, skipping
    DROP TABLE
    CREATE TABLE pgbench_accounts_new (
    category    integer default (nextval('pgbench_category_seq') / 20),
    aid         integer NOT NULL,
    bid         integer,
    abalance    integer,
    filler      character(1000)
    )
    WITH (FILLFACTOR = 90);
    CREATE TABLE
    INSERT INTO pgbench_accounts_new
        (aid, bid, abalance, filler)
    SELECT aid, bid, abalance,
            '11111111111111111111111111111111111111111111111111' ||
            '11111111111111111111111111111111111111111111111111' ||
            '22222222222222222222222222222222222222222222222222' ||
            '22222222222222222222222222222222222222222222222222' ||
            '33333333333333333333333333333333333333333333333333' ||
            '33333333333333333333333333333333333333333333333333' ||
            '44444444444444444444444444444444444444444444444444' ||
            '44444444444444444444444444444444444444444444444444' ||
            '55555555555555555555555555555555555555555555555555' ||
            '55555555555555555555555555555555555555555555555555'
    FROM pgbench_accounts;
    INSERT 0 1000000
    DROP TABLE pgbench_accounts;
    DROP TABLE
    ALTER TABLE pgbench_accounts_new RENAME TO pgbench_accounts;
    ALTER TABLE
    ALTER TABLE pgbench_accounts ADD CONSTRAINT pgbench_accounts_pkey
    PRIMARY KEY (category, aid);
    ALTER TABLE
    VACUUM FULL ANALYZE pgbench_accounts;
    VACUUM
  2. Run sample plprofiler report

    
    $ plprofiler run --command "SELECT tpcb(1, 2, 3, -42)" -U postgres -d pgbench_plprofiler --output ~/tpcb-test1.html
    SELECT tpcb(1, 2, 3, -42)
    -- row1:
    tpcb: -42

(1 rows) SELECT 1 (0.030 seconds)

Traceback (most recent call last): File "/usr/local/bin/plprofiler", line 11, in load_entry_point('plprofiler==4.1', 'console_scripts', 'plprofiler')() File "/usr/local/lib/python3.8/dist-packages/plprofiler-4.1-py3.8.egg/plprofiler/plprofiler_tool.py", line 75, in main return run_command(sys.argv[2:]) File "/usr/local/lib/python3.8/dist-packages/plprofiler-4.1-py3.8.egg/plprofiler/plprofiler_tool.py", line 846, in run_command plp.report(report_data, output_fd) File "/usr/local/lib/python3.8/dist-packages/plprofiler-4.1-py3.8.egg/plprofiler/plprofiler.py", line 1012, in report report.generate(report_data, output_fd) File "/usr/local/lib/python3.8/dist-packages/plprofiler-4.1-py3.8.egg/plprofiler/plprofiler_report.py", line 21, in generate self.out(" %s" %(cgi.escape(config['title']), )) AttributeError: module 'cgi' has no attribute 'escape'



Will submit the pull request to fix this shortly. 

Regards,
Sachin
wieck commented 2 years ago

Fixed in https://github.com/bigsql/plprofiler/commit/56800386455dff6cc924c074cd1f105b1c315be1