Skip to content

Commit

Permalink
Sync sql install and samples files.
Browse files Browse the repository at this point in the history
* Mysql Samples: add helpful comments
* Postgrsql install: add comments, move down/up a few tables in order to syns with mysql install
* Postgrsql samples: add comments and sync with mysql samples
* Mssql: sync with postgresql install and samples, replace all [] quotes to "".
* Mssql: replace INSERT ... SELECT UNION ALL ... to insert with values INSERT ... VALUES (...), (...);
  • Loading branch information
Tomasz Narloch committed Feb 24, 2017
1 parent cd8ae42 commit 4c32beb
Show file tree
Hide file tree
Showing 18 changed files with 7,798 additions and 9,068 deletions.
49 changes: 39 additions & 10 deletions installation/sql/mysql/sample_blog.sql

Large diffs are not rendered by default.

59 changes: 47 additions & 12 deletions installation/sql/mysql/sample_brochure.sql

Large diffs are not rendered by default.

72 changes: 58 additions & 14 deletions installation/sql/mysql/sample_data.sql

Large diffs are not rendered by default.

92 changes: 75 additions & 17 deletions installation/sql/mysql/sample_learn.sql

Large diffs are not rendered by default.

105 changes: 85 additions & 20 deletions installation/sql/mysql/sample_testing.sql

Large diffs are not rendered by default.

665 changes: 368 additions & 297 deletions installation/sql/postgresql/joomla.sql

Large diffs are not rendered by default.

393 changes: 202 additions & 191 deletions installation/sql/postgresql/sample_blog.sql

Large diffs are not rendered by default.

201 changes: 201 additions & 0 deletions installation/sql/postgresql/sample_brochure.sql

Large diffs are not rendered by default.

399 changes: 230 additions & 169 deletions installation/sql/postgresql/sample_data.sql

Large diffs are not rendered by default.

1,657 changes: 839 additions & 818 deletions installation/sql/postgresql/sample_learn.sql

Large diffs are not rendered by default.

1,731 changes: 881 additions & 850 deletions installation/sql/postgresql/sample_testing.sql

Large diffs are not rendered by default.

4,827 changes: 2,270 additions & 2,557 deletions installation/sql/sqlazure/joomla.sql

Large diffs are not rendered by default.

583 changes: 222 additions & 361 deletions installation/sql/sqlazure/sample_blog.sql

Large diffs are not rendered by default.

565 changes: 233 additions & 332 deletions installation/sql/sqlazure/sample_brochure.sql

Large diffs are not rendered by default.

544 changes: 251 additions & 293 deletions installation/sql/sqlazure/sample_data.sql

Large diffs are not rendered by default.

2,390 changes: 876 additions & 1,514 deletions installation/sql/sqlazure/sample_learn.sql

Large diffs are not rendered by default.

2,448 changes: 909 additions & 1,539 deletions installation/sql/sqlazure/sample_testing.sql

Large diffs are not rendered by default.

86 changes: 12 additions & 74 deletions libraries/joomla/database/driver/sqlsrv.php
Expand Up @@ -148,6 +148,9 @@ public function connect()

// Set charactersets.
$this->utf = $this->setUtf();

// Set QUOTED_IDENTIFIER always ON
sqlsrv_query($this->connection, 'SET QUOTED_IDENTIFIER ON');
}

/**
Expand Down Expand Up @@ -710,93 +713,28 @@ public function execute()
*/
public function replacePrefix($query, $prefix = '#__')
{
$startPos = 0;
$literal = '';

$query = trim($query);
$n = strlen($query);

while ($startPos < $n)
if (strpos($query, "'"))
{
$ip = strpos($query, $prefix, $startPos);

if ($ip === false)
{
break;
}

$j = strpos($query, "N'", $startPos);
$k = strpos($query, '"', $startPos);

if (($k !== false) && (($k < $j) || ($j === false)))
{
$quoteChar = '"';
$j = $k;
}
else
{
$quoteChar = "'";
}
$parts = explode("'", $query);

if ($j === false)
for ($nIndex = 0, $size = count($parts); $nIndex < $size; $nIndex = $nIndex + 2)
{
$j = $n;
}

$literal .= str_replace($prefix, $this->tablePrefix, substr($query, $startPos, $j - $startPos));
$startPos = $j;

$j = $startPos + 1;

if ($j >= $n)
{
break;
}

// Quote comes first, find end of quote
while (true)
{
$k = strpos($query, $quoteChar, $j);
$escaped = false;

if ($k === false)
if (strpos($parts[$nIndex], $prefix) !== false)
{
break;
$parts[$nIndex] = str_replace($prefix, $this->tablePrefix, $parts[$nIndex]);
}

$l = $k - 1;

while ($l >= 0 && $query{$l} == '\\')
{
$l--;
$escaped = !$escaped;
}

if ($escaped)
{
$j = $k + 1;
continue;
}

break;
}

if ($k === false)
{
// Error in the query - no end quote; ignore it
break;
}

$literal .= substr($query, $startPos, $k - $startPos + 1);
$startPos = $k + 1;
$query = implode("'", $parts);
}

if ($startPos < $n)
else
{
$literal .= substr($query, $startPos, $n - $startPos);
$query = str_replace($prefix, $this->tablePrefix, $query);
}

return $literal;
return $query;
}

/**
Expand Down

0 comments on commit 4c32beb

Please sign in to comment.