From c725b4f0feb2f44cc46cc67b3236d29078fe8716 Mon Sep 17 00:00:00 2001 From: El RIDO Date: Sat, 22 Jan 2022 21:29:39 +0100 Subject: [PATCH] handle 'IF NOT EXISTS' differently in OCI --- lib/Data/Database.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/Data/Database.php b/lib/Data/Database.php index f616a96..59c7017 100644 --- a/lib/Data/Database.php +++ b/lib/Data/Database.php @@ -792,10 +792,24 @@ class Database extends AbstractData "vizhash $dataType, " . "postdate INT$after_key )" ); - self::$_db->exec( - 'CREATE INDEX IF NOT EXISTS comment_parent ON ' . - self::_sanitizeIdentifier('comment') . '(pasteid)' - ); + if (self::$_type === 'oci') { + self::$_db->exec( + 'declare + already_exists exception; + columns_indexed exception; + pragma exception_init( already_exists, -955 ); + pragma exception_init(columns_indexed, -1408); + begin + execute immediate \'create index comment_parent on ' . self::_sanitizeIdentifier('comment') . ' (pasteid)\'; + exception + end' + ); + } else { + self::$_db->exec( + 'CREATE INDEX IF NOT EXISTS comment_parent ON ' . + self::_sanitizeIdentifier('comment') . '(pasteid)' + ); + } } /**