Revision 3383
Added by Aaron Marcuse-Kubitza over 12 years ago
lib/sql.py | ||
---|---|---|
1298 | 1298 |
# temp tables permanent in debug_temp mode |
1299 | 1299 |
|
1300 | 1300 |
# Create table |
1301 |
while True:
|
|
1301 |
def create():
|
|
1302 | 1302 |
str_ = 'CREATE' |
1303 | 1303 |
if temp: str_ += ' TEMP' |
1304 | 1304 |
str_ += ' TABLE '+table.to_str(db)+' (\n' |
1305 | 1305 |
str_ += '\n, '.join(c.to_str(db) for c in cols) |
1306 | 1306 |
str_ += '\n);' |
1307 | 1307 |
|
1308 |
try: |
|
1309 |
run_query(db, str_, recover=True, cacheable=True, log_level=2, |
|
1310 |
log_ignore_excs=(DuplicateException,)) |
|
1311 |
break |
|
1312 |
except DuplicateException: |
|
1313 |
table.name = next_version(table.name) |
|
1314 |
# try again with next version of name |
|
1308 |
run_query(db, str_, recover=True, cacheable=True, log_level=2, |
|
1309 |
log_ignore_excs=(DuplicateException,)) |
|
1310 |
if table.is_temp: |
|
1311 |
while True: |
|
1312 |
try: |
|
1313 |
create() |
|
1314 |
break |
|
1315 |
except DuplicateException: |
|
1316 |
table.name = next_version(table.name) |
|
1317 |
# try again with next version of name |
|
1318 |
else: create() |
|
1315 | 1319 |
|
1316 | 1320 |
# Add indexes |
1317 | 1321 |
if has_pkey: has_pkey = already_indexed |
Also available in: Unified diff
sql.py: create_table(): Only version temp tables, so that e.g. staging tables are not created with a version # if they already exist. This will help make `make install` idempotent.