|
Moodle
2.2.1
http://www.collinsharper.com
|


This class generate SQL code to be used against PostgreSQL It extends XMLDBgenerator so everything can be overridden as needed to generate correct SQL.
Definition at line 37 of file postgres_sql_generator.php.
| addslashes | ( | $ | s | ) |
Reimplemented from sql_generator.
Definition at line 409 of file postgres_sql_generator.php.

| getAlterFieldSQL | ( | $ | xmldb_table, |
| $ | xmldb_field, | ||
| $ | skip_type_clause = NULL, |
||
| $ | skip_default_clause = NULL, |
||
| $ | skip_notnull_clause = NULL |
||
| ) |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to alter the field in the table PostgreSQL has some severe limits:
To store all the needed SQL commands
Get the normla names of the table and field
Take a look to field metadata
Detect if we are changing the type of the column
Detect if we are changing the precision
Detect if we are changing the decimals
Detect if we are changing the default
Detect if we are changing the nullability
Get the quoted name of the table and field
Decide if we have changed the column specs (type/precision/decimals)
if specs have changed, need to alter column
Always drop any exiting default before alter column (some type changes can cause casting error in default for column)
Drop default clause
Some castings must be performed explicity (mainly from text|char to numeric|integer)
If the default has changed or we have performed one change in specs
Add default clause
Only drop default if we haven't performed one specs change
Drop default clause
If the not null has changed
Return the results
Reimplemented from sql_generator.
Definition at line 211 of file postgres_sql_generator.php.


| getCheckConstraintsFromDB | ( | $ | xmldb_table, |
| $ | xmldb_field = null |
||
| ) |
Given one xmldb_table returns one array with all the check constraints in the table (fetched from DB) Optionally the function allows one xmldb_field to be specified in order to return only the check constraints belonging to one field. Each element contains the name of the constraint and its description If no check constraints are found, returns an empty array
TODO: Moodle 2.1 - drop in Moodle 2.1
Filter by the required field if specified
Lets clean a bit each constraint description, looking for the filtered field
description starts by $filter@ assume it's a constraint belonging to the field
Assign filtered results to the final results array
Reimplemented from sql_generator.
Definition at line 370 of file postgres_sql_generator.php.


| getCommentSQL | ( | $ | xmldb_table | ) |
Returns the code (in array) needed to add one comment to the table
Reimplemented from sql_generator.
Definition at line 160 of file postgres_sql_generator.php.

| getCreateDefaultSQL | ( | $ | xmldb_table, |
| $ | xmldb_field | ||
| ) |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to create its default (usually invoked from getModifyDefaultSQL()
Just a wrapper over the getAlterFieldSQL() function for PostgreSQL that is capable of handling defaults
Reimplemented from sql_generator.
Definition at line 344 of file postgres_sql_generator.php.

| getCreateTempTableSQL | ( | $ | xmldb_table | ) |
Given one correct xmldb_table, returns the SQL statements to create temporary table (inside one array)
Reimplemented from sql_generator.
Definition at line 84 of file postgres_sql_generator.php.

| getDropDefaultSQL | ( | $ | xmldb_table, |
| $ | xmldb_field | ||
| ) |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop its default (usually invoked from getModifyDefaultSQL()
Just a wrapper over the getAlterFieldSQL() function for PostgreSQL that is capable of handling defaults
Reimplemented from sql_generator.
Definition at line 354 of file postgres_sql_generator.php.

| getDropEnumSQL | ( | $ | xmldb_table, |
| $ | xmldb_field | ||
| ) |
Given one xmldb_table and one xmldb_field, return the SQL statements needed to drop its enum (usually invoked from getModifyEnumSQL()
TODO: Moodle 2.1 - drop in Moodle 2.1
Let's introspect to know the real name of the check constraint
Get the 1st (should be only one)
Extract the REAL name
All we have to do is to drop the check constraint
Constraint not found. Nothing to do
Reimplemented from sql_generator.
Definition at line 327 of file postgres_sql_generator.php.

| getDropTempTableSQL | ( | $ | xmldb_table | ) |
Given one correct xmldb_table and the new name, returns the SQL statements to drop it (inside one array)
Reimplemented from sql_generator.
Definition at line 95 of file postgres_sql_generator.php.

| getRenameTableExtraSQL | ( | $ | xmldb_table, |
| $ | newname | ||
| ) |
Returns the code (array of statements) needed to execute extra statements on table rename
Rename de sequence
Rename all the check constraints in the table
Drop the old constraint
Reimplemented from sql_generator.
Definition at line 171 of file postgres_sql_generator.php.

| static getReservedWords | ( | ) | [static] |
Returns an array of reserved words (lowercase) for this DB
This file contains the reserved words for PostgreSQL databases http://www.postgresql.org/docs/current/static/sql-keywords-appendix.html
Reimplemented from sql_generator.
Definition at line 490 of file postgres_sql_generator.php.
| getResetSequenceSQL | ( | $ | table | ) |
Reset a sequence to the id field of a table.
| string | $table | name of table or xmldb_table object |
Reimplemented from sql_generator.
Definition at line 66 of file postgres_sql_generator.php.
| getSequenceFromDB | ( | $ | xmldb_table | ) |
Given one xmldb_table returns one string with the sequence of the table in the table (fetched from DB) The sequence name for Postgres has one standard name convention: tablename_fieldname_seq so we just calculate it and confirm it's present in pg_class If no sequence is found, returns false
Reimplemented from sql_generator.
Definition at line 435 of file postgres_sql_generator.php.

| getTypeSQL | ( | $ | xmldb_type, |
| $ | xmldb_length = null, |
||
| $ | xmldb_decimals = null |
||
| ) |
Given one XMLDB Type, length and decimals, returns the DB proper SQL type
Reimplemented from sql_generator.
Definition at line 104 of file postgres_sql_generator.php.
| isNameInUse | ( | $ | object_name, |
| $ | type, | ||
| $ | table_name | ||
| ) |
Given one object name and it's type (pk, uk, fk, ck, ix, uix, seq, trg) return if such name is currently in use (true) or no (false) (invoked from getNameForObject()
Reimplemented from sql_generator.
Definition at line 455 of file postgres_sql_generator.php.
| $default_for_char = '' |
Reimplemented from sql_generator.
Definition at line 44 of file postgres_sql_generator.php.
| $enum_inline_code = false |
Definition at line 51 of file postgres_sql_generator.php.
| $number_type = 'NUMERIC' |
Only set values that are different from the defaults present in XMLDBgenerator.
Reimplemented from sql_generator.
Definition at line 41 of file postgres_sql_generator.php.
| $rename_index_sql = 'ALTER TABLE OLDINDEXNAME RENAME TO NEWINDEXNAME' |
Reimplemented from sql_generator.
Definition at line 53 of file postgres_sql_generator.php.
| $rename_key_sql = null |
Reimplemented from sql_generator.
Definition at line 56 of file postgres_sql_generator.php.
| $sequence_extra_code = false |
Reimplemented from sql_generator.
Definition at line 46 of file postgres_sql_generator.php.
| $sequence_name = 'BIGSERIAL' |
Reimplemented from sql_generator.
Definition at line 47 of file postgres_sql_generator.php.
| $sequence_name_small = 'SERIAL' |
Reimplemented from sql_generator.
Definition at line 48 of file postgres_sql_generator.php.
| $sequence_only = true |
Reimplemented from sql_generator.
Definition at line 49 of file postgres_sql_generator.php.
$std_strings = null [protected] |
Definition at line 59 of file postgres_sql_generator.php.
| $unsigned_allowed = false |
Reimplemented from sql_generator.
Definition at line 43 of file postgres_sql_generator.php.