File tree 1 file changed +11
-1
lines changed
1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,17 @@ chmod 777 ~ hits.tsv
10
10
11
11
sudo -u postgres psql -t -c ' CREATE DATABASE test'
12
12
sudo -u postgres psql test -t < create.sql
13
- sudo -u postgres psql test -t -c ' \timing' -c " \\ copy hits FROM 'hits.tsv' with freeze"
13
+
14
+ # Load data: wrap TRUNCATE and \copy FREEZE in a single transaction
15
+ # If we dont' do this, Postgres will throw an error:
16
+ # "ERROR: cannot perform COPY FREEZE because the table was not created or truncated in the current subtransaction"
17
+ # (i.e. Postgres requires that the table be either created or truncated in the current subtransaction)
18
+ sudo -u postgres psql test << 'EOF '
19
+ BEGIN;
20
+ TRUNCATE TABLE hits;
21
+ \copy hits FROM 'hits.tsv' with freeze;
22
+ COMMIT;
23
+ EOF
14
24
15
25
sudo -u postgres psql test -t -c ' VACUUM ANALYZE hits'
16
26
You can’t perform that action at this time.
0 commit comments