-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump_module.c
More file actions
49 lines (34 loc) · 1.05 KB
/
dump_module.c
File metadata and controls
49 lines (34 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include <postgres.h>
#include <fmgr.h>
#include <utils/builtins.h>
#include <plpgsql.h>
#include "string_helper.h"
#include "dump_plpgsql_function.h"
#include "dump_sql_parse_tree.h"
PG_MODULE_MAGIC;
PG_FUNCTION_INFO_V1(dump_sql_parse_tree);
Datum dump_sql_parse_tree( PG_FUNCTION_ARGS )
{
char * query = text_to_cstring( PG_GETARG_TEXT_P( 0 ) );
DumpContext * context = new_dump_context();
// debug_query_string = query;
xml_pi( context, "xml", "version", "%.1f", 1.0, NULL );
dump_sql_parse_tree_internal( context, query );
if ( *context->output )
PG_RETURN_TEXT_P( cstring_to_text( *context->output ) );
else
PG_RETURN_NULL();
}
PG_FUNCTION_INFO_V1(dump_plpgsql_function);
Datum dump_plpgsql_function( PG_FUNCTION_ARGS )
{
DumpContext * context = new_dump_context();
xml_pi( context, "xml", "version", "%.1f", 1.0, NULL );
const char * result = dump_plpgsql_function_internal( context, PG_GETARG_OID( 0 ) );
PG_RETURN_TEXT_P( cstring_to_text( result ) );
}
void _PG_init()
{
string_helper_init();
plpgsql_HashTableInit();
}