Difference between revisions of "User:Minooz/PostgreSQL Adapter-nexj/schema-init"

From CDOT Wiki
Jump to: navigation, search
(Created page with ' {{MinNexJ_Express Index}}')
 
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
 +
<big><big> PostgreSQL Adapter for NexJ - Working Inside Schema 'test' </big></big>
 +
{{MinNexJ_Express Index}}
 +
 +
== Initializing the SQL environment==
 +
* ''PostgreSQLAdapter.java''
 +
: When a connection is first established, this initial SQL statement should execute in MySQL, which is not the case for PostgreSQL, so the implementation was removed from PostgreSQLAdapter.java:
 +
::
 +
<source lang=java>
 +
/* MySQLAdapter.java */
 +
 +
public String getInitialSQL()
 +
  {
 +
      StringBuffer buf = new StringBuffer();
  
{{MinNexJ_Express Index}}
+
      buf.append("set sql_mode = concat(@@sql_mode, ',ANSI_QUOTES')"); // allow using doublequote when quoting column names in "CREATE TABLE" statements
 +
      buf.append(";set optimizer_search_depth = 0"); // let DB automatically decide on how long it takes to examine plans, improves long planning sessions
 +
      buf.append(";set max_sort_length = ").append
 +
            (Math.max(MAX_VARCHAR_PRECISION, MAX_VARBINARY_PRECISION)); // set TEXT/BLOB minimum sorting length to be same as cutoff between varchar/text
 +
      return buf.toString();
 +
  }
 +
</source>
 +
* ''postgresql_create.sql''
 +
: This file was just created as a copy of mysql_create.sql, which was not the case for PostgreSQL again. So the line in the file is removed for now. The file itself may be deleted later, if there was no need for it. Name of the script file is being returned in '''''getCreateEtcScriptName()'''''' in '''PostgreSQLSchemaManager.java'''
 +
::
 +
<source lang=java>
 +
/* nexj/core/persistence/sql/etc/postgresql_create.sql */
 +
set sql_mode = concat(@@sql_mode, ',ANSI_QUOTES');
 +
</source>
 +
: After activating the connection, the database is locked.

Latest revision as of 14:46, 15 December 2010

PostgreSQL Adapter for NexJ - Working Inside Schema 'test'

Min NexJ Express | JSON_Adapter | Continuous Integration for NexJ Express Code | REST Server | PostgreSQL Adapter

Initializing the SQL environment

  • PostgreSQLAdapter.java
When a connection is first established, this initial SQL statement should execute in MySQL, which is not the case for PostgreSQL, so the implementation was removed from PostgreSQLAdapter.java:
/* MySQLAdapter.java */

public String getInitialSQL()
   {
      StringBuffer buf = new StringBuffer();

      buf.append("set sql_mode = concat(@@sql_mode, ',ANSI_QUOTES')"); // allow using doublequote when quoting column names in "CREATE TABLE" statements
      buf.append(";set optimizer_search_depth = 0"); // let DB automatically decide on how long it takes to examine plans, improves long planning sessions
      buf.append(";set max_sort_length = ").append
            (Math.max(MAX_VARCHAR_PRECISION, MAX_VARBINARY_PRECISION)); // set TEXT/BLOB minimum sorting length to be same as cutoff between varchar/text
      return buf.toString();
   }
  • postgresql_create.sql
This file was just created as a copy of mysql_create.sql, which was not the case for PostgreSQL again. So the line in the file is removed for now. The file itself may be deleted later, if there was no need for it. Name of the script file is being returned in getCreateEtcScriptName()' in PostgreSQLSchemaManager.java
/* nexj/core/persistence/sql/etc/postgresql_create.sql */
set sql_mode = concat(@@sql_mode, ',ANSI_QUOTES');
After activating the connection, the database is locked.