Remove unused payload column frosub-select that fails in postgres. Use boolean true/false for 'used' column so that queries run in postres

This commit is contained in:
Ray Sayre 2013-12-18 13:01:36 -08:00
parent ad9ce4d8cf
commit c969b37bac
2 changed files with 7 additions and 7 deletions

View File

@ -207,7 +207,7 @@ public class DatabaseRuleManager
String.format(
"SELECT r.dataSource, r.payload "
+ "FROM %1$s r "
+ "INNER JOIN(SELECT dataSource, max(version) as version, payload FROM %1$s GROUP BY dataSource) ds "
+ "INNER JOIN(SELECT dataSource, max(version) as version FROM %1$s GROUP BY dataSource) ds "
+ "ON r.datasource = ds.datasource and r.version = ds.version",
getRulesTable()
)

View File

@ -213,7 +213,7 @@ public class DatabaseSegmentManager
for (DataSegment segment : segments) {
batch.add(
String.format(
"UPDATE %s SET used=1 WHERE id = '%s'",
"UPDATE %s SET used=true WHERE id = '%s'",
getSegmentsTable(),
segment.getIdentifier()
)
@ -244,7 +244,7 @@ public class DatabaseSegmentManager
public Void withHandle(Handle handle) throws Exception
{
handle.createStatement(
String.format("UPDATE %s SET used=1 WHERE id = :id", getSegmentsTable())
String.format("UPDATE %s SET used=true WHERE id = :id", getSegmentsTable())
)
.bind("id", segmentId)
.execute();
@ -278,7 +278,7 @@ public class DatabaseSegmentManager
public Void withHandle(Handle handle) throws Exception
{
handle.createStatement(
String.format("UPDATE %s SET used=0 WHERE dataSource = :dataSource", getSegmentsTable())
String.format("UPDATE %s SET used=false WHERE dataSource = :dataSource", getSegmentsTable())
)
.bind("dataSource", ds)
.execute();
@ -308,7 +308,7 @@ public class DatabaseSegmentManager
public Void withHandle(Handle handle) throws Exception
{
handle.createStatement(
String.format("UPDATE %s SET used=0 WHERE id = :segmentID", getSegmentsTable())
String.format("UPDATE %s SET used=false WHERE id = :segmentID", getSegmentsTable())
).bind("segmentID", segmentID)
.execute();
@ -408,7 +408,7 @@ public class DatabaseSegmentManager
public List<Map<String, Object>> withHandle(Handle handle) throws Exception
{
return handle.createQuery(
String.format("SELECT payload FROM %s WHERE used=1", getSegmentsTable())
String.format("SELECT payload FROM %s WHERE used=true", getSegmentsTable())
).list();
}
}
@ -465,4 +465,4 @@ public class DatabaseSegmentManager
private String getSegmentsTable() {
return dbTables.get().getSegmentsTable();
}
}
}