Project

General

Profile

« Previous | Next » 

Revision 2662

schemas/functions.sql: _nullIf(): Fixed bug where wrong var name was used to retrieve type param. Reenabled _nullIf now that it's working.

View differences:

schemas/functions.sql
108 108
    LANGUAGE plpgsql IMMUTABLE
109 109
    AS $$
110 110
BEGIN
111
    IF new.result = 'str' THEN -- no cast needed
111
    IF new.type = 'str' THEN -- no cast needed
112 112
        new.result := (SELECT nullif(new.value, new."null"));
113 113
    -- Invalid value -> warning, but invalid null value -> error
114
    ELSIF new.result = 'float' THEN
114
    ELSIF new.type = 'float' THEN
115 115
        new.result := (SELECT nullif(functions."double precision"(new.value),
116 116
            new."null"::double precision));
117 117
    END IF;
......
223 223
SET default_with_oids = false;
224 224

  
225 225
--
226
-- Name: !disabled!_nullIf; Type: TABLE; Schema: functions; Owner: -; Tablespace: 
227
--
228

  
229
CREATE TABLE "!disabled!_nullIf" (
230
    result text,
231
    not_null_col boolean DEFAULT true NOT NULL,
232
    "null" text,
233
    type datatype DEFAULT 'str'::datatype NOT NULL,
234
    value text
235
);
236

  
237

  
238
--
239 226
-- Name: _alt; Type: TABLE; Schema: functions; Owner: -; Tablespace: 
240 227
--
241 228

  
......
288 275

  
289 276

  
290 277
--
278
-- Name: _nullIf; Type: TABLE; Schema: functions; Owner: -; Tablespace: 
279
--
280

  
281
CREATE TABLE "_nullIf" (
282
    result text,
283
    not_null_col boolean DEFAULT true NOT NULL,
284
    "null" text,
285
    type datatype DEFAULT 'str'::datatype NOT NULL,
286
    value text
287
);
288

  
289

  
290
--
291 291
-- Name: _alt_0; Type: INDEX; Schema: functions; Owner: -; Tablespace: 
292 292
--
293 293

  
......
466 466
-- Name: _nullIf_null; Type: INDEX; Schema: functions; Owner: -; Tablespace: 
467 467
--
468 468

  
469
CREATE INDEX "_nullIf_null" ON "!disabled!_nullIf" USING btree ("null");
469
CREATE INDEX "_nullIf_null" ON "_nullIf" USING btree ("null");
470 470

  
471 471

  
472 472
--
473 473
-- Name: _nullIf_type; Type: INDEX; Schema: functions; Owner: -; Tablespace: 
474 474
--
475 475

  
476
CREATE INDEX "_nullIf_type" ON "!disabled!_nullIf" USING btree (type);
476
CREATE INDEX "_nullIf_type" ON "_nullIf" USING btree (type);
477 477

  
478 478

  
479 479
--
480 480
-- Name: _nullIf_unique; Type: INDEX; Schema: functions; Owner: -; Tablespace: 
481 481
--
482 482

  
483
CREATE UNIQUE INDEX "_nullIf_unique" ON "!disabled!_nullIf" USING btree (ensure_not_null("null"), type, ensure_not_null(value));
483
CREATE UNIQUE INDEX "_nullIf_unique" ON "_nullIf" USING btree (ensure_not_null("null"), type, ensure_not_null(value));
484 484

  
485 485

  
486 486
--
487 487
-- Name: _nullIf_value; Type: INDEX; Schema: functions; Owner: -; Tablespace: 
488 488
--
489 489

  
490
CREATE INDEX "_nullIf_value" ON "!disabled!_nullIf" USING btree (value);
490
CREATE INDEX "_nullIf_value" ON "_nullIf" USING btree (value);
491 491

  
492 492

  
493 493
--
......
515 515
-- Name: _nullIf; Type: TRIGGER; Schema: functions; Owner: -
516 516
--
517 517

  
518
CREATE TRIGGER "_nullIf" BEFORE INSERT OR UPDATE ON "!disabled!_nullIf" FOR EACH ROW EXECUTE PROCEDURE "_nullIf"();
518
CREATE TRIGGER "_nullIf" BEFORE INSERT OR UPDATE ON "_nullIf" FOR EACH ROW EXECUTE PROCEDURE "_nullIf"();
519 519

  
520 520

  
521 521
--

Also available in: Unified diff