public static boolean setTimestampVariableForUnspecifiedColumn(
      SchemaContext sc, DMLStatement dmls, PEColumn column) {
    boolean ret = false;

    // only set the timestamp variable if this is a timestamp column
    if (column.getType().getBaseType().getDataType() != Types.TIMESTAMP) {
      return ret;
    }

    // for an update statement if the on update is set and
    // the column is not specified then set the timestamp variable
    if ((dmls instanceof UpdateStatement) && column.isOnUpdated()) {
      ret = true;
      return ret;
    }

    boolean isNullable = column.isNullable();
    ExpressionNode defaultValue = column.getDefaultValue();
    if (defaultValue == null) {
      // no default value column modifier specified
      // now we need to know if the on update has also been set or not
      if (!column.isOnUpdated() && !isNullable) {
        // on update is not specified so default value becomes current timestamp
        ret = true;
      }
      //			else {
      //				With an ON UPDATE CURRENT_TIMESTAMP clause but no DEFAULT clause,
      //				the column is automatically updated to the current timestamp.
      //				The default is 0 unless the column is defined with the NULL attribute,
      //				in which case the default is NULL.
      //			}
    } else {
      if (dmls instanceof UpdateStatement) {
        if (column.isOnUpdated()) {
          ret = true;
        }
      } else {
        if (column.getDefaultValue() == null) {
          // null default value
          // do not set timestamp variable
        } else {
          Object o = column.getDefaultValue();
          if (o instanceof IdentifierLiteralExpression) {
            if (StringUtils.equals(
                ((IdentifierLiteralExpression) o).asString(sc.getValues()), "0")) {
              // do nothing
            } else {
              // for a timestamp column only other choice is current_timestamp
              ret = true;
            }
          } else if (o instanceof LiteralExpression) {
            // for literal default value (ie. 0 or 'yyyy-mm-dd hh:mm:ss')
            // do not set timestamp variable
          }
        }
      }
    }

    return ret;
  }
 @Override
 public String getSQL(SchemaContext sc, Emitter emitter, EmitOptions opts, boolean unused) {
   if (likeClause != null) {
     StringBuilder buf = new StringBuilder();
     buf.append("SHOW TABLE STATUS LIKE ");
     Singletons.require(DBNative.class)
         .getEmitter()
         .emitExpression(sc, sc.getValues(), likeClause, buf, -1);
     return buf.toString();
   } else return "show table status ...";
 }
 private static SchemaCacheKey<PEContainerTenant> convert(
     SchemaContext sc, Map<PEColumn, ConstantExpression> unorderedValues) {
   PETable ofTab = unorderedValues.keySet().iterator().next().getTable().asTable();
   ContainerDistributionVector cdv = (ContainerDistributionVector) ofTab.getDistributionVector(sc);
   PEContainer cont = cdv.getContainer(sc);
   List<PEColumn> discColOrder = cont.getDiscriminantColumns(sc);
   List<Pair<PEColumn, LiteralExpression>> ordered =
       new ArrayList<Pair<PEColumn, LiteralExpression>>();
   for (PEColumn pec : discColOrder) {
     ConstantExpression ce = unorderedValues.get(pec);
     if (ce == null) throw new SchemaException(Pass.PLANNER, "Malformed discriminant key");
     ordered.add(new Pair<PEColumn, LiteralExpression>(pec, (LiteralExpression) ce));
   }
   String discValue = PEContainerTenant.buildDiscriminantValue(sc, sc.getValues(), ordered);
   return PEContainerTenant.getContainerTenantKey(cont, discValue);
 }