[GENERAL] building extension with large string inserts - Mailing list pgsql-general

From Tom van Tilburg
Subject [GENERAL] building extension with large string inserts
Date
Msg-id CAP3PPDhTNJ59p16zwsMA=s-SeCQmi1eLAYPQ+_So34EP0bRkrg@mail.gmail.com
Whole thread Raw
Responses Re: [GENERAL] building extension with large string inserts  (Tom Lane <tgl@sss.pgh.pa.us>)
List 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 by date:

Previous
From: Albe Laurenz
Date:
Subject: Re: [GENERAL] Feature proposal, DBURL: psqlpgsql://joe:p4zzw0rd@example.org:2345/dbname
Next
From: Adrian Klaver
Date:
Subject: Re: [GENERAL] Feature proposal, DBURL: psqlpgsql://joe:p4zzw0rd@example.org:2345/dbname