Skip to content

Commit

Permalink
Add support for printing CreatePLangStmt tags
Browse files Browse the repository at this point in the history
  • Loading branch information
bennieswart committed Jan 13, 2020
1 parent 1f8f706 commit a6e3196
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
24 changes: 24 additions & 0 deletions pglast/printers/ddl.py
Original file line number Diff line number Diff line change
Expand Up @@ -871,6 +871,30 @@ def create_function_option(node, output):
output.print_symbol(node.arg)


@node_printer('CreatePLangStmt')
def create_plang_stmt(node, output):
output.write('CREATE ')
if node.replace:
output.write('OR REPLACE ')
if node.pltrusted:
output.write('TRUSTED ')
output.write('PROCEDURAL LANGUAGE ')
output.print_name(node.plname)
if node.plhandler:
output.newline()
with output.push_indent(2):
output.write('HANDLER ')
output.print_name(node.plhandler)
if node.plinline:
output.newline()
output.write('INLINE ')
output.print_name(node.plinline)
if node.plvalidator:
output.newline()
output.write('VALIDATOR ')
output.print_name(node.plvalidator)


@node_printer('CreatePolicyStmt')
@node_printer('AlterPolicyStmt')
def create_policy_stmt(node, output):
Expand Down
10 changes: 10 additions & 0 deletions tests/test_printers_prettification/ddl/create_language.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
CREATE OR REPLACE LANGUAGE lang
=
CREATE OR REPLACE PROCEDURAL LANGUAGE lang

CREATE OR REPLACE TRUSTED LANGUAGE trustlang HANDLER s1.fhandler INLINE s1.finline VALIDATOR fvalidator
=
CREATE OR REPLACE TRUSTED PROCEDURAL LANGUAGE trustlang
HANDLER s1.fhandler
INLINE s1.finline
VALIDATOR fvalidator

0 comments on commit a6e3196

Please sign in to comment.