Syntax error at end of input position

Reported by Tomas Janco tomas.janco@myinphinity.com I have found following problem with JDBC driver: When an updatable result set is created for a table without primary key, any update fails with e...

Reported by

Tomas Janco tomas.janco@myinphinity.com

I have found following problem with JDBC driver:
When an updatable result set is created for a table without primary key, any update fails with error: «syntax error at end of input»
The driver generates invalid SQL query to update the table.

JDBC driver version: 42.2.18 (jre8)
Server version: PostgreSQL 9.6.6, compiled by Visual C++ build 1800, 64-bit

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

public class TestPgSql {
/* test table schema:
CREATE TABLE public.sample
(
id integer,
value character varying(255) COLLATE pg_catalog.»default»
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
INSERT INTO public.sample(id, value)
VALUES (1, ‘abcd’);
*/

public static void main(String args[]) throws Exception {
    Connection conn = DriverManager.getConnection("jdbc:postgresql://localhost/...?user=....&password=....");
    String sql = "SELECT * FROM sample WHERE id = 1;";
    PreparedStatement stmt = conn.prepareStatement(sql, ResultSet.CONCUR_UPDATABLE, ResultSet.TYPE_FORWARD_ONLY);
    ResultSet rs = stmt.executeQuery();
    rs.next();
    rs.updateString("value", "something");
    rs.updateRow();
    rs.close();
}

}

Expected behavior:
The code successfully updates the table OR throws an error explaining primary key is not present in result set and is required for updatable result set.

Actual behavior:
Incorrect SQL command is generated internally: «UPDATE sample SET «value» = $1 WHERE «
The query is missing the WHERE condition expression.
This results in following exception being thrown:

Exception in thread «main» org.postgresql.util.PSQLException: ERROR: syntax error at end of input
Position: 39
at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2553)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:2285)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:323)
at org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:473)
at org.postgresql.jdbc.PgStatement.execute(PgStatement.java:393)
at org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedStatement.java:164)
at org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatement.java:130)
at org.postgresql.jdbc.PgResultSet.updateRow(PgResultSet.java:1445)
at TestPgSql.main(TestPgSql.java:35)

Hello,

I am trying to build a query using StringBuilder based off a variable
size ArrayList of inputs. When testing a simplest use case of one input
ID, I get an syntax error at end of input. However, if I copy the
generated SQL and run it in pgAdmin3, it is able to execute successfully.
Below is the error with loglevel2 enabled. Any advice would be much
appreciated.

SELECT seq_chromats.species_code_4, seq_chromats.fasta_header_line,
seq_chromats.fasta_sequence, seq_chromats.flag_two_reads_exist,
seq_amplicons.amplicon_name, seq_primers.primer_name FROM seq_amplicons
INNER JOIN seq_primers ON seq_primers.amplicon_name =
seq_amplicons.amplicon_name INNER JOIN seq_chromats ON
seq_chromats.primer_id = seq_primers.primer_id WHERE
seq_amplicons.amplicon_name IN ((‘0_8156_01’))
14:40:53.272 (1) PostgreSQL 9.1 JDBC4 (build 901)
14:40:53.277 (1) Trying to establish a protocol version 3 connection to
localhost:5432
14:40:53.282 (1) FE=> StartupPacket(user=sswap_agent,
database=treegenes_development, client_encoding=UTF8, DateStyle=ISO,
extra_float_digits=2)
14:40:53.286 (1) <=BE AuthenticationReqMD5(salt=3ce4592b)
14:40:53.287 (1) FE=>
Password(md5digest=md5b4b2bdfb96e02dea70d85a4890a23c4e)
14:40:53.290 (1) <=BE AuthenticationOk
14:40:53.303 (1) <=BE ParameterStatus(application_name = )
14:40:53.303 (1) <=BE ParameterStatus(client_encoding = UTF8)
14:40:53.303 (1) <=BE ParameterStatus(DateStyle = ISO, MDY)
14:40:53.303 (1) <=BE ParameterStatus(integer_datetimes = on)
14:40:53.303 (1) <=BE ParameterStatus(IntervalStyle = postgres)
14:40:53.303 (1) <=BE ParameterStatus(is_superuser = off)
14:40:53.303 (1) <=BE ParameterStatus(server_encoding = SQL_ASCII)
14:40:53.303 (1) <=BE ParameterStatus(server_version = 9.0.7)
14:40:53.303 (1) <=BE ParameterStatus(session_authorization = sswap_agent)
14:40:53.303 (1) <=BE ParameterStatus(standard_conforming_strings = off)
14:40:53.303 (1) <=BE ParameterStatus(TimeZone = US/Pacific)
14:40:53.303 (1) <=BE BackendKeyData(pid=30534,ckey=1141196332)
14:40:53.303 (1) <=BE ReadyForQuery(I)
14:40:53.305 (1) simple execute,
handler=org(dot)postgresql(dot)core(dot)SetupQueryRunner$SimpleResultHandler(at)4b0d78ec,
maxRows=0, fetchSize=0, flags=23
14:40:53.305 (1) FE=> Parse(stmt=null,query=»SET extra_float_digits =
3″,oids={})
14:40:53.307 (1) FE=> Bind(stmt=null,portal=null)
14:40:53.307 (1) FE=> Execute(portal=null,limit=1)
14:40:53.307 (1) FE=> Sync
14:40:53.309 (1) <=BE ParseComplete [null]
14:40:53.309 (1) <=BE BindComplete [null]
14:40:53.309 (1) <=BE CommandStatus(SET)
14:40:53.309 (1) <=BE ReadyForQuery(I)
14:40:53.310 (1) compatible = 9.1
14:40:53.310 (1) loglevel = 2
14:40:53.310 (1) prepare threshold = 5
getConnection returning
driver[className=org.postgresql.Driver,org(dot)postgresql(dot)Driver(at)4669b7fe]
14:40:53.338 (1) simple execute,
handler=org(dot)postgresql(dot)jdbc2(dot)AbstractJdbc2Statement$StatementResultHandler(at)31b27882,
maxRows=0, fetchSize=0, flags=17
14:40:53.338 (1) FE=> Parse(stmt=null,query=»SELECT
seq_chromats.species_code_4, seq_chromats.fasta_header_line,
seq_chromats.fasta_sequence, seq_chromats.flag_two_reads_exist,
seq_amplicons.amplicon_name, seq_primers.primer_name FROM seq_amplicons
INNER JOIN seq_primers ON seq_primers.amplicon_name =
seq_amplicons.amplicon_name INNER JOIN seq_chromats ON
seq_chromats.primer_id = seq_primers.primer_id WHERE
seq_amplicons.amplicon_name IN («,oids={})
14:40:53.339 (1) FE=> Bind(stmt=null,portal=null)
14:40:53.339 (1) FE=> Describe(portal=null)
14:40:53.339 (1) FE=> Execute(portal=null,limit=0)
14:40:53.339 (1) FE=> Sync
14:40:53.346 (1) <=BE ErrorMessage(ERROR: syntax error at end of input
Position: 400)
org.postgresql.util.PSQLException: ERROR: syntax error at end of input
Position: 400
at
org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
at
org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
at
org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:374)
at
org.postgresql.jdbc2.AbstractJdbc2Statement.executeQuery(AbstractJdbc2Statement.java:254)
at
edu.dendrome.sswap.QueryWithConfig.queryChromatSeqsByAmplicon(QueryWithConfig.java:380)
at
edu.dendrome.sswap.AmpliconMultiFastaService.initializeRequest(AmpliconMultiFastaService.java:88)
at
info.sswap.api.servlet.SimpleSSWAPServlet.handleRequest(SimpleSSWAPServlet.java:125)
at
info.sswap.api.servlet.AbstractSSWAPServlet.doPost(AbstractSSWAPServlet.java:658)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
at
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
at
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
at
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
at java.lang.Thread.run(Thread.java:680)
SQLException: SQLState(42601)
14:40:53.350 (1) <=BE ReadyForQuery(I)
ERROR: syntax error at end of input
Position: 400

Best,
-Hans

Syntax errors are quite common while coding.

But, things go for a toss when it results in website errors.

PostgreSQL error 42601 also occurs due to syntax errors in the database queries.

At Bobcares, we often get requests from PostgreSQL users to fix errors as part of our Server Management Services.

Today, let’s check PostgreSQL error in detail and see how our Support Engineers fix it for the customers.

What causes error 42601 in PostgreSQL?

PostgreSQL is an advanced database engine. It is popular for its extensive features and ability to handle complex database situations.

Applications like Instagram, Facebook, Apple, etc rely on the PostgreSQL database.

But what causes error 42601?

PostgreSQL error codes consist of five characters. The first two characters denote the class of errors. And the remaining three characters indicate a specific condition within that class.

Here, 42 in 42601 represent the class “Syntax Error or Access Rule Violation“.

In short, this error mainly occurs due to the syntax errors in the queries executed. A typical error shows up as:

Here, the syntax error has occurred in position 119 near the value “parents” in the query.

How we fix the error?

Now let’s see how our PostgreSQL engineers resolve this error efficiently.

Recently, one of our customers contacted us with this error. He tried to execute the following code,

CREATE OR REPLACE FUNCTION prc_tst_bulk(sql text)
RETURNS TABLE (name text, rowcount integer) AS
$$
BEGIN
WITH m_ty_person AS (return query execute sql)
select name, count(*) from m_ty_person where name like '%a%' group by name
union
select name, count(*) from m_ty_person where gender = 1 group by name;
END
$$ LANGUAGE plpgsql;

But, this ended up in PostgreSQL error 42601. And he got the following error message,

ERROR: syntax error at or near "return"
LINE 5: WITH m_ty_person AS (return query execute sql)

Our PostgreSQL Engineers checked the issue and found out the syntax error. The statement in Line 5 was a mix of plain and dynamic SQL. In general, the PostgreSQL query should be either fully dynamic or plain. Therefore, we changed the code as,

RETURN QUERY EXECUTE '
WITH m_ty_person AS (' || sql || $x$)
SELECT name, count(*)::int FROM m_ty_person WHERE name LIKE '%a%' GROUP BY name
UNION
SELECT name, count(*)::int FROM m_ty_person WHERE gender = 1 GROUP BY name$x$;

This resolved the error 42601, and the code worked fine.

[Need more assistance to solve PostgreSQL error 42601?- We’ll help you.]

Conclusion

In short, PostgreSQL error 42601 occurs due to the syntax errors in the code. Today, in this write-up, we have discussed how our Support Engineers fixed this error for our customers.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

var google_conversion_label = «owonCMyG5nEQ0aD71QM»;

  • Summary

  • Files

  • Reviews

  • Support

  • News

  • Discussion

  • Donate

Menu


  • Create Topic


  • Stats Graph

Forums

  • Mobile Development
    128

  • Open Discussion
    842

  • Help
    3043

  • Cloud Development
    20

  • Developers
    417

Help

  • Formatting Help

Transformation PostgreSQL syntax error at end of input


Created:

2013-01-15

Updated:

2013-01-16

  • dabgdk

    I just added a transformation to my SQL config file:

    insert into sym_transform_table (transform_id, source_node_group_id, target_node_group_id, transform_point, column_policy, source_table_name, target_table_name, delete_action, transform_order) values (‘stockcurrent’, ‘store’, ‘corp’, ‘LOAD’, ‘IMPLIED’, ‘stockcurrent’, ‘stockcurrent’, ‘NONE’, 1);

    insert into sym_transform_column (transform_id, include_on, target_column_name, source_column_name, pk, transform_type, transform_expression, transform_order) values (‘stockcurrent’, ‘*’, ‘units’, ‘units’, 1, ‘additive’, null, 1);

    The goal is to fix my issue that I originally described here: https://sourceforge.net/p/symmetricds/discussion/739235/thread/8f41f4af/

    The problem is that with the above entries, upon making a sale, the inventory channel goes into error.

    [corp-000] — IncomingBatchService — Retrying batch 001-5
    [corp-000] — DataLoaderService — Failed to load batch 001-5 because: ERROR: syntax error at end of input
    Position: 54
    [store-001] — AcknowledgeService — Received an error from node 000 for batch 5. Check the outgoing_batch table for more info.

    I ran this SQL query trying to figure out what the problem was:

    sample001=# select * from sym_data order by data_id desc;

    But this doesn’t return anything that catches my eye.

    NOTE: Unsure of how to format the output from the above command; I am going to directly paste the contents of the shell and see how it looks.

    data_id | table_name | event_type | row_data | pk_data | old_data | trigger_hist_id | channel_id | transaction_id | source_node_id | external_data | create_time
    ———+—————+————+———————————————————————————————————————————————————————————————————————————————————-+————————————————-+————————————————————————————————————————————————+——————+————+—————-+—————-+—————+—————————-
    15 | sym_node_host | U | «000»,»cb-xfce»,»192.168.1.110″,»goodwill»,»Linux»,»i386″,»2.6.32-5-686″,»1″,»7582168″,»17354752″,»111542272″,»1.6.0_26″,»Sun Microsystems Inc.»,»3.2.0″,»-05:00″,»2013-01-14 15:45:00.000000″,»2013-01-14 15:28:01.129000″,»2013-01-14 15:28:01.137342″ | «000»,»cb-xfce» | | 21 | heartbeat | 211585 | 000 | | 2013-01-14 15:47:56.081046
    14 | sym_node_host | U | «001»,»cb-xfce»,»192.168.1.110″,»goodwill»,»Linux»,»i386″,»2.6.32-5-686″,»1″,»6904656″,»17354752″,»111542272″,»1.6.0_26″,»Sun Microsystems Inc.»,»3.2.0″,»-05:00″,»2013-01-14 15:45:00.000000″,»2013-01-14 15:28:01.129000″,»2013-01-14 15:32:37.410614″ | «001»,»cb-xfce» | | 21 | heartbeat | 211542 | | | 2013-01-14 15:47:37.839644
    13 | sym_node | U | «001»,»store»,»001″,»1″,»http://cb-xfce:31415/sync/store-001″,»?»,»3.2.0″,»PostgreSQL»,»8.4″,»2013-01-14 15:45:00.321000″,»-05:00″,»1″,»1″,»000″,»server» | «001» | | 26 | config | 211541 | | | 2013-01-14 15:47:37.786959
    12 | taxlines | I | «2287187e-3553-4724-a439-4dee818914f7″,»6e729b86-70c7-4165-8b55-9d5bfc406e1e»,»001″,»1.1000000000000001″,»0.11″ | | | 5 | sale | 209963 | | | 2013-01-14 15:37:45.930526
    11 | payments | I | «e2a54e52-d342-4a76-b31d-0d403bf6846d»,»6e729b86-70c7-4165-8b55-9d5bfc406e1e»,»cash»,»1.2100000000000002″,»no ID»,»T0s=» | | | 22 | sale | 209963 | | | 2013-01-14 15:37:45.930526
    10 | stockdiary | I | «859032c0-ffaf-43ba-84a3-c438ca014c5c»,»2013-01-14 15:35:08.708000″,»-1″,»0″,»e8856496-28b5-4cae-9136-132db00400fb»,,»-1″,»1.1000000000000001″ | | | 8 | inventory | 209963 | | | 2013-01-14 15:37:45.930526
    9 | stockcurrent | U | «0»,»e8856496-28b5-4cae-9136-132db00400fb»,,»4″ | «0»,»e8856496-28b5-4cae-9136-132db00400fb»,,»5″ | «0»,»e8856496-28b5-4cae-9136-132db00400fb»,,»5″ | 14 | inventory | 209963 | | | 2013-01-14 15:37:45.930526
    ——————————————

    The above is the update made to the stockcurrent table. There were 5 items in inventory, now there are 4. What is interesting to me about the above piece is that it contains

    «0»,»e8856496-28b5-4cae-9136-132db00400fb»,,»5″

    as the “pk_data”. Not sure why this is; almost none of the other results from that query have data in that column, and before I added that transformation, this column had no data when that query ran.

    When the sale was made, the ‘store’ database correctly processed the stockcurrent table and decreased stock to ‘4’. The ‘corp’ db did not.

    Unfortunately, “syntax error at end of input” is not helping me very much.
    What is the problem?

    I probably did not provide enough information here, so please let me know what else I need to post.

     

    Last edit: dabgdk 2013-01-15

  • dabgdk

    The only place that the «syntax error at end of input» error shows up is in the sym_incoming_batch table:

    select * from sym_incoming_batch where batch_id = 5;

    Which produces this output:


    batch_id | node_id | channel_id | status | error_flag | network_millis | filter_millis | database_millis | failed_row_number | failed_line_number | byte_count | statement_count | fallback_insert_count | fallback_update_count | ignore_count | missing_delete_count | skip_count | sql_state | sql_code | sql_message | last_update_hostname | last_update_time | create_time
    ———-+———+————+———+————+—————-+—————+——————+——————-+———————+————+——————+————————+————————+—————+———————-+————+————+———-+————————————-+———————-+————————+—————————
    5 | 001 | inventory | ER | 1 | 0 | 0 | 0 | 0 | 0 | 250 | 0 | 0 | 0 | 0 | 0 | 0 | 42601 | 0 | ERROR: syntax error at end of input | cb-xfce | 2013-01-14 15:46:11.9 | 2013-01-14 15:35:27.76009
    : Position: 54
    (1 row)

    (END)

  • dabgdk

    I decided to try doing something else.

    insert into sym_transform_table (transform_id, source_node_group_id, target_node_group_id, transform_point, column_policy, source_table_name, target_table_name, delete_action, transform_order) values (‘stockcurrent’, ‘store’, ‘corp’, ‘LOAD’, ‘IMPLIED’, ‘stockcurrent’, ‘stockcurrent’, ‘NONE’, 1);

    insert into sym_transform_column (transform_id, include_on, target_column_name, source_column_name, pk, transform_type, transform_expression, transform_order) values (‘stockcurrent’, ‘U’, ‘units’, ‘units’, 0, ‘additive’, null, 1);

    I modified my transformation; specifically, changed the “include_on” from ‘*’ to ‘U’ and “pk” from ‘1’ to ‘0’.

    [corp-000] — DataLoaderService — Failed to load batch 001-4 because: ERROR: column «units» specified more than once
    Position: 87
    [store-001] — AcknowledgeService — Received an error from node 000 for batch 4. Check the outgoing_batch table for more info.
    [store-001] — PushService — Pushed data to corp:000:000. 2 data and 1 batches were processed
    [store-001] — PushService — Push data sent to corp:000:000
    [corp-000] — IncomingBatchService — Retrying batch 001-4
    [corp-000] — DatabaseWriter — Failed to process a update event in batch 4.
    Failed sql was: insert into «stockcurrent»(«location», «product», «attributesetinstance_id», «units», «units») (select ?,?,?,?,? where (select 1 from «stockcurrent» where «location» = ? and «product» = ? and «attributesetinstance_id» = ? and «units» = ? and «units» = ?) is null)
    Failed row data was: «0»,»e8856496-28b5-4cae-9136-132db00400fb»,,»4″,»-1″

    The original SQL queries (from the client application):

    UPDATE STOCKCURRENT SET UNITS = (UNITS + ?) WHERE LOCATION = ? AND PRODUCT = ? AND ATTRIBUTESETINSTANCE_ID = ?

    UPDATE STOCKCURRENT SET UNITS = (UNITS + ?) WHERE LOCATION = ? AND PRODUCT = ? AND ATTRIBUTESETINSTANCE_ID IS NULL

    INSERT INTO STOCKCURRENT (LOCATION, PRODUCT, ATTRIBUTESETINSTANCE_ID, UNITS) VALUES (?, ?, ?, ?)

    From my understanding of the client code, the insert query does not occur unless the update query fails first. The code checks to see if ATTRIBUTESETINSTANCE is null, and if so, runs the second query I provided above; otherwise, the first one is run.

    I have a number of questions from having done the above.

    1. Why is it that the original SQL query shows 4 ‘?’s but the one that is passed from the transformation has 5?
    2. Why is the column “units” used twice?
    3. What exactly is the “pk” data column in the “sym_transform_column” table? Why is it an integer?
    4. Why is there a nested select in the failed query?
    5. The “Failed row data” was «0»,»e8856496-28b5-4cae-9136-132db00400fb»,,»4″,»-1″; is the “-1” the additive transformation? If this is the case, how do I use it?
  • dabgdk

    1. If «include_on» from the sym_transform_column table was set to ‘U’, why is the transform running an insert? Shouldn’t the insert have been sent through?

     

    Last edit: dabgdk 2013-01-16

  • dabgdk

    Changed the transform again, and got this stack trace:

    [store-001] — DataExtractorService — Failed to extract batch 000-7
    org.jumpmind.db.sql.SqlException: ERROR: syntax error at end of input
    Position: 54
    at org.jumpmind.db.sql.AbstractSqlTemplate.translate(AbstractSqlTemplate.java:260)
    at org.jumpmind.db.sql.AbstractSqlTemplate.translate(AbstractSqlTemplate.java:251)
    at org.jumpmind.db.sql.JdbcSqlTemplate.execute(JdbcSqlTemplate.java:391)
    at org.jumpmind.db.sql.JdbcSqlTemplate.update(JdbcSqlTemplate.java:261)
    at org.jumpmind.db.sql.AbstractSqlTemplate.update(AbstractSqlTemplate.java:184)
    at org.jumpmind.symmetric.io.data.transform.AdditiveColumnTransform.transform(AdditiveColumnTransform.java:141)
    at org.jumpmind.symmetric.io.data.transform.AdditiveColumnTransform.transform(AdditiveColumnTransform.java:38)
    at org.jumpmind.symmetric.io.data.writer.TransformWriter.transformColumn(TransformWriter.java:388)
    at org.jumpmind.symmetric.io.data.writer.TransformWriter.create(TransformWriter.java:340)
    at org.jumpmind.symmetric.io.data.writer.TransformWriter.transform(TransformWriter.java:210)
    at org.jumpmind.symmetric.io.data.writer.TransformWriter.write(TransformWriter.java:187)
    at org.jumpmind.symmetric.io.data.DataProcessor.forEachDataInTable(DataProcessor.java:188)
    at org.jumpmind.symmetric.io.data.DataProcessor.forEachTableInBatch(DataProcessor.java:160)
    at org.jumpmind.symmetric.io.data.DataProcessor.process(DataProcessor.java:110)
    at org.jumpmind.symmetric.service.impl.DataExtractorService.extractOutgoingBatch(DataExtractorService.java:509)
    at org.jumpmind.symmetric.service.impl.DataExtractorService.extract(DataExtractorService.java:347)
    at org.jumpmind.symmetric.service.impl.DataExtractorService.extract(DataExtractorService.java:309)
    at org.jumpmind.symmetric.service.impl.PushService.pushToNode(PushService.java:175)
    at org.jumpmind.symmetric.service.impl.PushService.execute(PushService.java:145)
    at org.jumpmind.symmetric.service.impl.NodeCommunicationService$2.run(NodeCommunicationService.java:236)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at end of input
    Position: 54
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:334)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
    at org.jumpmind.db.sql.JdbcSqlTemplate$5.execute(JdbcSqlTemplate.java:283)
    at org.jumpmind.db.sql.JdbcSqlTemplate$5.execute(JdbcSqlTemplate.java:261)
    at org.jumpmind.db.sql.JdbcSqlTemplate.execute(JdbcSqlTemplate.java:389)
    … 20 more

    The transform:

    insert into sym_transform_table (transform_id, source_node_group_id, target_node_group_id, transform_point, column_policy, source_table_name, target_table_name, delete_action) values (‘stockcurrent’, ‘store’, ‘corp’, ‘EXTRACT’, ‘IMPLIED’, ‘stockcurrent’, ‘stockcurrent’, ‘NONE’);

    insert into sym_transform_column (transform_id, include_on, target_column_name, source_column_name, pk, transform_type, transform_expression) values (‘stockcurrent’, ‘U’, ‘units’, ‘units’, 2, ‘additive’, 1);

    Not sure why I got a stack trace for this instance, but no stack trace when I first posted.

  • dabgdk

    Just after that stack trace, I get

    [store-001] — PushService — Push data sent to corp:000:000
    [store-001] — PushService — Did not receive an acknowledgement for the batches sent
    [store-001] — PushService — Pushed data to corp:000:000. 2 data and 1 batches were processed

    every time the system retries sending the batch and throws the trace.

  • Mark Hanes

    What sql data type is your units column on the stockcurrent table on both ends of the synchronization?

    What are the contents of sym_data related to batch 000-7? Look on store-001 server to find the data.

  • dabgdk

    The units column is «double precision».

    Unfortunately, as I’ve been attempting to get this transformation to work I’ve been repeatedly dropping the db and recreating it; however, I was able to reproduce the last failure I shared by putting the transform queries back as they were.

    So, batch 000-4 (not 000-7 because I dropped that db):

    The contents of sym_data on the store-001 server relevant to batch 000-4 is:


    8 | stockcurrent | U | «0»,»e8856496-28b5-4cae-9136-132db00400fb»,,»4″ | «0»,»e8856496-28b5-4cae-9136-132db00400fb»,,»5″ | «0»,»e8856496-28b5-4cae-9136-132db00400fb»,,»5″ | 14 | inventory | 222189 | | | 2013-01-15 15:31:37.553972


    Side note:

    I have not modified the «symmetric.properties» file from the defaults it came configured with.

    Once I got the example provided with Symmetric to function, I tried to use that as my base to get to using my own data.

    I have a dump of the database that I restore to each server each time I screw up. Here is a basic outline of what I do:

    1. Drop both databases from the servers (sample001 for the client, samplecorp for the server).
    2. Create both databases and load the dump files into them; they now have a simple Openbravo database with NO symmetric data.
    3. Run command «../bin/symadmin —engine corp-000 create-sym-tables» from the samplecorp database.
    4. Run command «../bin/dbimport —engine corp-000 ob-setup.sql» on the samplecorp database, with «ob-setup.sql» containing ONLY symmetric related SQL commands (all the setup for openbravo taken care of in step 2).
    5. Start the symmetric server. Wait until it begins to complain repeatedly of store001 not being registered.
    6. Run command «../bin/symadmin —engine corp-000 open-registration store 001» on the samplecorp database.
    7. Wait until there are no more updates happening with symmetric data or channels and such; usually a couple minutes. Then attempt to make a sale by connecting my client to the sample001 database.

    Something that might be important: when I finally got the example to run, and in many cases with my own data, I see

    [store-001] — PushService — Did not receive an acknowledgement for the batches sent

    over and over again. Once I see these errors, they never cease, and in some cases no more data will pass from the store001 database.

  • dabgdk

    Sample001 database is PostgreSQL 8.4.4 running on FreeBSD 8.1; samplecorp is 8.4.13 running on CrunchBang Linux.

    The Linux/samplecorp database server has Sun (Oracle?) Java 1.6.0_26; FreeBSD, «Diablo Java(TM) SE Runtime Environment (build 1.6.0_07-b02)»

  • dabgdk

    I guess it doesn’t really matter which version of Java the FreeBSD system has; it never runs for these tests.

  • Mark Hanes

    One thing you could try is changing the column on both source and target databases to be an integer type instead of a double-precision type. It’s just a guess, really. clear our your sym-data entries and make a change to the source and see if it makes a difference.

  • dabgdk

    Hey Mark,

    Did what you suggested:

    1. Dropped both dbs
    2. Created both dbs and populated with the Openbravo test data

    I then modified BOTH “stockcurrent” tables in this way:

    alter table stockcurrent alter column units type integer;

    which caused the output of “d stockcurrent” to be:


               Table "public.stockcurrent"
         Column          |       Type        | Modifiers
    

    ————————-+——————-+————
    location | character varying | not null
    product | character varying | not null
    attributesetinstance_id | character varying |
    units | integer | not null
    Indexes:
    «stockcurrent_inx» UNIQUE, btree (location, product, attributesetinstance_id)
    Foreign-key constraints:
    «stockcurrent_attsetinst» FOREIGN KEY (attributesetinstance_id) REFERENCES attributesetinstance(id)
    «stockcurrent_fk_1» FOREIGN KEY (product) REFERENCES products(id)
    «stockcurrent_fk_2» FOREIGN KEY (location) REFERENCES locations(id)


    I then inserted an entry into the table on the sampleCORP db side:

    INSERT INTO STOCKCURRENT (LOCATION, PRODUCT, ATTRIBUTESETINSTANCE_ID, UNITS) VALUES (‘0’, ‘e8856496-28b5-4cae-9136-132db00400fb’, null, 5);

    which then was correctly synced to the sample001 db via symmetricds. (I verified this).

    Next I ran this query on the sample001 db:

    update stockcurrent set units = 4 where product = ‘e8856496-28b5-4cae-9136-132db00400fb’;

    and in about five seconds, the output below began to be generated over and over.

    [store-001] — RouterService — Routed 1 data events in 15393 ms
    [store-001] — DataExtractorService — Failed to extract batch 000-3
    org.jumpmind.db.sql.SqlException: ERROR: syntax error at end of input
    Position: 54
    at org.jumpmind.db.sql.AbstractSqlTemplate.translate(AbstractSqlTemplate.java:260)
    at org.jumpmind.db.sql.AbstractSqlTemplate.translate(AbstractSqlTemplate.java:251)
    at org.jumpmind.db.sql.JdbcSqlTemplate.execute(JdbcSqlTemplate.java:391)
    at org.jumpmind.db.sql.JdbcSqlTemplate.update(JdbcSqlTemplate.java:261)
    at org.jumpmind.db.sql.AbstractSqlTemplate.update(AbstractSqlTemplate.java:184)
    at org.jumpmind.symmetric.io.data.transform.AdditiveColumnTransform.transform(AdditiveColumnTransform.java:141)
    at org.jumpmind.symmetric.io.data.transform.AdditiveColumnTransform.transform(AdditiveColumnTransform.java:38)
    at org.jumpmind.symmetric.io.data.writer.TransformWriter.transformColumn(TransformWriter.java:388)
    at org.jumpmind.symmetric.io.data.writer.TransformWriter.create(TransformWriter.java:340)
    at org.jumpmind.symmetric.io.data.writer.TransformWriter.transform(TransformWriter.java:210)
    at org.jumpmind.symmetric.io.data.writer.TransformWriter.write(TransformWriter.java:187)
    at org.jumpmind.symmetric.io.data.DataProcessor.forEachDataInTable(DataProcessor.java:188)
    at org.jumpmind.symmetric.io.data.DataProcessor.forEachTableInBatch(DataProcessor.java:160)
    at org.jumpmind.symmetric.io.data.DataProcessor.process(DataProcessor.java:110)
    at org.jumpmind.symmetric.service.impl.DataExtractorService.extractOutgoingBatch(DataExtractorService.java:509)
    at org.jumpmind.symmetric.service.impl.DataExtractorService.extract(DataExtractorService.java:347)
    at org.jumpmind.symmetric.service.impl.DataExtractorService.extract(DataExtractorService.java:309)
    at org.jumpmind.symmetric.service.impl.PushService.pushToNode(PushService.java:175)
    at org.jumpmind.symmetric.service.impl.PushService.execute(PushService.java:145)
    at org.jumpmind.symmetric.service.impl.NodeCommunicationService$2.run(NodeCommunicationService.java:236)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at end of input
    Position: 54
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:334)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
    at org.jumpmind.db.sql.JdbcSqlTemplate$5.execute(JdbcSqlTemplate.java:283)
    at org.jumpmind.db.sql.JdbcSqlTemplate$5.execute(JdbcSqlTemplate.java:261)
    at org.jumpmind.db.sql.JdbcSqlTemplate.execute(JdbcSqlTemplate.java:389)
    … 20 more
    [store-001] — PushService — Push data sent to corp:000:000
    [store-001] — PushService — Did not receive an acknowledgement for the batches sent
    [store-001] — PushService — Pushed data to corp:000:000. 1 data and 1 batches were processed
    [store-001] — DataExtractorService — Failed to extract batch 000-3
    org.jumpmind.db.sql.SqlException: ERROR: syntax error at end of input
    Position: 54
    at org.jumpmind.db.sql.AbstractSqlTemplate.translate(Abs…

  • dabgdk

    Is there anything that can be done to generate a more descriptive or complete error message? I imagine that «ERROR: syntax error at end of input Position: 54» isn’t helping you much either.

  • Mark Hanes

    In the conf directory there are probably two files, log4j.xml and log4j-debug.xml. If so, copy the «debug» one over the log4j.xml one, restart symmetric, and the logging level should be bumped out to the point there might be more useful information, such as the SQL being run, etc.

  • dabgdk

    This is SymmetricDS version 3.2.0.

  • dabgdk

    Well, I am very happy to see the line

    SQL: update «stockcurrent» set «units»=»units»+(-1) where

    but it seems part of it was chopped off?

    [corp-000] — RouterService — Routing config, data.enqueue.time.ms=0, data.routed.count=0, total.time.ms=20
    [corp-000] — RouterService — Routing inventory, data.enqueue.time.ms=0, data.routed.count=0, total.time.ms=26
    [corp-000] — RouterService — Routing maint, data.enqueue.time.ms=0, data.routed.count=0, total.time.ms=53
    [corp-000] — RouterService — Routing opstat, data.enqueue.time.ms=0, data.routed.count=0, total.time.ms=52
    [corp-000] — RouterService — Routing reload, data.enqueue.time.ms=0, data.routed.count=0, total.time.ms=42
    [corp-000] — RouterService — Routing sale, data.enqueue.time.ms=0, data.routed.count=0, total.time.ms=41
    [corp-000] — RouterService — Routing heartbeat, data.enqueue.time.ms=0, data.routed.count=0, total.time.ms=62
    [corp-000] — RouterService — Routing default, data.enqueue.time.ms=0, data.routed.count=0, total.time.ms=47
    [store-001] — TransformWriter — 1 transformation(s) started because of UPDATE on stockcurrent. The original row data was: {location=0, product=e8856496-28b5-4cae-9136-132db00400fb, attributesetinstance_id=null, units=4}
    [store-001] — AdditiveColumnTransform — Old, new, transform expression as received: 5, 4, 1
    [store-001] — AdditiveColumnTransform — SQL: update «stockcurrent» set «units»=»units»+(-1) where
    [store-001] — DataExtractorService — Failed to extract batch 000-3
    org.jumpmind.db.sql.SqlException: ERROR: syntax error at end of input
    Position: 54
    at org.jumpmind.db.sql.AbstractSqlTemplate.translate(AbstractSqlTemplate.java:260)
    at org.jumpmind.db.sql.AbstractSqlTemplate.translate(AbstractSqlTemplate.java:251)
    at org.jumpmind.db.sql.JdbcSqlTemplate.execute(JdbcSqlTemplate.java:391)
    at org.jumpmind.db.sql.JdbcSqlTemplate.update(JdbcSqlTemplate.java:261)
    at org.jumpmind.db.sql.AbstractSqlTemplate.update(AbstractSqlTemplate.java:184)
    at org.jumpmind.symmetric.io.data.transform.AdditiveColumnTransform.transform(AdditiveColumnTransform.java:141)
    at org.jumpmind.symmetric.io.data.transform.AdditiveColumnTransform.transform(AdditiveColumnTransform.java:38)
    at org.jumpmind.symmetric.io.data.writer.TransformWriter.transformColumn(TransformWriter.java:388)
    at org.jumpmind.symmetric.io.data.writer.TransformWriter.create(TransformWriter.java:340)
    at org.jumpmind.symmetric.io.data.writer.TransformWriter.transform(TransformWriter.java:210)
    at org.jumpmind.symmetric.io.data.writer.TransformWriter.write(TransformWriter.java:187)
    at org.jumpmind.symmetric.io.data.DataProcessor.forEachDataInTable(DataProcessor.java:188)
    at org.jumpmind.symmetric.io.data.DataProcessor.forEachTableInBatch(DataProcessor.java:160)
    at org.jumpmind.symmetric.io.data.DataProcessor.process(DataProcessor.java:110)
    at org.jumpmind.symmetric.service.impl.DataExtractorService.extractOutgoingBatch(DataExtractorService.java:509)
    at org.jumpmind.symmetric.service.impl.DataExtractorService.extract(DataExtractorService.java:347)
    at org.jumpmind.symmetric.service.impl.DataExtractorService.extract(DataExtractorService.java:309)
    at org.jumpmind.symmetric.service.impl.PushService.pushToNode(PushService.java:175)
    at org.jumpmind.symmetric.service.impl.PushService.execute(PushService.java:145)
    at org.jumpmind.symmetric.service.impl.NodeCommunicationService$2.run(NodeCommunicationService.java:236)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
    at java.lang.Thread.run(Thread.java:662)
    Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at end of input
    Position: 54
    at org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExecutorImpl.java:2103)
    at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
    at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:257)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.execute(AbstractJdbc2Statement.java:512)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeWithFlags(AbstractJdbc2Statement.java:388)
    at org.postgresql.jdbc2.AbstractJdbc2Statement.executeUpdate(AbstractJdbc2Statement.java:334)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
    at org.apache.commons.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
    at org.jumpmind.db.sql.JdbcSqlTemplate$5.execute(JdbcSqlTemplate.java:283)
    at org.jumpmind.db.sql.JdbcSqlTemplate$5.execute(JdbcSqlTemplate.java:261)
    at org.jumpmind.db.sql.JdbcSqlTemplate.execute(JdbcSqlTemplate.java:389)
    … 20 more
    [store-001] — PushService — Push data sent to corp:000:000
    [store-001] — PushService — Reading ack: null
    [store-001] — PushService — Reading extend ack: null
    [store-001] — PushService — Did not receive an acknowledgement for the batches sent
    [store-001] — PushService — Pushed data to corp:000:000. 1 data and 1 batches were processed
    [store-001] — PushService — Push completed for corp:000:000
    [store-001] — PushService — Push requested for corp:000:000
    [store-001] — PullService — Pull requested for corp:000:000
    [corp-000] — PullUriHandler — @doFilter
    [corp-000] — PullUriHandler — requestURI= /sync/corp-000/pull
    [corp-000] — PullUriHandler — Supports compression.
    [corp-000] — CompressionServletResponseWrapper — CompressionServletResponseWrapper constructor gets called
    [corp-000] — PullUriHandler — doFilter gets called with compression
    [corp-000] — PullUriHandler — Pull request received from 001
    [corp-000] — CompressionServletResponseWrapper — createOutputStream gets called
    [corp-000] — CompressionServletResponseWrapper — stream is set to org.jumpmind.symmetric.web.compression.CompressionResponseStream@5098f9 in getOutputStream
    [corp-000] — PullUriHandler — Done with Pull request from 001
    [store-001] — PullService — Pull data received from corp:000:000. 0 rows and 0 batches were processed
    [store-001] — StagingDataWriter — Writing staging data: nodeid,001
    [store-001] — StagingDataWriter — Writing staging data: binary,BASE64
    [store-001] — StagingDataWriter — Writing staging data: channel,inventory
    [store-001] — StagingDataWriter — Writing staging data: batch,3
    [store-001] — TransformWriter — 1 transformation(s) started because of UPDATE on stockcurrent. The original row data was: {location=0, product=e8856496-28b5-4cae-9136-132db00400fb, attributesetinstance_id=null, units=4}
    [store-001] — AdditiveColumnTransform — Old, new, transform expression as received: 5, 4, 1
    [store-001] — AdditiveColumnTransform — SQL: update «stockcurrent» set «units»=»units»+(-1) where
    [store-001] — DataExtractorService — Failed to extract batch 000-3
    org.jumpmind.db.sql.SqlException: ERROR: syntax error at end of input
    Position: 54
    at org.jumpmind.db.sql.Abs…

  • dabgdk

    Would this indicate a problem with the «where … » formation part of the transformation? Doesn’t the pk data get used to form this part of the query?

    What exactly does the «pk» integer column of sym_transform_column do?

  • dabgdk

     

    Last edit: dabgdk 2013-01-16

  • dabgdk

    Would it help at all to post configs, or maybe a copy of the postgresql dump file I’ve been using?

  • Mark Hanes

    Does the table have a primary key? The PK column is used to designate the columns that should be used as part of a primary key when doing the transformation. I would have thought you would not have needed to specify the PK columns since you were using «implied», but if your table doesn’t have a primary key you’ll need to add copy column entries where PK is true (1) so SymmetricDS can complete the wheres clause.

    Hope this helps.

  • dabgdk

    Stockcurrent does not have a primary key, but the three columns other than “units” will always be unique.

    Ok, so PK is a boolean? That should definitely have been mentioned in the documentation. Looking back on it, I can see that this is somewhat implied- but I think it would help a lot for clarity’s sake to specify this.

    I would have thought you would not have needed to specify the PK columns since you were using «implied», but if your table doesn’t have a primary key you’ll need to add copy column entries where PK is true (1) so SymmetricDS can complete the wheres clause.

    Where the documentation discusses “IMPLIED”, it might be mentioned that only tables with primary keys will work with the option.

    Are you saying that I need more than one transform? One for the “units” column, and the others for copying the columns over?

    Do I need to have the ‘units’ transform PK value be ‘0’ since it is not a primary key?

  • Mark Hanes

    What is probably going wrong is that Implied is having trouble finding the primary key on the target (since there is none). Try adding sym_column_transform entries for each of your three columns that make up your key. Set the PK column (a boolean) to 1 representing true. THe transform type, of course, is COPY.

    That might clear up the issue.

  • dabgdk

    Thanks a lot Mark. Wow, that was a lot of troubleshooting. I haven’t gotten things to work out just yet, but I did get

    2013-01-16 13:52:09,830 DEBUG [store-001] [AdditiveColumnTransform] [store-001-push-7] Old, new, transform expression as received: 5, 4, 1
    2013-01-16 13:52:09,830 DEBUG [store-001] [AdditiveColumnTransform] [store-001-push-7] SQL: update «stockcurrent» set «units»=»units»+(-1) where «location»=? and «product»=?

    In my logs, so I know I’m close.

    Again, thank you.

  • Mark Hanes

    The typical table will have a primary key, so I hadn’t thought that that might be the issue. If there had been one, I don’t think you’d have to specify any columns in sym_column_transform for the primary key entries.


Log in to post a comment.

Я использовал следующий оператор SQL как в MySQL, так и в PostgreSQL, но он не работает в PostgreSQL.

db.Query(`SELECT COUNT(*) as N FROM email WHERE address = ?`, email)

с этой ошибкой:

pq: F:"scan.l" M:"syntax error at end of input" S:"ERROR" C:"42601" P:"50" R:"scanner_yyerror" L:"993"

В чем проблема? Сообщения об ошибках в PostgreSQL очень загадочны.

4 ответы

Вы не предоставили никаких подробностей о языке/среде, но я все равно попытаюсь предположить:

Подготовленные операторы MySQL изначально используют ? в качестве заполнителя параметра, но PostgreSQL использует $1, $2 и т.д. Попробуйте заменить ? с $1 и посмотрим, работает ли это:

WHERE address = $1

Сообщения об ошибках в PostgreSQL очень загадочны.

В общем, я обнаружил, что сообщения об ошибках Postgres лучше, чем у конкурирующих продуктов (кхм, MySQL и особенно Oracle), но в данном случае вам удалось запутать синтаксический анализатор до безумия. :)

Создан 09 июля ’18, 13:07

В golang для запросов мы используем

  • MySQL использует? вариант
  • PostgreSQL использует перечисляемый синтаксис переменных $1, $2 и т. д.
  • SQLite принимает оба? и синтаксис $1
  • Oracle использует синтаксис :name

Создан 08 фев.

Вы используете Go правильно?

попробовать:

db.Query(`SELECT COUNT(*) as N FROM email WHERE address = $1`, email)

ответ дан 29 окт ’12, 10:10

В моем случае это произошло из-за использования —строчного комментария, когда программа, отвечающая за взаимодействие с базой данных, читала несколько строк моего запроса как одну гигантскую строку. Это означало, что комментарий к строке испортил оставшуюся часть запроса. Исправление состояло в том, чтобы вместо этого использовать /* блочный комментарий */.

ответ дан 07 апр.

Не тот ответ, который вы ищете? Просмотрите другие вопросы с метками

sql
postgresql
go

or задайте свой вопрос.

Понравилась статья? Поделить с друзьями:
  • Svchost exe выдает ошибку
  • Svchost error application error
  • Synology как изменить тип raid
  • Synology cloud sync яндекс диск ошибка при авторизации
  • Synergy one ui error 1337