Re: Including SQL files - Mailing list pgsql-general

From Pavel Stehule
Subject Re: Including SQL files
Date
Msg-id CAFj8pRDzcHXpaTLB5jeO4cPfhzzFCQr4yY49JzT73bXqZhX_yw@mail.gmail.com
Whole thread Raw
In response to Including SQL files  (Alexander Farber <alexander.farber@gmail.com>)
List pgsql-general
Hi

2016-03-21 15:42 GMT+01:00 Alexander Farber <alexander.farber@gmail.com>:
Hello fellow pgsql users,

I am programming a word game backend in PL/pgSQL and have already reached a point, where (too) many stored functions are declared in a single file words.sql:

# SELECT proname || '(' || oidvectortypes(proargtypes) || ')'
        FROM pg_proc INNER JOIN pg_namespace ns ON (pg_proc.pronamespace = ns.oid)
        WHERE ns.nspname = 'public' ORDER BY proname;
                            ?column?
-----------------------------------------------------------------
 test1(integer)
 words_hash(character varying)
 words_join_new_game(integer, integer)
 words_merge_users(jsonb, inet)
 words_paying_user(integer)
 words_play(integer, integer, jsonb)
 words_shuffle(character varying[])
 words_skip_game(integer, integer)
 words_surrender_game(integer, integer)
 words_swap_game(integer, integer, character varying)
 words_trigger()
 words_valid_user(integer, character varying, character varying)
(12 rows)

I would prefer to have every stored function in a separate file (which would make reading git history easier too) and include them from words.sql.

Is there such a thing for PostgreSQL 9.5.1 available please and if not - could you share your approaches here?

why you need it?

I developed large plpgsql application, and I used more than thirty files fit plpgsql functions. For deployment  I had prepared Makefile. One file holds one schema usually.

Regards

Pavel
 

The "EXEC SQL INCLUDE" described at http://www.postgresql.org/docs/9.5/static/ecpg-preproc.html seems to be something different?

Regards
Alex


pgsql-general by date:

Previous
From: Alexander Farber
Date:
Subject: Including SQL files
Next
From: Victor Yegorov
Date:
Subject: Re: Including SQL files