Basic problems using plpythonu - bug?

Поиск
Список
Период
Сортировка
От Curt Schwaderer
Тема Basic problems using plpythonu - bug?
Дата
Msg-id 007001c633e8$f228fec0$67fea8c0@curtf5ff5b67a9
обсуждение исходный текст
Ответы Re: Basic problems using plpythonu - bug?
Список pgsql-general
I'm trying to do something pretty basic per the documentation using plpython triggers. When I change the "cfgCmd" field in the SysConfig table below, the trigger works fine and if I have a null function that does nothing but write to the pipe, that all works fine. The trouble is when the function attemts to read from the SysConfig database, "cfgCmd" field which tells the function what to do. When I write a value to the SysConfig table, cfgCmd field, the server log says:
 
ERROR: plppython: function "send_ctl_msg" failed
DETAIL: exceptions.KeyError: 'cfgCmd'
 
What's a key error? I can't find any documentation on it? Also, when I try to reference TD["old"][<column name>] this gives me an error too. Does this have something to do with the untrusted language part or am I doing something wrong? Thanks much for any help,
Curt
 
Here is the trigger function:
 
-- Send Control Message (send_ctl_msg)
CREATE FUNCTION send_ctl_msg() RETURNS trigger AS $$
  import os
  import os.path
 
  pipe_loc = TD["args"][0]
 
  old = TD["old"]
  new = TD["new"]
 
  rv = plpy.execute("SELECT * from ucfg.SysConfig",1)
  ens_cmd = rv[0]["cfgCmd"]
  plpy.log(cmd)
 
  if os.path.exists(pipe_loc):
    pipeout = open(pipe_loc,"w")
    print >>pipeout,ens_cmd
  else:
    plpy.error("Build System cmd FIFO not found. Make sure VMD is running")
$$ LANGUAGE plpythonu;
 
Here is the table it's trying to access:
 
CREATE TABLE ucfg.SysConfig (
  -- System map selection and running
  startupSysMapName VARCHAR(64) REFERENCES ucfg.SysMaps(sysMapName),
    -- System map to load and run at system boot.
  activeSysMapName  VARCHAR(64) REFERENCES ucfg.SysMaps(sysMapName),
    -- System map that is currently loaded.
  checkSysMapName   VARCHAR(64) REFERENCES ucfg.SysMaps(sysMapName),
    -- System map to be checked to see if it builds properly
  cfgCmd            VARCHAR(16),  -- ENS configuration control command
    -- "NONE", "CHECK", "LOAD", "RUN", "STOP"
);
Here is the trigger function:
CREATE TRIGGER tr_exec
  AFTER UPDATE ON ucfg.SysConfig for EACH ROW
  EXECUTE PROCEDURE public.send_ctl_msg("/var/ens/cmdfifo");

В списке pgsql-general по дате отправления:

Предыдущее
От: Scott Marlowe
Дата:
Сообщение: Re: A question about Vacuum analyze
Следующее
От: Teodor Sigaev
Дата:
Сообщение: Re: TSearch2 / German compound words / UTF-8