empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From franci...@apache.org
Subject svn commit: r1091793 - /incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
Date Wed, 13 Apr 2011 14:16:22 GMT
Author: francisdb
Date: Wed Apr 13 14:16:21 2011
New Revision: 1091793

URL: http://svn.apache.org/viewvc?rev=1091793&view=rev
Log:
EMPIREDB-107 Limit function for postgres sql not implemented

Modified:
    incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java

Modified: incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
URL: http://svn.apache.org/viewvc/incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java?rev=1091793&r1=1091792&r2=1091793&view=diff
==============================================================================
--- incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
(original)
+++ incubator/empire-db/trunk/empire-db/src/main/java/org/apache/empire/db/postgresql/DBDatabaseDriverPostgreSQL.java
Wed Apr 13 14:16:21 2011
@@ -83,10 +83,55 @@ public class DBDatabaseDriverPostgreSQL 
     {
         private final static long serialVersionUID = 1L;
       
+        protected int limit = -1;
+        protected int skip  = -1;
+        
         public DBCommandPostreSQL(DBDatabase db)
         {
             super(db);
         }
+        
+        @Override
+        public boolean limitRows(int numRows)
+        {
+            limit = numRows;
+            return success();
+        }
+
+        @Override
+        public boolean skipRows(int numRows)
+        {
+            skip = numRows;
+            return success();
+        }
+         
+        @Override
+        public void clearLimit()
+        {
+            limit = -1;
+            skip  = -1;
+        }
+        
+        @Override
+        public boolean getSelect(StringBuilder buf)
+        {   // call base class
+            if (super.getSelect(buf)==false)
+                return false;
+            // add limit and offset
+            if (limit>=0)
+            {   buf.append("\r\nLIMIT ");
+                buf.append(String.valueOf(limit));
+                // Offset
+                if (skip>=0) 
+                {   buf.append(" OFFSET ");
+                    buf.append(String.valueOf(skip));
+                }    
+            }
+            // done
+            return success();
+        }
+        
+        
     }
     
     private String databaseName;
@@ -270,8 +315,10 @@ public class DBDatabaseDriverPostgreSQL 
     {
         switch (type)
         {   // return support info 
-            case CREATE_SCHEMA: return true;
-            case SEQUENCES:     return true;    
+            case CREATE_SCHEMA: 	return true;
+            case SEQUENCES:     	return true;    
+            case QUERY_LIMIT_ROWS:  return true;
+            case QUERY_SKIP_ROWS:   return true;
             default:
                 // All other features are not supported by default
                 return false;



Mime
View raw message