Project

General

Profile

« Previous | Next » 

Revision 2251

sql.py: put_table(): Changed temp_suffix to temp_prefix so all temp tables for a given out_table would have the same prefix. (Existing name collisions due to truncated names are not a problem because version prefixes are automatically added.)

View differences:

sql.py
778 778
    @return (table, col) Where the pkeys (from INSERT RETURNING) are made
779 779
        available
780 780
    '''
781
    temp_suffix = clean_name(out_table)
782
        # suffix, not prefix, so main name won't be removed if name is truncated
783
    pkeys_ref = ['pkeys_'+temp_suffix]
781
    temp_prefix = clean_name(out_table)
782
    pkeys_ref = [temp_prefix+'_pkeys']
784 783
    
785 784
    # Join together input tables
786 785
    in_tables = in_tables[:] # don't modify input!
......
814 813
        db.log_debug('Ignoring rows with '+in_col+' = '+value)
815 814
    
816 815
    # Do inserts and selects
817
    out_pkeys_ref = ['out_pkeys_'+temp_suffix]
816
    out_pkeys_ref = [temp_prefix+'_out_pkeys']
818 817
    while True:
819 818
        try:
820 819
            cur = insert_select(db, out_table, mapping.keys(),
......
825 824
                add_row_num(db, out_pkeys_ref[0]) # for joining with input pkeys
826 825
            
827 826
            # Get input pkeys corresponding to rows in insert
828
            in_pkeys_ref = ['in_pkeys_'+temp_suffix]
827
            in_pkeys_ref = [temp_prefix+'_in_pkeys']
829 828
            run_query_into(db, *mk_main_select([in_pkey]),
830 829
                into_ref=in_pkeys_ref)
831 830
            add_row_num(db, in_pkeys_ref[0]) # for joining with output pkeys
......
845 844
                order_by=None, start=0, table_is_esc=table_is_esc))
846 845
            
847 846
            # Save existing pkeys in temp table for joining on
848
            existing_pkeys_ref = ['existing_pkeys_'+temp_suffix]
847
            existing_pkeys_ref = [temp_prefix+'_existing_pkeys']
849 848
            run_query_into(db, *mk_select(db, pkeys_ref[0], [in_pkey],
850 849
                order_by=None, start=0, table_is_esc=True),
851 850
                into_ref=existing_pkeys_ref)

Also available in: Unified diff