Skip to content

Commit 2736f79

Browse files
committed
Merge commit 'refs/pull/14/head' of https://github.com/hackolade/PostgreSQL
2 parents 8d4c2f8 + c1b937f commit 2736f79

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

reverse_engineering/helpers/postgresHelpers/functionHelper.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const mapFunctionData = (functionData, functionArgs, additionalData) => {
6666
functionReturnsSetOf: additionalData?.returns_set,
6767
functionReturnType: functionData.return_data_type,
6868
functionLanguage: _.toLower(functionData.external_language),
69-
functionBody: functionData.routine_definition,
69+
functionBody: functionData.routine_definition ?? additionalData?.body,
7070
functionWindow: additionalData?.kind === 'w',
7171
functionVolatility: getVolatility(additionalData?.volatility),
7272
functionLeakProof: additionalData?.leak_proof,

reverse_engineering/helpers/queryConstants.js

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,25 @@ const getGET_TABLE_INDEXES = postgresVersion => {
7272
`;
7373
};
7474

75+
const getGET_FUNCTIONS_WITH_PROCEDURES_ADDITIONAL = postgresVersion => {
76+
const kindQuery =
77+
postgresVersion === 10 ? `CASE WHEN proiswindow is true THEN 'w' ELSE '' END AS kind` : 'prokind AS kind';
78+
79+
return `
80+
SELECT obj_description(oid, 'pg_proc') AS description,
81+
proname AS function_name,
82+
provolatile AS volatility,
83+
proparallel AS parallel,
84+
proisstrict AS strict,
85+
proretset AS returns_set,
86+
proleakproof AS leak_proof,
87+
procost AS estimated_cost,
88+
prorows AS estimated_rows,
89+
prosrc AS body,
90+
${kindQuery}
91+
FROM pg_catalog.pg_proc WHERE pronamespace = $1;`;
92+
};
93+
7594
const queryConstants = {
7695
PING: 'SELECT schema_name FROM information_schema.schemata LIMIT 1;',
7796
GET_VERSION: 'SELECT version()',
@@ -183,33 +202,8 @@ const queryConstants = {
183202
FROM information_schema.parameters
184203
WHERE specific_name = $1
185204
ORDER BY ordinal_position;`,
186-
GET_FUNCTIONS_WITH_PROCEDURES_ADDITIONAL: `
187-
SELECT obj_description(oid, 'pg_proc') AS description,
188-
proname AS function_name,
189-
provolatile AS volatility,
190-
proparallel AS parallel,
191-
proisstrict AS strict,
192-
proretset AS returns_set,
193-
proleakproof AS leak_proof,
194-
procost AS estimated_cost,
195-
prorows AS estimated_rows,
196-
prokind AS kind
197-
FROM pg_catalog.pg_proc WHERE pronamespace = $1;`,
198-
GET_FUNCTIONS_WITH_PROCEDURES_ADDITIONAL_V_10: `
199-
SELECT obj_description(oid, 'pg_proc') AS description,
200-
proname AS function_name,
201-
provolatile AS volatility,
202-
proparallel AS parallel,
203-
proisstrict AS strict,
204-
proretset AS returns_set,
205-
proleakproof AS leak_proof,
206-
procost AS estimated_cost,
207-
prorows AS estimated_rows,
208-
CASE
209-
WHEN proiswindow is true THEN 'w'
210-
ELSE ''
211-
END AS kind
212-
FROM pg_catalog.pg_proc WHERE pronamespace = $1;`,
205+
GET_FUNCTIONS_WITH_PROCEDURES_ADDITIONAL: getGET_FUNCTIONS_WITH_PROCEDURES_ADDITIONAL(),
206+
GET_FUNCTIONS_WITH_PROCEDURES_ADDITIONAL_V_10: getGET_FUNCTIONS_WITH_PROCEDURES_ADDITIONAL(10),
213207
GET_USER_DEFINED_TYPES: `
214208
SELECT pg_type.typrelid AS pg_class_oid,
215209
pg_type.typname AS name,

0 commit comments

Comments
 (0)