/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ LOAD 'age'; SET search_path TO ag_catalog; SELECT create_graph('cypher'); NOTICE: graph "cypher" has been created create_graph -------------- (1 row) -- cypher() function takes only a dollar-quoted string constant as an argument. -- All other cases throw an error. SELECT * FROM cypher('none', $$RETURN 0$$) as q(c agtype); ERROR: graph "none" does not exist LINE 1: SELECT * FROM cypher('none', $$RETURN 0$$) as q(c agtype); ^ SELECT * FROM cypher('cypher', $$RETURN 0$$) AS r(c agtype); c --- 0 (1 row) WITH r(c) AS ( SELECT * FROM cypher('cypher', $$RETURN 0$$) AS r(c agtype) ) SELECT * FROM r; c --- 0 (1 row) SELECT * FROM cypher('cypher', 'RETURN 0') AS r(c text); ERROR: a dollar-quoted string constant is expected LINE 1: SELECT * FROM cypher('cypher', 'RETURN 0') AS r(c text); ^ SELECT * FROM cypher('cypher', NULL) AS r(c text); ERROR: a dollar-quoted string constant is expected LINE 1: SELECT * FROM cypher('cypher', NULL) AS r(c text); ^ WITH q(s) AS ( VALUES (textout($$RETURN 0$$)) ) SELECT * FROM q, cypher('cypher', q.s) AS r(c text); ERROR: a dollar-quoted string constant is expected LINE 4: SELECT * FROM q, cypher('cypher', q.s) AS r(c text); ^ -- The numbers of the attributes must match. SELECT * FROM cypher('cypher', $$RETURN 0$$) AS r(c text, x text); ERROR: return row and column definition list do not match LINE 1: SELECT * FROM cypher('cypher', $$RETURN 0$$) AS r(c text, x ... ^ -- cypher() function can be called in ROWS FROM only if it is there solely. SELECT * FROM ROWS FROM (cypher('cypher', $$RETURN 0$$) AS (c agtype)); c --- 0 (1 row) SELECT * FROM ROWS FROM (cypher('cypher', $$RETURN 0$$) AS (c text), generate_series(1, 2)); ERROR: cypher(...) in ROWS FROM is not supported LINE 1: SELECT * FROM ROWS FROM (cypher('cypher', $$RETURN 0$$) AS (... ^ -- WITH ORDINALITY is not supported. SELECT * FROM ROWS FROM (cypher('cypher', $$RETURN 0$$) AS (c text)) WITH ORDINALITY; ERROR: WITH ORDINALITY is not supported LINE 2: FROM ROWS FROM (cypher('cypher', $$RETURN 0$$) AS (c text)) ... ^ -- cypher() function cannot be called in expressions. -- However, it can be called in subqueries. SELECT cypher('cypher', $$RETURN 0$$); ERROR: cypher(...) in expressions is not supported LINE 1: SELECT cypher('cypher', $$RETURN 0$$); ^ HINT: Use subquery instead if possible. SELECT (SELECT * FROM cypher('cypher', $$RETURN 0$$) AS r(c agtype)); c --- 0 (1 row) -- Attributes returned from cypher() function are agtype. If other than agtype -- is given in the column definition list and there is a type coercion from -- agtype to the given type, agtype will be coerced to that type. If there is -- not such a coercion, an error is thrown. SELECT * FROM cypher('cypher', $$RETURN true$$) AS (c bool); c --- t (1 row) SELECT * FROM cypher('cypher', $$RETURN 0$$) AS (c oid); ERROR: cannot cast type agtype to oid for column "c" LINE 1: SELECT * FROM cypher('cypher', $$RETURN 0$$) AS (c oid); ^ SELECT drop_graph('cypher', true); NOTICE: drop cascades to 2 other objects DETAIL: drop cascades to table cypher._ag_label_vertex drop cascades to table cypher._ag_label_edge NOTICE: graph "cypher" has been dropped drop_graph ------------ (1 row)