private static int generateCrudPKeyWhereClause ( Column partitioncolumn , Constraint pkey , StringBuilder sb ) { // Sort the catalog index columns by index column order. ArrayList < ColumnRef > indexColumns = new ArrayList < ColumnRef > ( pkey . getIndex ( ) . getColumns ( ) . size ( ) ) ; for ( ColumnRef c : pkey . getIndex ( ) . getColumns ( ) ) { indexColumns . add ( c ) ; } Collections . sort ( indexColumns , new ColumnRefComparator ( ) ) ; boolean first = true ; int partitionOffset = - 1 ; sb . append ( " WHERE " ) ; for ( ColumnRef pkc : indexColumns ) { if ( ! first ) sb . append ( " AND " ) ; first = false ; sb . append ( "(" + pkc . getColumn ( ) . getName ( ) + " = ?" + ")" ) ; if ( pkc . getColumn ( ) == partitioncolumn ) { partitionOffset = pkc . getIndex ( ) ; } } return partitionOffset ; }
Helper to generate a WHERE pkey_col1 = ? pkey_col2 = ? ... ; clause .