Skip to content

Commit

Permalink
updating uses of SPLIT AT
Browse files Browse the repository at this point in the history
  • Loading branch information
RaduBerinde committed Mar 21, 2017
1 parent c7d59e1 commit 4d0802d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion block_writer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func setupDatabase(dbURL string) (*sql.DB, error) {
if *splits > 0 {
r := rand.New(rand.NewSource(int64(time.Now().UnixNano())))
for i := 0; i < *splits; i++ {
if _, err := db.Exec(`ALTER TABLE blocks SPLIT AT ($1, '', 0)`, r.Int63()); err != nil {
if _, err := db.Exec(`ALTER TABLE blocks SPLIT AT VALUES ($1, '', 0)`, r.Int63()); err != nil {
return nil, err
}
}
Expand Down
6 changes: 3 additions & 3 deletions photos/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@ func runSplit(c *cobra.Command, args []string) error {
for count := 0; count < numSplits; {
// Use the userID generation logic.
userID := 1 + int(rand.ExpFloat64()/rate)
if _, err := db.Exec(`ALTER TABLE users SPLIT AT ($1)`, userID); err != nil {
if _, err := db.Exec(`ALTER TABLE users SPLIT AT VALUES ($1)`, userID); err != nil {
log.Printf("problem splitting: %v", err)
} else {
count++
}
}

splitByUUID(db, numSplits, "photos", `ALTER TABLE photos SPLIT AT ($1)`)
splitByUUID(db, numSplits, "comments", `ALTER TABLE comments SPLIT AT ($1, '2016-01-01', '')`)
splitByUUID(db, numSplits, "photos", `ALTER TABLE photos SPLIT AT VALUES ($1)`)
splitByUUID(db, numSplits, "comments", `ALTER TABLE comments SPLIT AT VALUES ($1, '2016-01-01', '')`)
return nil
}

Expand Down

0 comments on commit 4d0802d

Please sign in to comment.