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( String.format(
"SELECT r.dataSource, r.payload " "SELECT r.dataSource, r.payload "
+ "FROM %1$s r " + "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", + "ON r.datasource = ds.datasource and r.version = ds.version",
getRulesTable() getRulesTable()
) )

View File

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