Revision 2698
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
615 | 615 |
return_type = 'SETOF '+returning.to_str(db)+'%TYPE' |
616 | 616 |
while True: |
617 | 617 |
try: |
618 |
func_schema = None |
|
619 |
if not db.autocommit: func_schema = 'pg_temp' |
|
620 |
function = sql_gen.Table(function_name, func_schema).to_str(db) |
|
618 |
function = sql_gen.TempFunction(function_name, db.autocommit) |
|
621 | 619 |
|
622 | 620 |
function_query = '''\ |
623 |
CREATE FUNCTION '''+function+'''() |
|
621 |
CREATE FUNCTION '''+function.to_str(db)+'''()
|
|
624 | 622 |
RETURNS '''+return_type+''' |
625 | 623 |
LANGUAGE sql |
626 | 624 |
AS $$ |
... | ... | |
635 | 633 |
# try again with next version of name |
636 | 634 |
|
637 | 635 |
# Return query that uses function |
638 |
func_table = sql_gen.NamedTable('f', sql_gen.CustomCode(function+'()'),
|
|
636 |
func_table = sql_gen.NamedTable('f', sql_gen.FunctionCall(function),
|
|
639 | 637 |
[returning_name]) # AS clause requires function alias |
640 | 638 |
return mk_select(db, func_table, start=0, order_by=None) |
641 | 639 |
|
Also available in: Unified diff
sql.py: mk_insert_select(): embeddable: Use sql_gen.TempFunction and sql_gen.FunctionCall