[GENERAL] building extension with large string inserts

Поиск
Список
Период
Сортировка
От Tom van Tilburg
Тема [GENERAL] building extension with large string inserts
Дата
Msg-id CAP3PPDhTNJ59p16zwsMA=s-SeCQmi1eLAYPQ+_So34EP0bRkrg@mail.gmail.com
обсуждение исходный текст
Ответы Re: [GENERAL] building extension with large string inserts
Список pgsql-general
I am trying to build an extension where there is the need to insert large strings consisting of javascript code. The easiest way to get these string currently into a table is by using

\set varname `cat mycode.js`
INSERT INTO mytable VALUES (:'varname');

and run this from the psql client.
psql will escape the string nicely and stuff it into a text field.

This does not work with extensions since I cannot use \set anywhere else than the psql client.

What would be a proper way to get this code into a table via an extension? I've been working on generating INSERT statements for the extension's sql file but it seems a tedious job to escape the code myself. 

Best,
 Tom

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

Предыдущее
От: Albe Laurenz
Дата:
Сообщение: Re: [GENERAL] Feature proposal, DBURL: psqlpgsql://joe:p4zzw0rd@example.org:2345/dbname
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: [GENERAL] Feature proposal, DBURL: psqlpgsql://joe:p4zzw0rd@example.org:2345/dbname