-- returns the number of locks released
CREATEFUNCTION UnlockRows(text)
RETURNS int
- AS '
+ AS $$
DECLARE
ret int;
BEGIN
IF NOT LongTransactionsEnabled() THEN
- RAISE EXCEPTION ''Long transaction support disabled, use EnableLongTransaction() to enable.'';
+ RAISE EXCEPTION 'Long transaction support disabled, use EnableLongTransaction() to enable.';
END IF;
- EXECUTE ''DELETE FROM authorization_table where authid = '' ||
+ EXECUTE 'DELETE FROM authorization_table where authid = ' ||
quote_literal($1);
GET DIAGNOSTICS ret = ROW_COUNT;
RETURN ret;
END;
-'
+$$
LANGUAGE 'plpgsql' _VOLATILE_STRICT;
-- LockRow([schema], table, rowid, auth, [expires])
-- Returns 1 if successfully obtained the lock, 0 otherwise
CREATEFUNCTION LockRow(text, text, text, text, timestamp)
RETURNS int
- AS '
+ AS $$
DECLARE
myschema alias for $1;
mytable alias for $2;
BEGIN
IF NOT LongTransactionsEnabled() THEN
- RAISE EXCEPTION ''Long transaction support disabled, use EnableLongTransaction() to enable.'';
+ RAISE EXCEPTION 'Long transaction support disabled, use EnableLongTransaction() to enable.';
END IF;
- EXECUTE ''DELETE FROM authorization_table WHERE expires < now()'';
+ EXECUTE 'DELETE FROM authorization_table WHERE expires < now()';
SELECT c.oid INTO mytoid FROM pg_class c, pg_namespace n
WHERE c.relname = mytable
AND c.relnamespace = n.oid
AND n.nspname = myschema;
- -- RAISE NOTICE ''toid: %'', mytoid;
+ -- RAISE NOTICE 'toid: %', mytoid;
FOR myrec IN SELECT * FROM authorization_table WHERE
toid = mytoid AND rid = myrid
END IF;
END LOOP;
- EXECUTE ''INSERT INTO authorization_table VALUES (''||
- quote_literal(mytoid::text)||'',''||quote_literal(myrid)||
- '',''||quote_literal(expires::text)||
- '',''||quote_literal(authid) ||'')'';
+ EXECUTE 'INSERT INTO authorization_table VALUES ('||
+ quote_literal(mytoid::text)||','||quote_literal(myrid)||
+ ','||quote_literal(expires::text)||
+ ','||quote_literal(authid) ||')';
GET DIAGNOSTICS ret = ROW_COUNT;
RETURN ret;
-END;'
+END;
+$$
LANGUAGE 'plpgsql' _VOLATILE_STRICT;
-- LockRow(schema, table, rid, authid);
CREATEFUNCTION LockRow(text, text, text, text)
RETURNS int
AS
-'SELECT LockRow($1, $2, $3, $4, now()::timestamp+''1:00'');'
+$$ SELECT LockRow($1, $2, $3, $4, now()::timestamp+'1:00'); $$
LANGUAGE 'sql' _VOLATILE_STRICT;
-- LockRow(table, rid, authid);
CREATEFUNCTION LockRow(text, text, text)
RETURNS int
AS
-'SELECT LockRow(current_schema(), $1, $2, $3, now()::timestamp+''1:00'');'
+$$ SELECT LockRow(current_schema(), $1, $2, $3, now()::timestamp+'1:00'); $$
LANGUAGE 'sql' _VOLATILE_STRICT;
-- LockRow(schema, table, rid, expires);
CREATEFUNCTION LockRow(text, text, text, timestamp)
RETURNS int
AS
-'SELECT LockRow(current_schema(), $1, $2, $3, $4);'
+$$ SELECT LockRow(current_schema(), $1, $2, $3, $4); $$
LANGUAGE 'sql' _VOLATILE_STRICT;
CREATEFUNCTION AddAuth(text)
RETURNS BOOLEAN
- AS '
+ AS $$
DECLARE
lockid alias for $1;
okay boolean;
BEGIN
-- check to see if table exists
-- if not, CREATE TEMP TABLE mylock (transid xid, lockcode text)
- okay := ''f'';
- FOR myrec IN SELECT * FROM pg_class WHERE relname = ''temp_lock_have_table'' LOOP
- okay := ''t'';
+ okay := 'f';
+ FOR myrec IN SELECT * FROM pg_class WHERE relname = 'temp_lock_have_table' LOOP
+ okay := 't';
END LOOP;
- IF (okay <> ''t'') THEN
+ IF (okay <> 't') THEN
CREATE TEMP TABLE temp_lock_have_table (transid xid, lockcode text);
-- this will only work from pgsql7.4 up
-- ON COMMIT DELETE ROWS;
END IF;
-- INSERT INTO mylock VALUES ( $1)
--- EXECUTE ''INSERT INTO temp_lock_have_table VALUES ( ''||
--- quote_literal(getTransactionID()) || '','' ||
--- quote_literal(lockid) ||'')'';
+-- EXECUTE 'INSERT INTO temp_lock_have_table VALUES ( '||
+-- quote_literal(getTransactionID()) || ',' ||
+-- quote_literal(lockid) ||')';
INSERT INTO temp_lock_have_table VALUES (getTransactionID(), lockid);
RETURN true::boolean;
END;
-'
+$$
LANGUAGE PLPGSQL;
--
CREATEFUNCTION CheckAuth(text, text, text)
RETURNS INT
- AS '
+ AS $$
DECLARE
schema text;
BEGIN
IF NOT LongTransactionsEnabled() THEN
- RAISE EXCEPTION ''Long transaction support disabled, use EnableLongTransaction() to enable.'';
+ RAISE EXCEPTION 'Long transaction support disabled, use EnableLongTransaction() to enable.';
END IF;
- if ( $1 != '''' ) THEN
+ if ( $1 != '' ) THEN
schema = $1;
ELSE
SELECT current_schema() into schema;
-- TODO: check for an already existing trigger ?
- EXECUTE ''CREATE TRIGGER check_auth BEFORE UPDATE OR DELETE ON ''
- || quote_ident(schema) || ''.'' || quote_ident($2)
- ||'' FOR EACH ROW EXECUTE PROCEDURE CheckAuthTrigger(''
- || quote_literal($3) || '')'';
+ EXECUTE 'CREATE TRIGGER check_auth BEFORE UPDATE OR DELETE ON '
+ || quote_ident(schema) || '.' || quote_ident($2)
+ ||' FOR EACH ROW EXECUTE PROCEDURE CheckAuthTrigger('
+ || quote_literal($3) || ')';
RETURN 0;
END;
-'
+$$
LANGUAGE 'plpgsql';
-- CheckAuth(<table>, <ridcolumn>)
CREATEFUNCTION CheckAuth(text, text)
RETURNS INT
AS
- 'SELECT CheckAuth('''', $1, $2)'
+ $$ SELECT CheckAuth('', $1, $2) $$
LANGUAGE 'SQL';
CREATEFUNCTION CheckAuthTrigger()
--
CREATEFUNCTION EnableLongTransactions()
RETURNS TEXT
- AS '
+ AS $$
DECLARE
"query" text;
exists bool;
BEGIN
- exists = ''f'';
- FOR rec IN SELECT * FROM pg_class WHERE relname = ''authorization_table''
+ exists = 'f';
+ FOR rec IN SELECT * FROM pg_class WHERE relname = 'authorization_table'
LOOP
- exists = ''t'';
+ exists = 't';
END LOOP;
IF NOT exists
THEN
- "query" = ''CREATE TABLE authorization_table (
+ "query" = 'CREATE TABLE authorization_table (
toid oid, -- table oid
rid text, -- row id
expires timestamp,
authid text
- )'';
+ )';
EXECUTE "query";
END IF;
- exists = ''f'';
- FOR rec IN SELECT * FROM pg_class WHERE relname = ''authorized_tables''
+ exists = 'f';
+ FOR rec IN SELECT * FROM pg_class WHERE relname = 'authorized_tables'
LOOP
- exists = ''t'';
+ exists = 't';
END LOOP;
IF NOT exists THEN
- "query" = ''CREATE VIEW authorized_tables AS '' ||
- ''SELECT '' ||
- ''n.nspname as schema, '' ||
- ''c.relname as table, trim('' ||
- quote_literal(chr(92) || ''000'') ||
- '' from t.tgargs) as id_column '' ||
- ''FROM pg_trigger t, pg_class c, pg_proc p '' ||
- '', pg_namespace n '' ||
- ''WHERE p.proname = '' || quote_literal(''checkauthtrigger'') ||
- '' AND c.relnamespace = n.oid'' ||
- '' AND t.tgfoid = p.oid and t.tgrelid = c.oid'';
+ "query" = 'CREATE VIEW authorized_tables AS ' ||
+ 'SELECT ' ||
+ 'n.nspname as schema, ' ||
+ 'c.relname as table, trim(' ||
+ quote_literal(chr(92) || '000') ||
+ ' from t.tgargs) as id_column ' ||
+ 'FROM pg_trigger t, pg_class c, pg_proc p ' ||
+ ', pg_namespace n ' ||
+ 'WHERE p.proname = ' || quote_literal('checkauthtrigger') ||
+ ' AND c.relnamespace = n.oid' ||
+ ' AND t.tgfoid = p.oid and t.tgrelid = c.oid';
EXECUTE "query";
END IF;
- RETURN ''Long transactions support enabled'';
+ RETURN 'Long transactions support enabled';
END;
-'
+$$
LANGUAGE 'plpgsql';
--
--
CREATEFUNCTION LongTransactionsEnabled()
RETURNS bool
-AS '
+AS $$
DECLARE
rec RECORD;
BEGIN
- FOR rec IN SELECT oid FROM pg_class WHERE relname = ''authorized_tables''
+ FOR rec IN SELECT oid FROM pg_class WHERE relname = 'authorized_tables'
LOOP
- return ''t'';
+ return 't';
END LOOP;
- return ''f'';
+ return 'f';
END;
-'
+$$
LANGUAGE 'plpgsql';
--
--
CREATEFUNCTION DisableLongTransactions()
RETURNS TEXT
- AS '
+ AS $$
DECLARE
rec RECORD;
--
FOR rec IN
SELECT c.relname, t.tgname, t.tgargs FROM pg_trigger t, pg_class c, pg_proc p
- WHERE p.proname = ''checkauthtrigger'' and t.tgfoid = p.oid and t.tgrelid = c.oid
+ WHERE p.proname = 'checkauthtrigger' and t.tgfoid = p.oid and t.tgrelid = c.oid
LOOP
- EXECUTE ''DROP TRIGGER '' || quote_ident(rec.tgname) ||
- '' ON '' || quote_ident(rec.relname);
+ EXECUTE 'DROP TRIGGER ' || quote_ident(rec.tgname) ||
+ ' ON ' || quote_ident(rec.relname);
END LOOP;
--
-- Drop the authorization_table table
--
- FOR rec IN SELECT * FROM pg_class WHERE relname = ''authorization_table'' LOOP
+ FOR rec IN SELECT * FROM pg_class WHERE relname = 'authorization_table' LOOP
DROP TABLE authorization_table;
END LOOP;
--
-- Drop the authorized_tables view
--
- FOR rec IN SELECT * FROM pg_class WHERE relname = ''authorized_tables'' LOOP
+ FOR rec IN SELECT * FROM pg_class WHERE relname = 'authorized_tables' LOOP
DROP VIEW authorized_tables;
END LOOP;
- RETURN ''Long transactions support disabled'';
+ RETURN 'Long transactions support disabled';
END;
-'
+$$
LANGUAGE 'plpgsql';
---------------------------------------------------------------
-----------------------------------------------------------------------
-- Deprecation in 1.2.3
CREATEFUNCTION find_extent(text,text,text) RETURNS box2d AS
-'
+$$
DECLARE
schemaname alias for $1;
tablename alias for $2;
myrec RECORD;
BEGIN
- FOR myrec IN EXECUTE ''SELECT extent("''||columnname||''") FROM "''||schemaname||''"."''||tablename||''"'' LOOP
+ FOR myrec IN EXECUTE 'SELECT extent("' || columnname || '") FROM "' || schemaname || '"."' || tablename || '"' LOOP
return myrec.extent;
END LOOP;
END;
-'
+$$
LANGUAGE 'plpgsql' _IMMUTABLE_STRICT; -- WITH (isstrict);
-- Availability: 1.2.2
CREATEFUNCTION ST_find_extent(text,text,text) RETURNS box2d AS
-'
+$$
DECLARE
schemaname alias for $1;
tablename alias for $2;
myrec RECORD;
BEGIN
- FOR myrec IN EXECUTE ''SELECT extent("''||columnname||''") FROM "''||schemaname||''"."''||tablename||''"'' LOOP
+ FOR myrec IN EXECUTE 'SELECT extent("' || columnname || '") FROM "' || schemaname || '"."' || tablename || '"' LOOP
return myrec.extent;
END LOOP;
END;
-'
+$$
LANGUAGE 'plpgsql' _IMMUTABLE_STRICT; -- WITH (isstrict);
-----------------------------------------------------------------------
-- Deprecation in 1.2.3
CREATEFUNCTION find_extent(text,text) RETURNS box2d AS
-'
+$$
DECLARE
tablename alias for $1;
columnname alias for $2;
myrec RECORD;
BEGIN
- FOR myrec IN EXECUTE ''SELECT extent("''||columnname||''") FROM "''||tablename||''"'' LOOP
+ FOR myrec IN EXECUTE 'SELECT extent("' || columnname || '") FROM "' || tablename || '"' LOOP
return myrec.extent;
END LOOP;
END;
-'
+$$
LANGUAGE 'plpgsql' _IMMUTABLE_STRICT; -- WITH (isstrict);
-- Availability: 1.2.2
CREATEFUNCTION ST_find_extent(text,text) RETURNS box2d AS
-'
+$$
DECLARE
tablename alias for $1;
columnname alias for $2;
myrec RECORD;
BEGIN
- FOR myrec IN EXECUTE ''SELECT extent("''||columnname||''") FROM "''||tablename||''"'' LOOP
+ FOR myrec IN EXECUTE 'SELECT extent("' || columnname || '") FROM "' || tablename || '"' LOOP
return myrec.extent;
END LOOP;
END;
-'
+$$
LANGUAGE 'plpgsql' _IMMUTABLE_STRICT; -- WITH (isstrict);
-------------------------------------------------------------------
-----------------------------------------------------------------------
CREATEFUNCTION rename_geometry_table_constraints() RETURNS text
AS
-'
-SELECT ''rename_geometry_table_constraint() is obsoleted''::text
-'
+$$
+SELECT 'rename_geometry_table_constraint() is obsoleted'::text
+$$
LANGUAGE 'SQL' _IMMUTABLE;
-----------------------------------------------------------------------
-----------------------------------------------------------------------
CREATEFUNCTION fix_geometry_columns() RETURNS text
AS
-'
+$$
DECLARE
mislinked record;
result text;
FROM pg_namespace n, pg_class c, pg_attribute a,
pg_constraint sridcheck, pg_constraint typecheck
WHERE ( f_table_schema is NULL
- OR f_table_schema = ''''
+ OR f_table_schema = ''
OR f_table_schema NOT IN (
SELECT nspname::varchar
FROM pg_namespace nn, pg_class cc, pg_attribute aa
AND f_geometry_column::name = a.attname
AND sridcheck.conrelid = c.oid
- AND sridcheck.consrc LIKE ''(srid(% = %)''
- AND sridcheck.consrc ~ textcat('' = '', srid::text)
+ AND sridcheck.consrc LIKE '(srid(% = %)'
+ AND sridcheck.consrc ~ textcat(' = ', srid::text)
AND typecheck.conrelid = c.oid
AND typecheck.consrc LIKE
- ''((geometrytype(%) = ''''%''''::text) OR (% IS NULL))''
- AND typecheck.consrc ~ textcat('' = '''''', type::text)
+ '((geometrytype(%) = ''%''::text) OR (% IS NULL))'
+ AND typecheck.consrc ~ textcat(' = ''', type::text)
AND NOT EXISTS (
SELECT oid FROM geometry_columns gc
GET DIAGNOSTICS foundschema = ROW_COUNT;
-- no linkage to system table needed
- return ''fixed:''||foundschema::text;
+ return 'fixed:'||foundschema::text;
END;
-'
+$$
LANGUAGE 'plpgsql' _VOLATILE;
-----------------------------------------------------------------------
-- it and probe.
-----------------------------------------------------------------------
CREATEFUNCTION probe_geometry_columns() RETURNS text AS
-'
+$$
DECLARE
inserted integer;
oldcount integer;
pg_namespace n,
pg_constraint sridcheck, pg_constraint typecheck
- WHERE t.typname = ''geometry''
+ WHERE t.typname = 'geometry'
AND a.atttypid = t.oid
AND a.attrelid = c.oid
AND c.relnamespace = n.oid
AND sridcheck.connamespace = n.oid
AND typecheck.connamespace = n.oid
AND sridcheck.conrelid = c.oid
- AND sridcheck.consrc LIKE ''(srid(''||a.attname||'') = %)''
+ AND sridcheck.consrc LIKE '(srid('||a.attname||') = %)'
AND typecheck.conrelid = c.oid
AND typecheck.consrc LIKE
- ''((geometrytype(''||a.attname||'') = ''''%''''::text) OR (% IS NULL))''
+ '((geometrytype('||a.attname||') = ''%''::text) OR (% IS NULL))'
;
INSERT INTO geometry_columns SELECT
- ''''::varchar as f_table_catalogue,
+ ''::varchar as f_table_catalogue,
n.nspname::varchar as f_table_schema,
c.relname::varchar as f_table_name,
a.attname::varchar as f_geometry_column,
2 as coord_dimension,
- trim(both '' =)'' from substr(sridcheck.consrc,
- strpos(sridcheck.consrc, ''='')))::integer as srid,
- trim(both '' =)'''''' from substr(typecheck.consrc,
- strpos(typecheck.consrc, ''=''),
- strpos(typecheck.consrc, ''::'')-
- strpos(typecheck.consrc, ''='')
+ trim(both ' =)' from substr(sridcheck.consrc,
+ strpos(sridcheck.consrc, '=')))::integer as srid,
+ trim(both ' =)''' from substr(typecheck.consrc,
+ strpos(typecheck.consrc, '='),
+ strpos(typecheck.consrc, '::')-
+ strpos(typecheck.consrc, '=')
))::varchar as type
FROM pg_class c, pg_attribute a, pg_type t,
pg_namespace n,
pg_constraint sridcheck, pg_constraint typecheck
- WHERE t.typname = ''geometry''
+ WHERE t.typname = 'geometry'
AND a.atttypid = t.oid
AND a.attrelid = c.oid
AND c.relnamespace = n.oid
AND sridcheck.connamespace = n.oid
AND typecheck.connamespace = n.oid
AND sridcheck.conrelid = c.oid
- AND sridcheck.consrc LIKE ''(srid(''||a.attname||'') = %)''
+ AND sridcheck.consrc LIKE '(srid('||a.attname||') = %)'
AND typecheck.conrelid = c.oid
AND typecheck.consrc LIKE
- ''((geometrytype(''||a.attname||'') = ''''%''''::text) OR (% IS NULL))''
+ '((geometrytype('||a.attname||') = ''%''::text) OR (% IS NULL))'
AND NOT EXISTS (
SELECT oid FROM geometry_columns gc
stale = 0;
END IF;
- RETURN ''probed:''||probed::text||
- '' inserted:''||inserted::text||
- '' conflicts:''||(probed-inserted)::text||
- '' stale:''||stale::text;
+ RETURN 'probed:'||probed::text||
+ ' inserted:'||inserted::text||
+ ' conflicts:'||(probed-inserted)::text||
+ ' stale:'||stale::text;
END
-'
+$$
LANGUAGE 'plpgsql' _VOLATILE;
-----------------------------------------------------------------------
CREATEFUNCTION AddGeometryColumn(varchar,varchar,varchar,varchar,integer,varchar,integer)
RETURNS text
AS
-'
+$$
DECLARE
catalog_name alias for $1;
schema_name alias for $2;
BEGIN
- IF ( not ( (new_type =''GEOMETRY'') or
- (new_type =''GEOMETRYCOLLECTION'') or
- (new_type =''POINT'') or
- (new_type =''MULTIPOINT'') or
- (new_type =''POLYGON'') or
- (new_type =''MULTIPOLYGON'') or
- (new_type =''LINESTRING'') or
- (new_type =''MULTILINESTRING'') or
- (new_type =''GEOMETRYCOLLECTIONM'') or
- (new_type =''POINTM'') or
- (new_type =''MULTIPOINTM'') or
- (new_type =''POLYGONM'') or
- (new_type =''MULTIPOLYGONM'') or
- (new_type =''LINESTRINGM'') or
- (new_type =''MULTILINESTRINGM'') or
- (new_type = ''CIRCULARSTRING'') or
- (new_type = ''CIRCULARSTRINGM'') or
- (new_type = ''COMPOUNDCURVE'') or
- (new_type = ''COMPOUNDCURVEM'') or
- (new_type = ''CURVEPOLYGON'') or
- (new_type = ''CURVEPOLYGONM'') or
- (new_type = ''MULTICURVE'') or
- (new_type = ''MULTICURVEM'') or
- (new_type = ''MULTISURFACE'') or
- (new_type = ''MULTISURFACEM'')) )
+ IF ( not ( (new_type ='GEOMETRY') or
+ (new_type ='GEOMETRYCOLLECTION') or
+ (new_type ='POINT') or
+ (new_type ='MULTIPOINT') or
+ (new_type ='POLYGON') or
+ (new_type ='MULTIPOLYGON') or
+ (new_type ='LINESTRING') or
+ (new_type ='MULTILINESTRING') or
+ (new_type ='GEOMETRYCOLLECTIONM') or
+ (new_type ='POINTM') or
+ (new_type ='MULTIPOINTM') or
+ (new_type ='POLYGONM') or
+ (new_type ='MULTIPOLYGONM') or
+ (new_type ='LINESTRINGM') or
+ (new_type ='MULTILINESTRINGM') or
+ (new_type = 'CIRCULARSTRING') or
+ (new_type = 'CIRCULARSTRINGM') or
+ (new_type = 'COMPOUNDCURVE') or
+ (new_type = 'COMPOUNDCURVEM') or
+ (new_type = 'CURVEPOLYGON') or
+ (new_type = 'CURVEPOLYGONM') or
+ (new_type = 'MULTICURVE') or
+ (new_type = 'MULTICURVEM') or
+ (new_type = 'MULTISURFACE') or
+ (new_type = 'MULTISURFACEM')) )
THEN
- RAISE EXCEPTION ''Invalid type name - valid ones are:
+ RAISE EXCEPTION 'Invalid type name - valid ones are:
GEOMETRY, GEOMETRYCOLLECTION, POINT,
MULTIPOINT, POLYGON, MULTIPOLYGON,
LINESTRING, MULTILINESTRING,
MULTIPOINTM, POLYGONM, MULTIPOLYGONM,
LINESTRINGM, MULTILINESTRINGM
CIRCULARSTRINGM, COMPOUNDCURVEM,
- CURVEPOLYGONM, MULTICURVEM or MULTISURFACEM'';
- return ''fail'';
+ CURVEPOLYGONM, MULTICURVEM or MULTISURFACEM';
+ return 'fail';
END IF;
IF ( (new_dim >4) or (new_dim <0) ) THEN
- RAISE EXCEPTION ''invalid dimension'';
- return ''fail'';
+ RAISE EXCEPTION 'invalid dimension';
+ return 'fail';
END IF;
- IF ( (new_type LIKE ''%M'') and (new_dim!=3) ) THEN
+ IF ( (new_type LIKE '%M') and (new_dim!=3) ) THEN
- RAISE EXCEPTION ''TypeM needs 3 dimensions'';
- return ''fail'';
+ RAISE EXCEPTION 'TypeM needs 3 dimensions';
+ return 'fail';
END IF;
- IF ( schema_name != '''' ) THEN
- schema_ok = ''f'';
+ IF ( schema_name != '' ) THEN
+ schema_ok = 'f';
FOR rec IN SELECT nspname FROM pg_namespace WHERE text(nspname) = schema_name LOOP
- schema_ok := ''t'';
+ schema_ok := 't';
END LOOP;
- if ( schema_ok <> ''t'' ) THEN
- RAISE NOTICE ''Invalid schema name - using current_schema()'';
+ if ( schema_ok <> 't' ) THEN
+ RAISE NOTICE 'Invalid schema name - using current_schema()';
SELECT current_schema() into real_schema;
ELSE
real_schema = schema_name;
-- Add geometry column
- EXECUTE ''ALTER TABLE '' ||
- quote_ident(real_schema) || ''.'' || quote_ident(table_name)
- || '' ADD COLUMN '' || quote_ident(column_name) ||
- '' geometry '';
+ EXECUTE 'ALTER TABLE ' ||
+ quote_ident(real_schema) || '.' || quote_ident(table_name)
+ || ' ADD COLUMN ' || quote_ident(column_name) ||
+ ' geometry ';
-- Delete stale record in geometry_column (if any)
- EXECUTE ''DELETE FROM geometry_columns WHERE
- f_table_catalog = '' || quote_literal('''') ||
- '' AND f_table_schema = '' ||
+ EXECUTE 'DELETE FROM geometry_columns WHERE
+ f_table_catalog = ' || quote_literal('') ||
+ ' AND f_table_schema = ' ||
quote_literal(real_schema) ||
- '' AND f_table_name = '' || quote_literal(table_name) ||
- '' AND f_geometry_column = '' || quote_literal(column_name);
+ ' AND f_table_name = ' || quote_literal(table_name) ||
+ ' AND f_geometry_column = ' || quote_literal(column_name);
-- Add record in geometry_column
- EXECUTE ''INSERT INTO geometry_columns VALUES ('' ||
- quote_literal('''') || '','' ||
- quote_literal(real_schema) || '','' ||
- quote_literal(table_name) || '','' ||
- quote_literal(column_name) || '','' ||
- new_dim::text || '','' || new_srid::text || '','' ||
- quote_literal(new_type) || '')'';
+ EXECUTE 'INSERT INTO geometry_columns VALUES (' ||
+ quote_literal('') || ',' ||
+ quote_literal(real_schema) || ',' ||
+ quote_literal(table_name) || ',' ||
+ quote_literal(column_name) || ',' ||
+ new_dim::text || ',' || new_srid::text || ',' ||
+ quote_literal(new_type) || ')';
-- Add table checks
- EXECUTE ''ALTER TABLE '' ||
- quote_ident(real_schema) || ''.'' || quote_ident(table_name)
- || '' ADD CONSTRAINT ''
- || quote_ident(''enforce_srid_'' || column_name)
- || '' CHECK (SRID('' || quote_ident(column_name) ||
- '') = '' || new_srid::text || '')'' ;
-
- EXECUTE ''ALTER TABLE '' ||
- quote_ident(real_schema) || ''.'' || quote_ident(table_name)
- || '' ADD CONSTRAINT ''
- || quote_ident(''enforce_dims_'' || column_name)
- || '' CHECK (ndims('' || quote_ident(column_name) ||
- '') = '' || new_dim::text || '')'' ;
-
- IF (not(new_type = ''GEOMETRY'')) THEN
- EXECUTE ''ALTER TABLE '' ||
- quote_ident(real_schema) || ''.'' || quote_ident(table_name)
- || '' ADD CONSTRAINT ''
- || quote_ident(''enforce_geotype_'' || column_name)
- || '' CHECK (geometrytype('' ||
- quote_ident(column_name) || '')='' ||
- quote_literal(new_type) || '' OR ('' ||
- quote_ident(column_name) || '') is null)'';
+ EXECUTE 'ALTER TABLE ' ||
+ quote_ident(real_schema) || '.' || quote_ident(table_name)
+ || ' ADD CONSTRAINT '
+ || quote_ident('enforce_srid_' || column_name)
+ || ' CHECK (SRID(' || quote_ident(column_name) ||
+ ') = ' || new_srid::text || ')' ;
+
+ EXECUTE 'ALTER TABLE ' ||
+ quote_ident(real_schema) || '.' || quote_ident(table_name)
+ || ' ADD CONSTRAINT '
+ || quote_ident('enforce_dims_' || column_name)
+ || ' CHECK (ndims(' || quote_ident(column_name) ||
+ ') = ' || new_dim::text || ')' ;
+
+ IF (not(new_type = 'GEOMETRY')) THEN
+ EXECUTE 'ALTER TABLE ' ||
+ quote_ident(real_schema) || '.' || quote_ident(table_name)
+ || ' ADD CONSTRAINT '
+ || quote_ident('enforce_geotype_' || column_name)
+ || ' CHECK (geometrytype(' ||
+ quote_ident(column_name) || ')=' ||
+ quote_literal(new_type) || ' OR (' ||
+ quote_ident(column_name) || ') is null)';
END IF;
return
- real_schema || ''.'' ||
- table_name || ''.'' || column_name ||
- '' SRID:'' || new_srid::text ||
- '' TYPE:'' || new_type ||
- '' DIMS:'' || new_dim::text || chr(10) || '' '';
+ real_schema || '.' ||
+ table_name || '.' || column_name ||
+ ' SRID:' || new_srid::text ||
+ ' TYPE:' || new_type ||
+ ' DIMS:' || new_dim::text || chr(10) || ' ';
END;
-'
+$$
LANGUAGE 'plpgsql' _VOLATILE_STRICT; -- WITH (isstrict);
----------------------------------------------------------------------------
-- when catalogue is undefined
--
----------------------------------------------------------------------------
-CREATEFUNCTION AddGeometryColumn(varchar,varchar,varchar,integer,varchar,integer) RETURNS text AS '
+CREATEFUNCTION AddGeometryColumn(varchar,varchar,varchar,integer,varchar,integer) RETURNS text AS $$
DECLARE
ret text;
BEGIN
- SELECT AddGeometryColumn('''',$1,$2,$3,$4,$5,$6) into ret;
+ SELECT AddGeometryColumn('',$1,$2,$3,$4,$5,$6) into ret;
RETURN ret;
END;
-'
+$$
LANGUAGE 'plpgsql' _STABLE_STRICT; -- WITH (isstrict);
----------------------------------------------------------------------------
-- when catalogue and schema are undefined
--
----------------------------------------------------------------------------
-CREATEFUNCTION AddGeometryColumn(varchar,varchar,integer,varchar,integer) RETURNS text AS '
+CREATEFUNCTION AddGeometryColumn(varchar,varchar,integer,varchar,integer) RETURNS text AS $$
DECLARE
ret text;
BEGIN
- SELECT AddGeometryColumn('''','''',$1,$2,$3,$4,$5) into ret;
+ SELECT AddGeometryColumn('','',$1,$2,$3,$4,$5) into ret;
RETURN ret;
END;
-'
+$$
LANGUAGE 'plpgsql' _VOLATILE_STRICT; -- WITH (isstrict);
-----------------------------------------------------------------------
CREATEFUNCTION DropGeometryColumn(varchar, varchar,varchar,varchar)
RETURNS text
AS
-'
+$$
DECLARE
catalog_name alias for $1;
schema_name alias for $2;
-- Find, check or fix schema_name
- IF ( schema_name != '''' ) THEN
- okay = ''f'';
+ IF ( schema_name != '' ) THEN
+ okay = 'f';
FOR myrec IN SELECT nspname FROM pg_namespace WHERE text(nspname) = schema_name LOOP
- okay := ''t'';
+ okay := 't';
END LOOP;
- IF ( okay <> ''t'' ) THEN
- RAISE NOTICE ''Invalid schema name - using current_schema()'';
+ IF ( okay <> 't' ) THEN
+ RAISE NOTICE 'Invalid schema name - using current_schema()';
SELECT current_schema() into real_schema;
ELSE
real_schema = schema_name;
END IF;
-- Find out if the column is in the geometry_columns table
- okay = ''f'';
+ okay = 'f';
FOR myrec IN SELECT * from geometry_columns where f_table_schema = text(real_schema) and f_table_name = table_name and f_geometry_column = column_name LOOP
- okay := ''t'';
+ okay := 't';
END LOOP;
- IF (okay <> ''t'') THEN
- RAISE EXCEPTION ''column not found in geometry_columns table'';
- RETURN ''f'';
+ IF (okay <> 't') THEN
+ RAISE EXCEPTION 'column not found in geometry_columns table';
+ RETURN 'f';
END IF;
-- Remove ref from geometry_columns table
- EXECUTE ''delete from geometry_columns where f_table_schema = '' ||
- quote_literal(real_schema) || '' and f_table_name = '' ||
- quote_literal(table_name) || '' and f_geometry_column = '' ||
+ EXECUTE 'delete from geometry_columns where f_table_schema = ' ||
+ quote_literal(real_schema) || ' and f_table_name = ' ||
+ quote_literal(table_name) || ' and f_geometry_column = ' ||
quote_literal(column_name);
-- Remove table column
- EXECUTE ''ALTER TABLE '' || quote_ident(real_schema) || ''.'' ||
- quote_ident(table_name) || '' DROP COLUMN '' ||
+ EXECUTE 'ALTER TABLE ' || quote_ident(real_schema) || '.' ||
+ quote_ident(table_name) || ' DROP COLUMN ' ||
quote_ident(column_name);
- RETURN real_schema || ''.'' || table_name || ''.'' || column_name ||'' effectively removed.'';
+ RETURN real_schema || '.' || table_name || '.' || column_name ||' effectively removed.';
END;
-'
+$$
LANGUAGE 'plpgsql' _VOLATILE_STRICT; -- WITH (isstrict);
-----------------------------------------------------------------------
CREATEFUNCTION DropGeometryColumn(varchar,varchar,varchar)
RETURNS text
AS
-'
+$$
DECLARE
ret text;
BEGIN
- SELECT DropGeometryColumn('''',$1,$2,$3) into ret;
+ SELECT DropGeometryColumn('',$1,$2,$3) into ret;
RETURN ret;
END;
-'
+$$
LANGUAGE 'plpgsql' _VOLATILE_STRICT; -- WITH (isstrict);
-----------------------------------------------------------------------
CREATEFUNCTION DropGeometryColumn(varchar,varchar)
RETURNS text
AS
-'
+$$
DECLARE
ret text;
BEGIN
- SELECT DropGeometryColumn('''','''',$1,$2) into ret;
+ SELECT DropGeometryColumn('','',$1,$2) into ret;
RETURN ret;
END;
-'
+$$
LANGUAGE 'plpgsql' _VOLATILE_STRICT; -- WITH (isstrict);
-----------------------------------------------------------------------
CREATEFUNCTION DropGeometryTable(varchar, varchar,varchar)
RETURNS text
AS
-'
+$$
DECLARE
catalog_name alias for $1;
schema_name alias for $2;
BEGIN
- IF ( schema_name = '''' ) THEN
+ IF ( schema_name = '' ) THEN
SELECT current_schema() into real_schema;
ELSE
real_schema = schema_name;
END IF;
-- Remove refs from geometry_columns table
- EXECUTE ''DELETE FROM geometry_columns WHERE '' ||
- ''f_table_schema = '' || quote_literal(real_schema) ||
- '' AND '' ||
- '' f_table_name = '' || quote_literal(table_name);
+ EXECUTE 'DELETE FROM geometry_columns WHERE ' ||
+ 'f_table_schema = ' || quote_literal(real_schema) ||
+ ' AND ' ||
+ ' f_table_name = ' || quote_literal(table_name);
-- Remove table
- EXECUTE ''DROP TABLE ''
- || quote_ident(real_schema) || ''.'' ||
+ EXECUTE 'DROP TABLE '
+ || quote_ident(real_schema) || '.' ||
quote_ident(table_name);
RETURN
- real_schema || ''.'' ||
- table_name ||'' dropped.'';
+ real_schema || '.' ||
+ table_name ||' dropped.';
END;
-'
+$$
LANGUAGE 'plpgsql' _VOLATILE_STRICT; -- WITH (isstrict);
-----------------------------------------------------------------------
--
-----------------------------------------------------------------------
CREATEFUNCTION DropGeometryTable(varchar,varchar) RETURNS text AS
-'SELECT DropGeometryTable('''',$1,$2)'
+$$ SELECT DropGeometryTable('',$1,$2) $$
LANGUAGE 'sql' WITH (isstrict);
-----------------------------------------------------------------------
--
-----------------------------------------------------------------------
CREATEFUNCTION DropGeometryTable(varchar) RETURNS text AS
-'SELECT DropGeometryTable('''','''',$1)'
+$$ SELECT DropGeometryTable('','',$1) $$
LANGUAGE 'sql' _VOLATILE_STRICT; -- WITH (isstrict);
-----------------------------------------------------------------------
CREATEFUNCTION UpdateGeometrySRID(varchar,varchar,varchar,varchar,integer)
RETURNS text
AS
-'
+$$
DECLARE
catalog_name alias for $1;
schema_name alias for $2;
-- Find, check or fix schema_name
- IF ( schema_name != '''' ) THEN
- okay = ''f'';
+ IF ( schema_name != '' ) THEN
+ okay = 'f';
FOR myrec IN SELECT nspname FROM pg_namespace WHERE text(nspname) = schema_name LOOP
- okay := ''t'';
+ okay := 't';
END LOOP;
- IF ( okay <> ''t'' ) THEN
- RAISE EXCEPTION ''Invalid schema name'';
+ IF ( okay <> 't' ) THEN
+ RAISE EXCEPTION 'Invalid schema name';
ELSE
real_schema = schema_name;
END IF;
END IF;
-- Find out if the column is in the geometry_columns table
- okay = ''f'';
+ okay = 'f';
FOR myrec IN SELECT * from geometry_columns where f_table_schema = text(real_schema) and f_table_name = table_name and f_geometry_column = column_name LOOP
- okay := ''t'';
+ okay := 't';
END LOOP;
- IF (okay <> ''t'') THEN
- RAISE EXCEPTION ''column not found in geometry_columns table'';
- RETURN ''f'';
+ IF (okay <> 't') THEN
+ RAISE EXCEPTION 'column not found in geometry_columns table';
+ RETURN 'f';
END IF;
-- Update ref from geometry_columns table
- EXECUTE ''UPDATE geometry_columns SET SRID = '' || new_srid::text ||
- '' where f_table_schema = '' ||
- quote_literal(real_schema) || '' and f_table_name = '' ||
- quote_literal(table_name) || '' and f_geometry_column = '' ||
+ EXECUTE 'UPDATE geometry_columns SET SRID = ' || new_srid::text ||
+ ' where f_table_schema = ' ||
+ quote_literal(real_schema) || ' and f_table_name = ' ||
+ quote_literal(table_name) || ' and f_geometry_column = ' ||
quote_literal(column_name);
-- Make up constraint name
- cname = ''enforce_srid_'' || column_name;
+ cname = 'enforce_srid_' || column_name;
-- Drop enforce_srid constraint
- EXECUTE ''ALTER TABLE '' || quote_ident(real_schema) ||
- ''.'' || quote_ident(table_name) ||
- '' DROP constraint '' || quote_ident(cname);
+ EXECUTE 'ALTER TABLE ' || quote_ident(real_schema) ||
+ '.' || quote_ident(table_name) ||
+ ' DROP constraint ' || quote_ident(cname);
-- Update geometries SRID
- EXECUTE ''UPDATE '' || quote_ident(real_schema) ||
- ''.'' || quote_ident(table_name) ||
- '' SET '' || quote_ident(column_name) ||
- '' = setSRID('' || quote_ident(column_name) ||
- '', '' || new_srid::text || '')'';
+ EXECUTE 'UPDATE ' || quote_ident(real_schema) ||
+ '.' || quote_ident(table_name) ||
+ ' SET ' || quote_ident(column_name) ||
+ ' = setSRID(' || quote_ident(column_name) ||
+ ', ' || new_srid::text || ')';
-- Reset enforce_srid constraint
- EXECUTE ''ALTER TABLE '' || quote_ident(real_schema) ||
- ''.'' || quote_ident(table_name) ||
- '' ADD constraint '' || quote_ident(cname) ||
- '' CHECK (srid('' || quote_ident(column_name) ||
- '') = '' || new_srid::text || '')'';
+ EXECUTE 'ALTER TABLE ' || quote_ident(real_schema) ||
+ '.' || quote_ident(table_name) ||
+ ' ADD constraint ' || quote_ident(cname) ||
+ ' CHECK (srid(' || quote_ident(column_name) ||
+ ') = ' || new_srid::text || ')';
- RETURN real_schema || ''.'' || table_name || ''.'' || column_name ||'' SRID changed to '' || new_srid::text;
+ RETURN real_schema || '.' || table_name || '.' || column_name ||' SRID changed to ' || new_srid::text;
END;
-'
+$$
LANGUAGE 'plpgsql' _VOLATILE_STRICT; -- WITH (isstrict);
-----------------------------------------------------------------------
-----------------------------------------------------------------------
CREATEFUNCTION UpdateGeometrySRID(varchar,varchar,varchar,integer)
RETURNS text
- AS '
+ AS $$
DECLARE
ret text;
BEGIN
- SELECT UpdateGeometrySRID('''',$1,$2,$3,$4) into ret;
+ SELECT UpdateGeometrySRID('',$1,$2,$3,$4) into ret;
RETURN ret;
END;
-'
+$$
LANGUAGE 'plpgsql' _VOLATILE_STRICT; -- WITH (isstrict);
-----------------------------------------------------------------------
-----------------------------------------------------------------------
CREATEFUNCTION UpdateGeometrySRID(varchar,varchar,integer)
RETURNS text
- AS '
+ AS $$
DECLARE
ret text;
BEGIN
- SELECT UpdateGeometrySRID('''','''',$1,$2,$3) into ret;
+ SELECT UpdateGeometrySRID('','',$1,$2,$3) into ret;
RETURN ret;
END;
-'
+$$
LANGUAGE 'plpgsql' _VOLATILE_STRICT; -- WITH (isstrict);
-----------------------------------------------------------------------
-- FIND_SRID( <schema>, <table>, <geom col> )
-----------------------------------------------------------------------
CREATEFUNCTION find_srid(varchar,varchar,varchar) RETURNS int4 AS
-'DECLARE
+$$
+DECLARE
schem text;
tabl text;
sr int4;
BEGIN
IF $1 IS NULL THEN
- RAISE EXCEPTION ''find_srid() - schema is NULL!'';
+ RAISE EXCEPTION 'find_srid() - schema is NULL!';
END IF;
IF $2 IS NULL THEN
- RAISE EXCEPTION ''find_srid() - table name is NULL!'';
+ RAISE EXCEPTION 'find_srid() - table name is NULL!';
END IF;
IF $3 IS NULL THEN
- RAISE EXCEPTION ''find_srid() - column name is NULL!'';
+ RAISE EXCEPTION 'find_srid() - column name is NULL!';
END IF;
schem = $1;
tabl = $2;
-- if the table contains a . and the schema is empty
-- split the table into a schema and a table
-- otherwise drop through to default behavior
- IF ( schem = '''' and tabl LIKE ''%.%'' ) THEN
- schem = substr(tabl,1,strpos(tabl,''.'')-1);
+ IF ( schem = '' and tabl LIKE '%.%' ) THEN
+ schem = substr(tabl,1,strpos(tabl,'.')-1);
tabl = substr(tabl,length(schem)+2);
ELSE
- schem = schem || ''%'';
+ schem = schem || '%';
END IF;
select SRID into sr from geometry_columns where f_table_schema like schem and f_table_name = tabl and f_geometry_column = $3;
IF NOT FOUND THEN
- RAISE EXCEPTION ''find_srid() - couldnt find the corresponding SRID - is the geometry registered in the GEOMETRY_COLUMNS table? Is there an uppercase/lowercase missmatch?'';
+ RAISE EXCEPTION 'find_srid() - couldnt find the corresponding SRID - is the geometry registered in the GEOMETRY_COLUMNS table? Is there an uppercase/lowercase missmatch?';
END IF;
return sr;
END;
-'
+$$
LANGUAGE 'plpgsql' _IMMUTABLE_STRICT; -- WITH (iscachable);
---------------------------------------------------------------
CREATEFUNCTION get_proj4_from_srid(integer) RETURNS text AS
-'
+$$
BEGIN
RETURN proj4text::text FROM spatial_ref_sys WHERE srid= $1;
END;
-'
+$$
LANGUAGE 'plpgsql' _IMMUTABLE_STRICT; -- WITH (iscachable,isstrict);
CREATEFUNCTION postgis_full_version() RETURNS text
-AS '
+AS $$
DECLARE
libver text;
projver text;
SELECT postgis_scripts_installed() INTO dbproc;
SELECT postgis_scripts_released() INTO relproc;
- fullver = ''POSTGIS="'' || libver || ''"'';
+ fullver = 'POSTGIS="' || libver || '"';
IF geosver IS NOT NULL THEN
- fullver = fullver || '' GEOS="'' || geosver || ''"'';
+ fullver = fullver || ' GEOS="' || geosver || '"';
END IF;
IF jtsver IS NOT NULL THEN
- fullver = fullver || '' JTS="'' || jtsver || ''"'';
+ fullver = fullver || ' JTS="' || jtsver || '"';
END IF;
IF projver IS NOT NULL THEN
- fullver = fullver || '' PROJ="'' || projver || ''"'';
+ fullver = fullver || ' PROJ="' || projver || '"';
END IF;
IF usestats THEN
- fullver = fullver || '' USE_STATS'';
+ fullver = fullver || ' USE_STATS';
END IF;
- -- fullver = fullver || '' DBPROC="'' || dbproc || ''"'';
- -- fullver = fullver || '' RELPROC="'' || relproc || ''"'';
+ -- fullver = fullver || ' DBPROC="' || dbproc || '"';
+ -- fullver = fullver || ' RELPROC="' || relproc || '"';
IF dbproc != relproc THEN
- fullver = fullver || '' (procs from '' || dbproc || '' need upgrade)'';
+ fullver = fullver || ' (procs from ' || dbproc || ' need upgrade)';
END IF;
RETURN fullver;
END
-'
+$$
LANGUAGE 'plpgsql' _IMMUTABLE;
---------------------------------------------------------------
-- Deprecation in 1.2.3
CREATEFUNCTION locate_along_measure(geometry, float8)
RETURNS geometry
- AS 'SELECT locate_between_measures($1, $2, $2)'
+ AS $$ SELECT locate_between_measures($1, $2, $2) $$
LANGUAGE 'sql' _IMMUTABLE_STRICT;
-- Availability: 1.2.2
CREATEFUNCTION ST_locate_along_measure(geometry, float8)
RETURNS geometry
- AS 'SELECT locate_between_measures($1, $2, $2)'
+ AS $$ SELECT locate_between_measures($1, $2, $2) $$
LANGUAGE 'sql' _IMMUTABLE_STRICT;
---------------------------------------------------------------
-- Not quite equivalent to GeometryType
CREATEFUNCTION ST_GeometryType(geometry)
RETURNS text
- AS '
+ AS $$
DECLARE
gtype text := geometrytype($1);
BEGIN
- IF (gtype IN (''POINT'', ''POINTM'')) THEN
- gtype := ''Point'';
- ELSIF (gtype IN (''LINESTRING'', ''LINESTRINGM'')) THEN
- gtype := ''LineString'';
- ELSIF (gtype IN (''POLYGON'', ''POLYGONM'')) THEN
- gtype := ''Polygon'';
- ELSIF (gtype IN (''MULTIPOINT'', ''MULTIPOINTM'')) THEN
- gtype := ''MultiPoint'';
- ELSIF (gtype IN (''MULTILINESTRING'', ''MULTILINESTRINGM'')) THEN
- gtype := ''MultiLineString'';
- ELSIF (gtype IN (''MULTIPOLYGON'', ''MULTIPOLYGONM'')) THEN
- gtype := ''MultiPolygon'';
+ IF (gtype IN ('POINT', 'POINTM')) THEN
+ gtype := 'Point';
+ ELSIF (gtype IN ('LINESTRING', 'LINESTRINGM')) THEN
+ gtype := 'LineString';
+ ELSIF (gtype IN ('POLYGON', 'POLYGONM')) THEN
+ gtype := 'Polygon';
+ ELSIF (gtype IN ('MULTIPOINT', 'MULTIPOINTM')) THEN
+ gtype := 'MultiPoint';
+ ELSIF (gtype IN ('MULTILINESTRING', 'MULTILINESTRINGM')) THEN
+ gtype := 'MultiLineString';
+ ELSIF (gtype IN ('MULTIPOLYGON', 'MULTIPOLYGONM')) THEN
+ gtype := 'MultiPolygon';
ELSE
- gtype := ''Geometry'';
+ gtype := 'Geometry';
END IF;
- RETURN ''ST_'' || gtype;
+ RETURN 'ST_' || gtype;
END
- '
- LANGUAGE 'plpgsql' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
+$$
+LANGUAGE 'plpgsql' _IMMUTABLE_STRICT; -- WITH (isstrict,iscachable);
-- Deprecation in 1.2.3
CREATEFUNCTION PointN(geometry,integer)
-- Deprecation in 1.2.3
CREATE OR REPLACE FUNCTION BdPolyFromText(text, integer)
RETURNS geometry
-AS '
+AS $$
DECLARE
geomtext alias for $1;
srid alias for $2;
IF mline IS NULL
THEN
- RAISE EXCEPTION ''Input is not a MultiLinestring'';
+ RAISE EXCEPTION 'Input is not a MultiLinestring';
END IF;
geom := BuildArea(mline);
- IF GeometryType(geom) != ''POLYGON''
+ IF GeometryType(geom) != 'POLYGON'
THEN
- RAISE EXCEPTION ''Input returns more then a single polygon, try using BdMPolyFromText instead'';
+ RAISE EXCEPTION 'Input returns more then a single polygon, try using BdMPolyFromText instead';
END IF;
RETURN geom;
END;
-'
+$$
LANGUAGE 'plpgsql' _IMMUTABLE_STRICT;
-- Availability: 1.2.2
CREATE OR REPLACE FUNCTION ST_BdPolyFromText(text, integer)
RETURNS geometry
-AS '
+AS $$
DECLARE
geomtext alias for $1;
srid alias for $2;
IF mline IS NULL
THEN
- RAISE EXCEPTION ''Input is not a MultiLinestring'';
+ RAISE EXCEPTION 'Input is not a MultiLinestring';
END IF;
geom := BuildArea(mline);
- IF GeometryType(geom) != ''POLYGON''
+ IF GeometryType(geom) != 'POLYGON'
THEN
- RAISE EXCEPTION ''Input returns more then a single polygon, try using BdMPolyFromText instead'';
+ RAISE EXCEPTION 'Input returns more then a single polygon, try using BdMPolyFromText instead';
END IF;
RETURN geom;
END;
-'
+$$
LANGUAGE 'plpgsql' _IMMUTABLE_STRICT;
--
-- Deprecation in 1.2.3
CREATEFUNCTION BdMPolyFromText(text, integer)
RETURNS geometry
-AS '
+AS $$
DECLARE
geomtext alias for $1;
srid alias for $2;
IF mline IS NULL
THEN
- RAISE EXCEPTION ''Input is not a MultiLinestring'';
+ RAISE EXCEPTION 'Input is not a MultiLinestring';
END IF;
geom := multi(BuildArea(mline));
RETURN geom;
END;
-'
+$$
LANGUAGE 'plpgsql' _IMMUTABLE_STRICT;
-- Availability: 1.2.2
CREATEFUNCTION ST_BdMPolyFromText(text, integer)
RETURNS geometry
-AS '
+AS $$
DECLARE
geomtext alias for $1;
srid alias for $2;
IF mline IS NULL
THEN
- RAISE EXCEPTION ''Input is not a MultiLinestring'';
+ RAISE EXCEPTION 'Input is not a MultiLinestring';
END IF;
geom := multi(BuildArea(mline));
RETURN geom;
END;
-'
+$$
LANGUAGE 'plpgsql' _IMMUTABLE_STRICT;
#include "long_xact.sql.in"