From 046cdae1a14a686238ab91b1f883335b2de5a78c Mon Sep 17 00:00:00 2001
From: Dan Goodliffe <dan@randomdan.homeip.net>
Date: Tue, 1 Jun 2021 00:17:38 +0100
Subject: Generate DbStmt templates from .sql files

m4 generator and related code. Reshuffles some CTF stuff to avoid
pulling in all of CTF and iostream for its fixed_string. Moves CTF out
of AdHoc namespace.
Add some initial SQL statements.
---
 lib/output/pq/sql/selectColumns.sql | 6 ++++++
 1 file changed, 6 insertions(+)
 create mode 100644 lib/output/pq/sql/selectColumns.sql

(limited to 'lib/output/pq/sql/selectColumns.sql')

diff --git a/lib/output/pq/sql/selectColumns.sql b/lib/output/pq/sql/selectColumns.sql
new file mode 100644
index 0000000..e9cd107
--- /dev/null
+++ b/lib/output/pq/sql/selectColumns.sql
@@ -0,0 +1,6 @@
+SELECT t.table_name, STRING_AGG(c.column_name, '|' ORDER BY c.ordinal_position)
+FROM mygrate.source s
+	JOIN information_schema.tables t USING(table_schema)
+	LEFT OUTER JOIN information_schema.columns c USING(table_schema, table_name)
+WHERE s.id = $1
+GROUP BY t.table_name
-- 
cgit v1.2.3

