Skip to content

Lock table query does not escape table name #230

Description

@deric

Namespace containing e.g. dash - is not escaped properly in LOCK TABLE query, unlike CREATE INDEX queries.

running index repack only:

$ pg_repack -d my_db -x -t "app-production".ratings -e
LOG: (query) CREATE INDEX CONCURRENTLY index_477119363 ON "app-production".ratings USING btree ("!update_time") TABLESPACE pg_default
INFO: repacking index ""app-production".ratings_userid_index"
LOG: (query) SELECT pgc.relname, nsp.nspname FROM pg_class pgc INNER JOIN pg_namespace nsp ON nsp.oid = pgc.relnamespace WHERE pgc.relname = 'index_477119364' AND nsp.nspname = $1
LOG:    (param:0) = app-production
LOG: (query) SELECT repack.repack_indexdef($1, $2, $3, true)
LOG:    (param:0) = 477119364
LOG:    (param:1) = 475998744
LOG:    (param:2) = (null)
LOG: (query) CREATE INDEX CONCURRENTLY index_477119364 ON "app-production".ratings USING btree (userid) TABLESPACE pg_default
LOG: (query) BEGIN ISOLATION LEVEL READ COMMITTED
LOG: (query) SET LOCAL statement_timeout = 100
LOG: (query) LOCK TABLE app-production.ratings IN ACCESS EXCLUSIVE MODE
ERROR:  syntax error at or near "-"
LINE 1: LOCK TABLE app-production.ratings IN ACCESS EXCLUSIVE MODE
                        ^
LOG: (query) RESET statement_timeout
ERROR: query failed: ERROR:  current transaction is aborted, commands ignored until end of transaction block
DETAIL: query was: RESET statement_timeout
pg_repack 1.4.5

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions