Revision 2420
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
868 | 868 |
pkeys_cols = [in_pkey_col, out_pkey_col] |
869 | 869 |
|
870 | 870 |
pkeys_table_exists_ref = [False] |
871 |
def run_query_into_pkeys(query, params): |
|
871 |
def insert_into_pkeys(joins, cols): |
|
872 |
query, params = mk_select(db, joins, cols, order_by=None, start=0) |
|
872 | 873 |
if pkeys_table_exists_ref[0]: |
873 | 874 |
insert_select(db, pkeys, pkeys_names, query, params) |
874 | 875 |
else: |
... | ... | |
951 | 952 |
if has_joins: |
952 | 953 |
select_joins = input_joins+[sql_gen.Join(out_table, join_cols)] |
953 | 954 |
db.log_debug('Getting output pkeys of existing/inserted rows') |
954 |
run_query_into_pkeys(*mk_select(db, select_joins, pkeys_cols, |
|
955 |
order_by=None, start=0)) |
|
955 |
insert_into_pkeys(select_joins, pkeys_cols) |
|
956 | 956 |
else: |
957 | 957 |
add_row_num(db, insert_out_pkeys) # for joining with input pkeys |
958 | 958 |
|
... | ... | |
964 | 964 |
db.log_debug('Joining together output and input pkeys') |
965 | 965 |
pkey_joins = [insert_in_pkeys, sql_gen.Join(insert_out_pkeys, |
966 | 966 |
{row_num_col: sql_gen.join_same_not_null})] |
967 |
run_query_into_pkeys(*mk_select(db, pkey_joins, pkeys_names, |
|
968 |
order_by=None, start=0)) |
|
967 |
insert_into_pkeys(pkey_joins, pkeys_names) |
|
969 | 968 |
|
970 | 969 |
db.log_debug('Adding pkey on returned pkeys table to enable fast joins') |
971 | 970 |
index_pkey(db, pkeys) |
... | ... | |
974 | 973 |
missing_rows_joins = input_joins+[sql_gen.Join(pkeys, |
975 | 974 |
{in_pkey: sql_gen.join_same_not_null}, sql_gen.filter_out)] |
976 | 975 |
# must use join_same_not_null or query will take forever |
977 |
run_query_into_pkeys(*mk_select(db, missing_rows_joins, |
|
978 |
[in_pkey_col, sql_gen.NamedCol(out_pkey, None)], order_by=None, |
|
979 |
start=0)) |
|
976 |
insert_into_pkeys(missing_rows_joins, |
|
977 |
[in_pkey_col, sql_gen.NamedCol(out_pkey, None)]) |
|
980 | 978 |
|
981 | 979 |
return sql_gen.Col(out_pkey, pkeys) |
982 | 980 |
|
Also available in: Unified diff
sql.py: put_table(): Factored out mk_select() calls in calls to run_query_into_pkeys() into new helper function insert_into_pkeys()