Correct stable function in test
authorPallavi Sontakke <[email protected]>
Wed, 20 Jul 2016 09:42:04 +0000 (15:12 +0530)
committerPallavi Sontakke <[email protected]>
Wed, 20 Jul 2016 09:42:04 +0000 (15:12 +0530)
src/test/regress/expected/xl_functions.out
src/test/regress/sql/xl_functions.sql

index 6133401b1b55a861a95ec762d40d906f38a64f2b..d33919cb0d232a1494d5c47218f38bcd96bcfe8c 100644 (file)
@@ -21,23 +21,19 @@ SELECT * from xl_funct2;
 
 --STABLE functions
 -- checking STABLE function in DEFAULT of non-distribution column
-create table xl_users (userid text, seq int, name text);
-insert into xl_users values ('id',1,'pallavi');
-insert into xl_users values ('id2',2,'xyz');
-create or replace function xl_get_first_user() returns text as
-$$ SELECT name FROM xl_users ORDER BY userid LIMIT 1; $$
-language sql stable;
+create function xl_nochange(text) returns text
+  as 'select $1 limit 1' language sql stable;
 CREATE TABLE xl_funct3(
        a integer,
        b integer,
-       c text DEFAULT xl_get_first_user()
+       c text DEFAULT xl_nochange('hello')
 ) DISTRIBUTE BY HASH(a);
 INSERT INTO xl_funct3(a,b) VALUES (1,2);--c should be pallavi
 INSERT INTO xl_funct3(a,b,c) VALUES (3,4,'qwerty');-- c should be qwerty
 SELECT * from xl_funct3;
- a | b |    c    
----+---+---------
- 1 | 2 | pallavi
+ a | b |   c    
+---+---+--------
+ 1 | 2 | hello
  3 | 4 | qwerty
 (2 rows)
 
@@ -45,15 +41,15 @@ SELECT * from xl_funct3;
 CREATE TABLE xl_funct4(
        a integer,
        b integer,
-       c text DEFAULT xl_get_first_user()
+       c text DEFAULT xl_nochange('hello')
 ) DISTRIBUTE BY HASH(c);
 INSERT INTO xl_funct4(a,b) VALUES (1,2);--c should be pallavi
 INSERT INTO xl_funct4(a,b,c) VALUES (3,4,'qwerty');-- c should be qwerty
 SELECT * from xl_funct4;
- a | b |    c    
----+---+---------
- 1 | 2 | pallavi
+ a | b |   c    
+---+---+--------
  3 | 4 | qwerty
+ 1 | 2 | hello
 (2 rows)
 
 --VOLATILE functions
@@ -113,7 +109,6 @@ DROP SEQUENCE xl_INSERT_SEQ;
 DROP TABLE xl_funct2;
 DROP TABLE xl_funct3;
 DROP TABLE xl_funct4;
-DROP TABLE xl_users;
-DROP FUNCTION xl_get_first_user();
+DROP FUNCTION xl_nochange(text);
 DROP TABLE xl_funct5;
 DROP FUNCTION xl_get_curr_decade();
index 2b485c16fda8030d5c880d1a4c5f7952a8290597..59b1f9e615750c4387c5536f53e84b8b3ef93ab9 100755 (executable)
@@ -20,18 +20,13 @@ SELECT * from xl_funct2;
 
 --STABLE functions
 -- checking STABLE function in DEFAULT of non-distribution column
-create table xl_users (userid text, seq int, name text);
-insert into xl_users values ('id',1,'pallavi');
-insert into xl_users values ('id2',2,'xyz');
-
-create or replace function xl_get_first_user() returns text as
-$$ SELECT name FROM xl_users ORDER BY userid LIMIT 1; $$
-language sql stable;
+create function xl_nochange(text) returns text
+  as 'select $1 limit 1' language sql stable;
 
 CREATE TABLE xl_funct3(
        a integer,
        b integer,
-       c text DEFAULT xl_get_first_user()
+       c text DEFAULT xl_nochange('hello')
 ) DISTRIBUTE BY HASH(a);
 
 INSERT INTO xl_funct3(a,b) VALUES (1,2);--c should be pallavi
@@ -43,7 +38,7 @@ SELECT * from xl_funct3;
 CREATE TABLE xl_funct4(
        a integer,
        b integer,
-       c text DEFAULT xl_get_first_user()
+       c text DEFAULT xl_nochange('hello')
 ) DISTRIBUTE BY HASH(c);
 
 INSERT INTO xl_funct4(a,b) VALUES (1,2);--c should be pallavi
@@ -101,7 +96,6 @@ DROP SEQUENCE xl_INSERT_SEQ;
 DROP TABLE xl_funct2;
 DROP TABLE xl_funct3;
 DROP TABLE xl_funct4;
-DROP TABLE xl_users;
-DROP FUNCTION xl_get_first_user();
+DROP FUNCTION xl_nochange(text);
 DROP TABLE xl_funct5;
 DROP FUNCTION xl_get_curr_decade();