Escaping text / hstore

From: pinker <pinker(at)onet(dot)eu>
To: pgsql-general(at)postgresql(dot)org
Subject: Escaping text / hstore
Date: 2015-10-20 14:00:04
Message-ID: 1445349604011-5870728.post@n5.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Maybe somebody have an idea how to escape text string for use in hstore
column? I have tried $$ and quote_literal in audit trigger function, but
still db won't let me pass values with // or ' to the hstore...INSERT FROM
trigger function:
EXECUTE 'INSERT INTO history.' || TG_TABLE_SCHEMA || '_' ||
TG_TABLE_NAME || l_table_suffix || '(operation, event_time,
executed_by, new_value) VALUES(''' || TG_OP || ''', ''' ||
CURRENT_TIMESTAMP || ''', ''' || SESSION_USER || ''', $$''' ||
hstore(NEW) || '''$$)';
During insert occurs error:
INSERT INTO my_table ("some_id", "someother_id","description") VALUES (1751,
10907,'gdfddfg''gdfg');
The same occurs with backslash:
INSERT INTO my_table ("some_id", "someother_id","description") VALUES (1751,
10907,'gdfddfg//gdfg');
ERROR: Syntax error near ''' at position 73LINE 2: ..., '2015-10-20
15:41:08.534645+02', 'my_user', $$'"some...
^QUERY: INSERT INTO history.public_my_table_2015_10(operation, event_time,
executed_by, new_value) VALUES('INSERT', '2015-10-20
15:41:08.534645+02', 'my_user', $$'"some_id"=>"1751",
"someother_id"=>"10907", "description"=>"gdfddfg'gdfg"'$$)CONTEXT: PL/pgSQL
function insert() line 6 at EXECUTE statement

--
View this message in context: http://postgresql.nabble.com/Escaping-text-hstore-tp5870728.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message hubert depesz lubaczewski 2015-10-20 14:07:18 Re: Escaping text / hstore
Previous Message Kevin Grittner 2015-10-20 13:45:22 Re: Multiple word synonyms (maybe?)