]> Kevux Git Server - koopa/commitdiff
Progress: continue development on database abstraction
authorKevin Day <thekevinday@gmail.com>
Fri, 25 Jan 2019 02:18:02 +0000 (20:18 -0600)
committerKevin Day <thekevinday@gmail.com>
Fri, 25 Jan 2019 02:18:02 +0000 (20:18 -0600)
29 files changed:
common/database/classes/database_alter_foreign_table.php
common/database/classes/database_alter_foreign_table_action.php [deleted file]
common/database/classes/database_alter_table.php
common/database/classes/database_query.php
common/database/classes/database_string.php
common/database/enumerations/database_constraint.php
common/database/enumerations/database_constraint_mode.php [new file with mode: 0644]
common/database/enumerations/database_replica_identity.php [new file with mode: 0644]
common/database/enumerations/database_row_level_security.php [new file with mode: 0644]
common/database/enumerations/database_trigger.php [moved from common/database/enumerations/database_enable_trigger.php with 93% similarity]
common/database/traits/database_action_cluster_on.php [new file with mode: 0644]
common/database/traits/database_action_constraint.php [new file with mode: 0644]
common/database/traits/database_action_disable_rule.php [new file with mode: 0644]
common/database/traits/database_action_disable_trigger.php [new file with mode: 0644]
common/database/traits/database_action_enable_rule.php [new file with mode: 0644]
common/database/traits/database_action_enable_trigger.php [new file with mode: 0644]
common/database/traits/database_action_not_of.php [new file with mode: 0644]
common/database/traits/database_action_of.php [new file with mode: 0644]
common/database/traits/database_action_replica_identity.php [new file with mode: 0644]
common/database/traits/database_action_row_level_security.php [new file with mode: 0644]
common/database/traits/database_action_set_logged.php [new file with mode: 0644]
common/database/traits/database_action_set_tablespace.php [new file with mode: 0644]
common/database/traits/database_action_without_cluster.php [new file with mode: 0644]
common/database/traits/database_column_set_storage.php
common/database/traits/database_disable_trigger.php [new file with mode: 0644]
common/database/traits/database_enable_trigger.php
common/database/traits/database_no_wait.php
common/database/traits/database_rename_to.php
common/database/traits/database_set_tablespace.php

index 29dd114abe29ebce9de852494a3248f18ff24514..838757687a2afcaefdee6254558ce1bed4fd84b8 100644 (file)
@@ -11,20 +11,18 @@ require_once('common/base/classes/base_return.php');
 require_once('common/database/classes/database_query.php');
 
 require_once('common/database/traits/database_action_add_column.php');
-require_once('common/database/traits/database_action_add_constraint.php');
 require_once('common/database/traits/database_action_alter_column.php');
 require_once('common/database/traits/database_action_alter_column_options.php');
 require_once('common/database/traits/database_action_alter_column_reset.php');
 require_once('common/database/traits/database_action_alter_column_set.php');
 require_once('common/database/traits/database_action_disable_trigger.php');
 require_once('common/database/traits/database_action_drop_columm.php');
-require_once('common/database/traits/database_action_drop_constraint.php');
+require_once('common/database/traits/database_action_constraint.php');
 require_once('common/database/traits/database_action_enable_trigger.php');
 require_once('common/database/traits/database_action_inherit.php');
 require_once('common/database/traits/database_action_options.php');
 require_once('common/database/traits/database_action_owner_to.php');
 require_once('common/database/traits/database_action_set_oids.php');
-require_once('common/database/traits/database_action_validate_constraint.php');
 require_once('common/database/traits/database_if_exists.php');
 require_once('common/database/traits/database_name.php');
 require_once('common/database/traits/database_only.php');
@@ -40,21 +38,18 @@ require_once('common/database/traits/database_wildcard.php');
  */
 class c_database_alter_foreign_table extends c_database_query {
   use t_database_action_add_column;
-  use t_database_action_add_constraint;
   use t_database_action_alter_column;
   use t_database_action_alter_column_options;
   use t_database_action_alter_column_reset;
   use t_database_action_alter_column_set;
-  use t_database_action_alter_constraint;
+  use t_database_action_constraint;
   use t_database_action_disable_trigger;
   use t_database_action_drop_columm;
-  use t_database_action_drop_constraint;
   use t_database_action_enable_trigger;
   use t_database_action_inherit;
   use t_database_action_options;
   use t_database_action_owner_to;
   use t_database_action_set_oids;
-  use t_database_action_validate_constraint;
   use t_database_if_exists;
   use t_database_name;
   use t_database_only;
@@ -73,21 +68,18 @@ class c_database_alter_foreign_table extends c_database_query {
     parent::__construct();
 
     $this->action_add_column           = NULL;
-    $this->action_add_constraint       = NULL;
     $this->action_alter_column         = NULL;
     $this->action_alter_column_options = NULL;
     $this->action_alter_column_reset   = NULL;
     $this->action_alter_column_set     = NULL;
-    $this->action_alter_constraint     = NULL;
+    $this->action_constraint           = NULL;
     $this->action_disable_trigger      = NULL;
     $this->action_drop_columm          = NULL;
-    $this->action_drop_constraint      = NULL;
     $this->action_enable_trigger       = NULL;
     $this->action_inherit              = NULL;
     $this->action_options              = NULL;
     $this->action_owner_to             = NULL;
     $this->action_set_oids             = NULL;
-    $this->action_validate_constraint  = NULL;
     $this->if_exists                   = NULL;
     $this->name                        = NULL;
     $this->only                        = NULL;
@@ -104,21 +96,18 @@ class c_database_alter_foreign_table extends c_database_query {
     parent::__destruct();
 
     unset($this->action_add_column);
-    unset($this->action_add_constraint);
     unset($this->action_alter_column);
     unset($this->action_alter_column_options);
     unset($this->action_alter_column_reset);
     unset($this->action_alter_column_set);
-    unset($this->action_alter_constraint);
+    unset($this->action_constraint);
     unset($this->action_disable_trigger);
     unset($this->action_drop_columm);
-    unset($this->action_drop_constraint);
     unset($this->action_enable_trigger);
     unset($this->action_inherit);
     unset($this->action_options);
     unset($this->action_owner_to);
     unset($this->action_set_oids);
-    unset($this->action_validate_constraint);
     unset($this->if_exists);
     unset($this->name);
     unset($this->only);
@@ -176,9 +165,6 @@ class c_database_alter_foreign_table extends c_database_query {
     if (isset($this->rename_column)) {
       $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_rename_column();
     }
-    else if (isset($this->rename_constraint)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_rename_constraint();
-    }
     else if (isset($this->rename_to)) {
       $value = $if_exists . $value . ' ' . $this->p_do_build_rename_to();
     }
@@ -188,9 +174,6 @@ class c_database_alter_foreign_table extends c_database_query {
     else if (isset($this->action_add_column)) {
       $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_add_column();
     }
-    else if (isset($this->action_add_constraint)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_add_constraint();
-    }
     else if (isset($this->action_alter_column)) {
       $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_column();
     }
@@ -203,8 +186,8 @@ class c_database_alter_foreign_table extends c_database_query {
     else if (isset($this->action_alter_column_set)) {
       $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_column_set();
     }
-    else if (isset($this->action_alter_constraint)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_constraint();
+    else if (isset($this->action_constraint)) {
+      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_constraint();
     }
     else if (isset($this->action_disable_trigger)) {
       $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_disable_trigger();
@@ -212,9 +195,6 @@ class c_database_alter_foreign_table extends c_database_query {
     else if (isset($this->action_drop_columm)) {
       $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_drop_columm();
     }
-    else if (isset($this->action_drop_constraint)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_drop_constraint();
-    }
     else if (isset($this->action_enable_trigger)) {
       $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_enable_trigger();
     }
@@ -230,9 +210,6 @@ class c_database_alter_foreign_table extends c_database_query {
     else if (isset($this->action_set_oids)) {
       $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_set_oids();
     }
-    else if (isset($this->action_validate_constraint)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_validate_constraint();
-    }
     else {
       unset($value);
       unset($if_exists);
diff --git a/common/database/classes/database_alter_foreign_table_action.php b/common/database/classes/database_alter_foreign_table_action.php
deleted file mode 100644 (file)
index e3b2d79..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-<?php
-/**
- * @file
- * Provides a class for specific Postgesql query: ALTER FOREIGN TABLE action.
- */
-namespace n_koopa;
-
-require_once('common/base/classes/base_error.php');
-require_once('common/base/classes/base_return.php');
-
-require_once('common/database/classes/database_query.php');
-
-require_once('common/database/traits/database_add_column.php');
-require_once('common/database/traits/database_alter_column.php');
-require_once('common/database/traits/database_constraint.php');
-require_once('common/database/traits/database_drop_column.php');
-require_once('common/database/traits/database_enable_trigger.php');
-require_once('common/database/traits/database_inherit.php');
-require_once('common/database/traits/database_options.php');
-require_once('common/database/traits/database_owner_to.php');
-require_once('common/database/traits/database_set_with_oids.php');
-
-/**
- * The class for building and returning a Postgresql ALTER FOREIGN TABLE action query string.
- *
- * @see: https://www.postgresql.org/docs/current/static/sql-alterforeigntable.html
- */
-class c_database_alter_foreign_table_action extends c_database_query {
-  use t_database_add_column;
-  use t_database_alter_column;
-  use t_database_constraint;
-  use t_database_drop_column;
-  use t_database_enable_trigger;
-  use t_database_inherit;
-  use t_database_options;
-  use t_database_owner_to;
-  use t_database_set_with_oids;
-
-  protected const p_QUERY_COMMAND = '';
-
-  /**
-   * Class constructor.
-   */
-  public function __construct() {
-    parent::__construct();
-
-    $this->add_column     = NULL;
-    $this->alter_column   = NULL;
-    $this->constraint     = NULL;
-    $this->drop_column    = NULL;
-    $this->enable_trigger = NULL;
-    $this->inherit        = NULL;
-    $this->options        = NULL;
-    $this->owner_to       = NULL;
-    $this->set_with_oids  = NULL;
-  }
-
-  /**
-   * Class destructor.
-   */
-  public function __destruct() {
-    parent::__destruct();
-
-    unset($this->add_column);
-    unset($this->alter_column);
-    unset($this->constaint);
-    unset($this->drop_column);
-    unset($this->enable_trigger);
-    unset($this->inherit);
-    unset($this->options);
-    unset($this->owner_to);
-    unset($this->set_with_oids);
-  }
-
-  /**
-   * @see: t_base_return_value::p_s_new()
-   */
-  public static function s_new($value) {
-    return self::p_s_new($value, __CLASS__);
-  }
-
-  /**
-   * @see: t_base_return_value::p_s_value()
-   */
-  public static function s_value($return) {
-    return self::p_s_value($return, __CLASS__);
-  }
-
-  /**
-   * @see: t_base_return_value_exact::p_s_value_exact()
-   */
-  public static function s_value_exact($return) {
-    return self::p_s_value_exact($return, __CLASS__, '');
-  }
-
-  /**
-   * Implements do_build().
-   */
-  public function do_build() {
-    $value = NULL;
-    if (is_array($this->add_column)) {
-      $value = $this->p_do_build_add_column();
-    }
-    else if (is_array($this->alter_column)) {
-      $value = $this->p_do_build_alter_column();
-    }
-    else if (is_array($this->constraint)) {
-      $value = $this->p_do_build_constraint();
-    }
-    else if (is_array($this->drop_column)) {
-      $value = $this->p_do_build_drop_column();
-    }
-    else if (is_array($this->enable_trigger)) {
-      $value = $this->p_do_build_enable_trigger();
-    }
-    else if (is_array($this->inherit)) {
-      $value = $this->p_do_build_inherit();
-    }
-    else if (is_array($this->options)) {
-      $value = '(' . $this->p_do_build_options() . ')';
-    }
-    else if (is_array($this->owner_to)) {
-      $value = $this->p_do_build_owner_to();
-    }
-    else if (is_bool($this->set_with_oids)) {
-      $value = $this->p_do_build_set_with_oids();
-    }
-    else {
-      unset($value);
-      return new c_base_return_false();
-    }
-
-    $this->value = static::p_QUERY_COMMAND;
-    $this->value .= ' ' . $value;
-    unset($value);
-
-    return new c_base_return_true();
-  }
-}
index 3a1dc784267d00d5dd96a5f6e2c2c5ae2c6890f9..9161458d613538adbc3ffa0035d0425d5425d4b0 100644 (file)
@@ -11,20 +11,26 @@ require_once('common/base/classes/base_return.php');
 require_once('common/database/classes/database_query.php');
 
 require_once('common/database/traits/database_action_add_column.php');
-require_once('common/database/traits/database_action_add_constraint.php');
 require_once('common/database/traits/database_action_alter_column.php');
 require_once('common/database/traits/database_action_alter_column_options.php');
 require_once('common/database/traits/database_action_alter_column_reset.php');
 require_once('common/database/traits/database_action_alter_column_set.php');
-require_once('common/database/traits/database_action_alter_constraint.php');
+require_once('common/database/traits/database_action_cluster_on.php');
+require_once('common/database/traits/database_action_constraint.php');
+require_once('common/database/traits/database_action_disable_rule.php');
 require_once('common/database/traits/database_action_disable_trigger.php');
 require_once('common/database/traits/database_action_drop_columm.php');
-require_once('common/database/traits/database_action_drop_constraint.php');
+require_once('common/database/traits/database_action_enable_rule.php');
 require_once('common/database/traits/database_action_enable_trigger.php');
 require_once('common/database/traits/database_action_inherit.php');
 require_once('common/database/traits/database_action_owner_to.php');
+require_once('common/database/traits/database_action_replica_identity.php');
+require_once('common/database/traits/database_action_row_level_security.php');
+require_once('common/database/traits/database_action_set_logged.php');
+require_once('common/database/traits/database_action_set_of.php');
 require_once('common/database/traits/database_action_set_oids.php');
-require_once('common/database/traits/database_action_validate_constraint.php');
+require_once('common/database/traits/database_action_set_tablespace.php');
+require_once('common/database/traits/database_action_without_cluster.php');
 require_once('common/database/traits/database_attach_partition.php');
 require_once('common/database/traits/database_detach_partition.php');
 require_once('common/database/traits/database_if_exists.php');
@@ -47,20 +53,27 @@ require_once('common/database/traits/database_wildcard.php');
  */
 class c_database_alter_table extends c_database_query {
   use t_database_action_add_column;
-  use t_database_action_add_constraint;
   use t_database_action_alter_column;
   use t_database_action_alter_column_options;
   use t_database_action_alter_column_reset;
   use t_database_action_alter_column_set;
-  use t_database_action_alter_constraint;
+  use t_database_action_cluster_on;
+  use t_database_action_constraint;
+  use t_database_action_disable_rule;
   use t_database_action_disable_trigger;
   use t_database_action_drop_columm;
-  use t_database_action_drop_constraint;
+  use t_database_action_enable_rule;
   use t_database_action_enable_trigger;
   use t_database_action_inherit;
+  use t_database_action_not_of;
+  use t_database_action_of;
   use t_database_action_owner_to;
+  use t_database_action_replica_identity;
+  use t_database_action_row_level_security;
+  use t_database_action_set_logged;
   use t_database_action_set_oids;
-  use t_database_action_validate_constraint;
+  use t_database_action_set_tablespace;
+  use t_database_action_without_cluster;
   use t_database_attach_partition;
   use t_database_detach_partition;
   use t_database_if_exists;
@@ -85,20 +98,28 @@ class c_database_alter_table extends c_database_query {
     parent::__construct();
 
     $this->action_add_column           = NULL;
-    $this->action_add_constraint       = NULL;
     $this->action_alter_column         = NULL;
     $this->action_alter_column_options = NULL;
     $this->action_alter_column_reset   = NULL;
     $this->action_alter_column_set     = NULL;
-    $this->action_alter_constraint     = NULL;
+    $this->action_cluster_on           = NULL;
+    $this->action_constraint           = NULL;
+    $this->action_disable_rule         = NULL;
     $this->action_disable_trigger      = NULL;
     $this->action_drop_columm          = NULL;
-    $this->action_drop_constraint      = NULL;
+    $this->action_enable_rule          = NULL;
     $this->action_enable_trigger       = NULL;
     $this->action_inherit              = NULL;
+    $this->action_not_of               = NULL;
     $this->action_options              = NULL;
     $this->action_owner_to             = NULL;
+    $this->action_replica_identity     = NULL;
+    $this->action_row_level_security   = NULL;
+    $this->action_set_logged           = NULL;
+    $this->action_set_of               = NULL;
     $this->action_set_oids             = NULL;
+    $this->action_set_tablespace       = NULL;
+    $this->action_without_cluster      = NULL;
     $this->attach_partition            = NULL;
     $this->detach_partition            = NULL;
     $this->if_exists                   = NULL;
@@ -119,21 +140,28 @@ class c_database_alter_table extends c_database_query {
    */
   public function __destruct() {
     unset($this->action_add_column);
-    unset($this->action_add_constraint);
     unset($this->action_alter_column);
     unset($this->action_alter_column_options);
     unset($this->action_alter_column_reset);
     unset($this->action_alter_column_set);
-    unset($this->action_alter_constraint);
+    unset($this->action_cluster_on);
+    unset($this->action_constraint);
+    unset($this->action_disable_rule);
     unset($this->action_disable_trigger);
     unset($this->action_drop_columm);
-    unset($this->action_drop_constraint);
+    unset($this->action_enable_rule);
     unset($this->action_enable_trigger);
     unset($this->action_inherit);
+    unset($this->action_not_of);
     unset($this->action_options);
     unset($this->action_owner_to);
+    unset($this->action_replica_identity);
+    unset($this->action_row_level_security);
+    unset($this->action_set_logged);
+    unset($this->action_set_of);
     unset($this->action_set_oids);
-    unset($this->action_validate_constraint);
+    unset($this->action_set_tablespace);
+    unset($this->action_without_cluster);
     unset($this->attach_partition);
     unset($this->detach_partition);
     unset($this->if_exists);
@@ -221,66 +249,90 @@ class c_database_alter_table extends c_database_query {
         $value .= ' ' . $this->p_do_build_no_wait();
       }
     }
-    else if (isset($this->attach_partition)) {
-      $value =$if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_attach_partition();
-    }
-    else if (isset($this->detach_partition)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_detach_partition();
-    }
-    else if (isset($this->action_add_column)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_add_column();
-    }
-    else if (isset($this->action_add_constraint)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_add_constraint();
-    }
-    else if (isset($this->action_alter_column)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_column();
-    }
-    else if (isset($this->action_alter_column_options)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_column_options();
-    }
-    else if (isset($this->action_alter_column_reset)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_column_reset();
-    }
-    else if (isset($this->action_alter_column_set)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_column_set();
-    }
-    else if (isset($this->action_alter_constraint)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_alter_constraint();
-    }
-    else if (isset($this->action_disable_trigger)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_disable_trigger();
-    }
-    else if (isset($this->action_drop_columm)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_drop_columm();
-    }
-    else if (isset($this->action_drop_constraint)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_drop_constraint();
-    }
-    else if (isset($this->action_enable_trigger)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_enable_trigger();
-    }
-    else if (isset($this->action_inherit)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_inherit();
-    }
-    else if (isset($this->action_options)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_options();
-    }
-    else if (isset($this->action_owner_to)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_owner_to();
-    }
-    else if (isset($this->action_set_oids)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_set_oids();
-    }
-    else if (isset($this->action_validate_constraint)) {
-      $value = $if_exists . $only . $value . ' ' . $wildcard . $this->p_do_build_action_validate_constraint();
-    }
     else {
-      unset($value);
-      unset($if_exists);
-      unset($only);
-      unset($wildcard);
-      return new c_base_return_false();
+      $value = $if_exists . $only . $value . ' ' . $wildcard;
+      if (isset($this->action_add_column)) {
+        $value .= $this->p_do_build_action_add_column();
+      }
+      else if (isset($this->action_alter_column)) {
+        $value .= $this->p_do_build_action_alter_column();
+      }
+      else if (isset($this->action_alter_column_options)) {
+        $value .= $this->p_do_build_action_alter_column_options();
+      }
+      else if (isset($this->action_alter_column_reset)) {
+        $value .= $this->p_do_build_action_alter_column_reset();
+      }
+      else if (isset($this->action_alter_column_set)) {
+        $value .= $this->p_do_build_action_alter_column_set();
+      }
+      else if (isset($this->action_cluster_on)) {
+        $value .= $this->p_do_build_action_cluster_on();
+      }
+      else if (isset($this->action_constraint)) {
+        $value .= $this->p_do_build_action_constraint();
+      }
+      else if (isset($this->action_disable_rule)) {
+        $value .= $this->p_do_build_action_disable_rule();
+      }
+      else if (isset($this->action_disable_trigger)) {
+        $value .= $this->p_do_build_action_disable_trigger();
+      }
+      else if (isset($this->action_drop_columm)) {
+        $value .= $this->p_do_build_action_drop_columm();
+      }
+      else if (isset($this->action_enable_rule)) {
+        $value .= $this->p_do_build_action_enable_rule();
+      }
+      else if (isset($this->action_enable_trigger)) {
+        $value .= $this->p_do_build_action_enable_trigger();
+      }
+      else if (isset($this->action_inherit)) {
+        $value .= $this->p_do_build_action_inherit();
+      }
+      else if (isset($this->action_not_of)) {
+        $value .= $this->p_do_build_action_not_of();
+      }
+      else if (isset($this->action_options)) {
+        $value .= $this->p_do_build_action_options();
+      }
+      else if (isset($this->action_owner_to)) {
+        $value .= $this->p_do_build_action_owner_to();
+      }
+      else if (isset($this->action_replica_identity)) {
+        $value .= $this->p_do_build_action_replica_identity();
+      }
+      else if (isset($this->action_row_level_security)) {
+        $value .= $this->p_do_build_action_row_level_security();
+      }
+      else if (isset($this->action_set_logged)) {
+        $value .= $this->p_do_build_action_set_logged();
+      }
+      else if (isset($this->action_set_of)) {
+        $value .= $this->p_do_build_action_set_of();
+      }
+      else if (isset($this->action_set_oids)) {
+        $value .= $this->p_do_build_action_set_oids();
+      }
+      else if (isset($this->action_set_tablespace)) {
+        $value .= $this->p_do_build_action_set_tablespace();
+      }
+      else if (isset($this->action_without_cluster)) {
+        $value .= $this->p_do_build_action_without_cluster();
+      }
+      else if (isset($this->attach_partition)) {
+        $value .= $this->p_do_build_attach_partition();
+      }
+      else if (isset($this->detach_partition)) {
+        $value .= $this->p_do_build_detach_partition();
+      }
+      else {
+        unset($value);
+        unset($if_exists);
+        unset($only);
+        unset($wildcard);
+        return new c_base_return_false();
+      }
     }
     unset($if_exists);
     unset($only);
index 0689f6ce7228c50f9fda018397061d3839c9342b..ddc7c964dc49c574beed4914c20012ad7856b1d1 100644 (file)
@@ -259,7 +259,7 @@ abstract class c_database_query extends c_base_return_string implements i_databa
 
       foreach ($this->placeholders as $placeholder) {
         if ($placeholder instanceof i_database_query_placeholder) {
-          $input_parameters[$placeholder->get_name()->get_value_exact()] = $placeholder->get_value_exact();
+          $input_parameters[strval($placeholder)] = $placeholder->get_value_exact();
         }
       }
 
index f0225af56b861bda231231a4ee49abfdb9157317..0cf78935792b5ec6f79a4f5320a1bc5b60fc4bba 100644 (file)
@@ -19,6 +19,7 @@ class c_database_string {
   public const ALL                                   = 'all';
   public const ALLOW_CONNECTIONS                     = 'allow_connections';
   public const ALTER                                 = 'alter';
+  public const ALTER_CONSTRAINT                      = 'alter constraint';
   public const AS                                    = 'as';
   public const ASCEND                                = 'asc';
   public const ATTACH_PARTITION                      = 'attach partition';
@@ -55,12 +56,15 @@ class c_database_string {
   public const CREATEDB                              = 'createdb';
   public const CREATEROLE                            = 'createrole';
   public const CREATE_SLOT                           = 'create_slot';
+  public const CURRENT_USER                          = 'current user';
   public const CYCLE                                 = 'cycle';
   public const DEFAULT                               = 'default';
+  public const DEFERRABLE                            = 'deferrable';
   public const DELETE                                = 'delete';
   public const DEPENDS_ON_EXTENSION                  = 'depends on extension';
   public const DESCEND                               = 'desc';
   public const DISABLE                               = 'disable';
+  public const DISABLE_RULE                          = 'disable rule';
   public const DISABLE_TRIGGER                       = 'disable trigger';
   public const DOMAIN                                = 'domain';
   public const DROP                                  = 'drop';
@@ -69,8 +73,11 @@ class c_database_string {
   public const DROP_TABLE                            = 'drop table';
   public const ENABLE                                = 'enable';
   public const ENABLED                               = 'enabled';
+  public const ENABLE_ALWAYS_RULE                    = 'enable always rule';
   public const ENABLE_ALWAYS_TRIGGER                 = 'enable always trigger';
+  public const ENABLE_REPLICA_RULE                   = 'enable replica rule';
   public const ENABLE_REPLICA_TRIGGER                = 'enable replica trigger';
+  public const ENABLE_RULE                           = 'enable rule';
   public const ENABLE_TRIGGER                        = 'enable trigger';
   public const EVENT_TRIGGER                         = 'event trigger';
   public const EXECUTE                               = 'execute';
@@ -87,6 +94,7 @@ class c_database_string {
   public const FOR_SEARCH                            = 'for search';
   public const FOR_VALUES                            = 'for values';
   public const FROM_CURRENT                          = 'from current';
+  public const FULL                                  = 'full';
   public const FUNCTION                              = 'function';
   public const GRANT                                 = 'grant';
   public const GRANT_OPTION_FOR                      = 'grant option for';
@@ -101,6 +109,8 @@ class c_database_string {
   public const INOUT                                 = 'inout';
   public const IN_SCHEMA                             = 'in schema';
   public const INHERIT                               = 'inherit';
+  public const INITIALLY_DEFERRED                    = 'initially deferred';
+  public const INITIALLY_IMMEDIATE                   = 'initially immediate';
   public const INSERT                                = 'insert';
   public const IS_TEMPLATE                           = 'is_template';
   public const LANGUAGE                              = 'language';
@@ -121,11 +131,14 @@ class c_database_string {
   public const NOLOGIN                               = 'nologin';
   public const NOREPLICATION                         = 'noreplication';
   public const NOSUPERUSER                           = 'nosuperuser';
+  public const NOTHING                               = 'nothing';
+  public const NOWAIT                               = 'nowait';
   public const NO_HANDLER                            = 'no handler';
   public const NO_INHERIT                            = 'no inherit';
   public const NO_VALIDATOR                          = 'no validator';
-  public const NO_WAIT                               = 'nowait';
+  public const NOT_DEFERRABLE                        = 'not deferrable';
   public const NOT_LEAKPROOF                         = 'not leakproof';
+  public const NOT_OF                                = 'not of';
   public const NOT_NULL                              = 'not null';
   public const NOT_VALID                             = 'not valid';
   public const ON_FUNCTIONS                          = 'on functons';
@@ -158,6 +171,7 @@ class c_database_string {
   public const RENAME_TO                             = 'rename to';
   public const RENAME_COLUMN                         = 'rename column';
   public const RENAME_CONSTRAINT                     = 'rename constraint';
+  public const REPLICA_IDENTITY                      = 'replica identity';
   public const REPLICATION                           = 'replication';
   public const RESET                                 = 'reset';
   public const RESET_ALL                             = 'reset all';
@@ -169,6 +183,7 @@ class c_database_string {
   public const REVOKE                                = 'revoke';
   public const ROLE                                  = 'role';
   public const ROWS                                  = 'rows';
+  public const ROW_LEVEL_SECURITY                    = 'row level security';
   public const SAFE                                  = 'safe';
   public const SCHEMA                                = 'schema';
   public const SECURITY_DEFINER                      = 'security definer';
@@ -176,15 +191,18 @@ class c_database_string {
   public const SELECT                                = 'select';
   public const SEQUENCE                              = 'sequence';
   public const SERVER                                = 'server';
+  public const SESSION_USER                          = 'session user';
   public const SET                                   = 'set';
   public const SET_DATA                              = 'set data';
   public const SET_DEFAULT                           = 'set default';
+  public const SET_LOGGED                            = 'set logged';
   public const SET_PUBLICATION                       = 'set publication';
   public const SET_SCHEMA                            = 'set schema';
   public const SET_STATISTICS                        = 'set statistics';
   public const SET_STORAGE                           = 'set storage';
   public const SET_TABLE                             = 'set table';
   public const SET_TABLESPACE                        = 'set tablespace';
+  public const SET_UNLOGGED                          = 'set unlogged';
   public const SET_WITH_OIDS                         = 'set with oids';
   public const SET_WITHOUT_CLUSTER                   = 'set without cluster';
   public const SET_WITHOUT_OIDS                      = 'set without oids';
@@ -214,6 +232,7 @@ class c_database_string {
   public const USER_CURRENT                          = 'current_user';
   public const USER_SESSION                          = 'session_user';
   public const USING                                 = 'using';
+  public const USING_INDEX                           = 'using index';
   public const VALIDATOR                             = 'validator';
   public const VALIDATE_CONSTRAINT                   = 'validate constraint';
   public const VALIDUNTIL                            = 'validuntil';
@@ -222,6 +241,7 @@ class c_database_string {
   public const VOLATILE                              = 'volatile';
   public const VIEW                                  = 'view';
   public const WITH                                  = 'with';
+  public const WITHOUT_CLUSTER                       = 'without cluster';
   public const WITH_CHECK                            = 'with check';
   public const WITH_GRANT_OPTION                     = 'with grant option';
 }
index 90946683598dce7e6e3e3e9bda0e73012a687413..036db68127c1a1f22946027bcabe980bf619056c 100644 (file)
@@ -10,9 +10,10 @@ namespace n_koopa;
 /**
  * Codes associated with database constaint.
  */
-class e_database_constaint {
+class e_database_constraint {
   public const NONE     = 0;
   public const ADD      = 1;
-  public const DROP     = 2;
-  public const VALIDATE = 3;
+  public const ALTER    = 2;
+  public const DROP     = 3;
+  public const VALIDATE = 4;
 }
diff --git a/common/database/enumerations/database_constraint_mode.php b/common/database/enumerations/database_constraint_mode.php
new file mode 100644 (file)
index 0000000..6193772
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+/**
+ * @file
+ * Provides enumeration classes for managing codes used for generating specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+/**
+ * Codes associated with database constaint mode.
+ */
+class e_database_constraint_mode {
+  public const NONE                = 0;
+  public const DEFERRABLE          = 1;
+  public const INITIALLY_DEFERRED  = 2;
+  public const INITIALLY_IMMEDIATE = 3;
+  public const NOT_DEFERRABLE      = 4;
+}
diff --git a/common/database/enumerations/database_replica_identity.php b/common/database/enumerations/database_replica_identity.php
new file mode 100644 (file)
index 0000000..7746b9a
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+/**
+ * @file
+ * Provides enumeration classes for managing codes used for generating specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+/**
+ * Codes associated with REPLICA IDENTITY, and related queries.
+ */
+class e_database_replica_identity {
+  public const NONE        = 0;
+  public const DEFAULT     = 1;
+  public const FULL        = 2;
+  public const NOTHING     = 3;
+  public const USING_INDEX = 4;
+}
diff --git a/common/database/enumerations/database_row_level_security.php b/common/database/enumerations/database_row_level_security.php
new file mode 100644 (file)
index 0000000..cf23f91
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+/**
+ * @file
+ * Provides enumeration classes for managing codes used for generating specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+/**
+ * Codes associated with REPLICA IDENTITY, and related queries.
+ */
+class e_database_row_level_security {
+  public const NONE     = 0;
+  public const DISABLE  = 1;
+  public const ENABLE   = 2;
+  public const FORCE    = 3;
+  public const NO_FORCE = 4;
+}
similarity index 93%
rename from common/database/enumerations/database_enable_trigger.php
rename to common/database/enumerations/database_trigger.php
index 07004c7519741869f0e7c4815002c1543142f7c9..25a32d122206e0be49d2223192454eb5ab996b99 100644 (file)
@@ -10,7 +10,7 @@ namespace n_koopa;
 /**
  * Codes associated with postgresql enable/disable trigger information.
  */
-class e_database_enable_trigger {
+class e_database_trigger {
   public const NONE    = 0;
   public const ALL     = 1;
   public const ALWAYS  = 2;
diff --git a/common/database/traits/database_action_cluster_on.php b/common/database/traits/database_action_cluster_on.php
new file mode 100644 (file)
index 0000000..3082f25
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql action CLUSTER ON functionality.
+ */
+trait t_database_action_cluster_on {
+  protected $action_cluster_on;
+
+  /**
+   * Set the action CLUSTER ON settings.
+   *
+   * @param string|null $name
+   *   The index name to use.
+   *   Set to NULL to disable.
+   *
+   * @return c_base_return_status
+   *   TRUE on success, FALSE otherwise.
+   *   FALSE with the error bit set is returned on error.
+   */
+  public function set_action_cluster_on($name) {
+    if (is_null($name)) {
+      $this->action_cluster_on = NULL;
+      return new c_base_return_true();
+    }
+
+    if (!is_string($name)) {
+      $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+      return c_base_return_error::s_false($error);
+    }
+
+    $placeholder = $this->add_placeholder($name);
+    if ($placeholder->has_error()) {
+      return c_base_return_error::s_false($placeholder->get_error());
+    }
+
+    $this->action_cluster_on = $placeholder;
+    unset($placeholder);
+
+    return new c_base_return_true();
+  }
+
+  /**
+   * Get the currently assigned name to rename to.
+   *
+   * @return i_database_query_placeholder|c_base_return_null
+   *   A name query placeholder.
+   *   NULL is returned if not set (rename to is not to be used).
+   *   NULL with the error bit set is returned on error.
+   */
+  public function get_action_cluster_on() {
+    if (is_null($this->action_cluster_on)) {
+      return new c_base_return_null();
+    }
+
+    if (isset($this->action_cluster_on)) {
+      return clone($this->action_cluster_on);
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_cluster_on', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    return c_base_return_error::s_null($error);
+  }
+
+  /**
+   * Perform the common build process for this trait.
+   *
+   * As an internal trait method, the caller is expected to perform any appropriate validation.
+   *
+   * @return string|null
+   *   A string is returned.
+   *   NULL is returned if there is nothing to process or there is an error.
+   */
+  protected function p_do_build_action_cluster_on() {
+    return c_database_string::CLUSTER_ON . ' ' . $this->action_cluster_on;
+  }
+}
diff --git a/common/database/traits/database_action_constraint.php b/common/database/traits/database_action_constraint.php
new file mode 100644 (file)
index 0000000..501181e
--- /dev/null
@@ -0,0 +1,205 @@
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+require_once('common/database/enumerations/database_cascade.php');
+require_once('common/database/enumerations/database_constraint.php');
+require_once('common/database/enumerations/database_constraint_mode.php');
+
+/**
+ * Provide the sql ADD/ALTER/VALIDATE/DROP action CONSTAINT functionality.
+ */
+trait t_database_action_constraint {
+  protected $action_constraint;
+
+  /**
+   * Set the ADD/ALTER/VALIDATE/DROP action CONSTRAINT settings.
+   *
+   * @param string|null $action_constraint_name
+   *   The name to use.
+   *   Set to NULL to disable.
+   * @param int|null $type
+   *   The type code representing the constaint operation.
+   *   This can only be NULL when $action_constraint_name is NULL.
+   * @param bool|int|null $value
+   *   When $type is ADD, then this is a boolean such that NOT VALID is added when TRUE.
+   *   When $type is ALTER, then this is an integer of e_database_constraint_mode.
+   *   When $type is DROP, then this is a boolean such that IS EXISTS is added when TRUE.
+   *   Otherwise this should be NULL.
+   * @param int|null $cascade
+   *   When $type is DROP, this must be an integer representing CASCADE or RESTRICT.
+   *   Otherwise this should be NULL.
+   *
+   * @return c_base_return_status
+   *   TRUE on success, FALSE otherwise.
+   *   FALSE with the error bit set is returned on error.
+   */
+  public function set_action_constraint($action_constraint_name, $type = NULL, $value = NULL, $cascade = NULL) {
+    if (is_null($action_constraint)) {
+      $this->action_constraint = NULL;
+      return new c_base_return_true();
+    }
+
+    if (!is_string($action_constraint_name)) {
+      $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'action_constraint', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+      return c_base_return_error::s_false($error);
+    }
+
+    $placeholder = $this->add_placeholder($name);
+    if ($placeholder->has_error()) {
+      return c_base_return_error::s_false($placeholder->get_error());
+    }
+
+    $action_constraint = [
+      'name' => $placeholder,
+      'type' => $type,
+      'value' => NULL,
+      'cascade' => NULL,
+    ];
+    unset($placeholder);
+
+    if ($type === e_database_constraint::ADD) {
+      if (!is_bool($value)) {
+        unset($action_constraint);
+        $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+        return c_base_return_error::s_false($error);
+      }
+
+      $action_constraint['value'] = $value;
+    }
+    else if ($type === e_database_constraint::ALTER) {
+      switch($value) {
+        case e_database_constraint_mode::DEFERRABLE:
+        case e_database_constraint_mode::INITIALLY_DEFERRED:
+        case e_database_constraint_mode::INITIALLY_IMMEDIATE:
+        case e_database_constraint_mode::NOT_DEFERRABLE:
+          break;
+
+        default:
+          unset($action_constraint);
+          $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+          return c_base_return_error::s_false($error);
+      }
+
+      $action_constraint['value'] = $value;
+    }
+    else if ($type === e_database_constraint::DROP) {
+      if (!is_bool($value)) {
+        unset($action_constraint);
+        $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'value', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+        return c_base_return_error::s_false($error);
+      }
+
+      $action_constraint['value'] = $value;
+    }
+    else if ($type === e_database_constraint::VALIDATE) {
+      switch ($cascade) {
+        case e_database_cascade::CASCADE:
+        case e_database_cascade::RESTRICT:
+          $action_constraint['cascade'] = $cascade;
+          break;
+        default:
+          unset($action_constraint);
+          $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'cascade', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+          return c_base_return_error::s_false($error);
+      }
+    }
+    else {
+      unset($action_constraint);
+      $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+      return c_base_return_error::s_false($error);
+    }
+
+    $this->action_constraint = $action_constraint;
+    unset($action_constraint);
+    return new c_base_return_true();
+  }
+
+  /**
+   * Get the currently assigned action_constraint settings.
+   *
+   * @return c_base_return_array|c_base_return_null
+   *   An array of action_constraint settings.
+   *   NULL is returned if not set (action_constraint is not to be used).
+   *   NULL with the error bit set is returned on error.
+   */
+  public function get_action_constraint() {
+    if (is_null($this->action_constraint)) {
+      return new c_base_return_null();
+    }
+
+    if (is_array($this->action_constraint)) {
+      return c_base_return_array::s_new($this->action_constraint);
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_constraint', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    return c_base_return_error::s_null($error);
+  }
+
+  /**
+   * Perform the common build process for this trait.
+   *
+   * As an internal trait method, the caller is expected to perform any appropriate validation.
+   *
+   * @return string|null
+   *   A string is returned.
+   *   NULL is returned if there is nothing to process or there is an error.
+   */
+  protected function p_do_build_action_constraint() {
+    $value = NULL;
+    if ($this->action_constraint['type'] === e_database_constraint::ADD) {
+      $value = c_database_string::ADD . ' ' . $this->action_constraint['name'];
+
+      if ($this->action_constraint['value']) {
+        $value .= ' ' . c_database_string::NOT_VALID;
+      }
+    }
+    else if ($this->action_constraint['type'] === e_database_constraint::ALTER) {
+      $value = c_database_string::ALTER_CONSTRAINT . ' ' . $this->action_constraint['name'];
+
+      if ($this->action_constraint['value'] === e_database_constraint_mode::DEFERRABLE) {
+        $value .= ' ' . c_database_string::DEFERRABLE;
+      }
+      else if ($this->action_constraint['value'] === e_database_constraint_mode::INITIALLY_DEFERRED) {
+        $value .= ' ' . c_database_string::INITIALLY_DEFERRED;
+      }
+      else if ($this->action_constraint['value'] === e_database_constraint_mode::INITIALLY_IMMEDIATE) {
+        $value .= ' ' . c_database_string::INITIALLY_IMMEDIATE;
+      }
+      else if ($this->action_constraint['value'] === e_database_constraint_mode::NOT_DEFERRABLE) {
+        $value .= ' ' . c_database_string::NOT_DEFERRABLE;
+      }
+    }
+    else if ($this->action_constraint['type'] === e_database_constraint::DROP) {
+      $value = c_database_string::DROP_CONSTRAINT . ' ' . $this->action_constraint['name'];
+    }
+    else if ($this->action_constraint['type'] === e_database_constraint::VALIDATE) {
+      $value = c_database_string::VALIDATE_CONSTAINT;
+
+      if ($this->action_constraint['value']) {
+        $value .= ' ' . c_database_string::NOT_VALID;
+      }
+
+      $value .=' ' . $this->action_constraint['name'];
+
+      if ($this->action_constraint['cascade'] === e_database_cascade::CASCADE) {
+        $value .= ' ' . c_database_string::CASCADE;
+      }
+      else if ($this->action_constraint['cascade'] === e_database_cascade::RESTRICT) {
+        $value .= ' ' . c_database_string::RESTRICT;
+      }
+    }
+
+    return $value;
+  }
+}
diff --git a/common/database/traits/database_action_disable_rule.php b/common/database/traits/database_action_disable_rule.php
new file mode 100644 (file)
index 0000000..7dedad2
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+require_once('common/database/enumerations/database_rule.php');
+
+/**
+ * Provide the sql action DISABLE RULE functionality.
+ */
+trait t_database_action_disable_rule {
+  protected $action_disable_rule;
+
+  /**
+   * Set the action DISABLE RULE value.
+   *
+   * @param string|null $name
+   *   A string representing the rule name.
+   *   Set to NULL to disable.
+   *
+   * @return c_base_return_status
+   *   TRUE on success, FALSE otherwise.
+   *   FALSE with the error bit set is returned on error.
+   */
+  public function set_action_disable_rule($name) {
+    if (is_null($name)) {
+      $this->action_disable_rule = NULL;
+      return new c_base_return_true();
+    }
+
+    if (!is_string($name)) {
+      $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+      return c_base_return_error::s_false($error);
+    }
+
+    $placeholder = $this->add_placeholder($name);
+    if ($placeholder->has_error()) {
+      return c_base_return_error::s_false($placeholder->get_error());
+    }
+
+    $this->action_disable_rule = $placeholder;
+    unset($placeholder);
+
+    return new c_base_return_true();
+  }
+
+  /**
+   * Get the currently assigned enable rule settings.
+   *
+   * @return c_base_return_string|c_base_return_null
+   *   A string containing the disable rule name.
+   *   NULL is returned if not set (not to be confused with DISABLE RULE).
+   *   NULL with the error bit set is returned on error.
+   */
+  public function get_action_disable_rule() {
+    if (is_null($this->action_disable_rule)) {
+      return new c_base_return_null();
+    }
+
+    if (is_string($this->action_disable_rule)) {
+      return c_base_return_string::s_new($this->action_disable_rule);
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_disable_rule', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    return c_base_return_error::s_null($error);
+  }
+
+  /**
+   * Perform the common build process for this trait.
+   *
+   * As an internal trait method, the caller is expected to perform any appropriate validation.
+   *
+   * @return string|null
+   *   A string is returned.
+   *   NULL is returned if there is nothing to process or there is an error.
+   */
+  protected function p_do_build_action_disable_rule() {
+    return c_database_string::DISABLE_RULE . ' ' . $this->action_disable_rule;
+  }
+}
diff --git a/common/database/traits/database_action_disable_trigger.php b/common/database/traits/database_action_disable_trigger.php
new file mode 100644 (file)
index 0000000..6e91e0e
--- /dev/null
@@ -0,0 +1,128 @@
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+require_once('common/database/enumerations/database_disable_trigger.php');
+
+/**
+ * Provide the sql action DISABLE TRIGGER functionality.
+ */
+trait t_database_action_disable_trigger {
+  protected $action_disable_trigger;
+
+  /**
+   * Set the action DISABLE TRIGGER value.
+   *
+   * @param int|null $type
+   *   An integer representing the type of the trigger.
+   *   Set to NULL to disable.
+   * @param string|null $name
+   *   A string representing the table name depending on the $type.
+   *   Use type NAME to explicitly require this.
+   *   Some types require this value, others ignore it.
+   *
+   * @return c_base_return_status
+   *   TRUE on success, FALSE otherwise.
+   *   FALSE with the error bit set is returned on error.
+   */
+  public function set_action_disable_trigger($type, $name = NULL) {
+    if (is_null($type)) {
+      $this->action_disable_trigger = NULL;
+      return new c_base_return_true();
+    }
+
+    $use_name = NULL;
+    switch ($type) {
+      case e_database_trigger::ALWAYS:
+      case e_database_trigger::NAME:
+      case e_database_trigger::REPLICA:
+        if (!is_string($name)) {
+          unset($use_name);
+          $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+          return c_base_return_error::s_false($error);
+        }
+
+        $use_name = $this->add_placeholder($name);
+        if ($use_name->has_error()) {
+          return c_base_return_error::s_false($placeholder->get_error());
+        }
+        break;
+      case e_database_trigger::ALL:
+        $use_name = c_database_string::ALL;
+        break;
+      case e_database_trigger::USER:
+        $use_name = c_database_string::USER;
+        break;
+      default:
+        unset($use_name);
+        $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+        return c_base_return_error::s_false($error);
+    }
+
+    $this->action_disable_trigger = [
+      'type' => $type,
+      'name' => $use_name,
+    ];
+    unset($use_name);
+
+    return new c_base_return_true();
+  }
+
+  /**
+   * Get the currently assigned enable trigger settings.
+   *
+   * @return c_base_return_array|c_base_return_null
+   *   An array containing the enable trigger settings.
+   *   NULL is returned if not set (not to be confused with DISABLE TRIGGER).
+   *   NULL with the error bit set is returned on error.
+   */
+  public function get_action_disable_trigger() {
+    if (is_null($this->action_disable_trigger)) {
+      return new c_base_return_null();
+    }
+
+    if (is_array($this->action_disable_trigger)) {
+      return c_base_return_array::s_new($this->action_disable_trigger);
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_disable_trigger', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    return c_base_return_error::s_null($error);
+  }
+
+  /**
+   * Perform the common build process for this trait.
+   *
+   * As an internal trait method, the caller is expected to perform any appropriate validation.
+   *
+   * @return string|null
+   *   A string is returned.
+   *   NULL is returned if there is nothing to process or there is an error.
+   */
+  protected function p_do_build_action_disable_trigger() {
+    $value = c_database_string::DISABLE_TRIGGER;
+
+    if ($this->action_disable_trigger['type'] === e_database_trigger::NAME) {
+      if (is_string($this->action_disable_trigger['name'])) {
+          $value .= ' ' . $this->action_disable_trigger['name'];
+      }
+    }
+    else if ($this->action_disable_trigger['type'] === e_database_trigger::ALL) {
+      $value .= ' ' . c_database_string::ALL;
+    }
+    else if ($this->action_disable_trigger['type'] === e_database_trigger::USER) {
+      $value .= ' ' . c_database_string::USER;
+    }
+
+    return $value;
+  }
+}
diff --git a/common/database/traits/database_action_enable_rule.php b/common/database/traits/database_action_enable_rule.php
new file mode 100644 (file)
index 0000000..ee9f121
--- /dev/null
@@ -0,0 +1,138 @@
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+require_once('common/database/enumerations/database_enable_rule.php');
+
+/**
+ * Provide the sql action ENABLE RULE functionality.
+ */
+trait t_database_action_enable_rule {
+  protected $action_enable_rule;
+
+  /**
+   * Set the action ENABLE RULE value.
+   *
+   * @param int|null $type
+   *   An integer representing the type of the rule.
+   *   Set to NULL to disable.
+   * @param string|null $name
+   *   A string representing the table name depending on the $type.
+   *   Use type NAME to explicitly require this.
+   *   Some types require this value, others ignore it.
+   *
+   * @return c_base_return_status
+   *   TRUE on success, FALSE otherwise.
+   *   FALSE with the error bit set is returned on error.
+   */
+  public function set_action_enable_rule($type, $name = NULL) {
+    if (is_null($type)) {
+      $this->action_enable_rule = NULL;
+      return new c_base_return_true();
+    }
+
+    $use_name = NULL;
+    switch ($type) {
+      case e_database_rule::ALWAYS:
+      case e_database_rule::NAME:
+      case e_database_rule::REPLICA:
+        if (!is_string($name)) {
+          unset($use_name);
+          $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+          return c_base_return_error::s_false($error);
+        }
+
+        $use_name = $this->add_placeholder($name);
+        if ($use_name->has_error()) {
+          return c_base_return_error::s_false($placeholder->get_error());
+        }
+        break;
+      case e_database_rule::ALL:
+        $use_name = c_database_string::ALL;
+        break;
+      case e_database_rule::USER:
+        $use_name = c_database_string::USER;
+        break;
+      default:
+        unset($use_name);
+        $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+        return c_base_return_error::s_false($error);
+    }
+
+    $this->action_enable_rule = [
+      'type' => $type,
+      'name' => $use_name,
+    ];
+    unset($use_name);
+
+    return new c_base_return_true();
+  }
+
+  /**
+   * Get the currently assigned enable rule settings.
+   *
+   * @return c_base_return_array|c_base_return_null
+   *   An array containing the enable rule settings.
+   *   NULL is returned if not set (not to be confused with DISABLE RULE).
+   *   NULL with the error bit set is returned on error.
+   */
+  public function get_action_enable_rule() {
+    if (is_null($this->action_enable_rule)) {
+      return new c_base_return_null();
+    }
+
+    if (is_array($this->action_enable_rule)) {
+      return c_base_return_array::s_new($this->action_enable_rule);
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_enable_rule', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    return c_base_return_error::s_null($error);
+  }
+
+  /**
+   * Perform the common build process for this trait.
+   *
+   * As an internal trait method, the caller is expected to perform any appropriate validation.
+   *
+   * @return string|null
+   *   A string is returned.
+   *   NULL is returned if there is nothing to process or there is an error.
+   */
+  protected function p_do_build_action_enable_rule() {
+    $value = NULL;
+
+    if ($this->action_enable_rule['type'] === e_database_rule::ALWAYS || $this->action_enable_rule['type'] === e_database_rule::REPLICA) {
+      if (is_string($this->action_enable_rule['name'])) {
+        if ($this->action_enable_rule['type'] === e_database_rule::ALWAYS) {
+          $value = c_database_string::ENABLE_ALWAYS_RULE . ' ' . $this->action_enable_rule['name'];
+        }
+        else if ($this->action_enable_rule['type'] === e_database_rule::REPLICA) {
+          $value = c_database_string::ENABLE_REPLICA_RULE . ' ' . $this->action_enable_rule['name'];
+        }
+      }
+    }
+    else if ($this->action_enable_rule['type'] === e_database_rule::NAME) {
+      if (is_string($this->action_enable_rule['name'])) {
+          $value = c_database_string::ENABLE_RULE . ' ' . $this->action_enable_rule['name'];
+      }
+    }
+    else if ($this->action_enable_rule['type'] === e_database_rule::ALL) {
+      $value = c_database_string::ENABLE_RULE . ' ' . c_database_string::ALL;
+    }
+    else if ($this->action_enable_rule['type'] === e_database_rule::USER) {
+      $value = c_database_string::ENABLE_RULE . ' ' . c_database_string::USER;
+    }
+
+    return $value;
+  }
+}
diff --git a/common/database/traits/database_action_enable_trigger.php b/common/database/traits/database_action_enable_trigger.php
new file mode 100644 (file)
index 0000000..f779ea7
--- /dev/null
@@ -0,0 +1,138 @@
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+require_once('common/database/enumerations/database_enable_trigger.php');
+
+/**
+ * Provide the sql action ENABLE TRIGGER functionality.
+ */
+trait t_database_action_enable_trigger {
+  protected $action_enable_trigger;
+
+  /**
+   * Set the action ENABLE TRIGGER value.
+   *
+   * @param int|null $type
+   *   An integer representing the type of the trigger.
+   *   Set to NULL to disable.
+   * @param string|null $name
+   *   A string representing the table name depending on the $type.
+   *   Use type NAME to explicitly require this.
+   *   Some types require this value, others ignore it.
+   *
+   * @return c_base_return_status
+   *   TRUE on success, FALSE otherwise.
+   *   FALSE with the error bit set is returned on error.
+   */
+  public function set_action_enable_trigger($type, $name = NULL) {
+    if (is_null($type)) {
+      $this->action_enable_trigger = NULL;
+      return new c_base_return_true();
+    }
+
+    $use_name = NULL;
+    switch ($type) {
+      case e_database_trigger::ALWAYS:
+      case e_database_trigger::NAME:
+      case e_database_trigger::REPLICA:
+        if (!is_string($name)) {
+          unset($use_name);
+          $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+          return c_base_return_error::s_false($error);
+        }
+
+        $use_name = $this->add_placeholder($name);
+        if ($use_name->has_error()) {
+          return c_base_return_error::s_false($placeholder->get_error());
+        }
+        break;
+      case e_database_trigger::ALL:
+        $use_name = c_database_string::ALL;
+        break;
+      case e_database_trigger::USER:
+        $use_name = c_database_string::USER;
+        break;
+      default:
+        unset($use_name);
+        $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+        return c_base_return_error::s_false($error);
+    }
+
+    $this->action_enable_trigger = [
+      'type' => $type,
+      'name' => $use_name,
+    ];
+    unset($use_name);
+
+    return new c_base_return_true();
+  }
+
+  /**
+   * Get the currently assigned enable trigger settings.
+   *
+   * @return c_base_return_array|c_base_return_null
+   *   An array containing the enable trigger settings.
+   *   NULL is returned if not set (not to be confused with DISABLE TRIGGER).
+   *   NULL with the error bit set is returned on error.
+   */
+  public function get_action_enable_trigger() {
+    if (is_null($this->action_enable_trigger)) {
+      return new c_base_return_null();
+    }
+
+    if (is_array($this->action_enable_trigger)) {
+      return c_base_return_array::s_new($this->action_enable_trigger);
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_enable_trigger', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    return c_base_return_error::s_null($error);
+  }
+
+  /**
+   * Perform the common build process for this trait.
+   *
+   * As an internal trait method, the caller is expected to perform any appropriate validation.
+   *
+   * @return string|null
+   *   A string is returned.
+   *   NULL is returned if there is nothing to process or there is an error.
+   */
+  protected function p_do_build_action_enable_trigger() {
+    $value = NULL;
+
+    if ($this->action_enable_trigger['type'] === e_database_trigger::ALWAYS || $this->action_enable_trigger['type'] === e_database_trigger::REPLICA) {
+      if (is_string($this->action_enable_trigger['name'])) {
+        if ($this->action_enable_trigger['type'] === e_database_trigger::ALWAYS) {
+          $value = c_database_string::ENABLE_ALWAYS_TRIGGER . ' ' . $this->action_enable_trigger['name'];
+        }
+        else if ($this->action_enable_trigger['type'] === e_database_trigger::REPLICA) {
+          $value = c_database_string::ENABLE_REPLICA_TRIGGER . ' ' . $this->action_enable_trigger['name'];
+        }
+      }
+    }
+    else if ($this->action_enable_trigger['type'] === e_database_trigger::NAME) {
+      if (is_string($this->action_enable_trigger['name'])) {
+          $value = c_database_string::ENABLE_TRIGGER . ' ' . $this->action_enable_trigger['name'];
+      }
+    }
+    else if ($this->action_enable_trigger['type'] === e_database_trigger::ALL) {
+      $value = c_database_string::ENABLE_TRIGGER . ' ' . c_database_string::ALL;
+    }
+    else if ($this->action_enable_trigger['type'] === e_database_trigger::USER) {
+      $value = c_database_string::ENABLE_TRIGGER . ' ' . c_database_string::USER;
+    }
+
+    return $value;
+  }
+}
diff --git a/common/database/traits/database_action_not_of.php b/common/database/traits/database_action_not_of.php
new file mode 100644 (file)
index 0000000..0d5872c
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql action NOT OF functionality.
+ */
+trait t_database_action_not_of {
+  protected $action_not_of;
+
+  /**
+   * Set the action NOT OF settings.
+   *
+   * @param bool|null $not_of
+   *   Set to TRUE to enable.
+   *   Set to FALSE for nothing.
+   *   Set to NULL to disable.
+   *
+   * @return c_base_return_status
+   *   TRUE on success, FALSE otherwise.
+   *   FALSE with the error bit set is returned on error.
+   */
+  public function set_action_not_of($not_of) {
+    if (is_null($enable)) {
+      $this->action_not_of = NULL;
+      return new c_base_return_true();
+    }
+
+    if (!is_bool($not_of)) {
+      $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'not_of', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+      return c_base_return_error::s_false($error);
+    }
+
+    $this->action_not_of = $enable;
+    return new c_base_return_true();
+  }
+
+  /**
+   * Get the currently assigned NOT OF setting.
+   *
+   * @return c_base_return_bool|c_base_return_null
+   *   A boolean representing whether or NOT OF is to be used.
+   *   NULL is returned if not set (this is not to be used).
+   *   NULL with the error bit set is returned on error.
+   */
+  public function get_action_not_of() {
+    if (is_null($this->action_not_of)) {
+      return new c_base_return_null();
+    }
+
+    if (is_bool($this->action_not_of)) {
+      return c_base_return_bool:s_new($this->action_not_of);
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_not_of', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    return c_base_return_error::s_null($error);
+  }
+
+  /**
+   * Perform the common build process for this trait.
+   *
+   * As an internal trait method, the caller is expected to perform any appropriate validation.
+   *
+   * @return string|null
+   *   A string is returned.
+   *   NULL is returned if there is nothing to process or there is an error.
+   */
+  protected function p_do_build_action_not_of() {
+    return $this->action_not_of ? c_database_string::NOT_OF : NULL;
+  }
+}
diff --git a/common/database/traits/database_action_of.php b/common/database/traits/database_action_of.php
new file mode 100644 (file)
index 0000000..9270153
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql action OF functionality.
+ */
+trait t_database_action_of {
+  protected $action_of;
+
+  /**
+   * Set the action OF settings.
+   *
+   * @param string|null $type_name
+   *   The of type name to set to.
+   *   Set to NULL to disable.
+   *
+   * @return c_base_return_status
+   *   TRUE on success, FALSE otherwise.
+   *   FALSE with the error bit set is returned on error.
+   */
+  public function set_action_of($type_name) {
+    if (is_null($type_name)) {
+      $this->action_of = NULL;
+      return new c_base_return_true();
+    }
+
+    if (!is_string($type_name)) {
+      $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'type_name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+      return c_base_return_error::s_false($error);
+    }
+
+    $placeholder = $this->add_placeholder($type_name);
+    if ($placeholder->has_error()) {
+      return c_base_return_error::s_false($placeholder->get_error());
+    }
+
+    $this->action_of = $placeholder;
+    unset($placeholder);
+
+    return new c_base_return_true();
+  }
+
+  /**
+   * Get the currently assigned  action OF setting.
+   *
+   * @return i_database_query_placeholder|c_base_return_null
+   *   A tablespace name on success.
+   *   NULL is returned if not set (set tablespace is not to be used).
+   *   NULL with the error bit set is returned on error.
+   */
+  public function get_action_of() {
+    if (is_null($this->action_of)) {
+      return new c_base_return_null();
+    }
+
+    if (isset($this->action_of)) {
+      return clone($this->action_of);
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_of', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    return c_base_return_error::s_null($error);
+  }
+
+  /**
+   * Perform the common build process for this trait.
+   *
+   * As an internal trait method, the caller is expected to perform any appropriate validation.
+   *
+   * @return string|null
+   *   A string is returned.
+   *   NULL is returned if there is nothing to process or there is an error.
+   */
+  protected function p_do_build_action_of() {
+    return c_database_string::OF . ' ' . $this->action_of;
+  }
+}
diff --git a/common/database/traits/database_action_replica_identity.php b/common/database/traits/database_action_replica_identity.php
new file mode 100644 (file)
index 0000000..bf9db22
--- /dev/null
@@ -0,0 +1,125 @@
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/enumerations/database_replica_identity.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql action REPLICA IDENTITY attribute_option functionality.
+ */
+trait t_database_action_replica_identity {
+  protected $action_replica_identity;
+
+  /**
+   * Set the REPLICA IDENTITY attribute option settings.
+   *
+   * @param int|null $type
+   *   An integer of e_database_replica_identity to use.
+   *   Set to NULL to disable.
+   * @param string|null $name
+   *   (optional) The index name when $type is USING_INDEX.
+   *   Required when $type is USING_INDEX.
+   *
+   * @return c_base_return_status
+   *   TRUE on success, FALSE otherwise.
+   *   FALSE with the error bit reset is returned on error.
+   */
+  public function reset_action_replica_identity($type, $name = NULL) {
+    if (is_null($type)) {
+      $this->action_replica_identity = NULL;
+      return new c_base_return_true();
+    }
+
+    $placeholder_name = NULL;
+
+    switch ($type) {
+      case e_database_replica_identity::DEFAULT:
+      case e_database_replica_identity::FULL:
+      case e_database_replica_identity::NOTHING:
+        break;
+      case e_database_replica_identity::USING_INDEX:
+        if (!is_string($name)) {
+          unset($placeholder_name);
+          $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+          return c_base_return_error::s_false($error);
+        }
+
+        $placeholder_name = $this->add_placeholder($name);
+        if ($placeholder_name->has_error()) {
+          return c_base_return_error::s_false($placeholder_name->get_error());
+        }
+        break;
+      default:
+        unset($placeholder_name);
+        $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+        return c_base_return_error::s_false($error);
+    };
+
+    $this->action_replica_identity = [
+      'type' => $type,
+      'name' => $placeholder_name,
+    ];
+    unset($placeholder_name);
+
+    return new c_base_return_true();
+  }
+
+  /**
+   * Get the currently assigned settings.
+   *
+   * @return c_base_return_array|c_base_return_null
+   *   An array of settings or NULL if not defined.
+   *   NULL with the error bit reset is returned on error.
+   */
+  public function get_action_replica_identity() {
+    if (is_null($this->action_replica_identity)) {
+      return new c_base_return_null();
+    }
+
+    if (is_array($this->action_replica_identity)) {
+      return c_base_return_array::s_new($this->action_replica_identity);
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_replica_identity', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    return c_base_return_error::s_null($error);
+  }
+
+  /**
+   * Perform the common build process for this trait.
+   *
+   * As an internal trait method, the caller is expected to perform any appropriate validation.
+   *
+   * @return string|null
+   *   A string is returned.
+   *   NULL is returned if there is nothing to process or there is an error.
+   */
+  protected function p_do_build_action_replica_identity() {
+    $value = c_database_string::REPLICA_IDENTITY;
+
+    if ($this->action_replica_identity['type'] === e_database_replica_identity::DEFAULT) {
+      $value .= ' ' . c_database_string::DEFAULT;
+    }
+    else if ($this->action_replica_identity['type'] === e_database_replica_identity::FULL) {
+      $value .= ' ' . c_database_string::FULL;
+    }
+    else if ($this->action_replica_identity['type'] === e_database_replica_identity::NOTHING) {
+      $value .= ' ' . c_database_string::NOTHING;
+    }
+    else if ($this->action_replica_identity['type'] === e_database_replica_identity::USING_INDEX) {
+      $value .= ' ' . c_database_string::USING_INDEX;
+      $value .= ' ' . $this->action_replica_identity['name'];
+    }
+
+    return $value;
+  }
+}
diff --git a/common/database/traits/database_action_row_level_security.php b/common/database/traits/database_action_row_level_security.php
new file mode 100644 (file)
index 0000000..eeaa348
--- /dev/null
@@ -0,0 +1,111 @@
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/enumerations/database_row_level_security.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql action ROW LEVEL SECURITY attribute_option functionality.
+ */
+trait t_database_action_row_level_security {
+  protected $action_row_level_security;
+
+  /**
+   * Set the ROW LEVEL SECURITY attribute option settings.
+   *
+   * @param int|null $type
+   *   An integer of e_database_row_level_security to use.
+   *   Set to NULL to disable.
+   *
+   * @return c_base_return_status
+   *   TRUE on success, FALSE otherwise.
+   *   FALSE with the error bit reset is returned on error.
+   */
+  public function reset_action_row_level_security($type) {
+    if (is_null($type)) {
+      $this->action_row_level_security = NULL;
+      return new c_base_return_true();
+    }
+
+    $placeholder_name = NULL;
+
+    switch ($type) {
+      case e_database_row_level_security::DISABLE:
+      case e_database_row_level_security::ENABLE:
+      case e_database_row_level_security::FORCE:
+      case e_database_row_level_security::NO_FORCE:
+        break;
+      default:
+        unset($placeholder_name);
+        $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+        return c_base_return_error::s_false($error);
+    };
+
+    $this->action_row_level_security = [
+      'type' => $type,
+      'name' => $placeholder_name,
+    ];
+    unset($placeholder_name);
+
+    return new c_base_return_true();
+  }
+
+  /**
+   * Get the currently assigned settings.
+   *
+   * @return c_base_return_array|c_base_return_null
+   *   An array of settings or NULL if not defined.
+   *   NULL with the error bit reset is returned on error.
+   */
+  public function get_action_row_level_security() {
+    if (is_null($this->action_row_level_security)) {
+      return new c_base_return_null();
+    }
+
+    if (is_array($this->action_row_level_security)) {
+      return c_base_return_array::s_new($this->action_row_level_security);
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_row_level_security', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    return c_base_return_error::s_null($error);
+  }
+
+  /**
+   * Perform the common build process for this trait.
+   *
+   * As an internal trait method, the caller is expected to perform any appropriate validation.
+   *
+   * @return string|null
+   *   A string is returned.
+   *   NULL is returned if there is nothing to process or there is an error.
+   */
+  protected function p_do_build_action_row_level_security() {
+    $value = c_database_string::REPLICA_IDENTITY;
+
+    if ($this->action_row_level_security['type'] === e_database_row_level_security::DISABLE) {
+      $value .= ' ' . c_database_string::DISABLE;
+    }
+    else if ($this->action_row_level_security['type'] === e_database_row_level_security::ENABLE) {
+      $value .= ' ' . c_database_string::ENABLE;
+    }
+    else if ($this->action_row_level_security['type'] === e_database_row_level_security::FORCE) {
+      $value .= ' ' . c_database_string::FORCE;
+    }
+    else if ($this->action_row_level_security['type'] === e_database_row_level_security::NO_FORCE) {
+      $value .= ' ' . c_database_string::NO_FORCE;
+    }
+
+    $value .= ' ' . c_database_string::ROW_LEVEL_SECURITY;
+    return $value;
+  }
+}
diff --git a/common/database/traits/database_action_set_logged.php b/common/database/traits/database_action_set_logged.php
new file mode 100644 (file)
index 0000000..4cc6956
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+/**
+ * Provide the sql action SET LOGGED / SET UNLOGGED functionality.
+ */
+trait t_database_action_set_logged {
+  protected $action_set_logged;
+
+  /**
+   * Set the action SET LOGGED / SET UNLOGGED settings.
+   *
+   * @param bool|null $logged
+   *   Set to TRUE for logged.
+   *   Set to FALSE for unlogged.
+   *   Set to NULL to disable.
+   *
+   * @return c_base_return_status
+   *   TRUE on success, FALSE otherwise.
+   *   FALSE with the error bit set is returned on error.
+   */
+  public function set_action_set_logged($logged) {
+    if (is_null($logged)) {
+      $this->action_set_logged = NULL;
+      return new c_base_return_true();
+    }
+
+    if (is_bool($logged)) {
+      $this->action_set_logged = $logged;
+      return new c_base_return_true();
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'logged', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+    return c_base_return_error::s_false($error);
+  }
+
+  /**
+   * Get the currently assigned start with value.
+   *
+   * @return c_base_return_bool|c_base_return_null
+   *   A number representing the start with value.
+   *   NULL is returned if not set.
+   *   NULL with the error bit set is returned on error.
+   */
+  public function get_action_set_logged() {
+    if (is_null($this->action_set_logged)) {
+      return new c_base_return_null();
+    }
+
+    if (is_bool($this->action_set_logged)) {
+      return c_base_return_bool::s_new($this->action_set_logged);
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_set_logged', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    return c_base_return_error::s_null($error);
+  }
+
+  /**
+   * Perform the common build process for this trait.
+   *
+   * As an internal trait method, the caller is expected to perform any appropriate validation.
+   *
+   * @return string|null
+   *   A string is returned.
+   *   NULL is returned if there is nothing to process or there is an error.
+   */
+  protected function p_do_build_action_set_logged() {
+    if ($this->action_set_logged) {
+      return c_database_string::SET_LOGGED;
+    }
+
+    return c_database_string::SET_UNLOGGED;
+  }
+}
diff --git a/common/database/traits/database_action_set_tablespace.php b/common/database/traits/database_action_set_tablespace.php
new file mode 100644 (file)
index 0000000..cbb425b
--- /dev/null
@@ -0,0 +1,87 @@
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql action SET TABLESPACE functionality.
+ */
+trait t_database_action_set_tablespace {
+  protected $action_set_tablespace;
+
+  /**
+   * Set the action SET TABLESPACE settings.
+   *
+   * @param string|null $name
+   *   The tablespace name to set to.
+   *   Set to NULL to disable.
+   *
+   * @return c_base_return_status
+   *   TRUE on success, FALSE otherwise.
+   *   FALSE with the error bit set is returned on error.
+   */
+  public function set_action_set_tablespace($name) {
+    if (is_null($name)) {
+      $this->action_set_tablespace = NULL;
+      return new c_base_return_true();
+    }
+
+    if (!is_string($name)) {
+      $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+      return c_base_return_error::s_false($error);
+    }
+
+    $placeholder = $this->add_placeholder($name);
+    if ($placeholder->has_error()) {
+      return c_base_return_error::s_false($placeholder->get_error());
+    }
+
+    $this->action_set_tablespace = $placeholder;
+    unset($placeholder);
+
+    return new c_base_return_true();
+  }
+
+  /**
+   * Get the currently assigned tablespace name to set to.
+   *
+   * @return i_database_query_placeholder|c_base_return_null
+   *   A tablespace name on success.
+   *   NULL is returned if not set (set tablespace is not to be used).
+   *   NULL with the error bit set is returned on error.
+   */
+  public function get_action_set_tablespace() {
+    if (is_null($this->action_set_tablespace)) {
+      return new c_base_return_null();
+    }
+
+    if (isset($this->action_set_tablespace)) {
+      return clone($this->action_set_tablespace);
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_set_tablespace', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    return c_base_return_error::s_null($error);
+  }
+
+  /**
+   * Perform the common build process for this trait.
+   *
+   * As an internal trait method, the caller is expected to perform any appropriate validation.
+   *
+   * @return string|null
+   *   A string is returned.
+   *   NULL is returned if there is nothing to process or there is an error.
+   */
+  protected function p_do_build_action_set_tablespace() {
+    return c_database_string::SET_TABLESPACE . ' ' . $this->action_set_tablespace;
+  }
+}
diff --git a/common/database/traits/database_action_without_cluster.php b/common/database/traits/database_action_without_cluster.php
new file mode 100644 (file)
index 0000000..590fa47
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+/**
+ * Provide the sql WITHOUT CLUSTER functionality.
+ */
+trait t_database_action_without_cluster {
+  protected $action_without_cluster;
+
+  /**
+   * Set the WITHOUT CLUSTER value.
+   *
+   * @param bool|null $without_cluster
+   *   Set to TRUE for WITHOUT CLUSTER.
+   *   Set to FALSE for nothing.
+   *   Set to NULL to disable.
+   *
+   * @return c_base_return_status
+   *   TRUE on success, FALSE otherwise.
+   *   FALSE with the error bit set is returned on error.
+   */
+  public function set_action_without_cluster($without_cluster) {
+    if (is_null($without_cluster)) {
+      $this->action_without_cluster = NULL;
+      return new c_base_return_true();
+    }
+
+    if (is_bool($without_cluster)) {
+      $this->action_without_cluster = $without_cluster;
+      return new c_base_return_true();
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'without_cluster', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+    return c_base_return_error::s_false($error);
+  }
+
+  /**
+   * Get the currently assigned without cluster value.
+   *
+   * @return c_base_return_bool|c_base_return_null
+   *   TRUE for WITHOUT CLUSTER on success.
+   *   NULL is returned if not set.
+   *   NULL with the error bit set is returned on error.
+   */
+  public function get_action_without_cluster() {
+    if (is_null($this->action_without_cluster)) {
+      return new c_base_return_null();
+    }
+
+    if (is_bool($this->action_without_cluster)) {
+      return c_base_return_bool::s_new($this->action_without_cluster);
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'action_without_cluster', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    return c_base_return_error::s_null($error);
+  }
+
+  /**
+   * Perform the common build process for this trait.
+   *
+   * As an internal trait method, the caller is expected to perform any appropriate validation.
+   *
+   * @return string|null
+   *   A string is returned.
+   *   NULL is returned if there is nothing to process or there is an error.
+   */
+  protected function p_do_build_action_without_cluster() {
+    return $this->action_without_cluster ? c_database_string::WITHOUT_CLUSTER : NULL;
+  }
+}
index 320bd19a5aa0505878d3a0991652bf961a7790de..3c4e3ea160465b1ab5ffed8b64cf71ac7fca9130 100644 (file)
@@ -99,7 +99,7 @@ trait t_database_column_set_storage {
    *   NULL is returned if there is nothing to process or there is an error.
    */
   protected function p_do_build_column_set_storage() {
-    $value = c_database_string::COLUMN . ' ' . $this->column_set_storage['name']->get_name() . ' ' . c_database_string::SET_STORAGE . ' ';
+    $value = c_database_string::COLUMN . ' ' . $this->column_set_storage['name'] . ' ' . c_database_string::SET_STORAGE . ' ';
     if ($this->column_set_storage['type'] === e_database_column_set_storage::EXTENDED) {
       return $value . c_database_string::EXTENDED;
     }
diff --git a/common/database/traits/database_disable_trigger.php b/common/database/traits/database_disable_trigger.php
new file mode 100644 (file)
index 0000000..8c35bf4
--- /dev/null
@@ -0,0 +1,128 @@
+<?php
+/**
+ * @file
+ * Provides traits for specific Postgesql Queries.
+ *
+ * @see: https://www.postgresql.org/docs/current/static/sql-commands.html
+ */
+namespace n_koopa;
+
+require_once('common/base/classes/base_error.php');
+require_once('common/base/classes/base_return.php');
+
+require_once('common/database/classes/database_string.php');
+
+require_once('common/database/enumerations/database_disable_trigger.php');
+
+/**
+ * Provide the sql DISABLE TRIGGER functionality.
+ */
+trait t_database_disable_trigger {
+  protected $disable_trigger;
+
+  /**
+   * Set the DISABLE TRIGGER value.
+   *
+   * @param int|null $type
+   *   An integer representing the type of the trigger.
+   *   Set to NULL to disable.
+   * @param string|null $name
+   *   A string representing the table name depending on the $type.
+   *   Use type NAME to explicitly require this.
+   *   Some types require this value, others ignore it.
+   *
+   * @return c_base_return_status
+   *   TRUE on success, FALSE otherwise.
+   *   FALSE with the error bit set is returned on error.
+   */
+  public function set_disable_trigger($type, $name = NULL) {
+    if (is_null($type)) {
+      $this->disable_trigger = NULL;
+      return new c_base_return_true();
+    }
+
+    $use_name = NULL;
+    switch ($type) {
+      case e_database_trigger::ALWAYS:
+      case e_database_trigger::NAME:
+      case e_database_trigger::REPLICA:
+        if (!is_string($name)) {
+          unset($use_name);
+          $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+          return c_base_return_error::s_false($error);
+        }
+
+        $use_name = $this->add_placeholder($name);
+        if ($use_name->has_error()) {
+          return c_base_return_error::s_false($placeholder->get_error());
+        }
+        break;
+      case e_database_trigger::ALL:
+        $use_name = c_database_string::ALL;
+        break;
+      case e_database_trigger::USER:
+        $use_name = c_database_string::USER;
+        break;
+      default:
+        unset($use_name);
+        $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'type', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+        return c_base_return_error::s_false($error);
+    }
+
+    $this->disable_trigger = [
+      'type' => $type,
+      'name' => $use_name,
+    ];
+    unset($use_name);
+
+    return new c_base_return_true();
+  }
+
+  /**
+   * Get the currently assigned enable trigger settings.
+   *
+   * @return c_base_return_array|c_base_return_null
+   *   An array containing the enable trigger settings.
+   *   NULL is returned if not set (not to be confused with DISABLE TRIGGER).
+   *   NULL with the error bit set is returned on error.
+   */
+  public function get_disable_trigger() {
+    if (is_null($this->disable_trigger)) {
+      return new c_base_return_null();
+    }
+
+    if (is_array($this->disable_trigger)) {
+      return c_base_return_array::s_new($this->disable_trigger);
+    }
+
+    $error = c_base_error::s_log(NULL, ['arguments' => [':{variable_name}' => 'disable_trigger', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_VARIABLE);
+    return c_base_return_error::s_null($error);
+  }
+
+  /**
+   * Perform the common build process for this trait.
+   *
+   * As an internal trait method, the caller is expected to perform any appropriate validation.
+   *
+   * @return string|null
+   *   A string is returned.
+   *   NULL is returned if there is nothing to process or there is an error.
+   */
+  protected function p_do_build_disable_trigger() {
+    $value = c_database_string::DISABLE_TRIGGER;
+
+    if ($this->disable_trigger['type'] === e_database_trigger::NAME) {
+      if (is_string($this->disable_trigger['name'])) {
+          $value .= ' ' . $this->disable_trigger['name'];
+      }
+    }
+    else if ($this->disable_trigger['type'] === e_database_trigger::ALL) {
+      $value .= ' ' . c_database_string::ALL;
+    }
+    else if ($this->disable_trigger['type'] === e_database_trigger::USER) {
+      $value .= ' ' . c_database_string::USER;
+    }
+
+    return $value;
+  }
+}
index 039e8d2f601879472ceaa721cd7c1ee9dfc663bc..90e838f75bfcd8134e501c5874b12f362dcfe895 100644 (file)
@@ -15,20 +15,17 @@ require_once('common/database/classes/database_string.php');
 require_once('common/database/enumerations/database_enable_trigger.php');
 
 /**
- * Provide the sql SET WITH OIDS functionality.
+ * Provide the sql ENABLE TRIGGER functionality.
  */
 trait t_database_enable_trigger {
   protected $enable_trigger;
 
   /**
-   * Set the ENABLE TRIGGER or DISABLE TRIGGER value.
+   * Set the ENABLE TRIGGER value.
    *
-   * @param bool|null $enable_trigger
-   *   Set to TRUE for ENABLE TRIGGER, FALSE for DISABLE TRIGGER.
-   *   Set to NULL to disable (as-in: no SQL is generated, do not confuse this with the generated DISABLE TRIGGER state produced by FALSE).
    * @param int|null $type
    *   An integer representing the type of the trigger.
-   *   Should only be NULL when $enable_trigger is NULL.
+   *   Set to NULL to disable.
    * @param string|null $name
    *   A string representing the table name depending on the $type.
    *   Use type NAME to explicitly require this.
@@ -38,22 +35,17 @@ trait t_database_enable_trigger {
    *   TRUE on success, FALSE otherwise.
    *   FALSE with the error bit set is returned on error.
    */
-  public function set_enable_trigger($enable, $type = NULL, $name = NULL) {
-    if (is_null($enable_trigger)) {
+  public function set_enable_trigger($type, $name = NULL) {
+    if (is_null($type)) {
       $this->enable_trigger = NULL;
       return new c_base_return_true();
     }
 
-    if (!is_bool($enable_trigger)) {
-      $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'enable_trigger', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
-      return c_base_return_error::s_false($error);
-    }
-
     $use_name = NULL;
     switch ($type) {
-      case e_database_enable_trigger::ALWAYS:
-      case e_database_enable_trigger::NAME:
-      case e_database_enable_trigger::REPLICA:
+      case e_database_trigger::ALWAYS:
+      case e_database_trigger::NAME:
+      case e_database_trigger::REPLICA:
         if (!is_string($name)) {
           unset($use_name);
           $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
@@ -65,10 +57,10 @@ trait t_database_enable_trigger {
           return c_base_return_error::s_false($placeholder->get_error());
         }
         break;
-      case e_database_enable_trigger::ALL:
+      case e_database_trigger::ALL:
         $use_name = c_database_string::ALL;
         break;
-      case e_database_enable_trigger::USER:
+      case e_database_trigger::USER:
         $use_name = c_database_string::USER;
         break;
       default:
@@ -78,7 +70,6 @@ trait t_database_enable_trigger {
     }
 
     $this->enable_trigger = [
-      'status' => $enable_trigger,
       'type' => $type,
       'name' => $use_name,
     ];
@@ -119,45 +110,27 @@ trait t_database_enable_trigger {
    */
   protected function p_do_build_enable_trigger() {
     $value = NULL;
-    switch ($this->enable_trigger['type']) {
-      case e_database_enable_trigger::ALWAYS:
-      case e_database_enable_trigger::REPLICA:
-        if (is_string($this->enable_trigger['name'])) {
-          if ($this->enable_trigger['type'] === e_database_enable_trigger::ALWAYS) {
-            $value = c_database_string::ENABLE_ALWAYS_TRIGGER . ' ' . $this->enable_trigger['name'];
-          }
-          else if ($this->enable_trigger['type'] === e_database_enable_trigger::REPLICA) {
-            $value = c_database_string::ENABLE_REPLICA_TRIGGER . ' ' . $this->enable_trigger['name'];
-          }
-        }
-        break;
 
-      case e_database_enable_trigger::NAME:
-        if (is_string($this->enable_trigger['name'])) {
-          if ($this->enable_trigger['status']) {
-            $value = c_database_string::ENABLE_TRIGGER . ' ' . $this->enable_trigger['name'];
-          }
-          else {
-            $value = c_database_string::DISABLE_TRIGGER . ' ' . $this->enable_trigger['name'];
-          }
+    if ($this->enable_trigger['type'] === e_database_trigger::ALWAYS || $this->enable_trigger['type'] === e_database_trigger::REPLICA) {
+      if (is_string($this->enable_trigger['name'])) {
+        if ($this->enable_trigger['type'] === e_database_trigger::ALWAYS) {
+          $value = c_database_string::ENABLE_ALWAYS_TRIGGER . ' ' . $this->enable_trigger['name'];
         }
-        break;
-      case e_database_enable_trigger::ALL:
-        if ($this->enable_trigger['status']) {
-          $value = c_database_string::ENABLE_TRIGGER . ' ' . c_database_string::ALL;
-        }
-        else {
-          $value = c_database_string::DISABLE_TRIGGER . ' ' . c_database_string::ALL;
+        else if ($this->enable_trigger['type'] === e_database_trigger::REPLICA) {
+          $value = c_database_string::ENABLE_REPLICA_TRIGGER . ' ' . $this->enable_trigger['name'];
         }
-        break;
-      case e_database_enable_trigger::USER:
-        if ($this->enable_trigger['status']) {
-          $value = c_database_string::ENABLE_TRIGGER . ' ' . c_database_string::USER;
-        }
-        else {
-          $value = c_database_string::DISABLE_TRIGGER . ' ' . c_database_string::USER;
-        }
-        break;
+      }
+    }
+    else if ($this->enable_trigger['type'] === e_database_trigger::NAME) {
+      if (is_string($this->enable_trigger['name'])) {
+          $value = c_database_string::ENABLE_TRIGGER . ' ' . $this->enable_trigger['name'];
+      }
+    }
+    else if ($this->enable_trigger['type'] === e_database_trigger::ALL) {
+      $value = c_database_string::ENABLE_TRIGGER . ' ' . c_database_string::ALL;
+    }
+    else if ($this->enable_trigger['type'] === e_database_trigger::USER) {
+      $value = c_database_string::ENABLE_TRIGGER . ' ' . c_database_string::USER;
     }
 
     return $value;
index 025d2c03c84e6672de572543bdbeb385a5569073..8be5ac3db5af447f97ca91385a95e667cc9fffc4 100644 (file)
@@ -76,6 +76,6 @@ trait t_database_no_wait {
    *   NULL is returned if there is nothing to process or there is an error.
    */
   protected function p_do_build_no_wait() {
-    return $this->no_wait ? c_database_string::NO_WAIT : NULL;
+    return $this->no_wait ? c_database_string::NOWAIT : NULL;
   }
 }
index c8da2b7ba8e0a5a941be2b66fc31e29d0b953502..6bcd4032d6ba276e033253504b2cbed9fce2bb86 100644 (file)
@@ -30,7 +30,12 @@ trait t_database_rename_to {
    *   FALSE with the error bit set is returned on error.
    */
   public function set_rename_to($rename_to) {
-    if (!is_null($rename_to) && !is_string($rename_to)) {
+    if (is_null($rename_to)) {
+      $this->rename_to = NULL;
+      return new c_base_return_true();
+    }
+
+    if (!is_string($rename_to)) {
       $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'rename_to', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
       return c_base_return_error::s_false($error);
     }
index 3c8c5b87da4c50cddf9b6f2ecfd9d3806001169d..81dfc44e99390bbf1a9062e2f197a8ee396d3d93 100644 (file)
@@ -21,7 +21,7 @@ trait t_database_set_tablespace {
   /**
    * Set the SET TABLESPACE settings.
    *
-   * @param string|null $set_tablespace
+   * @param string|null $name
    *   The tablespace name to set to.
    *   Set to NULL to disable.
    *
@@ -29,13 +29,18 @@ trait t_database_set_tablespace {
    *   TRUE on success, FALSE otherwise.
    *   FALSE with the error bit set is returned on error.
    */
-  public function set_set_tablespace($set_tablespace) {
-    if (!is_null($set_tablespace) && !is_string($set_tablespace)) {
-      $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'set_tablespace', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
+  public function set_set_tablespace($name) {
+    if (is_null($name)) {
+      $this->set_tablespace = NULL;
+      return new c_base_return_true();
+    }
+
+    if (!is_string($name)) {
+      $error = c_base_error::s_log(NULL, ['arguments' => [':{argument_name}' => 'name', ':{function_name}' => __CLASS__ . '->' . __FUNCTION__]], i_base_error_messages::INVALID_ARGUMENT);
       return c_base_return_error::s_false($error);
     }
 
-    $placeholder = $this->add_placeholder($set_tablespace);
+    $placeholder = $this->add_placeholder($name);
     if ($placeholder->has_error()) {
       return c_base_return_error::s_false($placeholder->get_error());
     }