Visitar URL original
The set command in the stored procedure is invalid for subsequent query statements · Issue #145 · pgpool/pgpool2 · GitHub
Skip to content

The set command in the stored procedure is invalid for subsequent query statements #145

Description

@liujinyang-highgo

If some set command in procedure, that will be valid only in session to primary node, but not valid for sessions to standby node.

example as below:

  1. create PROCEDURE will be executed on primary node.

CREATE OR REPLACE PROCEDURE sub_proc1()
LANGUAGE plpgsql
AS $$
BEGIN
set enable_indexscan=off;
END;
$$;

  1. call procedure will be executed on primary node, enable_indexscan is set to off on session to primary node.

call sub_proc1();

  1. show command will be executed on standby node. the result of enable_indexscan is still default value(on), not changed;

    enable_indexscan;


on

(1 row)

  1. so subsequent select query will be routed to standby node, that means for those query enable_indexscan is still on .

is any solution for this?

Activity

  1. self-assigned this
    on Jan 28, 2026
  2. tatsuo-ishii commented on Jan 28, 2026

    @tatsuo-ishii
    Collaborator

    So your question is how to route a SELECT to primary node? You can use an SQL comment like this:

    test=# /*NO LOAD BALANCE*/select 1;
    NOTICE:  DB node id: 0 statement: /*NO LOAD BALANCE*/select 1;
     ?column? 
    ----------
            1
    (1 row)
    

    Note that NOTICE: DB node id: 0 statement: /*NO LOAD BALANCE*/select 1; is shown because of notice_per_node_statement = on

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

Metadata

Metadata

Assignees

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