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

From CDOT Wiki
Jump to: navigation, search
(Initializing the SQL environment)
Line 3: Line 3:
  
 
== Initializing the SQL environment==
 
== Initializing the SQL environment==
* ''PostgreSQLAdapter.java''
+
* '''''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:
 
: 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:
 
::
 
::
Line 20: Line 20:
 
   }
 
   }
 
</source>
 
</source>
* ''postgresql_create.sql''
+
* '''''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'''
 
: 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'''
 
::
 
::

Revision as of 14:48, 15 December 2010

PostgreSQL Adapter for NexJ - Working Inside Schema 'test'

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.