Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9229877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T05:40:54+00:00 2026-06-18T05:40:54+00:00

This psql session snippet should be self-explanatory: psql (9.1.7) Type help for help. =>

  • 0

This psql session snippet should be self-explanatory:

psql (9.1.7)
Type "help" for help.
=> CREATE TABLE languages(language VARCHAR NOT NULL);
CREATE TABLE
=> INSERT INTO languages VALUES ('english'),('french'),('turkish');
INSERT 0 3
=> SELECT language, to_tsvector('english', 'hello world') FROM languages;
 language|     to_tsvector     
---------+---------------------
 english | 'hello':1 'world':2
 french  | 'hello':1 'world':2
 turkish | 'hello':1 'world':2
(3 rows)

=> SELECT language, to_tsvector(language, 'hello world') FROM languages;
ERROR:  function to_tsvector(character varying, unknown) does not exist
LINE 1: select language, to_tsvector(language, 'hello world')...
                         ^
HINT:  No function matches the given name and argument types.  
You might need to add explicit type casts.

The problem is that Postgres function to_tsvector doesn’t like varchar field type but this call should be perfectly correct according to the documentation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T05:40:56+00:00Added an answer on June 18, 2026 at 5:40 am

    Use an explicit type cast:

    SELECT language, to_tsvector(language::regconfig, 'hello world') FROM languages;

    Or change the column languages.language to type regconfig. See @Swav’s answer.

    Why?

    Postgres allows function overloading. Function signatures are defined by their (optionally schema-qualified) name plus (the list of) input parameter type(s). The 2-parameter form of to_tsvector() expects type regconfig as first parameter:

    SELECT proname, pg_get_function_arguments(oid)
    FROM   pg_catalog.pg_proc
    WHERE  proname = 'to_tsvector'
    
       proname   | pg_get_function_arguments
    -------------+---------------------------
     to_tsvector | text
     to_tsvector | regconfig, text             -- you are here
    

    If no existing function matches exactly, the rules of Function Type Resolution decide the best match – if any. This is successful for to_tsvector('english', 'hello world'), with 'english' being an untyped string literal. But fails with a parameter typed varchar, because there is no registered implicit cast from varchar to regconfig. The manual:

    Discard candidate functions for which the input types do not match and
    cannot be converted (using an implicit conversion) to match. unknown
    literals
    are assumed to be convertible to anything for this purpose.

    Bold emphasis mine.
    The registered casts for regconfig:

    SELECT castsource::regtype, casttarget::regtype, castcontext
    FROM   pg_catalog.pg_cast
    WHERE  casttarget = 'regconfig'::regtype;
    
     castsource | casttarget | castcontext
    ------------+------------+-------------
     oid        | regconfig  | i
     bigint     | regconfig  | i
     smallint   | regconfig  | i
     integer    | regconfig  | i
    

    Explanation for castcontext:

    castcontext char
    Indicates what contexts the cast can be invoked
    in. e means only as an explicit cast (using CAST or :: syntax). a
    means implicitly in assignment to a target column, as well as
    explicitly. i means implicitly in expressions, as well as the other cases.

    Read more about the three different types of assignment in the chapter "CREATE CAST".

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I did this in psql: CREATE TABLE IF NOT EXISTS apiss (skey TEXT, time
I'm currently trying to store images in a psql table and was following this
I need to run this command psql -c create database $var with encoding 'unicode';
I have two tables that look like this: CREATE TABLE table1 (user_id int, the_date
This should be a simple one: I have an observableArray object called To in
I have a psql script that looks like this: -- first set of statements
I write PSQL script and using variables (for psql --variable key=value commandline syntax). This
This should be pretty straightfoward and I don't know why I am struggling with
this is my problem: myname@ubuntu:~$ sudo su postgres -c psql template1 Password: psql (9.1.6)
mohpc04pp1: /h/u544835 % psql arco Welcome to psql 8.1.17, the PostgreSQL interactive terminal. Type:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.