Revision 3525
Added by Aaron Marcuse-Kubitza over 12 years ago
sql_io.py | ||
---|---|---|
441 | 441 |
insert_into_pkeys(input_joins, [in_pkey_col, func_call], |
442 | 442 |
limit=0, recover=True) |
443 | 443 |
|
444 |
# Create error handling wrapper function |
|
444 |
## Create error handling wrapper function |
|
445 |
|
|
446 |
wrapper = db.TempFunction(sql_gen.concat(into.name, '_wrap')) |
|
447 |
|
|
445 | 448 |
select_cols = [in_pkey_col]+args.values() |
446 |
args = dict(((k, sql_gen.with_table(v, sql_gen.Table('row'))) |
|
449 |
row_var = sql_gen.Table('row') |
|
450 |
in_pkey_var = sql_gen.Col(in_pkey, 'row') |
|
451 |
|
|
452 |
args = dict(((k, sql_gen.with_table(v, row_var)) |
|
447 | 453 |
for k, v in args.iteritems())) |
448 | 454 |
func_call = sql_gen.FunctionCall(out_table, **args) |
449 |
wrapper = db.TempFunction(sql_gen.concat(into.name, '_wrap')) |
|
455 |
|
|
456 |
def mk_return(result): |
|
457 |
return sql_gen.ReturnQuery(sql.mk_select(db, |
|
458 |
fields=[in_pkey_var, result], explain=False)) |
|
459 |
exc_handler = func_wrapper_exception_handler(mk_return(None), |
|
460 |
args.values(), errors_table_) |
|
461 |
|
|
450 | 462 |
sql.define_func(db, sql_gen.FunctionDef(wrapper, |
451 | 463 |
sql_gen.SetOf(into), |
452 | 464 |
sql_gen.RowExcIgnore(sql_gen.RowType(in_table), |
453 | 465 |
sql.mk_select(db, input_joins, order_by=None), |
454 |
sql_gen.ReturnQuery(sql.mk_select(db, |
|
455 |
fields=[sql_gen.Col(in_pkey, 'row'), func_call], |
|
456 |
explain=False)), |
|
457 |
exc_handler=sql_gen.plpythonu_error_handler) |
|
466 |
mk_return(func_call), exc_handler=exc_handler) |
|
458 | 467 |
)) |
459 | 468 |
wrapper_table = sql_gen.FunctionCall(wrapper) |
460 | 469 |
else: |
Also available in: Unified diff
sql_io.py: put_table(): is_function: Creating error handling wrapper function: Handle errors using new func_wrapper_exception_handler(), which saves any data_exceptions in the errors table in addition to handling PL/Python errors