PREPARE in bash scripts

Поиск
Список
Период
Сортировка
От A.j. Langereis
Тема PREPARE in bash scripts
Дата
Msg-id 001201c5f011$9a4cc580$3e01a8c0@aarjan2
обсуждение исходный текст
Ответ на Logging prepared statements in 8.1?  (Bjørn T Johansen <btj@havleik.no>)
Ответы Re: PREPARE in bash scripts  (Martijn van Oosterhout <kleptog@svana.org>)
Список pgsql-general
Dear all,

I've written a bash script that looks like the one below:

#!/bin/bash

DBuser='root'
DBname='test'

psql -q --username=$DBuser --dbname=$DBname -c "prepare test_statement
(integer) as insert into tbl_test (col_test) values (\\$1)";

tail -f /root/testfile | while read a;
    do
        psql -q --username=$DBuser --dbname=$DBname -c "execute
test_statement ($a)";
    done;

psql -q --username=$DBuser --dbname=$DBname -c "deallocate test_statement";

Note that this is very stripped version of the real script, but it gives the
same errors:

ERROR:  prepared statement "test_statement" does not exist

I persume that this is caused because of the individual statements, each
using their own session. But is there a way to avoid this?
In reality the statement that is prepared is much more complex, and the
files that are processed are rather big. I hoped to gain more performance by
preparing the statement.

Your sincerely,

Aarjan Langereis

Ps. The bash script is ran on an Fedora Core 3 machine using PostgreSQL
8.1.0



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

Предыдущее
От: Bjørn T Johansen
Дата:
Сообщение: Logging prepared statements in 8.1?
Следующее
От: Hannes Dorbath
Дата:
Сообщение: TSearch2 / German compound words / UTF-8