Revision 3141
Added by Aaron Marcuse-Kubitza almost 12 years ago
lib/sql.py | ||
---|---|---|
776 | 776 |
@param into sql_gen.Table with suggested name of temp table to put RETURNING |
777 | 777 |
values in |
778 | 778 |
''' |
779 |
returning = kw_args.get('returning', None) |
|
780 |
ignore = kw_args.get('ignore', False) |
|
781 |
|
|
779 | 782 |
into = kw_args.pop('into', None) |
780 | 783 |
if into != None: kw_args['embeddable'] = True |
781 | 784 |
recover = kw_args.pop('recover', None) |
782 |
if kw_args.get('ignore', False): recover = True
|
|
785 |
if ignore: recover = True
|
|
783 | 786 |
cacheable = kw_args.pop('cacheable', True) |
784 | 787 |
log_level = kw_args.pop('log_level', 2) |
785 | 788 |
|
789 |
rowcount_only = ignore and returning == None # keep NULL rows on server |
|
790 |
if rowcount_only: into = sql_gen.Table('rowcount') |
|
791 |
|
|
786 | 792 |
cur = run_query_into(db, mk_insert_select(db, table, *args, **kw_args), |
787 | 793 |
into, recover=recover, cacheable=cacheable, log_level=log_level) |
794 |
if rowcount_only: empty_temp(db, into) |
|
788 | 795 |
autoanalyze(db, table) |
789 | 796 |
return cur |
790 | 797 |
|
Also available in: Unified diff
sql.py: insert_select(): If caller is only interested in the rowcount (if returning == None), keep the NULL rows for each insert on the server using CREATE TABLE AS. (CREATE TABLE AS sets rowcount to # rows in query, so rowcount will still be set correctly.)