Esempio n. 1
0
    def execute(self, environment):
        result2 = jsonMode.createDatabase(self.name)
        result = avlMode.createDatabase(self.name)
        """
        0: insert
        1: error
        2: exists
        """

        if self.mode == None:
            self.mode = 1

        if result == 0:
            Struct.createDatabase(self.name, self.mode, self.owner)
            report = "Base de datos: " + self.name + " insertada."
        elif result == 1:
            instruction.syntaxPostgreSQL.append("Error: XX000: Error interno")
            report = "Error al insertar la base de datos: " + self.name
        elif result == 2 and self.replace:
            Struct.replaceDatabase(self.name, self.mode, self.owner)
            report = "Base de datos '" + self.name + " ' reemplazada."
        elif result == 2 and self.exists:
            report = "Base de datos no insertada, " + self.name + " ya existe."
        else:
            instruction.semanticErrors.append([
                "La base de datos " + str(self.name) + " ya existe", self.row
            ])
            instruction.syntaxPostgreSQL.append(
                "Error: 42P04: La base de datos  " + str(self.name) +
                " ya existe")
            report = "Error: La base de datos ya existe"
        return report
Esempio n. 2
0
    def execute(self, environment):
        """
        0: insert
        1: error
        2: exists
        """

        if self.mode == None:
            self.mode = 'avl'
        elif self.mode == 1:
            self.mode = 'avl'
        elif self.mode == 2:
            self.mode = 'b'
        elif self.mode == 3:
            self.mode = 'bplus'
        elif self.mode == 4:
            self.mode = 'dict'
        elif self.mode == 5:
            self.mode = 'isam'
        elif self.mode == 6:
            self.mode = 'json'
        elif self.mode == 7:
            self.mode = 'hash'

        result = storage.createDatabase(self.name, self.mode)
        if result == 0:
            Struct.createDatabase(self.name, self.mode, self.owner)
            report = "Base de datos: " + self.name + " insertada."
        elif result == 1:
            instruction.syntaxPostgreSQL.append("Error: XX000: Error interno")
            report = "Error al insertar la base de datos: " + self.name
        elif result == 2 and self.replace:
            Struct.replaceDatabase(self.name, self.mode, self.owner)
            report = "Base de datos '" + self.name + " ' reemplazada."
        elif result == 2 and self.exists:
            report = "Base de datos no insertada, " + self.name + " ya existe."
        else:
            instruction.semanticErrors.append([
                "La base de datos " + str(self.name) + " ya existe", self.row
            ])
            instruction.syntaxPostgreSQL.append(
                "Error: 42P04: La base de datos  " + str(self.name) +
                " ya existe")
            report = "Error: La base de datos ya existe"
        return report